Settings Page (in work)

Fixing Web hosting in Azure
This commit is contained in:
2011-03-30 02:25:27 +03:00
parent 84642c37ad
commit 833083ca0e
21 changed files with 414 additions and 105 deletions
@@ -2,17 +2,23 @@
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Device.Location;
using System.IO;
using System.Net;
using System.Security;
using System.ServiceModel.Channels;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using Coding4Fun.Phone.Controls;
using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.Command;
using GalaSoft.MvvmLight.Messaging;
using GalaSoft.MvvmLight.Threading;
using Hammock;
using Hammock.Serialization;
using Microsoft.Phone;
using Microsoft.Phone.Controls;
using Microsoft.Silverlight.Testing;
using MyFriendsAround.Common.Entities;
@@ -20,6 +26,7 @@ using MyFriendsAround.WP7.Service;
using MyFriendsAround.WP7.Utils;
using MyFriendsAround.WP7.Views;
using Newtonsoft.Json;
using Microsoft.Phone.Tasks;
namespace MyFriendsAround.WP7.ViewModel
{
@@ -53,6 +60,14 @@ namespace MyFriendsAround.WP7.ViewModel
}
}
public string PageNameSettings
{
get
{
return "Settings";
}
}
/// <summary>
/// Initializes a new instance of the MainViewModel class.
/// </summary>
@@ -61,8 +76,12 @@ namespace MyFriendsAround.WP7.ViewModel
//
PublishLocationCommand = new RelayCommand(() => PublishLocationAction());
DisplayAboutCommand = new RelayCommand(() => DisplayAbout());
NavigateToAboutCommand = new RelayCommand(() => NavigateToAbout());
NavigateToSettingsCommand = new RelayCommand(() => NavigateToSettings());
RefreshFriendsCommand = new RelayCommand(() => RefreshFriends());
ShowAboutCommand = new RelayCommand(() => ShowAbout());
SaveMySettingsCommand = new RelayCommand(() => SaveMySettings());
CancelMySettingsCommand = new RelayCommand(() => CancelMySettings());
ChoosePhotoCommand = new RelayCommand(() => ChoosePhoto());
if (IsInDesignMode)
{
@@ -75,16 +94,115 @@ namespace MyFriendsAround.WP7.ViewModel
}
private void ChoosePhoto()
{
//choose photo
ShowCameraCaptureTask();
//ShowPhotoChooserTask();
}
private void ShowPhotoChooserTask()
{
var photoChooserTask = new PhotoChooserTask();
photoChooserTask.Completed += cameraTask_Completed;
photoChooserTask.Show();
}
private void ShowCameraCaptureTask()
{
var cameraTask = new CameraCaptureTask();
cameraTask.Completed += cameraTask_Completed;
cameraTask.Show();
}
private void cameraTask_Completed(object sender, PhotoResult e)
{
if (e.TaskResult == TaskResult.OK)
{
// Get the image temp file from e.OriginalFileName.
// Get the image temp stream from e.ChosenPhoto.
// Don't keep either the stream or rely on the temp
// file name as they may be vanished!
// Store the image bytes.
byte[] _imageBytes = new byte[e.ChosenPhoto.Length];
e.ChosenPhoto.Read(_imageBytes, 0, _imageBytes.Length);
// Seek back so we can create an image.
e.ChosenPhoto.Seek(0, SeekOrigin.Begin);
// Create an image from the stream.
var imageSource = PictureDecoder.DecodeJpeg(e.ChosenPhoto);
MyPicture = imageSource;
}
}
/// <summary>
/// The <see cref="MyPicture" /> property's name.
/// </summary>
public const string MyPicturePropertyName = "MyPicture";
private BitmapSource _myPicture = new BitmapImage(new Uri("/icons/anonymousIcon.png", UriKind.RelativeOrAbsolute));
/// <summary>
/// Gets the MyPicture property.
/// </summary>
public BitmapSource MyPicture
{
get
{
return _myPicture;
}
set
{
if (_myPicture == value)
{
return;
}
var oldValue = _myPicture;
_myPicture = value;
// Update bindings, no broadcast
RaisePropertyChanged(MyPicturePropertyName);
// Update bindings and broadcast change using GalaSoft.MvvmLight.Messenging
RaisePropertyChanged(MyPicturePropertyName, oldValue, value, true);
}
}
private void CancelMySettings()
{
//navigate back
this.PageNav.GoBack();
}
private void SaveMySettings()
{
//save settings locally and on the server
}
private void ShowAbout()
{
//
var aboutPrompt = new AboutPrompt();
aboutPrompt.Title = "About";
aboutPrompt.Body = Environment.NewLine + "Created by Claudiu Farcas" + Environment.NewLine + Environment.NewLine + "@claudiufarcas" + Environment.NewLine + Environment.NewLine + "Please visit" + Environment.NewLine + Environment.NewLine + "http://www.vorienteering.com";
aboutPrompt.VersionNumber = "1.0";
aboutPrompt.Show();
}
private void RefreshFriends()
{
IsBusy = true;
ServiceAgent.GetFriends(this.GetFriendsResult);
}
private void NavigateToAbout()
private void NavigateToSettings()
{
//
this.PageNav.NavigateTo(new Uri("/Views/AboutPage.xaml", UriKind.Relative));
this.PageNav.NavigateTo(new Uri("/Views/SettingsPage.xaml", UriKind.Relative));
}
@@ -193,8 +311,13 @@ namespace MyFriendsAround.WP7.ViewModel
public ICommand PublishLocationCommand { get; set; }
public ICommand DisplayAboutCommand { get; set; }
public ICommand NavigateToAboutCommand { get; set; }
public ICommand NavigateToSettingsCommand { get; set; }
public ICommand RefreshFriendsCommand { get; set; }
public ICommand ShowAboutCommand { get; set; }
public ICommand SaveMySettingsCommand { get; set; }
public ICommand CancelMySettingsCommand { get; set; }
public ICommand ChoosePhotoCommand { get; set; }
/// <summary>
@@ -228,6 +351,11 @@ namespace MyFriendsAround.WP7.ViewModel
get { return "About"; }
}
public string AppBarTextSettings
{
get { return "Settings"; }
}
public string AppBarTextPublish
{
get { return "Publish"; }
@@ -238,6 +366,18 @@ namespace MyFriendsAround.WP7.ViewModel
get { return "Refresh"; }
}
public string AppBarTextSaveSettings
{
get { return "Save"; }
}
public string AppBarTextCancelSettings
{
get { return "Cancel"; }
}
////public override void Cleanup()
////{
//// // Clean up if needed
@@ -21,7 +21,7 @@ using Newtonsoft.Json;
namespace MyFriendsAround.WP7.ViewModel
{
public class AboutViewModel : ViewModelBase
public class SettingsViewModel : ViewModelBase
{
public string ApplicationTitle
{
@@ -43,7 +43,7 @@ namespace MyFriendsAround.WP7.ViewModel
/// <summary>
/// Initializes a new instance of the MainViewModel class.
/// </summary>
public AboutViewModel()
public SettingsViewModel()
{
if (IsInDesignMode)
{
@@ -91,11 +91,11 @@ namespace MyFriendsAround.WP7.ViewModel
/// <summary>
/// Gets the About property.
/// </summary>
public AboutViewModel About
public SettingsViewModel Settings
{
get
{
AboutViewModel aboutViewModel = GetViewModel<AboutViewModel>("AboutViewModel");
SettingsViewModel aboutViewModel = GetViewModel<SettingsViewModel>("SettingsViewModel");
return aboutViewModel;
}
}
@@ -108,7 +108,7 @@ namespace MyFriendsAround.WP7.ViewModel
{
MainViewModel mainViewModel = GetViewModel<MainViewModel>("MainViewModel");
mainViewModel.Cleanup();
AboutViewModel aboutViewModel = GetViewModel<AboutViewModel>("AboutViewModel");
SettingsViewModel aboutViewModel = GetViewModel<SettingsViewModel>("SettingsViewModel");
aboutViewModel.Cleanup();
}