mirror of
https://github.com/farcasclaudiu/myfriendsaround.git
synced 2026-06-29 15:01:45 +03:00
Settings Page (in work)
Fixing Web hosting in Azure
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user