mirror of
https://github.com/farcasclaudiu/myfriendsaround.git
synced 2026-06-29 05:01:59 +03:00
offline images
friends list / select friend distance
This commit is contained in:
@@ -9,7 +9,7 @@
|
|||||||
</basicHttpBinding>
|
</basicHttpBinding>
|
||||||
</bindings>
|
</bindings>
|
||||||
<client>
|
<client>
|
||||||
<endpoint address="http://localhost:8192/GpsEmulator" binding="basicHttpBinding"
|
<endpoint address="http://localhost:9192/GpsEmulator" binding="basicHttpBinding"
|
||||||
bindingConfiguration="BasicHttpBinding_IGpsEmulatorService"
|
bindingConfiguration="BasicHttpBinding_IGpsEmulatorService"
|
||||||
contract="ServiceReference1.IGpsEmulatorService" name="BasicHttpBinding_IGpsEmulatorService" />
|
contract="ServiceReference1.IGpsEmulatorService" name="BasicHttpBinding_IGpsEmulatorService" />
|
||||||
</client>
|
</client>
|
||||||
|
|||||||
@@ -0,0 +1,95 @@
|
|||||||
|
using System;
|
||||||
|
using System.Net;
|
||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Controls;
|
||||||
|
using System.Windows.Documents;
|
||||||
|
using System.Windows.Ink;
|
||||||
|
using System.Windows.Input;
|
||||||
|
using System.Windows.Media;
|
||||||
|
using System.Windows.Media.Animation;
|
||||||
|
using System.Windows.Shapes;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Windows.Media.Imaging;
|
||||||
|
using System.IO;
|
||||||
|
using System.IO.IsolatedStorage;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
|
|
||||||
|
namespace WPImageCaching
|
||||||
|
{
|
||||||
|
internal static class ImageCache
|
||||||
|
{
|
||||||
|
private const string IMAGECACHEFILE = "imagecachefile.nfo";
|
||||||
|
internal static Dictionary<string, ImageCacheItem> imageCache;
|
||||||
|
|
||||||
|
|
||||||
|
public static BitmapImage GetImage(BitmapImage image)
|
||||||
|
{
|
||||||
|
string url = image.UriSource.ToString();
|
||||||
|
|
||||||
|
if (Environment.OSVersion.Platform == PlatformID.Win32NT)
|
||||||
|
{
|
||||||
|
//Wenn im Designmodus von Blend oder Visual Studio
|
||||||
|
image.UriSource = new Uri(url);
|
||||||
|
return image;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (imageCache==null)
|
||||||
|
{
|
||||||
|
LoadCachedImageInfo();
|
||||||
|
}
|
||||||
|
|
||||||
|
//Prüfen auf ein vorhandenes gespeichertes Bild
|
||||||
|
if (imageCache.ContainsKey(url))
|
||||||
|
{
|
||||||
|
//Prüfen auf Gültigkeit des Bildes
|
||||||
|
if (DateTime.Compare(DateTime.Now, imageCache[url].Expiration) >= 0)
|
||||||
|
{
|
||||||
|
ImageDownloadHelper.DownloadImage(url,image,imageCache[url]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//Bild ist noch gültig
|
||||||
|
image.SetSource(IsolatedStorageFile.GetUserStoreForApplication().OpenFile(imageCache[url].LocalFilename, FileMode.Open));
|
||||||
|
return image;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//Bild noch nicht gespeichert
|
||||||
|
ImageCacheItem item = new ImageCacheItem();
|
||||||
|
ImageDownloadHelper.DownloadImage(url, image, item);
|
||||||
|
}
|
||||||
|
return image;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Laden der Bildinformationen
|
||||||
|
private static void LoadCachedImageInfo()
|
||||||
|
{
|
||||||
|
if (IsolatedStorageFile.GetUserStoreForApplication().FileExists(IMAGECACHEFILE))
|
||||||
|
{
|
||||||
|
IsolatedStorageFileStream fs =
|
||||||
|
IsolatedStorageFile.GetUserStoreForApplication().OpenFile(IMAGECACHEFILE,FileMode.Open);
|
||||||
|
|
||||||
|
DataContractSerializer dcs = new DataContractSerializer(typeof(Dictionary<string, ImageCacheItem>));
|
||||||
|
imageCache = (Dictionary<string, ImageCacheItem>)dcs.ReadObject(fs);
|
||||||
|
fs.Close();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
imageCache = new Dictionary<string, ImageCacheItem>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Speichern der Bildinformationen
|
||||||
|
internal static void SaveCachedImageInfo()
|
||||||
|
{
|
||||||
|
IsolatedStorageFileStream fs =
|
||||||
|
IsolatedStorageFile.GetUserStoreForApplication().CreateFile(IMAGECACHEFILE);
|
||||||
|
|
||||||
|
DataContractSerializer dcs = new DataContractSerializer(typeof(Dictionary<string, ImageCacheItem>));
|
||||||
|
dcs.WriteObject(fs, imageCache);
|
||||||
|
fs.Flush();
|
||||||
|
fs.Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
using System;
|
||||||
|
using System.Net;
|
||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Controls;
|
||||||
|
using System.Windows.Documents;
|
||||||
|
using System.Windows.Ink;
|
||||||
|
using System.Windows.Input;
|
||||||
|
using System.Windows.Media;
|
||||||
|
using System.Windows.Media.Animation;
|
||||||
|
using System.Windows.Shapes;
|
||||||
|
using System.Windows.Data;
|
||||||
|
using System.Globalization;
|
||||||
|
using System.Windows.Media.Imaging;
|
||||||
|
|
||||||
|
namespace WPImageCaching
|
||||||
|
{
|
||||||
|
public class ImageCacheConverter : IValueConverter
|
||||||
|
{
|
||||||
|
|
||||||
|
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||||
|
{
|
||||||
|
if (value is BitmapImage)
|
||||||
|
{
|
||||||
|
return ImageCache.GetImage((BitmapImage)value);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
using System;
|
||||||
|
using System.Net;
|
||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Controls;
|
||||||
|
using System.Windows.Documents;
|
||||||
|
using System.Windows.Ink;
|
||||||
|
using System.Windows.Input;
|
||||||
|
using System.Windows.Media;
|
||||||
|
using System.Windows.Media.Animation;
|
||||||
|
using System.Windows.Shapes;
|
||||||
|
|
||||||
|
namespace WPImageCaching
|
||||||
|
{
|
||||||
|
//Beinhaltet die Informationen eines Bildes
|
||||||
|
internal class ImageCacheItem
|
||||||
|
{
|
||||||
|
public string LocalFilename { get; set; }
|
||||||
|
public string ImageID { get; set; }
|
||||||
|
public DateTime Expiration { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,132 @@
|
|||||||
|
using System;
|
||||||
|
using System.Net;
|
||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Controls;
|
||||||
|
using System.Windows.Documents;
|
||||||
|
using System.Windows.Ink;
|
||||||
|
using System.Windows.Input;
|
||||||
|
using System.Windows.Media;
|
||||||
|
using System.Windows.Media.Animation;
|
||||||
|
using System.Windows.Shapes;
|
||||||
|
using System.Text;
|
||||||
|
using System.Security.Cryptography;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO.IsolatedStorage;
|
||||||
|
using System.IO;
|
||||||
|
using System.Windows.Media.Imaging;
|
||||||
|
|
||||||
|
namespace WPImageCaching
|
||||||
|
{
|
||||||
|
internal static class ImageDownloadHelper
|
||||||
|
{
|
||||||
|
private const double EXPIRATIONDAYS = 1.0;
|
||||||
|
|
||||||
|
//Hilfsmethode zum Laden des Bildes
|
||||||
|
public static void DownloadImage(string url, BitmapImage image, ImageCacheItem item)
|
||||||
|
{
|
||||||
|
string filename = CreateUniqueFilename(url);
|
||||||
|
item.LocalFilename = filename;
|
||||||
|
|
||||||
|
//Erstellen des Hilfsobjektes zur Übergabe an den asynchronen Aufruf
|
||||||
|
AsyncDataTransfer transfer = new AsyncDataTransfer();
|
||||||
|
transfer.Item = item;
|
||||||
|
transfer.Image = image;
|
||||||
|
|
||||||
|
//Erstellen der Abfrage
|
||||||
|
var wc = (HttpWebRequest)HttpWebRequest.Create(url);
|
||||||
|
if (item.ImageID!=null)
|
||||||
|
{
|
||||||
|
//Prüfen, ob das Bild im Web immer noch aktuell ist
|
||||||
|
wc.Headers["If-None-Match"] = item.ImageID;
|
||||||
|
}
|
||||||
|
transfer.WebRequest = wc;
|
||||||
|
|
||||||
|
wc.BeginGetResponse(RequestCallback, transfer);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void RequestCallback(IAsyncResult result)
|
||||||
|
{
|
||||||
|
//War die Abfrage erfolgreich
|
||||||
|
if (!result.IsCompleted)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Herstellen des Hilfsobjektes
|
||||||
|
AsyncDataTransfer transfer = (AsyncDataTransfer)result.AsyncState;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var response = (HttpWebResponse)transfer.WebRequest.EndGetResponse(result);
|
||||||
|
|
||||||
|
//Bild wurde nicht geändert seit dem letzten Aufruf
|
||||||
|
if (response.StatusCode == HttpStatusCode.NotModified)
|
||||||
|
{
|
||||||
|
Deployment.Current.Dispatcher.BeginInvoke(() => transfer.Image.SetSource(IsolatedStorageFile.GetUserStoreForApplication().OpenFile(transfer.Item.LocalFilename, FileMode.Open)));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//Hat das Bild eine neue ID?
|
||||||
|
if (response.Headers["ETag"] != null)
|
||||||
|
{
|
||||||
|
transfer.Item.ImageID = response.Headers["ETag"];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
transfer.Item.ImageID = null;
|
||||||
|
}
|
||||||
|
//Gibt es ein Ablaufdatum?
|
||||||
|
if (response.Headers["Expires"] != null)
|
||||||
|
{
|
||||||
|
transfer.Item.Expiration = DateTime.Parse(response.Headers["Expires"]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
transfer.Item.Expiration = DateTime.Now.AddDays(EXPIRATIONDAYS);
|
||||||
|
}
|
||||||
|
|
||||||
|
var responseStream = response.GetResponseStream();
|
||||||
|
|
||||||
|
//Schreiben der Bilddatei
|
||||||
|
using (var bw = new BinaryWriter(IsolatedStorageFile.GetUserStoreForApplication().CreateFile(transfer.Item.LocalFilename)))
|
||||||
|
{
|
||||||
|
byte[] b = new byte[4096];
|
||||||
|
int read = 0;
|
||||||
|
while ((read = responseStream.Read(b, 0, b.Length)) > 0)
|
||||||
|
{
|
||||||
|
bw.Write(b, 0, read);
|
||||||
|
}
|
||||||
|
bw.Flush();
|
||||||
|
bw.Close();
|
||||||
|
}
|
||||||
|
//Setzen des Bildes
|
||||||
|
Deployment.Current.Dispatcher.BeginInvoke(() => transfer.Image.SetSource(IsolatedStorageFile.GetUserStoreForApplication().OpenFile(transfer.Item.LocalFilename, FileMode.Open)));
|
||||||
|
//Hinzufügen der Bildinformationen
|
||||||
|
ImageCache.imageCache.Add(transfer.WebRequest.RequestUri.ToString(), transfer.Item);
|
||||||
|
//Speichern der Bildinformationen
|
||||||
|
ImageCache.SaveCachedImageInfo();
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
//Nichts machen, da Bild nicht heruntergeladen werden konnte
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Erstellt einen eindeutigen Namen für das zu ladende Bild
|
||||||
|
private static string CreateUniqueFilename(string url)
|
||||||
|
{
|
||||||
|
string extension = System.IO.Path.GetExtension(url);
|
||||||
|
byte[] textToHash = Encoding.UTF8.GetBytes(url);
|
||||||
|
SHA1Managed sa = new SHA1Managed();
|
||||||
|
byte[] hash = sa.ComputeHash(textToHash);
|
||||||
|
return BitConverter.ToString(hash)+extension;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//Hilfsklasse für den asynchronen Aufruf
|
||||||
|
internal class AsyncDataTransfer
|
||||||
|
{
|
||||||
|
public ManualResetEvent ResetEvent { get; set; }
|
||||||
|
public HttpWebRequest WebRequest { get; set; }
|
||||||
|
public BitmapImage Image { get; set; }
|
||||||
|
public ImageCacheItem Item { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
using System.Reflection;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
// General Information about an assembly is controlled through the following
|
||||||
|
// set of attributes. Change these attribute values to modify the information
|
||||||
|
// associated with an assembly.
|
||||||
|
[assembly: AssemblyTitle("WPImageCaching")]
|
||||||
|
[assembly: AssemblyDescription("")]
|
||||||
|
[assembly: AssemblyConfiguration("")]
|
||||||
|
[assembly: AssemblyCompany("Microsoft")]
|
||||||
|
[assembly: AssemblyProduct("WPImageCaching")]
|
||||||
|
[assembly: AssemblyCopyright("Copyright © Microsoft 2010")]
|
||||||
|
[assembly: AssemblyTrademark("")]
|
||||||
|
[assembly: AssemblyCulture("")]
|
||||||
|
|
||||||
|
// Setting ComVisible to false makes the types in this assembly not visible
|
||||||
|
// to COM components. If you need to access a type in this assembly from
|
||||||
|
// COM, set the ComVisible attribute to true on that type.
|
||||||
|
[assembly: ComVisible(false)]
|
||||||
|
|
||||||
|
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||||
|
[assembly: Guid("a6a5ab19-1d8d-4a28-a25f-f1529b26d5b8")]
|
||||||
|
|
||||||
|
// Version information for an assembly consists of the following four values:
|
||||||
|
//
|
||||||
|
// Major Version
|
||||||
|
// Minor Version
|
||||||
|
// Build Number
|
||||||
|
// Revision
|
||||||
|
//
|
||||||
|
// You can specify all the values or you can default the Revision and Build Numbers
|
||||||
|
// by using the '*' as shown below:
|
||||||
|
[assembly: AssemblyVersion("1.0.0.0")]
|
||||||
|
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||||
@@ -0,0 +1,69 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup>
|
||||||
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||||
|
<ProductVersion>10.0.20506</ProductVersion>
|
||||||
|
<SchemaVersion>2.0</SchemaVersion>
|
||||||
|
<ProjectGuid>{17158FD9-80FD-49C1-9E3F-C5633602A4D9}</ProjectGuid>
|
||||||
|
<ProjectTypeGuids>{C089C8C0-30E0-4E22-80C0-CE093F111A43};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
|
||||||
|
<OutputType>Library</OutputType>
|
||||||
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||||
|
<RootNamespace>WPImageCaching</RootNamespace>
|
||||||
|
<AssemblyName>WPImageCaching</AssemblyName>
|
||||||
|
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||||
|
<SilverlightVersion>$(TargetFrameworkVersion)</SilverlightVersion>
|
||||||
|
<TargetFrameworkProfile>WindowsPhone</TargetFrameworkProfile>
|
||||||
|
<TargetFrameworkIdentifier>Silverlight</TargetFrameworkIdentifier>
|
||||||
|
<SilverlightApplication>false</SilverlightApplication>
|
||||||
|
<ValidateXaml>true</ValidateXaml>
|
||||||
|
<ThrowErrorsInValidation>true</ThrowErrorsInValidation>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<Optimize>false</Optimize>
|
||||||
|
<OutputPath>Bin\Debug</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;TRACE;SILVERLIGHT;WINDOWS_PHONE</DefineConstants>
|
||||||
|
<NoStdLib>true</NoStdLib>
|
||||||
|
<NoConfig>true</NoConfig>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<OutputPath>Bin\Release</OutputPath>
|
||||||
|
<DefineConstants>TRACE;SILVERLIGHT;WINDOWS_PHONE</DefineConstants>
|
||||||
|
<NoStdLib>true</NoStdLib>
|
||||||
|
<NoConfig>true</NoConfig>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="mscorlib" />
|
||||||
|
<Reference Include="System.Runtime.Serialization" />
|
||||||
|
<Reference Include="System.Windows" />
|
||||||
|
<Reference Include="system" />
|
||||||
|
<Reference Include="System.Core" />
|
||||||
|
<Reference Include="System.Xml" />
|
||||||
|
<Reference Include="System.Net" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="ImageCache.cs" />
|
||||||
|
<Compile Include="ImageCacheConverter.cs" />
|
||||||
|
<Compile Include="ImageCacheItem.cs" />
|
||||||
|
<Compile Include="ImageDownloadHelper.cs" />
|
||||||
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(MSBuildExtensionsPath)\Microsoft\Silverlight for Phone\$(TargetFrameworkVersion)\Microsoft.Silverlight.$(TargetFrameworkProfile).Overrides.targets" />
|
||||||
|
<Import Project="$(MSBuildExtensionsPath)\Microsoft\Silverlight for Phone\$(TargetFrameworkVersion)\Microsoft.Silverlight.CSharp.targets" />
|
||||||
|
<ProjectExtensions />
|
||||||
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
|
Other similar extension points exist, see Microsoft.Common.targets.
|
||||||
|
<Target Name="BeforeBuild">
|
||||||
|
</Target>
|
||||||
|
<Target Name="AfterBuild">
|
||||||
|
</Target>
|
||||||
|
-->
|
||||||
|
</Project>
|
||||||
@@ -10,15 +10,14 @@
|
|||||||
xmlns:my="clr-namespace:Coding4Fun.Phone.Controls.Converters;assembly=Coding4Fun.Phone.Controls"
|
xmlns:my="clr-namespace:Coding4Fun.Phone.Controls.Converters;assembly=Coding4Fun.Phone.Controls"
|
||||||
xmlns:my1="clr-namespace:Microsoft.Silverlight.Testing.Client;assembly=Microsoft.Silverlight.Testing"
|
xmlns:my1="clr-namespace:Microsoft.Silverlight.Testing.Client;assembly=Microsoft.Silverlight.Testing"
|
||||||
xmlns:Controls="clr-namespace:Coding4Fun.Phone.Controls;assembly=Coding4Fun.Phone.Controls"
|
xmlns:Controls="clr-namespace:Coding4Fun.Phone.Controls;assembly=Coding4Fun.Phone.Controls"
|
||||||
xmlns:Views="clr-namespace:MyFriendsAround.WP7.Views">
|
xmlns:Views="clr-namespace:MyFriendsAround.WP7.Views" xmlns:ImageCacherDemo="clr-namespace:WPImageCaching;assembly=WPImageCaching">
|
||||||
|
|
||||||
<!--Application Resources-->
|
<!--Application Resources-->
|
||||||
<Application.Resources>
|
<Application.Resources>
|
||||||
<vm:ViewModelLocator x:Key="Locator"
|
<vm:ViewModelLocator x:Key="Locator" d:IsDataSource="True" />
|
||||||
d:IsDataSource="True" />
|
|
||||||
<my:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter1" />
|
<my:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter1" />
|
||||||
<my1:InvertValueConverter x:Key="InvertValueConverter1" />
|
<my1:InvertValueConverter x:Key="InvertValueConverter1" />
|
||||||
|
<ImageCacherDemo:ImageCacheConverter x:Key="imageCacheConverter" />
|
||||||
</Application.Resources>
|
</Application.Resources>
|
||||||
|
|
||||||
<Application.ApplicationLifetimeObjects>
|
<Application.ApplicationLifetimeObjects>
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ namespace MyFriendsAround.WP7
|
|||||||
{
|
{
|
||||||
SaveModel();
|
SaveModel();
|
||||||
//
|
//
|
||||||
ViewModelLocator locator = Container.Instance.Resolve<ViewModelLocator>();
|
ViewModelLocator locator = Container.Instance.Resolve<ViewModelLocator>("ViewModelLocator");
|
||||||
locator.Cleanup();
|
locator.Cleanup();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -101,24 +101,22 @@ namespace MyFriendsAround.WP7
|
|||||||
MainViewModel mainModel = this.RetrieveFromIsolatedStorage<MainViewModel>();
|
MainViewModel mainModel = this.RetrieveFromIsolatedStorage<MainViewModel>();
|
||||||
if (mainModel != null)
|
if (mainModel != null)
|
||||||
{
|
{
|
||||||
mainModel.IsLoaded = true;
|
|
||||||
mainModel.IsBusy = false;
|
mainModel.IsBusy = false;
|
||||||
Container.Instance.RegisterInstance<MainViewModel>(mainModel, "MainViewModel");
|
Container.Instance.RegisterInstance<MainViewModel>(mainModel, Constants.VM_MAIN);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Container.Instance.RegisterInstance<MainViewModel>(new MainViewModel(), "MainViewModel");
|
Container.Instance.RegisterInstance<MainViewModel>(new MainViewModel(), Constants.VM_MAIN);
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
SettingsViewModel settingsModel = this.RetrieveFromIsolatedStorage<SettingsViewModel>();
|
SettingsViewModel settingsModel = this.RetrieveFromIsolatedStorage<SettingsViewModel>();
|
||||||
if (settingsModel != null)
|
if (settingsModel != null)
|
||||||
{
|
{
|
||||||
settingsModel.IsLoaded = true;
|
Container.Instance.RegisterInstance<SettingsViewModel>(settingsModel, Constants.VM_SETTINGS);
|
||||||
Container.Instance.RegisterInstance<SettingsViewModel>(settingsModel, "SettingsViewModel");
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Container.Instance.RegisterInstance<SettingsViewModel>(new SettingsViewModel(), "SettingsViewModel");
|
Container.Instance.RegisterInstance<SettingsViewModel>(new SettingsViewModel(), Constants.VM_SETTINGS);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -126,8 +124,8 @@ namespace MyFriendsAround.WP7
|
|||||||
|
|
||||||
private void SaveModel()
|
private void SaveModel()
|
||||||
{
|
{
|
||||||
this.SaveToIsolatedStorage<MainViewModel>(Container.Instance.Resolve<MainViewModel>("MainViewModel"));
|
this.SaveToIsolatedStorage<MainViewModel>(Container.Instance.Resolve<MainViewModel>(Constants.VM_MAIN));
|
||||||
this.SaveToIsolatedStorage<SettingsViewModel>(Container.Instance.Resolve<SettingsViewModel>("SettingsViewModel"));
|
this.SaveToIsolatedStorage<SettingsViewModel>(Container.Instance.Resolve<SettingsViewModel>(Constants.VM_SETTINGS));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,52 @@
|
|||||||
|
using System;
|
||||||
|
using System.Net;
|
||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Controls;
|
||||||
|
using System.Windows.Data;
|
||||||
|
using System.Windows.Documents;
|
||||||
|
using System.Windows.Ink;
|
||||||
|
using System.Windows.Input;
|
||||||
|
using System.Windows.Media;
|
||||||
|
using System.Windows.Media.Animation;
|
||||||
|
using System.Windows.Shapes;
|
||||||
|
using System.Windows.Media.Imaging;
|
||||||
|
using MyFriendsAround.WP7.Utils;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
|
namespace MyFriendsAround.WP7.Helpers.Converters
|
||||||
|
{
|
||||||
|
public class MyImageConverter : IValueConverter
|
||||||
|
{
|
||||||
|
private static BitmapImage anonymousBitmap =
|
||||||
|
new BitmapImage(new Uri("/icons/anonymousIcon.png", UriKind.RelativeOrAbsolute));
|
||||||
|
|
||||||
|
#region IValueConverter Members
|
||||||
|
|
||||||
|
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
|
||||||
|
{
|
||||||
|
string imageName = value.ToString();
|
||||||
|
if (!string.IsNullOrEmpty(imageName))
|
||||||
|
{
|
||||||
|
string[] res = imageName.Split('?');
|
||||||
|
byte[] img = IsolatedStorageHelper.LoadFromLocalStorageArray(res[0], "profiles");
|
||||||
|
if (img != null)
|
||||||
|
{
|
||||||
|
BitmapImage bi = new BitmapImage();
|
||||||
|
using (MemoryStream ms = new MemoryStream(img))
|
||||||
|
{
|
||||||
|
bi.SetSource(ms);
|
||||||
|
}
|
||||||
|
return bi;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return anonymousBitmap;
|
||||||
|
}
|
||||||
|
|
||||||
|
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -157,6 +157,7 @@
|
|||||||
<Compile Include="App.xaml.cs">
|
<Compile Include="App.xaml.cs">
|
||||||
<DependentUpon>App.xaml</DependentUpon>
|
<DependentUpon>App.xaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="Helpers\Converters\MyImageConverter.cs" />
|
||||||
<Compile Include="Helpers\Navigation\IPageNavigation.cs" />
|
<Compile Include="Helpers\Navigation\IPageNavigation.cs" />
|
||||||
<Compile Include="Helpers\Navigation\PageNavigation.cs" />
|
<Compile Include="Helpers\Navigation\PageNavigation.cs" />
|
||||||
<Compile Include="Service\ILocationService.cs" />
|
<Compile Include="Service\ILocationService.cs" />
|
||||||
@@ -165,6 +166,8 @@
|
|||||||
<Compile Include="Service\LocationService.cs" />
|
<Compile Include="Service\LocationService.cs" />
|
||||||
<Compile Include="Service\LocationStatusEventArgs.cs" />
|
<Compile Include="Service\LocationStatusEventArgs.cs" />
|
||||||
<Compile Include="Utils\ApplicationExtensions.cs" />
|
<Compile Include="Utils\ApplicationExtensions.cs" />
|
||||||
|
<Compile Include="Utils\Constants.cs" />
|
||||||
|
<Compile Include="Utils\Haversine.cs" />
|
||||||
<Compile Include="Utils\IsolatedStorageHelper.cs" />
|
<Compile Include="Utils\IsolatedStorageHelper.cs" />
|
||||||
<Compile Include="Utils\LittleWatson.cs">
|
<Compile Include="Utils\LittleWatson.cs">
|
||||||
<SubType>Code</SubType>
|
<SubType>Code</SubType>
|
||||||
@@ -280,6 +283,10 @@
|
|||||||
<Project>{B55A0F90-2B5A-4C4B-88F4-013AA1629866}</Project>
|
<Project>{B55A0F90-2B5A-4C4B-88F4-013AA1629866}</Project>
|
||||||
<Name>Phone7.Fx.Preview</Name>
|
<Name>Phone7.Fx.Preview</Name>
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
|
<ProjectReference Include="..\Libs\WPImageCaching\WPImageCaching.csproj">
|
||||||
|
<Project>{17158FD9-80FD-49C1-9E3F-C5633602A4D9}</Project>
|
||||||
|
<Name>WPImageCaching</Name>
|
||||||
|
</ProjectReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildExtensionsPath)\Microsoft\Silverlight for Phone\$(TargetFrameworkVersion)\Microsoft.Silverlight.$(TargetFrameworkProfile).Overrides.targets" />
|
<Import Project="$(MSBuildExtensionsPath)\Microsoft\Silverlight for Phone\$(TargetFrameworkVersion)\Microsoft.Silverlight.$(TargetFrameworkProfile).Overrides.targets" />
|
||||||
<Import Project="$(MSBuildExtensionsPath)\Microsoft\Silverlight for Phone\$(TargetFrameworkVersion)\Microsoft.Silverlight.CSharp.targets" />
|
<Import Project="$(MSBuildExtensionsPath)\Microsoft\Silverlight for Phone\$(TargetFrameworkVersion)\Microsoft.Silverlight.CSharp.targets" />
|
||||||
|
|||||||
@@ -11,13 +11,13 @@ namespace MyFriendsAround.WP7.Service
|
|||||||
public static class ServiceAgent
|
public static class ServiceAgent
|
||||||
{
|
{
|
||||||
|
|
||||||
private static int _timeOut = 10;
|
private static int _timeOut = 15;
|
||||||
public static string baseUrl;
|
public static string baseUrl;
|
||||||
|
|
||||||
static ServiceAgent()
|
static ServiceAgent()
|
||||||
{
|
{
|
||||||
//baseUrl = "http://myfriendsaround.cloudapp.net/myfriends";//live azure
|
baseUrl = "http://myfriendsaround.cloudapp.net/myfriends";//live azure
|
||||||
baseUrl = "http://127.0.0.1:82/myfriends";//running in local azure emulator
|
//baseUrl = "http://127.0.0.1:80/myfriends";//running in local azure emulator
|
||||||
//baseUrl = "http://localhost.:55672/myfriends";//for local asp.net mvc use
|
//baseUrl = "http://localhost.:55672/myfriends";//for local asp.net mvc use
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
using System;
|
||||||
|
using System.Net;
|
||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Controls;
|
||||||
|
using System.Windows.Documents;
|
||||||
|
using System.Windows.Ink;
|
||||||
|
using System.Windows.Input;
|
||||||
|
using System.Windows.Media;
|
||||||
|
using System.Windows.Media.Animation;
|
||||||
|
using System.Windows.Shapes;
|
||||||
|
|
||||||
|
namespace MyFriendsAround.WP7.Utils
|
||||||
|
{
|
||||||
|
public class Constants
|
||||||
|
{
|
||||||
|
public const string MYPICTURE_FILE_NAME = "myphoto.jpg";
|
||||||
|
//viewmodels names
|
||||||
|
public const string VM_MAIN = "MainViewModel";
|
||||||
|
public const string VM_SETTINGS = "SettingsViewModel";
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,60 @@
|
|||||||
|
using System;
|
||||||
|
using System.Net;
|
||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Controls;
|
||||||
|
using System.Windows.Documents;
|
||||||
|
using System.Windows.Ink;
|
||||||
|
using System.Windows.Input;
|
||||||
|
using System.Windows.Media;
|
||||||
|
using System.Windows.Media.Animation;
|
||||||
|
using System.Windows.Shapes;
|
||||||
|
|
||||||
|
namespace MyFriendsAround.WP7.Utils
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The distance type to return the results in.
|
||||||
|
/// </summary>
|
||||||
|
public enum DistanceType { Miles, Kilometers };
|
||||||
|
/// <summary>
|
||||||
|
/// Specifies a Latitude / Longitude point.
|
||||||
|
/// </summary>
|
||||||
|
public struct Position
|
||||||
|
{
|
||||||
|
public double Latitude;
|
||||||
|
public double Longitude;
|
||||||
|
}
|
||||||
|
|
||||||
|
public class Haversine
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the distance in miles or kilometers of any two
|
||||||
|
/// latitude / longitude points.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name=”pos1″></param>
|
||||||
|
/// <param name=”pos2″></param>
|
||||||
|
/// <param name=”type”></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static double Distance(Position pos1, Position pos2, DistanceType type)
|
||||||
|
{
|
||||||
|
double R = (type == DistanceType.Miles) ? 3960 : 6371;
|
||||||
|
double dLat = toRadian(pos2.Latitude - pos1.Latitude);
|
||||||
|
double dLon = toRadian(pos2.Longitude - pos1.Longitude);
|
||||||
|
double a = Math.Sin(dLat / 2) * Math.Sin(dLat / 2) +
|
||||||
|
Math.Cos(toRadian(pos1.Latitude)) * Math.Cos(toRadian(pos2.Latitude)) *
|
||||||
|
Math.Sin(dLon / 2) * Math.Sin(dLon / 2);
|
||||||
|
double c = 2 * Math.Asin(Math.Min(1, Math.Sqrt(a)));
|
||||||
|
double d = R * c;
|
||||||
|
return d;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Convert to Radians.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="val"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
private static double toRadian(double val)
|
||||||
|
{
|
||||||
|
return (Math.PI / 180) * val;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -60,7 +60,6 @@ namespace MyFriendsAround.WP7.ViewModel
|
|||||||
//
|
//
|
||||||
MainLoadCommand = new RelayCommand(() => MainLoad());
|
MainLoadCommand = new RelayCommand(() => MainLoad());
|
||||||
PublishLocationCommand = new RelayCommand(() => PublishLocationAction());
|
PublishLocationCommand = new RelayCommand(() => PublishLocationAction());
|
||||||
DisplayAboutCommand = new RelayCommand(() => DisplayAbout());
|
|
||||||
NavigateToSettingsCommand = new RelayCommand(() => NavigateToSettings());
|
NavigateToSettingsCommand = new RelayCommand(() => NavigateToSettings());
|
||||||
RefreshFriendsCommand = new RelayCommand(() => RefreshFriends());
|
RefreshFriendsCommand = new RelayCommand(() => RefreshFriends());
|
||||||
ShowAboutCommand = new RelayCommand(() => ShowAbout());
|
ShowAboutCommand = new RelayCommand(() => ShowAbout());
|
||||||
@@ -73,6 +72,7 @@ namespace MyFriendsAround.WP7.ViewModel
|
|||||||
ShowMyLocationCommand = new RelayCommand(() => ShowMyLocation());
|
ShowMyLocationCommand = new RelayCommand(() => ShowMyLocation());
|
||||||
MapZoomInCommand = new RelayCommand(() => MapZoomIn());
|
MapZoomInCommand = new RelayCommand(() => MapZoomIn());
|
||||||
MapZoomOutCommand = new RelayCommand(() => MapZoomOut());
|
MapZoomOutCommand = new RelayCommand(() => MapZoomOut());
|
||||||
|
ShowSelectFriendCommand = new RelayCommand(() => ShowSelectFriend());
|
||||||
|
|
||||||
if (IsInDesignMode)
|
if (IsInDesignMode)
|
||||||
{
|
{
|
||||||
@@ -93,91 +93,11 @@ namespace MyFriendsAround.WP7.ViewModel
|
|||||||
InitGps();
|
InitGps();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void MapZoomOut()
|
|
||||||
{
|
|
||||||
//
|
|
||||||
if(MapZoom<22)
|
|
||||||
{
|
|
||||||
MapZoom++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void MapZoomIn()
|
|
||||||
{
|
|
||||||
//
|
|
||||||
if (MapZoom >2 )
|
|
||||||
{
|
|
||||||
MapZoom--;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private void InitGps()
|
private void ShowSelectFriend()
|
||||||
{
|
{
|
||||||
App.LocationService.LocationChanged += new EventHandler<LocationChangedEventArgs>(LocationService_LocationChanged);
|
IsSelectFriend = true;
|
||||||
App.LocationService.StatusChanged += new EventHandler<LocationStatusEventArgs>(LocationService_StatusChanged);
|
|
||||||
App.LocationService.Start();
|
|
||||||
}
|
|
||||||
|
|
||||||
void LocationService_StatusChanged(object sender, LocationStatusEventArgs e)
|
|
||||||
{
|
|
||||||
GpsStatus = e.Status;
|
|
||||||
}
|
|
||||||
|
|
||||||
void LocationService_LocationChanged(object sender, LocationChangedEventArgs e)
|
|
||||||
{
|
|
||||||
if (e.Location != Location.Unknown)
|
|
||||||
{
|
|
||||||
GpsLocation = e.Location;
|
|
||||||
|
|
||||||
if (LastBoundRect!= null && LastBoundRect.Intersects(new LocationRect(
|
|
||||||
new GeoCoordinate(GpsLocation.Latitude, GpsLocation.Longitude),
|
|
||||||
.5,
|
|
||||||
.5)))
|
|
||||||
{
|
|
||||||
ObservableCollection<PushPinModel> _mynewlocation = new ObservableCollection<PushPinModel>();
|
|
||||||
_mynewlocation.Add(new PushPinModel()
|
|
||||||
{
|
|
||||||
Location = new GeoCoordinate(GpsLocation.Latitude, GpsLocation.Longitude),
|
|
||||||
PinUserName = "Me"
|
|
||||||
});
|
|
||||||
MyLocationPushPins = _mynewlocation;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
MyLocationPushPins = new ObservableCollection<PushPinModel>();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
System.Diagnostics.Debug.WriteLine("watcher_PositionChanged + " + DateTime.Now.Second);
|
|
||||||
}
|
|
||||||
|
|
||||||
void watcher_PositionChanged(object sender, GeoPositionChangedEventArgs<GeoCoordinate> e)
|
|
||||||
{
|
|
||||||
if (e.Position.Location != GeoCoordinate.Unknown)
|
|
||||||
{
|
|
||||||
GpsLocation = new Location(
|
|
||||||
e.Position.Location.Latitude,
|
|
||||||
e.Position.Location.Longitude,
|
|
||||||
e.Position.Timestamp);
|
|
||||||
|
|
||||||
if (LastBoundRect!=null && LastBoundRect.Intersects(new LocationRect(e.Position.Location, .5, .5)))
|
|
||||||
{
|
|
||||||
ObservableCollection<PushPinModel> _mynewlocation = new ObservableCollection<PushPinModel>();
|
|
||||||
_mynewlocation.Add(new PushPinModel()
|
|
||||||
{
|
|
||||||
Location = new GeoCoordinate(GpsLocation.Latitude, GpsLocation.Longitude),
|
|
||||||
PinUserName = "Me"
|
|
||||||
});
|
|
||||||
MyLocationPushPins = _mynewlocation;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
MyLocationPushPins = new ObservableCollection<PushPinModel>();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
System.Diagnostics.Debug.WriteLine("watcher_PositionChanged + " + DateTime.Now.Second);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -187,6 +107,8 @@ namespace MyFriendsAround.WP7.ViewModel
|
|||||||
|
|
||||||
#region Properties & Fields
|
#region Properties & Fields
|
||||||
|
|
||||||
|
private LocationRect LastBoundRect = null;
|
||||||
|
|
||||||
private PhotoChooserTask photoChooserTask;
|
private PhotoChooserTask photoChooserTask;
|
||||||
|
|
||||||
public string ApplicationTitle
|
public string ApplicationTitle
|
||||||
@@ -226,133 +148,7 @@ namespace MyFriendsAround.WP7.ViewModel
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region AppBarText
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The <see cref="GpsLocation" /> property's name.
|
|
||||||
/// </summary>
|
|
||||||
public const string GpsLocationPropertyName = "GpsLocation";
|
|
||||||
|
|
||||||
private Location _gpsLocation = Location.Unknown;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the GpsLocation property.
|
|
||||||
/// </summary>
|
|
||||||
public Location GpsLocation
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return _gpsLocation;
|
|
||||||
}
|
|
||||||
|
|
||||||
set
|
|
||||||
{
|
|
||||||
if (_gpsLocation == value)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
_gpsLocation = value;
|
|
||||||
|
|
||||||
// Update bindings, no broadcast
|
|
||||||
RaisePropertyChanged(GpsLocationPropertyName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The <see cref="GpsStatus" /> property's name.
|
|
||||||
/// </summary>
|
|
||||||
public const string GpsStatusPropertyName = "GpsStatus";
|
|
||||||
|
|
||||||
private GeoPositionStatus _gpsStatus = GeoPositionStatus.Disabled;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the GpsStatus property.
|
|
||||||
/// </summary>
|
|
||||||
public GeoPositionStatus GpsStatus
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return _gpsStatus;
|
|
||||||
}
|
|
||||||
|
|
||||||
set
|
|
||||||
{
|
|
||||||
if (_gpsStatus == value)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
_gpsStatus = value;
|
|
||||||
|
|
||||||
// Update bindings, no broadcast
|
|
||||||
RaisePropertyChanged(GpsStatusPropertyName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The <see cref="MyPicture" /> property's name.
|
|
||||||
/// </summary>
|
|
||||||
public const string MyPicturePropertyName = "MyPicture";
|
|
||||||
private ImageSource _myPicture = new BitmapImage(new Uri("/icons/anonymousIcon.png", UriKind.RelativeOrAbsolute));
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the MyPicture property.
|
|
||||||
/// </summary>
|
|
||||||
public ImageSource MyPicture
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return _myPicture;
|
|
||||||
}
|
|
||||||
|
|
||||||
set
|
|
||||||
{
|
|
||||||
if (_myPicture == value)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
_myPicture = value;
|
|
||||||
|
|
||||||
// Update bindings, no broadcast
|
|
||||||
RaisePropertyChanged(MyPicturePropertyName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The <see cref="MyName" /> property's name.
|
|
||||||
/// </summary>
|
|
||||||
public const string MyNamePropertyName = "MyName";
|
|
||||||
private string _myName = "Guest";
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the MyName property.
|
|
||||||
/// </summary>
|
|
||||||
public string MyName
|
|
||||||
{
|
|
||||||
get { return _myName; }
|
|
||||||
set
|
|
||||||
{
|
|
||||||
if (_myName == value)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
var oldValue = _myName;
|
|
||||||
_myName = value;
|
|
||||||
// Update bindings, no broadcast
|
|
||||||
RaisePropertyChanged(MyNamePropertyName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public string AppBarTextAbout
|
public string AppBarTextAbout
|
||||||
{
|
{
|
||||||
@@ -389,6 +185,220 @@ namespace MyFriendsAround.WP7.ViewModel
|
|||||||
get { return "Cancel"; }
|
get { return "Cancel"; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The <see cref="SelectedFriend" /> property's name.
|
||||||
|
/// </summary>
|
||||||
|
public const string SelectedFriendPropertyName = "SelectedFriend";
|
||||||
|
|
||||||
|
private PushPinModel _SelectedFriend = new PushPinModel()
|
||||||
|
{
|
||||||
|
Location = GeoCoordinate.Unknown,
|
||||||
|
PinUserName = "Guest",
|
||||||
|
PinImageUrl = string.Empty
|
||||||
|
};
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the SelectedFriend property.
|
||||||
|
/// </summary>
|
||||||
|
public PushPinModel SelectedFriend
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _SelectedFriend;
|
||||||
|
}
|
||||||
|
|
||||||
|
set
|
||||||
|
{
|
||||||
|
IsSelectFriend = false;
|
||||||
|
if (_SelectedFriend == value)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_SelectedFriend = value;
|
||||||
|
|
||||||
|
if (_SelectedFriend != null && _SelectedFriend.Location!=GeoCoordinate.Unknown)
|
||||||
|
MapCenter = _SelectedFriend.Location;
|
||||||
|
|
||||||
|
// Update bindings, no broadcast
|
||||||
|
RaisePropertyChanged(SelectedFriendPropertyName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The <see cref="IsSelectFriend" /> property's name.
|
||||||
|
/// </summary>
|
||||||
|
public const string IsSelectFriendPropertyName = "IsSelectFriend";
|
||||||
|
|
||||||
|
private bool _isSelectFriend = false;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the IsSelectFriend property.
|
||||||
|
/// </summary>
|
||||||
|
public bool IsSelectFriend
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _isSelectFriend;
|
||||||
|
}
|
||||||
|
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (_isSelectFriend == value)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_isSelectFriend = value;
|
||||||
|
|
||||||
|
// Update bindings, no broadcast
|
||||||
|
RaisePropertyChanged(IsSelectFriendPropertyName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The <see cref="GpsLocation" /> property's name.
|
||||||
|
/// </summary>
|
||||||
|
public const string GpsLocationPropertyName = "GpsLocation";
|
||||||
|
|
||||||
|
private Location _gpsLocation = Location.Unknown;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the GpsLocation property.
|
||||||
|
/// </summary>
|
||||||
|
public Location GpsLocation
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _gpsLocation;
|
||||||
|
}
|
||||||
|
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (_gpsLocation == value)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_gpsLocation = value;
|
||||||
|
|
||||||
|
// Update bindings, no broadcast
|
||||||
|
RaisePropertyChanged(GpsLocationPropertyName);
|
||||||
|
|
||||||
|
UpdateDistances();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void UpdateDistances()
|
||||||
|
{
|
||||||
|
foreach (var pushPin in PushPins)
|
||||||
|
{
|
||||||
|
pushPin.PinDistance =
|
||||||
|
(GpsLocation != Location.Unknown)
|
||||||
|
? Haversine.Distance(
|
||||||
|
new Position()
|
||||||
|
{Latitude = pushPin.Location.Latitude, Longitude = pushPin.Location.Longitude},
|
||||||
|
new Position() {Latitude = GpsLocation.Latitude, Longitude = GpsLocation.Longitude},
|
||||||
|
DistanceType.Kilometers)
|
||||||
|
: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The <see cref="GpsStatus" /> property's name.
|
||||||
|
/// </summary>
|
||||||
|
public const string GpsStatusPropertyName = "GpsStatus";
|
||||||
|
|
||||||
|
private GeoPositionStatus _gpsStatus = GeoPositionStatus.Disabled;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the GpsStatus property.
|
||||||
|
/// </summary>
|
||||||
|
public GeoPositionStatus GpsStatus
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _gpsStatus;
|
||||||
|
}
|
||||||
|
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (_gpsStatus == value)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_gpsStatus = value;
|
||||||
|
|
||||||
|
// Update bindings, no broadcast
|
||||||
|
RaisePropertyChanged(GpsStatusPropertyName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The <see cref="MyPicture" /> property's name.
|
||||||
|
/// </summary>
|
||||||
|
public const string MyPicturePropertyName = "MyPicture";
|
||||||
|
private string _myPicture = Constants.MYPICTURE_FILE_NAME;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the MyPicture property.
|
||||||
|
/// </summary>
|
||||||
|
public string MyPicture
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _myPicture;
|
||||||
|
}
|
||||||
|
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (_myPicture == value)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_myPicture = value;
|
||||||
|
|
||||||
|
// Update bindings, no broadcast
|
||||||
|
RaisePropertyChanged(MyPicturePropertyName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The <see cref="MyName" /> property's name.
|
||||||
|
/// </summary>
|
||||||
|
public const string MyNamePropertyName = "MyName";
|
||||||
|
private string _myName = "Guest";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the MyName property.
|
||||||
|
/// </summary>
|
||||||
|
public string MyName
|
||||||
|
{
|
||||||
|
get { return _myName; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (_myName == value)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_myName = value;
|
||||||
|
// Update bindings, no broadcast
|
||||||
|
RaisePropertyChanged(MyNamePropertyName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The <see cref="PushPins" /> property's name.
|
/// The <see cref="PushPins" /> property's name.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -401,6 +411,23 @@ namespace MyFriendsAround.WP7.ViewModel
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
|
if (IsInDesignMode)
|
||||||
|
{
|
||||||
|
ObservableCollection<PushPinModel> _testlist = new ObservableCollection<PushPinModel>();
|
||||||
|
_testlist.Add(new PushPinModel()
|
||||||
|
{
|
||||||
|
Location = new GeoCoordinate(10, 10),
|
||||||
|
PinUserName = "User1",
|
||||||
|
PinImageUrl = "http://www.clker.com/cliparts/b/1/f/a/1195445301811339265dagobert83_female_user_icon.svg.thumb.png"
|
||||||
|
});
|
||||||
|
_testlist.Add(new PushPinModel()
|
||||||
|
{
|
||||||
|
Location = new GeoCoordinate(20, 20),
|
||||||
|
PinUserName = "User2",
|
||||||
|
PinImageUrl = "http://www.spanishseo.org/files/avatar_selection/user.png"
|
||||||
|
});
|
||||||
|
return _testlist;
|
||||||
|
}
|
||||||
return _PushPins;
|
return _PushPins;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -415,6 +442,8 @@ namespace MyFriendsAround.WP7.ViewModel
|
|||||||
|
|
||||||
// Update bindings, no broadcast
|
// Update bindings, no broadcast
|
||||||
RaisePropertyChanged(PushPinsPropertyName);
|
RaisePropertyChanged(PushPinsPropertyName);
|
||||||
|
//
|
||||||
|
RefreshVisiblePushPins();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -427,6 +456,7 @@ namespace MyFriendsAround.WP7.ViewModel
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the VisiblePushPins property.
|
/// Gets the VisiblePushPins property.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[JsonIgnore]
|
||||||
public ObservableCollection<PushPinModel> VisiblePushPins
|
public ObservableCollection<PushPinModel> VisiblePushPins
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
@@ -581,11 +611,12 @@ namespace MyFriendsAround.WP7.ViewModel
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#region Commands
|
#region Commands
|
||||||
|
|
||||||
public ICommand MainLoadCommand { get; set; }
|
public ICommand MainLoadCommand { get; set; }
|
||||||
public ICommand PublishLocationCommand { get; set; }
|
public ICommand PublishLocationCommand { get; set; }
|
||||||
public ICommand DisplayAboutCommand { get; set; }
|
|
||||||
public ICommand NavigateToSettingsCommand { get; set; }
|
public ICommand NavigateToSettingsCommand { get; set; }
|
||||||
public ICommand ShowMyLocationCommand { get; set; }
|
public ICommand ShowMyLocationCommand { get; set; }
|
||||||
public ICommand RefreshFriendsCommand { get; set; }
|
public ICommand RefreshFriendsCommand { get; set; }
|
||||||
@@ -598,11 +629,75 @@ namespace MyFriendsAround.WP7.ViewModel
|
|||||||
public ICommand MapViewChangedCommand { get; set; }
|
public ICommand MapViewChangedCommand { get; set; }
|
||||||
public ICommand MapZoomInCommand { get; set; }
|
public ICommand MapZoomInCommand { get; set; }
|
||||||
public ICommand MapZoomOutCommand { get; set; }
|
public ICommand MapZoomOutCommand { get; set; }
|
||||||
|
public ICommand ShowSelectFriendCommand { get; set; }
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#region Implemented Commands & Methods
|
#region Implemented Commands & Methods
|
||||||
|
|
||||||
|
|
||||||
|
private void MapZoomOut()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
if (MapZoom < 22)
|
||||||
|
{
|
||||||
|
MapZoom++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void MapZoomIn()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
if (MapZoom > 2)
|
||||||
|
{
|
||||||
|
MapZoom--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void InitGps()
|
||||||
|
{
|
||||||
|
App.LocationService.LocationChanged += LocationService_LocationChanged;
|
||||||
|
App.LocationService.StatusChanged += LocationService_StatusChanged;
|
||||||
|
App.LocationService.Start();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LocationService_StatusChanged(object sender, LocationStatusEventArgs e)
|
||||||
|
{
|
||||||
|
GpsStatus = e.Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LocationService_LocationChanged(object sender, LocationChangedEventArgs e)
|
||||||
|
{
|
||||||
|
if (e.Location != Location.Unknown)
|
||||||
|
{
|
||||||
|
GpsLocation = e.Location;
|
||||||
|
|
||||||
|
if (LastBoundRect != null && LastBoundRect.Intersects(new LocationRect(
|
||||||
|
new GeoCoordinate(GpsLocation.Latitude, GpsLocation.Longitude),
|
||||||
|
.5,
|
||||||
|
.5)))
|
||||||
|
{
|
||||||
|
ObservableCollection<PushPinModel> _mynewlocation = new ObservableCollection<PushPinModel>();
|
||||||
|
_mynewlocation.Add(new PushPinModel()
|
||||||
|
{
|
||||||
|
Location = new GeoCoordinate(GpsLocation.Latitude, GpsLocation.Longitude),
|
||||||
|
PinUserName = "Me"
|
||||||
|
});
|
||||||
|
MyLocationPushPins = _mynewlocation;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MyLocationPushPins = new ObservableCollection<PushPinModel>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
System.Diagnostics.Debug.WriteLine("watcher_PositionChanged + " + DateTime.Now.Second);
|
||||||
|
}
|
||||||
|
|
||||||
private void ShowMyLocation()
|
private void ShowMyLocation()
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
@@ -614,24 +709,18 @@ namespace MyFriendsAround.WP7.ViewModel
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private LocationRect LastBoundRect = null;
|
|
||||||
private void MapViewChanged(LocationRect boundRectangle)
|
private void MapViewChanged(LocationRect boundRectangle)
|
||||||
{
|
{
|
||||||
LastBoundRect = boundRectangle;
|
LastBoundRect = boundRectangle;
|
||||||
//
|
//
|
||||||
ObservableCollection<PushPinModel> _newVisiblePushPins = new ObservableCollection<PushPinModel>();
|
RefreshVisiblePushPins();
|
||||||
//filter visible pushpins
|
|
||||||
foreach (PushPinModel pushPin in PushPins)
|
|
||||||
{
|
|
||||||
if (LastBoundRect!=null && LastBoundRect.Intersects(new LocationRect(
|
|
||||||
new GeoCoordinate(pushPin.Location.Latitude, pushPin.Location.Longitude),
|
|
||||||
.5, .5)))
|
|
||||||
{
|
|
||||||
_newVisiblePushPins.Add(pushPin);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
VisiblePushPins = _newVisiblePushPins;
|
|
||||||
//
|
//
|
||||||
|
RefreshMyLocation();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void RefreshMyLocation()
|
||||||
|
{
|
||||||
if (GpsLocation == Location.Unknown ||
|
if (GpsLocation == Location.Unknown ||
|
||||||
LastBoundRect == null ||
|
LastBoundRect == null ||
|
||||||
!LastBoundRect.Intersects(new LocationRect(
|
!LastBoundRect.Intersects(new LocationRect(
|
||||||
@@ -640,6 +729,32 @@ namespace MyFriendsAround.WP7.ViewModel
|
|||||||
{
|
{
|
||||||
MyLocationPushPins = new ObservableCollection<PushPinModel>();
|
MyLocationPushPins = new ObservableCollection<PushPinModel>();
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ObservableCollection<PushPinModel> _mynewlocation = new ObservableCollection<PushPinModel>();
|
||||||
|
_mynewlocation.Add(new PushPinModel()
|
||||||
|
{
|
||||||
|
Location = new GeoCoordinate(GpsLocation.Latitude, GpsLocation.Longitude),
|
||||||
|
PinUserName = "Me"
|
||||||
|
});
|
||||||
|
MyLocationPushPins = _mynewlocation;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void RefreshVisiblePushPins()
|
||||||
|
{
|
||||||
|
ObservableCollection<PushPinModel> _newVisiblePushPins = new ObservableCollection<PushPinModel>();
|
||||||
|
//filter visible pushpins
|
||||||
|
foreach (PushPinModel pushPin in PushPins)
|
||||||
|
{
|
||||||
|
if (LastBoundRect != null && LastBoundRect.Intersects(new LocationRect(
|
||||||
|
new GeoCoordinate(pushPin.Location.Latitude, pushPin.Location.Longitude),
|
||||||
|
.5, .5)))
|
||||||
|
{
|
||||||
|
_newVisiblePushPins.Add(pushPin);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
VisiblePushPins = _newVisiblePushPins;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void CropCancel()
|
public void CropCancel()
|
||||||
@@ -656,38 +771,11 @@ namespace MyFriendsAround.WP7.ViewModel
|
|||||||
|
|
||||||
private void MainLoad()
|
private void MainLoad()
|
||||||
{
|
{
|
||||||
if (IsLoaded)
|
//this.MyPicture = Constants.MYPICTURE_FILE_NAME + "?" + DateTime.UtcNow.Ticks;
|
||||||
{
|
RaisePropertyChanged(MyPicturePropertyName);
|
||||||
|
RaisePropertyChanged(MyNamePropertyName);
|
||||||
//
|
//
|
||||||
ThreadPool.QueueUserWorkItem(LoadMyPicture);
|
RefreshMyLocation();
|
||||||
//
|
|
||||||
IsLoaded = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void LoadMyPicture(object param) //Background thread
|
|
||||||
{
|
|
||||||
Thread.Sleep(500);
|
|
||||||
byte[] img = IsolatedStorageHelper.LoadFromLocalStorageArray("myphoto.jpg", "profiles");
|
|
||||||
if (img != null)
|
|
||||||
{
|
|
||||||
DispatcherHelper.CheckBeginInvokeOnUI(() =>
|
|
||||||
{
|
|
||||||
using (MemoryStream ms = new MemoryStream(img))
|
|
||||||
{
|
|
||||||
BitmapImage bi = new BitmapImage();
|
|
||||||
bi.SetSource(ms);
|
|
||||||
Container.Instance.Resolve<MainViewModel>("MainViewModel").MyPicture = bi;// PictureDecoder.DecodeJpeg(ms);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
DispatcherHelper.CheckBeginInvokeOnUI(() =>
|
|
||||||
{
|
|
||||||
Container.Instance.Resolve<MainViewModel>("MainViewModel").MyPicture = new BitmapImage(new Uri("/icons/anonymousIcon.png", UriKind.RelativeOrAbsolute));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -731,7 +819,7 @@ namespace MyFriendsAround.WP7.ViewModel
|
|||||||
byte[] _imageBytes = new byte[e.ChosenPhoto.Length];
|
byte[] _imageBytes = new byte[e.ChosenPhoto.Length];
|
||||||
e.ChosenPhoto.Read(_imageBytes, 0, _imageBytes.Length);
|
e.ChosenPhoto.Read(_imageBytes, 0, _imageBytes.Length);
|
||||||
//save
|
//save
|
||||||
IsolatedStorageHelper.SaveToLocalStorage("myphoto.jpg", "profiles", _imageBytes);
|
IsolatedStorageHelper.SaveToLocalStorage(Constants.MYPICTURE_FILE_NAME, "profiles", _imageBytes);
|
||||||
|
|
||||||
// Seek back so we can create an image.
|
// Seek back so we can create an image.
|
||||||
e.ChosenPhoto.Seek(0, SeekOrigin.Begin);
|
e.ChosenPhoto.Seek(0, SeekOrigin.Begin);
|
||||||
@@ -739,7 +827,7 @@ namespace MyFriendsAround.WP7.ViewModel
|
|||||||
//var imageSource = PictureDecoder.DecodeJpeg(e.ChosenPhoto);
|
//var imageSource = PictureDecoder.DecodeJpeg(e.ChosenPhoto);
|
||||||
BitmapImage bi = new BitmapImage();
|
BitmapImage bi = new BitmapImage();
|
||||||
bi.SetSource(e.ChosenPhoto);
|
bi.SetSource(e.ChosenPhoto);
|
||||||
MyPicture = bi;// imageSource;
|
//MyPicture = bi;// imageSource;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -779,12 +867,6 @@ namespace MyFriendsAround.WP7.ViewModel
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void DisplayAbout()
|
|
||||||
{
|
|
||||||
MessageBox.Show("About");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private void PopulatePushPins(List<Friend> list)
|
private void PopulatePushPins(List<Friend> list)
|
||||||
{
|
{
|
||||||
ObservableCollection<PushPinModel> result = new ObservableCollection<PushPinModel>();
|
ObservableCollection<PushPinModel> result = new ObservableCollection<PushPinModel>();
|
||||||
@@ -796,10 +878,24 @@ namespace MyFriendsAround.WP7.ViewModel
|
|||||||
PinSource = "/ApplicationIcon.png",
|
PinSource = "/ApplicationIcon.png",
|
||||||
Location = new GeoCoordinate(f.Latitude, f.Longitude),
|
Location = new GeoCoordinate(f.Latitude, f.Longitude),
|
||||||
PinUserName = f.FriendName,
|
PinUserName = f.FriendName,
|
||||||
PinImageUrl = string.Format("https://myfriendsaround.blob.core.windows.net/profiles/profile_{0}.jpg", f.Id)
|
PinImageUrl =
|
||||||
|
string.Format(
|
||||||
|
"https://myfriendsaround.blob.core.windows.net/profiles/profile_{0}.jpg",
|
||||||
|
f.Id),
|
||||||
|
PinLastUpdated = f.LastUpdated,
|
||||||
|
PinDistance =
|
||||||
|
(GpsLocation != Location.Unknown)
|
||||||
|
? Haversine.Distance(
|
||||||
|
new Position() {Latitude = f.Latitude, Longitude = f.Longitude},
|
||||||
|
new Position()
|
||||||
|
{Latitude = GpsLocation.Latitude, Longitude = GpsLocation.Longitude},
|
||||||
|
DistanceType.Kilometers)
|
||||||
|
: 0
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
PushPins = result;
|
PushPins = result;
|
||||||
|
if (result.Count > 0)
|
||||||
|
SelectedFriend = PushPins[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -875,7 +971,7 @@ namespace MyFriendsAround.WP7.ViewModel
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
//update also the picture
|
//update also the picture
|
||||||
byte[] img = IsolatedStorageHelper.LoadFromLocalStorageArray("myphoto.jpg", "profiles");
|
byte[] img = IsolatedStorageHelper.LoadFromLocalStorageArray(Constants.MYPICTURE_FILE_NAME, "profiles");
|
||||||
if (img != null)
|
if (img != null)
|
||||||
{
|
{
|
||||||
ServiceAgent.PublishMyPicture(Identification.GetDeviceId(), img, new EventHandler<PublishLocationEventArgs>(PublishMyPictureResult));
|
ServiceAgent.PublishMyPicture(Identification.GetDeviceId(), img, new EventHandler<PublishLocationEventArgs>(PublishMyPictureResult));
|
||||||
|
|||||||
@@ -43,7 +43,6 @@ namespace MyFriendsAround.WP7.ViewModel
|
|||||||
|
|
||||||
|
|
||||||
private string _pinUserName;
|
private string _pinUserName;
|
||||||
|
|
||||||
public string PinUserName
|
public string PinUserName
|
||||||
{
|
{
|
||||||
get { return _pinUserName; }
|
get { return _pinUserName; }
|
||||||
@@ -59,7 +58,6 @@ namespace MyFriendsAround.WP7.ViewModel
|
|||||||
|
|
||||||
|
|
||||||
private string _pinImageUrl;
|
private string _pinImageUrl;
|
||||||
|
|
||||||
public string PinImageUrl
|
public string PinImageUrl
|
||||||
{
|
{
|
||||||
get { return _pinImageUrl; }
|
get { return _pinImageUrl; }
|
||||||
@@ -73,6 +71,36 @@ namespace MyFriendsAround.WP7.ViewModel
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private DateTime _pinLastUpdated;
|
||||||
|
public DateTime PinLastUpdated
|
||||||
|
{
|
||||||
|
get { return _pinLastUpdated; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (_pinLastUpdated != value)
|
||||||
|
{
|
||||||
|
_pinLastUpdated = value;
|
||||||
|
OnPropertyChanged("PinLastUpdated");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private double _pinDistance;
|
||||||
|
public double PinDistance
|
||||||
|
{
|
||||||
|
get { return Math.Round(_pinDistance, 2); }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (_pinDistance != value)
|
||||||
|
{
|
||||||
|
_pinDistance = value;
|
||||||
|
OnPropertyChanged("PinDistance");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public event PropertyChangedEventHandler PropertyChanged;
|
public event PropertyChangedEventHandler PropertyChanged;
|
||||||
|
|
||||||
|
|||||||
@@ -15,8 +15,6 @@ namespace MyFriendsAround.WP7.ViewModel
|
|||||||
public class ViewModelBase : GalaSoft.MvvmLight.ViewModelBase
|
public class ViewModelBase : GalaSoft.MvvmLight.ViewModelBase
|
||||||
{
|
{
|
||||||
|
|
||||||
public bool IsLoaded { get; set; }
|
|
||||||
|
|
||||||
private object context;
|
private object context;
|
||||||
public object Context
|
public object Context
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
using MyFriendsAround.WP7.Helpers.Navigation;
|
using MyFriendsAround.WP7.Helpers.Navigation;
|
||||||
|
using MyFriendsAround.WP7.Utils;
|
||||||
using NetworkDetection;
|
using NetworkDetection;
|
||||||
|
|
||||||
namespace MyFriendsAround.WP7.ViewModel
|
namespace MyFriendsAround.WP7.ViewModel
|
||||||
@@ -85,7 +86,7 @@ namespace MyFriendsAround.WP7.ViewModel
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
MainViewModel mainViewModel = GetViewModel<MainViewModel>("MainViewModel");
|
MainViewModel mainViewModel = GetViewModel<MainViewModel>(Constants.VM_MAIN);
|
||||||
return mainViewModel;
|
return mainViewModel;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -97,7 +98,7 @@ namespace MyFriendsAround.WP7.ViewModel
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
SettingsViewModel aboutViewModel = GetViewModel<SettingsViewModel>("SettingsViewModel");
|
SettingsViewModel aboutViewModel = GetViewModel<SettingsViewModel>(Constants.VM_SETTINGS);
|
||||||
return aboutViewModel;
|
return aboutViewModel;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -108,9 +109,9 @@ namespace MyFriendsAround.WP7.ViewModel
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public void Cleanup()
|
public void Cleanup()
|
||||||
{
|
{
|
||||||
MainViewModel mainViewModel = GetViewModel<MainViewModel>("MainViewModel");
|
MainViewModel mainViewModel = GetViewModel<MainViewModel>(Constants.VM_MAIN);
|
||||||
mainViewModel.Cleanup();
|
mainViewModel.Cleanup();
|
||||||
SettingsViewModel aboutViewModel = GetViewModel<SettingsViewModel>("SettingsViewModel");
|
SettingsViewModel aboutViewModel = GetViewModel<SettingsViewModel>(Constants.VM_SETTINGS);
|
||||||
aboutViewModel.Cleanup();
|
aboutViewModel.Cleanup();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -118,11 +119,10 @@ namespace MyFriendsAround.WP7.ViewModel
|
|||||||
|
|
||||||
#region Local Helpers
|
#region Local Helpers
|
||||||
|
|
||||||
private T GetViewModel<T>(string key) where T : ViewModelBase
|
public static T GetViewModel<T>(string key) where T : ViewModelBase
|
||||||
{
|
{
|
||||||
// Create a new view model
|
// Create a new view model
|
||||||
T vm = Container.Instance.Resolve<T>(key);
|
T vm = Container.Instance.Resolve<T>(key);
|
||||||
|
|
||||||
//Assign the Context from PageNavigation to Context property of the ViewModelBase
|
//Assign the Context from PageNavigation to Context property of the ViewModelBase
|
||||||
vm.Context = vm.PageNav.CurrentContext;
|
vm.Context = vm.PageNav.CurrentContext;
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ using Microsoft.Phone.Tasks;
|
|||||||
using MyFriendsAround.WP7.Utils;
|
using MyFriendsAround.WP7.Utils;
|
||||||
using MyFriendsAround.WP7.ViewModel;
|
using MyFriendsAround.WP7.ViewModel;
|
||||||
using NetworkDetection;
|
using NetworkDetection;
|
||||||
|
using System.Threading;
|
||||||
|
|
||||||
namespace MyFriendsAround.WP7.Views
|
namespace MyFriendsAround.WP7.Views
|
||||||
{
|
{
|
||||||
@@ -53,7 +54,7 @@ namespace MyFriendsAround.WP7.Views
|
|||||||
|
|
||||||
private void NavigateBack()
|
private void NavigateBack()
|
||||||
{
|
{
|
||||||
Container.Instance.Resolve<MainViewModel>("MainViewModel").CropCancel();
|
Container.Instance.Resolve<MainViewModel>(Constants.VM_MAIN).CropCancel();
|
||||||
}
|
}
|
||||||
|
|
||||||
void task_Completed(object sender, PhotoResult e)
|
void task_Completed(object sender, PhotoResult e)
|
||||||
@@ -158,12 +159,7 @@ namespace MyFriendsAround.WP7.Views
|
|||||||
byte[] _imageBytes = new byte[stream.Length];
|
byte[] _imageBytes = new byte[stream.Length];
|
||||||
stream.Read(_imageBytes, 0, _imageBytes.Length);
|
stream.Read(_imageBytes, 0, _imageBytes.Length);
|
||||||
//save
|
//save
|
||||||
IsolatedStorageHelper.SaveToLocalStorage("myphoto.jpg", "profiles", _imageBytes);
|
IsolatedStorageHelper.SaveToLocalStorage(Constants.MYPICTURE_FILE_NAME, "profiles", _imageBytes);
|
||||||
//
|
|
||||||
//BitmapImage bi = new BitmapImage();
|
|
||||||
//stream.Seek(0, SeekOrigin.Begin);
|
|
||||||
//bi.SetSource(stream);
|
|
||||||
Container.Instance.Resolve<MainViewModel>("MainViewModel").MyPicture = wbm;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,14 +18,17 @@
|
|||||||
d:DesignHeight="768"
|
d:DesignHeight="768"
|
||||||
shell:SystemTray.IsVisible="True"
|
shell:SystemTray.IsVisible="True"
|
||||||
DataContext="{Binding Main, Source={StaticResource Locator}}"
|
DataContext="{Binding Main, Source={StaticResource Locator}}"
|
||||||
|
d:DataContext="{Binding Main, Source={StaticResource Locator}}"
|
||||||
xmlns:my="clr-namespace:Microsoft.Phone.Controls.Maps;assembly=Microsoft.Phone.Controls.Maps"
|
xmlns:my="clr-namespace:Microsoft.Phone.Controls.Maps;assembly=Microsoft.Phone.Controls.Maps"
|
||||||
xmlns:Preview="clr-namespace:Phone7.Fx.Preview;assembly=Phone7.Fx.Preview"
|
xmlns:Preview="clr-namespace:Phone7.Fx.Preview;assembly=Phone7.Fx.Preview"
|
||||||
xmlns:binding="clr-namespace:Coding4Fun.Phone.Controls.Binding;assembly=Coding4Fun.Phone.Controls"
|
xmlns:binding="clr-namespace:Coding4Fun.Phone.Controls.Binding;assembly=Coding4Fun.Phone.Controls"
|
||||||
xmlns:Core="clr-namespace:Microsoft.Phone.Controls.Maps.Core;assembly=Microsoft.Phone.Controls.Maps">
|
xmlns:Core="clr-namespace:Microsoft.Phone.Controls.Maps.Core;assembly=Microsoft.Phone.Controls.Maps"
|
||||||
|
xmlns:conv="clr-namespace:MyFriendsAround.WP7.Helpers.Converters">
|
||||||
|
|
||||||
<!--LayoutRoot contains the root grid where all other page content is placed-->
|
<!--LayoutRoot contains the root grid where all other page content is placed-->
|
||||||
|
|
||||||
<phone:PhoneApplicationPage.Resources>
|
<phone:PhoneApplicationPage.Resources>
|
||||||
|
<conv:MyImageConverter x:Key="myImageConverter" />
|
||||||
<ControlTemplate x:Key="PushpinControlTemplate1"
|
<ControlTemplate x:Key="PushpinControlTemplate1"
|
||||||
TargetType="my:Pushpin">
|
TargetType="my:Pushpin">
|
||||||
<Grid Height="24"
|
<Grid Height="24"
|
||||||
@@ -44,7 +47,7 @@
|
|||||||
<Grid Background="{TemplateBinding Background}"
|
<Grid Background="{TemplateBinding Background}"
|
||||||
HorizontalAlignment="Left">
|
HorizontalAlignment="Left">
|
||||||
<Image x:Name="imgFriend"
|
<Image x:Name="imgFriend"
|
||||||
Source="{Binding PinImageUrl, Mode=OneWay}"
|
Source="{Binding PinImageUrl, Mode=OneWay, Converter={StaticResource imageCacheConverter}}"
|
||||||
Margin="2, 2, 2, 24"
|
Margin="2, 2, 2, 24"
|
||||||
Width="48"
|
Width="48"
|
||||||
Height="48"
|
Height="48"
|
||||||
@@ -98,22 +101,9 @@
|
|||||||
Grid.RowSpan="2"
|
Grid.RowSpan="2"
|
||||||
Margin="0">
|
Margin="0">
|
||||||
|
|
||||||
<!--<Button Content="Publish"
|
|
||||||
HorizontalAlignment="Left" Margin="6,0,0,6" Name="btnPublishLocation"
|
|
||||||
Width="468"
|
|
||||||
Height="72"
|
|
||||||
VerticalAlignment="Bottom">
|
|
||||||
<i:Interaction.Triggers>
|
|
||||||
<i:EventTrigger EventName="Click">
|
|
||||||
<cmd:EventToCommand Command="{Binding PublishLocationCommand}"/>
|
|
||||||
</i:EventTrigger>
|
|
||||||
</i:Interaction.Triggers>
|
|
||||||
</Button>-->
|
|
||||||
|
|
||||||
<my:Map x:Name="map"
|
<my:Map x:Name="map"
|
||||||
CredentialsProvider="AkCiPfQt9YM0cCkZlltdR3mnFQRkV41l4f-eXFmf3qcBBhBC-EkvD8MuazOkMnE_"
|
CredentialsProvider="AkCiPfQt9YM0cCkZlltdR3mnFQRkV41l4f-eXFmf3qcBBhBC-EkvD8MuazOkMnE_"
|
||||||
HorizontalAlignment="Stretch"
|
HorizontalAlignment="Stretch"
|
||||||
ZoomBarVisibility="Visible"
|
|
||||||
Margin="6,0,6,0"
|
Margin="6,0,6,0"
|
||||||
VerticalAlignment="Stretch"
|
VerticalAlignment="Stretch"
|
||||||
Center="{Binding Path=MapCenter, Mode=TwoWay}"
|
Center="{Binding Path=MapCenter, Mode=TwoWay}"
|
||||||
@@ -163,6 +153,18 @@
|
|||||||
</i:EventTrigger>
|
</i:EventTrigger>
|
||||||
</i:Interaction.Triggers>
|
</i:Interaction.Triggers>
|
||||||
</Image>
|
</Image>
|
||||||
|
<Slider Orientation="Vertical"
|
||||||
|
Minimum="1"
|
||||||
|
Maximum="22"
|
||||||
|
Value="{Binding MapZoom, Mode=TwoWay}"
|
||||||
|
Height="300">
|
||||||
|
<!--<i:Interaction.Triggers>
|
||||||
|
<i:EventTrigger EventName="ValueChanged">
|
||||||
|
<cmd:EventToCommand Command="{Binding MapZoomChangedCommand}" />
|
||||||
|
</i:EventTrigger>
|
||||||
|
</i:Interaction.Triggers>-->
|
||||||
|
</Slider>
|
||||||
|
|
||||||
<Image Source="/icons/appbar.minus.rest.png"
|
<Image Source="/icons/appbar.minus.rest.png"
|
||||||
Margin="0"
|
Margin="0"
|
||||||
Width="64"
|
Width="64"
|
||||||
@@ -186,10 +188,12 @@
|
|||||||
<Grid x:Name="TitlePanel"
|
<Grid x:Name="TitlePanel"
|
||||||
Grid.Row="0"
|
Grid.Row="0"
|
||||||
Margin="0"
|
Margin="0"
|
||||||
Background="Black"
|
Background="Transparent"
|
||||||
VerticalAlignment="Top"
|
VerticalAlignment="Top"
|
||||||
HorizontalAlignment="Stretch"
|
HorizontalAlignment="Stretch"
|
||||||
Opacity="0.8">
|
Opacity="1">
|
||||||
|
<Rectangle Fill="Black"
|
||||||
|
Opacity="0.7"></Rectangle>
|
||||||
<TextBlock x:Name="ApplicationTitle"
|
<TextBlock x:Name="ApplicationTitle"
|
||||||
Margin="12, 12, 0, 0"
|
Margin="12, 12, 0, 0"
|
||||||
Text="{Binding ApplicationTitle}"
|
Text="{Binding ApplicationTitle}"
|
||||||
@@ -200,13 +204,18 @@
|
|||||||
<Grid Width="80"
|
<Grid Width="80"
|
||||||
Height="80"
|
Height="80"
|
||||||
HorizontalAlignment="Right"
|
HorizontalAlignment="Right"
|
||||||
Background="Transparent"
|
Background="{StaticResource PhoneAccentBrush}"
|
||||||
Opacity="1">
|
Opacity="1">
|
||||||
<Image x:Name="imgMine"
|
<Image x:Name="imgMine"
|
||||||
Opacity="1"
|
Opacity="1"
|
||||||
Source="{Binding MyPicture, Mode=OneWay}"
|
Source="{Binding SelectedFriend, Path=SelectedFriend.PinImageUrl, Converter={StaticResource imageCacheConverter}}"
|
||||||
Margin="0"
|
Margin="1"
|
||||||
Stretch="Fill">
|
Stretch="Fill">
|
||||||
|
<i:Interaction.Triggers>
|
||||||
|
<i:EventTrigger EventName="MouseLeftButtonDown">
|
||||||
|
<cmd:EventToCommand Command="{Binding ShowSelectFriendCommand}" />
|
||||||
|
</i:EventTrigger>
|
||||||
|
</i:Interaction.Triggers>
|
||||||
</Image>
|
</Image>
|
||||||
<Border Background="{StaticResource PhoneAccentBrush}"
|
<Border Background="{StaticResource PhoneAccentBrush}"
|
||||||
Width="80"
|
Width="80"
|
||||||
@@ -222,7 +231,7 @@
|
|||||||
HorizontalAlignment="Left"
|
HorizontalAlignment="Left"
|
||||||
VerticalAlignment="Center"
|
VerticalAlignment="Center"
|
||||||
Margin="2"
|
Margin="2"
|
||||||
Text="{Binding MyName, Mode=OneWay}"
|
Text="{Binding SelectedFriend, Path=SelectedFriend.PinUserName}"
|
||||||
Opacity="1" />
|
Opacity="1" />
|
||||||
</Border>
|
</Border>
|
||||||
</Grid>
|
</Grid>
|
||||||
@@ -239,19 +248,87 @@
|
|||||||
|
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
|
<Grid Background="Transparent"
|
||||||
|
VerticalAlignment="Stretch"
|
||||||
|
Grid.RowSpan="2"
|
||||||
|
Visibility="{Binding IsSelectFriend, Converter={StaticResource BooleanToVisibilityConverter1}}">
|
||||||
|
<Rectangle Fill="Black"
|
||||||
|
Opacity="0.7">
|
||||||
|
</Rectangle>
|
||||||
|
<StackPanel Margin="20"
|
||||||
|
Opacity="1"
|
||||||
|
Background="Black"
|
||||||
|
VerticalAlignment="Stretch"
|
||||||
|
HorizontalAlignment="Stretch"
|
||||||
|
Width="Auto"
|
||||||
|
Height="Auto">
|
||||||
|
<TextBlock Text="Select your friend"
|
||||||
|
Style="{StaticResource PhoneTextNormalStyle}"
|
||||||
|
TextAlignment="Center"
|
||||||
|
FontSize="24"
|
||||||
|
Padding="10"
|
||||||
|
Margin="0" />
|
||||||
|
<ListBox ItemsSource="{Binding PushPins, Mode=OneWay}"
|
||||||
|
HorizontalAlignment="Stretch"
|
||||||
|
VerticalAlignment="Stretch"
|
||||||
|
Margin="0"
|
||||||
|
Width="Auto"
|
||||||
|
Height="675"
|
||||||
|
Background="Black"
|
||||||
|
Opacity="1"
|
||||||
|
SelectedItem="{Binding SelectedFriend, Mode=TwoWay}">
|
||||||
|
<ListBox.ItemTemplate>
|
||||||
|
<DataTemplate>
|
||||||
|
<StackPanel Orientation="Horizontal"
|
||||||
|
HorizontalAlignment="Stretch"
|
||||||
|
Margin="4">
|
||||||
|
<Image Source="{Binding PinImageUrl, Mode=OneWay, Converter={StaticResource imageCacheConverter}}"
|
||||||
|
Width="96"
|
||||||
|
Height="96" />
|
||||||
|
<StackPanel Margin="10, 0,0,0">
|
||||||
|
<TextBlock Text="{Binding PinUserName}"
|
||||||
|
FontSize="24" />
|
||||||
|
<StackPanel Orientation="Horizontal">
|
||||||
|
<TextBlock Text="Last update:"
|
||||||
|
FontSize="20">
|
||||||
|
</TextBlock>
|
||||||
|
<TextBlock Text="{Binding PinLastUpdated}"
|
||||||
|
FontSize="20"
|
||||||
|
Margin="10, 0, 0, 0" />
|
||||||
|
</StackPanel>
|
||||||
|
<StackPanel Orientation="Horizontal">
|
||||||
|
<TextBlock Text="Distance:"
|
||||||
|
FontSize="20">
|
||||||
|
</TextBlock>
|
||||||
|
<TextBlock Text="{Binding PinDistance}"
|
||||||
|
FontSize="20"
|
||||||
|
Margin="10, 0, 0, 0" />
|
||||||
|
<TextBlock Text="Km"
|
||||||
|
Margin="5, 0, 0, 0"
|
||||||
|
FontSize="20">
|
||||||
|
</TextBlock>
|
||||||
|
</StackPanel>
|
||||||
|
</StackPanel>
|
||||||
|
</StackPanel>
|
||||||
|
</DataTemplate>
|
||||||
|
</ListBox.ItemTemplate>
|
||||||
|
</ListBox>
|
||||||
|
</StackPanel>
|
||||||
|
</Grid>
|
||||||
|
|
||||||
<Preview:BindableApplicationBar x:Name="AppBar"
|
<Preview:BindableApplicationBar x:Name="AppBar"
|
||||||
BarOpacity="0.8">
|
BarOpacity="0.8">
|
||||||
<Preview:BindableApplicationBarIconButton Command="{Binding ShowMyLocationCommand}"
|
<Preview:BindableApplicationBarIconButton Command="{Binding ShowMyLocationCommand}"
|
||||||
IconUri="/icons/appbar.location.png"
|
IconUri="/icons/appbar.location.png"
|
||||||
Text="{Binding AppBarTextMyLocation}"
|
Text="{Binding AppBarTextMyLocation}" />
|
||||||
IsEnabled="{Binding Path=IsBusy, Converter={StaticResource InvertValueConverter1}}" />
|
|
||||||
<Preview:BindableApplicationBarIconButton Command="{Binding RefreshFriendsCommand}"
|
<Preview:BindableApplicationBarIconButton Command="{Binding RefreshFriendsCommand}"
|
||||||
IconUri="/icons/appbar.sync.rest.png"
|
IconUri="/icons/appbar.sync.rest.png"
|
||||||
Text="{Binding AppBarTextRefresh}"
|
Text="{Binding AppBarTextRefresh}"
|
||||||
IsEnabled="{Binding Path=IsBusy, Converter={StaticResource InvertValueConverter1}}" />
|
IsEnabled="{Binding Path=IsBusy, Converter={StaticResource InvertValueConverter1}}" />
|
||||||
<Preview:BindableApplicationBarIconButton Command="{Binding PublishLocationCommand}"
|
<Preview:BindableApplicationBarIconButton Command="{Binding PublishLocationCommand}"
|
||||||
IconUri="/icons/appbar.publish.png"
|
IconUri="/icons/appbar.publish.png"
|
||||||
Text="{Binding AppBarTextPublish}" />
|
Text="{Binding AppBarTextPublish}"
|
||||||
|
IsEnabled="{Binding Path=IsBusy, Converter={StaticResource InvertValueConverter1}}" />
|
||||||
<Preview:BindableApplicationBarIconButton Command="{Binding NavigateToSettingsCommand}"
|
<Preview:BindableApplicationBarIconButton Command="{Binding NavigateToSettingsCommand}"
|
||||||
IconUri="/icons/appbar.feature.settings.rest.png"
|
IconUri="/icons/appbar.feature.settings.rest.png"
|
||||||
Text="{Binding AppBarTextSettings}" />
|
Text="{Binding AppBarTextSettings}" />
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
|
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
|
||||||
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
|
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:binding="clr-namespace:Coding4Fun.Phone.Controls.Binding;assembly=Coding4Fun.Phone.Controls" xmlns:Preview="clr-namespace:Phone7.Fx.Preview;assembly=Phone7.Fx.Preview" xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity" xmlns:cmd="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.Extras.WP7" FontFamily="{StaticResource PhoneFontFamilyNormal}"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:binding="clr-namespace:Coding4Fun.Phone.Controls.Binding;assembly=Coding4Fun.Phone.Controls" xmlns:Preview="clr-namespace:Phone7.Fx.Preview;assembly=Phone7.Fx.Preview" xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity" xmlns:cmd="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.Extras.WP7" xmlns:conv="clr-namespace:MyFriendsAround.WP7.Helpers.Converters" FontFamily="{StaticResource PhoneFontFamilyNormal}"
|
||||||
FontSize="{StaticResource PhoneFontSizeNormal}"
|
FontSize="{StaticResource PhoneFontSizeNormal}"
|
||||||
Foreground="{StaticResource PhoneForegroundBrush}"
|
Foreground="{StaticResource PhoneForegroundBrush}"
|
||||||
SupportedOrientations="Portrait" Orientation="Portrait"
|
SupportedOrientations="Portrait" Orientation="Portrait"
|
||||||
@@ -13,6 +13,11 @@
|
|||||||
mc:Ignorable="d" d:DesignHeight="768" d:DesignWidth="480"
|
mc:Ignorable="d" d:DesignHeight="768" d:DesignWidth="480"
|
||||||
shell:SystemTray.IsVisible="True">
|
shell:SystemTray.IsVisible="True">
|
||||||
|
|
||||||
|
|
||||||
|
<phone:PhoneApplicationPage.Resources>
|
||||||
|
<conv:MyImageConverter x:Key="myImageConverter" />
|
||||||
|
</phone:PhoneApplicationPage.Resources>
|
||||||
|
|
||||||
<i:Interaction.Triggers>
|
<i:Interaction.Triggers>
|
||||||
<i:EventTrigger EventName="Loaded">
|
<i:EventTrigger EventName="Loaded">
|
||||||
<cmd:EventToCommand Command="{Binding MainLoadCommand}" />
|
<cmd:EventToCommand Command="{Binding MainLoadCommand}" />
|
||||||
@@ -47,7 +52,7 @@
|
|||||||
<TextBox Height="67"
|
<TextBox Height="67"
|
||||||
HorizontalAlignment="Stretch"
|
HorizontalAlignment="Stretch"
|
||||||
Name="txtMyName"
|
Name="txtMyName"
|
||||||
Text="{Binding Path=MyName, Mode=TwoWay}"
|
Text="{Binding MyName, Mode=TwoWay}"
|
||||||
VerticalAlignment="Top"
|
VerticalAlignment="Top"
|
||||||
binding:TextBoxBinding.UpdateSourceOnChange="True" />
|
binding:TextBoxBinding.UpdateSourceOnChange="True" />
|
||||||
<TextBlock Text="My Picture"
|
<TextBlock Text="My Picture"
|
||||||
@@ -65,7 +70,8 @@
|
|||||||
VerticalAlignment="Stretch"
|
VerticalAlignment="Stretch"
|
||||||
Stretch="Uniform"
|
Stretch="Uniform"
|
||||||
Margin="1"
|
Margin="1"
|
||||||
Source="{Binding MyPicture, Mode=TwoWay}"></Image>
|
Source="{Binding MyPicture, Mode=OneWay, Converter={StaticResource myImageConverter}}">
|
||||||
|
</Image>
|
||||||
<i:Interaction.Triggers>
|
<i:Interaction.Triggers>
|
||||||
<i:EventTrigger EventName="Click">
|
<i:EventTrigger EventName="Click">
|
||||||
<cmd:EventToCommand
|
<cmd:EventToCommand
|
||||||
@@ -76,7 +82,7 @@
|
|||||||
</StackPanel>
|
</StackPanel>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
<Preview:BindableApplicationBar x:Name="AppBar"
|
<!--<Preview:BindableApplicationBar x:Name="AppBar"
|
||||||
BarOpacity="0.8">
|
BarOpacity="0.8">
|
||||||
<Preview:BindableApplicationBarIconButton Command="{Binding SaveMySettingsCommand}"
|
<Preview:BindableApplicationBarIconButton Command="{Binding SaveMySettingsCommand}"
|
||||||
IconUri="/Toolkit.Content/ApplicationBar.Check.png"
|
IconUri="/Toolkit.Content/ApplicationBar.Check.png"
|
||||||
@@ -85,7 +91,7 @@
|
|||||||
<Preview:BindableApplicationBarIconButton Command="{Binding CancelMySettingsCommand}"
|
<Preview:BindableApplicationBarIconButton Command="{Binding CancelMySettingsCommand}"
|
||||||
IconUri="/Toolkit.Content/ApplicationBar.Cancel.png"
|
IconUri="/Toolkit.Content/ApplicationBar.Cancel.png"
|
||||||
Text="{Binding AppBarTextCancelSettings}" />
|
Text="{Binding AppBarTextCancelSettings}" />
|
||||||
</Preview:BindableApplicationBar>
|
</Preview:BindableApplicationBar>-->
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
<add name="ApplicationServices" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|myfriendsaround.mdf;User Instance=true" providerName="System.Data.SqlClient" />
|
<add name="ApplicationServices" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|myfriendsaround.mdf;User Instance=true" providerName="System.Data.SqlClient" />
|
||||||
<!--<add name="myfriendsaroundConnectionString" connectionString="Data Source=ewzculop8c.database.windows.net;Initial Catalog=myfriendsaround;User ID=user;Password=password" providerName="System.Data.SqlClient" />-->
|
<!--<add name="myfriendsaroundConnectionString" connectionString="Data Source=ewzculop8c.database.windows.net;Initial Catalog=myfriendsaround;User ID=user;Password=password" providerName="System.Data.SqlClient" />-->
|
||||||
<add name="MyFriendsModelContainer"
|
<add name="MyFriendsModelContainer"
|
||||||
connectionString="metadata=res://*/MyFriendsModel.csdl|res://*/MyFriendsModel.ssdl|res://*/MyFriendsModel.msl;provider=System.Data.SqlClient;provider connection string="Server=ewzculop8c.database.windows.net;Database=myfriendsaround;User ID=claudiu@ewzculop8c;Password=Endava2011;Trusted_Connection=False;Encrypt=True"" providerName="System.Data.EntityClient" />
|
connectionString="metadata=res://*/MyFriendsModel.csdl|res://*/MyFriendsModel.ssdl|res://*/MyFriendsModel.msl;provider=System.Data.SqlClient;provider connection string="Server=ewzculop8c.database.windows.net;Database=myfriendsaround;User ID=[USER]@ewzculop8c;Password=[PASSWORD];Trusted_Connection=False;Encrypt=True"" providerName="System.Data.EntityClient" />
|
||||||
</connectionStrings>
|
</connectionStrings>
|
||||||
|
|
||||||
<appSettings>
|
<appSettings>
|
||||||
|
|||||||
@@ -31,6 +31,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MicroIoc.Core", "Libs\Micro
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{CC5FD16D-436D-48AD-A40C-5A424C6E3E79}") = "MyFriendsAroundWindowsAzure", "MyFriendsAroundWindowsAzure\MyFriendsAroundWindowsAzure.ccproj", "{C656965D-5A6E-4BD4-9945-9C906B89128D}"
|
Project("{CC5FD16D-436D-48AD-A40C-5A424C6E3E79}") = "MyFriendsAroundWindowsAzure", "MyFriendsAroundWindowsAzure\MyFriendsAroundWindowsAzure.ccproj", "{C656965D-5A6E-4BD4-9945-9C906B89128D}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WPImageCaching", "Libs\WPImageCaching\WPImageCaching.csproj", "{17158FD9-80FD-49C1-9E3F-C5633602A4D9}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
@@ -307,6 +309,26 @@ Global
|
|||||||
{C656965D-5A6E-4BD4-9945-9C906B89128D}.Tests|Mixed Platforms.ActiveCfg = Release|Any CPU
|
{C656965D-5A6E-4BD4-9945-9C906B89128D}.Tests|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||||
{C656965D-5A6E-4BD4-9945-9C906B89128D}.Tests|Mixed Platforms.Build.0 = Release|Any CPU
|
{C656965D-5A6E-4BD4-9945-9C906B89128D}.Tests|Mixed Platforms.Build.0 = Release|Any CPU
|
||||||
{C656965D-5A6E-4BD4-9945-9C906B89128D}.Tests|x86.ActiveCfg = Release|Any CPU
|
{C656965D-5A6E-4BD4-9945-9C906B89128D}.Tests|x86.ActiveCfg = Release|Any CPU
|
||||||
|
{17158FD9-80FD-49C1-9E3F-C5633602A4D9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{17158FD9-80FD-49C1-9E3F-C5633602A4D9}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{17158FD9-80FD-49C1-9E3F-C5633602A4D9}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||||
|
{17158FD9-80FD-49C1-9E3F-C5633602A4D9}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
|
||||||
|
{17158FD9-80FD-49C1-9E3F-C5633602A4D9}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||||
|
{17158FD9-80FD-49C1-9E3F-C5633602A4D9}.GPS_EMULATOR|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{17158FD9-80FD-49C1-9E3F-C5633602A4D9}.GPS_EMULATOR|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{17158FD9-80FD-49C1-9E3F-C5633602A4D9}.GPS_EMULATOR|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||||
|
{17158FD9-80FD-49C1-9E3F-C5633602A4D9}.GPS_EMULATOR|Mixed Platforms.Build.0 = Release|Any CPU
|
||||||
|
{17158FD9-80FD-49C1-9E3F-C5633602A4D9}.GPS_EMULATOR|x86.ActiveCfg = Release|Any CPU
|
||||||
|
{17158FD9-80FD-49C1-9E3F-C5633602A4D9}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{17158FD9-80FD-49C1-9E3F-C5633602A4D9}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{17158FD9-80FD-49C1-9E3F-C5633602A4D9}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||||
|
{17158FD9-80FD-49C1-9E3F-C5633602A4D9}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||||
|
{17158FD9-80FD-49C1-9E3F-C5633602A4D9}.Release|x86.ActiveCfg = Release|Any CPU
|
||||||
|
{17158FD9-80FD-49C1-9E3F-C5633602A4D9}.Tests|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{17158FD9-80FD-49C1-9E3F-C5633602A4D9}.Tests|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{17158FD9-80FD-49C1-9E3F-C5633602A4D9}.Tests|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||||
|
{17158FD9-80FD-49C1-9E3F-C5633602A4D9}.Tests|Mixed Platforms.Build.0 = Release|Any CPU
|
||||||
|
{17158FD9-80FD-49C1-9E3F-C5633602A4D9}.Tests|x86.ActiveCfg = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
@@ -317,5 +339,6 @@ Global
|
|||||||
{BF7316A8-A2C5-4176-8D7F-672AD12F474D} = {340549A1-45EA-4B49-B194-347C0078BAD8}
|
{BF7316A8-A2C5-4176-8D7F-672AD12F474D} = {340549A1-45EA-4B49-B194-347C0078BAD8}
|
||||||
{B55A0F90-2B5A-4C4B-88F4-013AA1629866} = {340549A1-45EA-4B49-B194-347C0078BAD8}
|
{B55A0F90-2B5A-4C4B-88F4-013AA1629866} = {340549A1-45EA-4B49-B194-347C0078BAD8}
|
||||||
{23F63AE9-A436-4B27-9113-4142C09ADD08} = {340549A1-45EA-4B49-B194-347C0078BAD8}
|
{23F63AE9-A436-4B27-9113-4142C09ADD08} = {340549A1-45EA-4B49-B194-347C0078BAD8}
|
||||||
|
{17158FD9-80FD-49C1-9E3F-C5633602A4D9} = {340549A1-45EA-4B49-B194-347C0078BAD8}
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
EndGlobal
|
EndGlobal
|
||||||
|
|||||||
Reference in New Issue
Block a user