diff --git a/main/Libs/GpsEmulator/GpsEmulatorClient/ServiceReferences.ClientConfig b/main/Libs/GpsEmulator/GpsEmulatorClient/ServiceReferences.ClientConfig
index 29ba77f..75bea97 100644
--- a/main/Libs/GpsEmulator/GpsEmulatorClient/ServiceReferences.ClientConfig
+++ b/main/Libs/GpsEmulator/GpsEmulatorClient/ServiceReferences.ClientConfig
@@ -9,7 +9,7 @@
-
diff --git a/main/Libs/WPImageCaching/ImageCache.cs b/main/Libs/WPImageCaching/ImageCache.cs
new file mode 100644
index 0000000..a49e5f1
--- /dev/null
+++ b/main/Libs/WPImageCaching/ImageCache.cs
@@ -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 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));
+ imageCache = (Dictionary)dcs.ReadObject(fs);
+ fs.Close();
+ }
+ else
+ {
+ imageCache = new Dictionary();
+ }
+ }
+
+ //Speichern der Bildinformationen
+ internal static void SaveCachedImageInfo()
+ {
+ IsolatedStorageFileStream fs =
+ IsolatedStorageFile.GetUserStoreForApplication().CreateFile(IMAGECACHEFILE);
+
+ DataContractSerializer dcs = new DataContractSerializer(typeof(Dictionary));
+ dcs.WriteObject(fs, imageCache);
+ fs.Flush();
+ fs.Close();
+ }
+ }
+}
diff --git a/main/Libs/WPImageCaching/ImageCacheConverter.cs b/main/Libs/WPImageCaching/ImageCacheConverter.cs
new file mode 100644
index 0000000..c680f50
--- /dev/null
+++ b/main/Libs/WPImageCaching/ImageCacheConverter.cs
@@ -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();
+ }
+ }
+}
diff --git a/main/Libs/WPImageCaching/ImageCacheItem.cs b/main/Libs/WPImageCaching/ImageCacheItem.cs
new file mode 100644
index 0000000..ec7e31d
--- /dev/null
+++ b/main/Libs/WPImageCaching/ImageCacheItem.cs
@@ -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; }
+ }
+}
diff --git a/main/Libs/WPImageCaching/ImageDownloadHelper.cs b/main/Libs/WPImageCaching/ImageDownloadHelper.cs
new file mode 100644
index 0000000..d37b075
--- /dev/null
+++ b/main/Libs/WPImageCaching/ImageDownloadHelper.cs
@@ -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; }
+ }
+}
diff --git a/main/Libs/WPImageCaching/Properties/AssemblyInfo.cs b/main/Libs/WPImageCaching/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..434979f
--- /dev/null
+++ b/main/Libs/WPImageCaching/Properties/AssemblyInfo.cs
@@ -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")]
diff --git a/main/Libs/WPImageCaching/WPImageCaching.csproj b/main/Libs/WPImageCaching/WPImageCaching.csproj
new file mode 100644
index 0000000..a82c778
--- /dev/null
+++ b/main/Libs/WPImageCaching/WPImageCaching.csproj
@@ -0,0 +1,69 @@
+
+
+
+ Debug
+ AnyCPU
+ 10.0.20506
+ 2.0
+ {17158FD9-80FD-49C1-9E3F-C5633602A4D9}
+ {C089C8C0-30E0-4E22-80C0-CE093F111A43};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}
+ Library
+ Properties
+ WPImageCaching
+ WPImageCaching
+ v4.0
+ $(TargetFrameworkVersion)
+ WindowsPhone
+ Silverlight
+ false
+ true
+ true
+
+
+ true
+ full
+ false
+ Bin\Debug
+ DEBUG;TRACE;SILVERLIGHT;WINDOWS_PHONE
+ true
+ true
+ prompt
+ 4
+
+
+ pdbonly
+ true
+ Bin\Release
+ TRACE;SILVERLIGHT;WINDOWS_PHONE
+ true
+ true
+ prompt
+ 4
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/main/MyFriendsAround.WP7/App.xaml b/main/MyFriendsAround.WP7/App.xaml
index cdb5ea9..b6b6b4c 100644
--- a/main/MyFriendsAround.WP7/App.xaml
+++ b/main/MyFriendsAround.WP7/App.xaml
@@ -10,15 +10,14 @@
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: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">
-
+
-
+
diff --git a/main/MyFriendsAround.WP7/App.xaml.cs b/main/MyFriendsAround.WP7/App.xaml.cs
index 20581f8..5421dd2 100644
--- a/main/MyFriendsAround.WP7/App.xaml.cs
+++ b/main/MyFriendsAround.WP7/App.xaml.cs
@@ -90,7 +90,7 @@ namespace MyFriendsAround.WP7
{
SaveModel();
//
- ViewModelLocator locator = Container.Instance.Resolve();
+ ViewModelLocator locator = Container.Instance.Resolve("ViewModelLocator");
locator.Cleanup();
}
@@ -101,24 +101,22 @@ namespace MyFriendsAround.WP7
MainViewModel mainModel = this.RetrieveFromIsolatedStorage();
if (mainModel != null)
{
- mainModel.IsLoaded = true;
mainModel.IsBusy = false;
- Container.Instance.RegisterInstance(mainModel, "MainViewModel");
+ Container.Instance.RegisterInstance(mainModel, Constants.VM_MAIN);
}
else
{
- Container.Instance.RegisterInstance(new MainViewModel(), "MainViewModel");
+ Container.Instance.RegisterInstance(new MainViewModel(), Constants.VM_MAIN);
}
//
SettingsViewModel settingsModel = this.RetrieveFromIsolatedStorage();
if (settingsModel != null)
{
- settingsModel.IsLoaded = true;
- Container.Instance.RegisterInstance(settingsModel, "SettingsViewModel");
+ Container.Instance.RegisterInstance(settingsModel, Constants.VM_SETTINGS);
}
else
{
- Container.Instance.RegisterInstance(new SettingsViewModel(), "SettingsViewModel");
+ Container.Instance.RegisterInstance(new SettingsViewModel(), Constants.VM_SETTINGS);
}
}
@@ -126,8 +124,8 @@ namespace MyFriendsAround.WP7
private void SaveModel()
{
- this.SaveToIsolatedStorage(Container.Instance.Resolve("MainViewModel"));
- this.SaveToIsolatedStorage(Container.Instance.Resolve("SettingsViewModel"));
+ this.SaveToIsolatedStorage(Container.Instance.Resolve(Constants.VM_MAIN));
+ this.SaveToIsolatedStorage(Container.Instance.Resolve(Constants.VM_SETTINGS));
}
diff --git a/main/MyFriendsAround.WP7/Helpers/Converters/MyImageConverter.cs b/main/MyFriendsAround.WP7/Helpers/Converters/MyImageConverter.cs
new file mode 100644
index 0000000..a01fd36
--- /dev/null
+++ b/main/MyFriendsAround.WP7/Helpers/Converters/MyImageConverter.cs
@@ -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
+ }
+}
diff --git a/main/MyFriendsAround.WP7/MyFriendsAround.WP7.csproj b/main/MyFriendsAround.WP7/MyFriendsAround.WP7.csproj
index e6849fd..f1a30fe 100644
--- a/main/MyFriendsAround.WP7/MyFriendsAround.WP7.csproj
+++ b/main/MyFriendsAround.WP7/MyFriendsAround.WP7.csproj
@@ -157,6 +157,7 @@
App.xaml
+
@@ -165,6 +166,8 @@
+
+
Code
@@ -280,6 +283,10 @@
{B55A0F90-2B5A-4C4B-88F4-013AA1629866}
Phone7.Fx.Preview
+
+ {17158FD9-80FD-49C1-9E3F-C5633602A4D9}
+ WPImageCaching
+
diff --git a/main/MyFriendsAround.WP7/Service/ServiceAgent.cs b/main/MyFriendsAround.WP7/Service/ServiceAgent.cs
index 491654c..8731764 100644
--- a/main/MyFriendsAround.WP7/Service/ServiceAgent.cs
+++ b/main/MyFriendsAround.WP7/Service/ServiceAgent.cs
@@ -11,13 +11,13 @@ namespace MyFriendsAround.WP7.Service
public static class ServiceAgent
{
- private static int _timeOut = 10;
+ private static int _timeOut = 15;
public static string baseUrl;
static ServiceAgent()
{
- //baseUrl = "http://myfriendsaround.cloudapp.net/myfriends";//live azure
- baseUrl = "http://127.0.0.1:82/myfriends";//running in local azure emulator
+ baseUrl = "http://myfriendsaround.cloudapp.net/myfriends";//live azure
+ //baseUrl = "http://127.0.0.1:80/myfriends";//running in local azure emulator
//baseUrl = "http://localhost.:55672/myfriends";//for local asp.net mvc use
}
diff --git a/main/MyFriendsAround.WP7/Utils/Constants.cs b/main/MyFriendsAround.WP7/Utils/Constants.cs
new file mode 100644
index 0000000..64d07f1
--- /dev/null
+++ b/main/MyFriendsAround.WP7/Utils/Constants.cs
@@ -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";
+ }
+}
diff --git a/main/MyFriendsAround.WP7/Utils/Haversine.cs b/main/MyFriendsAround.WP7/Utils/Haversine.cs
new file mode 100644
index 0000000..7577788
--- /dev/null
+++ b/main/MyFriendsAround.WP7/Utils/Haversine.cs
@@ -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
+{
+ ///
+ /// The distance type to return the results in.
+ ///
+ public enum DistanceType { Miles, Kilometers };
+ ///
+ /// Specifies a Latitude / Longitude point.
+ ///
+ public struct Position
+ {
+ public double Latitude;
+ public double Longitude;
+ }
+
+ public class Haversine
+ {
+ ///
+ /// Returns the distance in miles or kilometers of any two
+ /// latitude / longitude points.
+ ///
+ ///
+ ///
+ ///
+ ///
+ 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;
+ }
+ ///
+ /// Convert to Radians.
+ ///
+ ///
+ ///
+ private static double toRadian(double val)
+ {
+ return (Math.PI / 180) * val;
+ }
+ }
+
+}
diff --git a/main/MyFriendsAround.WP7/ViewModel/MainViewModel.cs b/main/MyFriendsAround.WP7/ViewModel/MainViewModel.cs
index cbd943d..257d765 100644
--- a/main/MyFriendsAround.WP7/ViewModel/MainViewModel.cs
+++ b/main/MyFriendsAround.WP7/ViewModel/MainViewModel.cs
@@ -60,7 +60,6 @@ namespace MyFriendsAround.WP7.ViewModel
//
MainLoadCommand = new RelayCommand(() => MainLoad());
PublishLocationCommand = new RelayCommand(() => PublishLocationAction());
- DisplayAboutCommand = new RelayCommand(() => DisplayAbout());
NavigateToSettingsCommand = new RelayCommand(() => NavigateToSettings());
RefreshFriendsCommand = new RelayCommand(() => RefreshFriends());
ShowAboutCommand = new RelayCommand(() => ShowAbout());
@@ -73,6 +72,7 @@ namespace MyFriendsAround.WP7.ViewModel
ShowMyLocationCommand = new RelayCommand(() => ShowMyLocation());
MapZoomInCommand = new RelayCommand(() => MapZoomIn());
MapZoomOutCommand = new RelayCommand(() => MapZoomOut());
+ ShowSelectFriendCommand = new RelayCommand(() => ShowSelectFriend());
if (IsInDesignMode)
{
@@ -93,91 +93,11 @@ namespace MyFriendsAround.WP7.ViewModel
InitGps();
}
- private void MapZoomOut()
+
+
+ private void ShowSelectFriend()
{
- //
- if(MapZoom<22)
- {
- MapZoom++;
- }
- }
-
- private void MapZoomIn()
- {
- //
- if (MapZoom >2 )
- {
- MapZoom--;
- }
- }
-
-
- private void InitGps()
- {
- App.LocationService.LocationChanged += new EventHandler(LocationService_LocationChanged);
- App.LocationService.StatusChanged += new EventHandler(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 _mynewlocation = new ObservableCollection();
- _mynewlocation.Add(new PushPinModel()
- {
- Location = new GeoCoordinate(GpsLocation.Latitude, GpsLocation.Longitude),
- PinUserName = "Me"
- });
- MyLocationPushPins = _mynewlocation;
- }
- else
- {
- MyLocationPushPins = new ObservableCollection();
- }
- }
-
- System.Diagnostics.Debug.WriteLine("watcher_PositionChanged + " + DateTime.Now.Second);
- }
-
- void watcher_PositionChanged(object sender, GeoPositionChangedEventArgs 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 _mynewlocation = new ObservableCollection();
- _mynewlocation.Add(new PushPinModel()
- {
- Location = new GeoCoordinate(GpsLocation.Latitude, GpsLocation.Longitude),
- PinUserName = "Me"
- });
- MyLocationPushPins = _mynewlocation;
- }
- else
- {
- MyLocationPushPins = new ObservableCollection();
- }
- }
-
- System.Diagnostics.Debug.WriteLine("watcher_PositionChanged + " + DateTime.Now.Second);
+ IsSelectFriend = true;
}
@@ -187,6 +107,8 @@ namespace MyFriendsAround.WP7.ViewModel
#region Properties & Fields
+ private LocationRect LastBoundRect = null;
+
private PhotoChooserTask photoChooserTask;
public string ApplicationTitle
@@ -226,133 +148,7 @@ namespace MyFriendsAround.WP7.ViewModel
#endregion
-
-
- ///
- /// The property's name.
- ///
- public const string GpsLocationPropertyName = "GpsLocation";
-
- private Location _gpsLocation = Location.Unknown;
-
- ///
- /// Gets the GpsLocation property.
- ///
- public Location GpsLocation
- {
- get
- {
- return _gpsLocation;
- }
-
- set
- {
- if (_gpsLocation == value)
- {
- return;
- }
-
- _gpsLocation = value;
-
- // Update bindings, no broadcast
- RaisePropertyChanged(GpsLocationPropertyName);
- }
- }
-
-
-
- ///
- /// The property's name.
- ///
- public const string GpsStatusPropertyName = "GpsStatus";
-
- private GeoPositionStatus _gpsStatus = GeoPositionStatus.Disabled;
-
- ///
- /// Gets the GpsStatus property.
- ///
- public GeoPositionStatus GpsStatus
- {
- get
- {
- return _gpsStatus;
- }
-
- set
- {
- if (_gpsStatus == value)
- {
- return;
- }
-
- _gpsStatus = value;
-
- // Update bindings, no broadcast
- RaisePropertyChanged(GpsStatusPropertyName);
- }
- }
-
- ///
- /// The property's name.
- ///
- public const string MyPicturePropertyName = "MyPicture";
- private ImageSource _myPicture = new BitmapImage(new Uri("/icons/anonymousIcon.png", UriKind.RelativeOrAbsolute));
-
- ///
- /// Gets the MyPicture property.
- ///
- public ImageSource MyPicture
- {
- get
- {
- return _myPicture;
- }
-
- set
- {
- if (_myPicture == value)
- {
- return;
- }
-
- _myPicture = value;
-
- // Update bindings, no broadcast
- RaisePropertyChanged(MyPicturePropertyName);
- }
- }
-
-
-
-
-
-
-
- ///
- /// The property's name.
- ///
- public const string MyNamePropertyName = "MyName";
- private string _myName = "Guest";
-
- ///
- /// Gets the MyName property.
- ///
- public string MyName
- {
- get { return _myName; }
- set
- {
- if (_myName == value)
- {
- return;
- }
- var oldValue = _myName;
- _myName = value;
- // Update bindings, no broadcast
- RaisePropertyChanged(MyNamePropertyName);
- }
- }
-
+ #region AppBarText
public string AppBarTextAbout
{
@@ -389,6 +185,220 @@ namespace MyFriendsAround.WP7.ViewModel
get { return "Cancel"; }
}
+ #endregion
+
+
+
+ ///
+ /// The property's name.
+ ///
+ public const string SelectedFriendPropertyName = "SelectedFriend";
+
+ private PushPinModel _SelectedFriend = new PushPinModel()
+ {
+ Location = GeoCoordinate.Unknown,
+ PinUserName = "Guest",
+ PinImageUrl = string.Empty
+ };
+
+ ///
+ /// Gets the SelectedFriend property.
+ ///
+ 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);
+ }
+ }
+
+
+
+ ///
+ /// The property's name.
+ ///
+ public const string IsSelectFriendPropertyName = "IsSelectFriend";
+
+ private bool _isSelectFriend = false;
+
+ ///
+ /// Gets the IsSelectFriend property.
+ ///
+ public bool IsSelectFriend
+ {
+ get
+ {
+ return _isSelectFriend;
+ }
+
+ set
+ {
+ if (_isSelectFriend == value)
+ {
+ return;
+ }
+
+ _isSelectFriend = value;
+
+ // Update bindings, no broadcast
+ RaisePropertyChanged(IsSelectFriendPropertyName);
+ }
+ }
+
+
+ ///
+ /// The property's name.
+ ///
+ public const string GpsLocationPropertyName = "GpsLocation";
+
+ private Location _gpsLocation = Location.Unknown;
+
+ ///
+ /// Gets the GpsLocation property.
+ ///
+ 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;
+ }
+ }
+
+
+ ///
+ /// The property's name.
+ ///
+ public const string GpsStatusPropertyName = "GpsStatus";
+
+ private GeoPositionStatus _gpsStatus = GeoPositionStatus.Disabled;
+
+ ///
+ /// Gets the GpsStatus property.
+ ///
+ public GeoPositionStatus GpsStatus
+ {
+ get
+ {
+ return _gpsStatus;
+ }
+
+ set
+ {
+ if (_gpsStatus == value)
+ {
+ return;
+ }
+
+ _gpsStatus = value;
+
+ // Update bindings, no broadcast
+ RaisePropertyChanged(GpsStatusPropertyName);
+ }
+ }
+
+
+ ///
+ /// The property's name.
+ ///
+ public const string MyPicturePropertyName = "MyPicture";
+ private string _myPicture = Constants.MYPICTURE_FILE_NAME;
+
+ ///
+ /// Gets the MyPicture property.
+ ///
+ public string MyPicture
+ {
+ get
+ {
+ return _myPicture;
+ }
+
+ set
+ {
+ if (_myPicture == value)
+ {
+ return;
+ }
+ _myPicture = value;
+
+ // Update bindings, no broadcast
+ RaisePropertyChanged(MyPicturePropertyName);
+ }
+ }
+
+
+
+ ///
+ /// The property's name.
+ ///
+ public const string MyNamePropertyName = "MyName";
+ private string _myName = "Guest";
+
+ ///
+ /// Gets the MyName property.
+ ///
+ public string MyName
+ {
+ get { return _myName; }
+ set
+ {
+ if (_myName == value)
+ {
+ return;
+ }
+ _myName = value;
+ // Update bindings, no broadcast
+ RaisePropertyChanged(MyNamePropertyName);
+ }
+ }
+
+
///
/// The property's name.
///
@@ -401,6 +411,23 @@ namespace MyFriendsAround.WP7.ViewModel
{
get
{
+ if (IsInDesignMode)
+ {
+ ObservableCollection _testlist = new ObservableCollection();
+ _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;
}
@@ -415,6 +442,8 @@ namespace MyFriendsAround.WP7.ViewModel
// Update bindings, no broadcast
RaisePropertyChanged(PushPinsPropertyName);
+ //
+ RefreshVisiblePushPins();
}
}
@@ -427,6 +456,7 @@ namespace MyFriendsAround.WP7.ViewModel
///
/// Gets the VisiblePushPins property.
///
+ [JsonIgnore]
public ObservableCollection VisiblePushPins
{
get
@@ -581,11 +611,12 @@ namespace MyFriendsAround.WP7.ViewModel
#endregion
+
+
#region Commands
public ICommand MainLoadCommand { get; set; }
public ICommand PublishLocationCommand { get; set; }
- public ICommand DisplayAboutCommand { get; set; }
public ICommand NavigateToSettingsCommand { get; set; }
public ICommand ShowMyLocationCommand { get; set; }
public ICommand RefreshFriendsCommand { get; set; }
@@ -598,11 +629,75 @@ namespace MyFriendsAround.WP7.ViewModel
public ICommand MapViewChangedCommand { get; set; }
public ICommand MapZoomInCommand { get; set; }
public ICommand MapZoomOutCommand { get; set; }
+ public ICommand ShowSelectFriendCommand { get; set; }
#endregion
+
+
+
#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 _mynewlocation = new ObservableCollection();
+ _mynewlocation.Add(new PushPinModel()
+ {
+ Location = new GeoCoordinate(GpsLocation.Latitude, GpsLocation.Longitude),
+ PinUserName = "Me"
+ });
+ MyLocationPushPins = _mynewlocation;
+ }
+ else
+ {
+ MyLocationPushPins = new ObservableCollection();
+ }
+ }
+
+ System.Diagnostics.Debug.WriteLine("watcher_PositionChanged + " + DateTime.Now.Second);
+ }
+
private void ShowMyLocation()
{
//
@@ -614,32 +709,52 @@ namespace MyFriendsAround.WP7.ViewModel
}
}
- private LocationRect LastBoundRect = null;
+
private void MapViewChanged(LocationRect boundRectangle)
{
LastBoundRect = boundRectangle;
//
+ RefreshVisiblePushPins();
+ //
+ RefreshMyLocation();
+ }
+
+ private void RefreshMyLocation()
+ {
+ if (GpsLocation == Location.Unknown ||
+ LastBoundRect == null ||
+ !LastBoundRect.Intersects(new LocationRect(
+ new GeoCoordinate(GpsLocation.Latitude, GpsLocation.Longitude),
+ .5, .5)))
+ {
+ MyLocationPushPins = new ObservableCollection();
+ }
+ else
+ {
+ ObservableCollection _mynewlocation = new ObservableCollection();
+ _mynewlocation.Add(new PushPinModel()
+ {
+ Location = new GeoCoordinate(GpsLocation.Latitude, GpsLocation.Longitude),
+ PinUserName = "Me"
+ });
+ MyLocationPushPins = _mynewlocation;
+ }
+ }
+
+ private void RefreshVisiblePushPins()
+ {
ObservableCollection _newVisiblePushPins = new ObservableCollection();
//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)))
+ if (LastBoundRect != null && LastBoundRect.Intersects(new LocationRect(
+ new GeoCoordinate(pushPin.Location.Latitude, pushPin.Location.Longitude),
+ .5, .5)))
{
_newVisiblePushPins.Add(pushPin);
}
}
VisiblePushPins = _newVisiblePushPins;
- //
- if (GpsLocation == Location.Unknown ||
- LastBoundRect == null ||
- !LastBoundRect.Intersects(new LocationRect(
- new GeoCoordinate(GpsLocation.Latitude, GpsLocation.Longitude),
- .5, .5)))
- {
- MyLocationPushPins = new ObservableCollection();
- }
}
public void CropCancel()
@@ -656,38 +771,11 @@ namespace MyFriendsAround.WP7.ViewModel
private void MainLoad()
{
- if (IsLoaded)
- {
- //
- ThreadPool.QueueUserWorkItem(LoadMyPicture);
- //
- 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").MyPicture = bi;// PictureDecoder.DecodeJpeg(ms);
- }
- });
- }
- else
- {
- DispatcherHelper.CheckBeginInvokeOnUI(() =>
- {
- Container.Instance.Resolve("MainViewModel").MyPicture = new BitmapImage(new Uri("/icons/anonymousIcon.png", UriKind.RelativeOrAbsolute));
- });
- }
+ //this.MyPicture = Constants.MYPICTURE_FILE_NAME + "?" + DateTime.UtcNow.Ticks;
+ RaisePropertyChanged(MyPicturePropertyName);
+ RaisePropertyChanged(MyNamePropertyName);
+ //
+ RefreshMyLocation();
}
@@ -731,7 +819,7 @@ namespace MyFriendsAround.WP7.ViewModel
byte[] _imageBytes = new byte[e.ChosenPhoto.Length];
e.ChosenPhoto.Read(_imageBytes, 0, _imageBytes.Length);
//save
- IsolatedStorageHelper.SaveToLocalStorage("myphoto.jpg", "profiles", _imageBytes);
+ IsolatedStorageHelper.SaveToLocalStorage(Constants.MYPICTURE_FILE_NAME, "profiles", _imageBytes);
// Seek back so we can create an image.
e.ChosenPhoto.Seek(0, SeekOrigin.Begin);
@@ -739,7 +827,7 @@ namespace MyFriendsAround.WP7.ViewModel
//var imageSource = PictureDecoder.DecodeJpeg(e.ChosenPhoto);
BitmapImage bi = new BitmapImage();
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 list)
{
ObservableCollection result = new ObservableCollection();
@@ -792,14 +874,28 @@ namespace MyFriendsAround.WP7.ViewModel
{
//f.LocationStr
result.Add(new PushPinModel()
- {
- PinSource = "/ApplicationIcon.png",
- Location = new GeoCoordinate(f.Latitude, f.Longitude),
- PinUserName = f.FriendName,
- PinImageUrl = string.Format("https://myfriendsaround.blob.core.windows.net/profiles/profile_{0}.jpg", f.Id)
+ {
+ PinSource = "/ApplicationIcon.png",
+ Location = new GeoCoordinate(f.Latitude, f.Longitude),
+ PinUserName = f.FriendName,
+ 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;
+ if (result.Count > 0)
+ SelectedFriend = PushPins[0];
}
@@ -875,7 +971,7 @@ namespace MyFriendsAround.WP7.ViewModel
else
{
//update also the picture
- byte[] img = IsolatedStorageHelper.LoadFromLocalStorageArray("myphoto.jpg", "profiles");
+ byte[] img = IsolatedStorageHelper.LoadFromLocalStorageArray(Constants.MYPICTURE_FILE_NAME, "profiles");
if (img != null)
{
ServiceAgent.PublishMyPicture(Identification.GetDeviceId(), img, new EventHandler(PublishMyPictureResult));
diff --git a/main/MyFriendsAround.WP7/ViewModel/PushPinModel.cs b/main/MyFriendsAround.WP7/ViewModel/PushPinModel.cs
index 171da7e..4b73fc9 100644
--- a/main/MyFriendsAround.WP7/ViewModel/PushPinModel.cs
+++ b/main/MyFriendsAround.WP7/ViewModel/PushPinModel.cs
@@ -43,7 +43,6 @@ namespace MyFriendsAround.WP7.ViewModel
private string _pinUserName;
-
public string PinUserName
{
get { return _pinUserName; }
@@ -59,7 +58,6 @@ namespace MyFriendsAround.WP7.ViewModel
private string _pinImageUrl;
-
public string 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;
diff --git a/main/MyFriendsAround.WP7/ViewModel/ViewModelBase.cs b/main/MyFriendsAround.WP7/ViewModel/ViewModelBase.cs
index 490265a..151c40c 100644
--- a/main/MyFriendsAround.WP7/ViewModel/ViewModelBase.cs
+++ b/main/MyFriendsAround.WP7/ViewModel/ViewModelBase.cs
@@ -15,8 +15,6 @@ namespace MyFriendsAround.WP7.ViewModel
public class ViewModelBase : GalaSoft.MvvmLight.ViewModelBase
{
- public bool IsLoaded { get; set; }
-
private object context;
public object Context
{
diff --git a/main/MyFriendsAround.WP7/ViewModel/ViewModelLocator.cs b/main/MyFriendsAround.WP7/ViewModel/ViewModelLocator.cs
index d89a811..16711ea 100644
--- a/main/MyFriendsAround.WP7/ViewModel/ViewModelLocator.cs
+++ b/main/MyFriendsAround.WP7/ViewModel/ViewModelLocator.cs
@@ -15,6 +15,7 @@
*/
using MyFriendsAround.WP7.Helpers.Navigation;
+using MyFriendsAround.WP7.Utils;
using NetworkDetection;
namespace MyFriendsAround.WP7.ViewModel
@@ -85,7 +86,7 @@ namespace MyFriendsAround.WP7.ViewModel
{
get
{
- MainViewModel mainViewModel = GetViewModel("MainViewModel");
+ MainViewModel mainViewModel = GetViewModel(Constants.VM_MAIN);
return mainViewModel;
}
}
@@ -97,7 +98,7 @@ namespace MyFriendsAround.WP7.ViewModel
{
get
{
- SettingsViewModel aboutViewModel = GetViewModel("SettingsViewModel");
+ SettingsViewModel aboutViewModel = GetViewModel(Constants.VM_SETTINGS);
return aboutViewModel;
}
}
@@ -108,9 +109,9 @@ namespace MyFriendsAround.WP7.ViewModel
///
public void Cleanup()
{
- MainViewModel mainViewModel = GetViewModel("MainViewModel");
+ MainViewModel mainViewModel = GetViewModel(Constants.VM_MAIN);
mainViewModel.Cleanup();
- SettingsViewModel aboutViewModel = GetViewModel("SettingsViewModel");
+ SettingsViewModel aboutViewModel = GetViewModel(Constants.VM_SETTINGS);
aboutViewModel.Cleanup();
}
@@ -118,11 +119,10 @@ namespace MyFriendsAround.WP7.ViewModel
#region Local Helpers
- private T GetViewModel(string key) where T : ViewModelBase
+ public static T GetViewModel(string key) where T : ViewModelBase
{
// Create a new view model
T vm = Container.Instance.Resolve(key);
-
//Assign the Context from PageNavigation to Context property of the ViewModelBase
vm.Context = vm.PageNav.CurrentContext;
diff --git a/main/MyFriendsAround.WP7/Views/CropPage.xaml.cs b/main/MyFriendsAround.WP7/Views/CropPage.xaml.cs
index 45e7407..82563d9 100644
--- a/main/MyFriendsAround.WP7/Views/CropPage.xaml.cs
+++ b/main/MyFriendsAround.WP7/Views/CropPage.xaml.cs
@@ -17,6 +17,7 @@ using Microsoft.Phone.Tasks;
using MyFriendsAround.WP7.Utils;
using MyFriendsAround.WP7.ViewModel;
using NetworkDetection;
+using System.Threading;
namespace MyFriendsAround.WP7.Views
{
@@ -53,7 +54,7 @@ namespace MyFriendsAround.WP7.Views
private void NavigateBack()
{
- Container.Instance.Resolve("MainViewModel").CropCancel();
+ Container.Instance.Resolve(Constants.VM_MAIN).CropCancel();
}
void task_Completed(object sender, PhotoResult e)
@@ -158,12 +159,7 @@ namespace MyFriendsAround.WP7.Views
byte[] _imageBytes = new byte[stream.Length];
stream.Read(_imageBytes, 0, _imageBytes.Length);
//save
- IsolatedStorageHelper.SaveToLocalStorage("myphoto.jpg", "profiles", _imageBytes);
- //
- //BitmapImage bi = new BitmapImage();
- //stream.Seek(0, SeekOrigin.Begin);
- //bi.SetSource(stream);
- Container.Instance.Resolve("MainViewModel").MyPicture = wbm;
+ IsolatedStorageHelper.SaveToLocalStorage(Constants.MYPICTURE_FILE_NAME, "profiles", _imageBytes);
}
}
diff --git a/main/MyFriendsAround.WP7/Views/MainPage.xaml b/main/MyFriendsAround.WP7/Views/MainPage.xaml
index 0292932..4f7dc38 100644
--- a/main/MyFriendsAround.WP7/Views/MainPage.xaml
+++ b/main/MyFriendsAround.WP7/Views/MainPage.xaml
@@ -18,14 +18,17 @@
d:DesignHeight="768"
shell:SystemTray.IsVisible="True"
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:Preview="clr-namespace:Phone7.Fx.Preview;assembly=Phone7.Fx.Preview"
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">
+
-
-
-
+
-
+
+
+
+
+
@@ -186,10 +188,12 @@
+ Opacity="1">
+
+
+
+
+
+
@@ -239,19 +248,87 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Text="{Binding AppBarTextMyLocation}" />
+ Text="{Binding AppBarTextPublish}"
+ IsEnabled="{Binding Path=IsBusy, Converter={StaticResource InvertValueConverter1}}" />
diff --git a/main/MyFriendsAround.WP7/Views/SettingsPage.xaml b/main/MyFriendsAround.WP7/Views/SettingsPage.xaml
index 56f52cc..84bef9d 100644
--- a/main/MyFriendsAround.WP7/Views/SettingsPage.xaml
+++ b/main/MyFriendsAround.WP7/Views/SettingsPage.xaml
@@ -5,7 +5,7 @@
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
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}"
Foreground="{StaticResource PhoneForegroundBrush}"
SupportedOrientations="Portrait" Orientation="Portrait"
@@ -13,6 +13,11 @@
mc:Ignorable="d" d:DesignHeight="768" d:DesignWidth="480"
shell:SystemTray.IsVisible="True">
+
+
+
+
+
@@ -47,7 +52,7 @@
+ Source="{Binding MyPicture, Mode=OneWay, Converter={StaticResource myImageConverter}}">
+
-
-
+ -->
diff --git a/main/MyFriendsAround.Web/Web.config b/main/MyFriendsAround.Web/Web.config
index 83b81f2..5818f40 100644
--- a/main/MyFriendsAround.Web/Web.config
+++ b/main/MyFriendsAround.Web/Web.config
@@ -9,7 +9,7 @@
+ 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" />
diff --git a/main/MyFriendsAround.sln b/main/MyFriendsAround.sln
index 0727136..380f527 100644
--- a/main/MyFriendsAround.sln
+++ b/main/MyFriendsAround.sln
@@ -31,6 +31,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MicroIoc.Core", "Libs\Micro
EndProject
Project("{CC5FD16D-436D-48AD-A40C-5A424C6E3E79}") = "MyFriendsAroundWindowsAzure", "MyFriendsAroundWindowsAzure\MyFriendsAroundWindowsAzure.ccproj", "{C656965D-5A6E-4BD4-9945-9C906B89128D}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WPImageCaching", "Libs\WPImageCaching\WPImageCaching.csproj", "{17158FD9-80FD-49C1-9E3F-C5633602A4D9}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
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.Build.0 = 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
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -317,5 +339,6 @@ Global
{BF7316A8-A2C5-4176-8D7F-672AD12F474D} = {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}
+ {17158FD9-80FD-49C1-9E3F-C5633602A4D9} = {340549A1-45EA-4B49-B194-347C0078BAD8}
EndGlobalSection
EndGlobal