From 5829ff5575a823e6ee204452297fc690a26745a3 Mon Sep 17 00:00:00 2001 From: Gustavo Martin Date: Thu, 5 Jun 2014 07:28:23 +0200 Subject: [PATCH] WeatherInformation, Windows Phone 8 implementation --- .../WeatherInformation/MainPage.xaml | 2 +- .../WeatherInformation/MainPage.xaml.cs | 2 +- .../WeatherInformation/MapPage.xaml | 2 +- .../WeatherInformation/MapPage.xaml.cs | 6 +-- .../SampleData/SettingsViewModelSampleData.xaml | 12 +++++ .../WeatherInformation/SettingsPage.xaml | 44 ++++++++++++++++++ .../WeatherInformation/SettingsPage.xaml.cs | 30 ++++++++++++ .../ViewModels/SettingsViewModel.cs | 53 ++++++++++++++++++++++ .../WeatherInformation/WeatherInformation.csproj | 13 ++++++ 9 files changed, 156 insertions(+), 8 deletions(-) create mode 100644 WindowsPhone/WeatherInformation/WeatherInformation/SampleData/SettingsViewModelSampleData.xaml create mode 100644 WindowsPhone/WeatherInformation/WeatherInformation/SettingsPage.xaml create mode 100644 WindowsPhone/WeatherInformation/WeatherInformation/SettingsPage.xaml.cs create mode 100644 WindowsPhone/WeatherInformation/WeatherInformation/ViewModels/SettingsViewModel.cs diff --git a/WindowsPhone/WeatherInformation/WeatherInformation/MainPage.xaml b/WindowsPhone/WeatherInformation/WeatherInformation/MainPage.xaml index 8c1626b..79e4893 100644 --- a/WindowsPhone/WeatherInformation/WeatherInformation/MainPage.xaml +++ b/WindowsPhone/WeatherInformation/WeatherInformation/MainPage.xaml @@ -81,7 +81,7 @@ - + diff --git a/WindowsPhone/WeatherInformation/WeatherInformation/MainPage.xaml.cs b/WindowsPhone/WeatherInformation/WeatherInformation/MainPage.xaml.cs index d53481a..d07378d 100644 --- a/WindowsPhone/WeatherInformation/WeatherInformation/MainPage.xaml.cs +++ b/WindowsPhone/WeatherInformation/WeatherInformation/MainPage.xaml.cs @@ -46,7 +46,7 @@ namespace WeatherInformation private void Settings_Click(object sender, EventArgs e) { - + NavigationService.Navigate(new Uri("/SettingsPage.xaml", UriKind.Relative)); } // Código de ejemplo para compilar una ApplicationBar traducida diff --git a/WindowsPhone/WeatherInformation/WeatherInformation/MapPage.xaml b/WindowsPhone/WeatherInformation/WeatherInformation/MapPage.xaml index c7d1ae2..04fc57f 100644 --- a/WindowsPhone/WeatherInformation/WeatherInformation/MapPage.xaml +++ b/WindowsPhone/WeatherInformation/WeatherInformation/MapPage.xaml @@ -10,7 +10,7 @@ FontFamily="{StaticResource PhoneFontFamilyNormal}" FontSize="{StaticResource PhoneFontSizeNormal}" Foreground="{StaticResource PhoneForegroundBrush}" - SupportedOrientations="Portrait" Orientation="Portrait" + SupportedOrientations="PortraitOrLandscape" Orientation="Portrait" mc:Ignorable="d" shell:SystemTray.IsVisible="True"> diff --git a/WindowsPhone/WeatherInformation/WeatherInformation/MapPage.xaml.cs b/WindowsPhone/WeatherInformation/WeatherInformation/MapPage.xaml.cs index 2862df7..0dde759 100644 --- a/WindowsPhone/WeatherInformation/WeatherInformation/MapPage.xaml.cs +++ b/WindowsPhone/WeatherInformation/WeatherInformation/MapPage.xaml.cs @@ -44,11 +44,7 @@ namespace WeatherInformation IsolatedStorageSettings.ApplicationSettings.Save(); } - bool locationConsentValue; - if (IsolatedStorageSettings.ApplicationSettings.TryGetValue("LocationConsent", out locationConsentValue)) - { - this.GetLocation(); - } + this.GetLocation(); } private async void GetLocation() diff --git a/WindowsPhone/WeatherInformation/WeatherInformation/SampleData/SettingsViewModelSampleData.xaml b/WindowsPhone/WeatherInformation/WeatherInformation/SampleData/SettingsViewModelSampleData.xaml new file mode 100644 index 0000000..19b5b85 --- /dev/null +++ b/WindowsPhone/WeatherInformation/WeatherInformation/SampleData/SettingsViewModelSampleData.xaml @@ -0,0 +1,12 @@ + + + + + + + + \ No newline at end of file diff --git a/WindowsPhone/WeatherInformation/WeatherInformation/SettingsPage.xaml b/WindowsPhone/WeatherInformation/WeatherInformation/SettingsPage.xaml new file mode 100644 index 0000000..fa99662 --- /dev/null +++ b/WindowsPhone/WeatherInformation/WeatherInformation/SettingsPage.xaml @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/WindowsPhone/WeatherInformation/WeatherInformation/SettingsPage.xaml.cs b/WindowsPhone/WeatherInformation/WeatherInformation/SettingsPage.xaml.cs new file mode 100644 index 0000000..3a91202 --- /dev/null +++ b/WindowsPhone/WeatherInformation/WeatherInformation/SettingsPage.xaml.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Navigation; +using Microsoft.Phone.Controls; +using Microsoft.Phone.Shell; + +namespace WeatherInformation +{ + public partial class SettingsPage : PhoneApplicationPage + { + public SettingsPage() + { + InitializeComponent(); + } + + private void LongListSelector_SelectionChanged(object sender, SelectionChangedEventArgs e) + { + object lol = this.SettingsList.SelectedItem; + } + + private void StackPanel_Tap(object sender, System.Windows.Input.GestureEventArgs e) + { + + } + } +} \ No newline at end of file diff --git a/WindowsPhone/WeatherInformation/WeatherInformation/ViewModels/SettingsViewModel.cs b/WindowsPhone/WeatherInformation/WeatherInformation/ViewModels/SettingsViewModel.cs new file mode 100644 index 0000000..c238a6f --- /dev/null +++ b/WindowsPhone/WeatherInformation/WeatherInformation/ViewModels/SettingsViewModel.cs @@ -0,0 +1,53 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace WeatherInformation.ViewModels +{ + class SettingsViewModel : INotifyPropertyChanged + { + public SettingsViewModel() + { + this.SettingsItems = new ObservableCollection(); + } + + private string _sampleProperty = "Sample Runtime Property Value"; + + public ObservableCollection SettingsItems { get; private set; } + /// + /// Propiedad Sample ViewModel; esta propiedad se usa en la vista para mostrar su valor mediante un enlace + /// + /// + public string SampleProperty + { + get + { + return _sampleProperty; + } + set + { + if (value != _sampleProperty) + { + _sampleProperty = value; + NotifyPropertyChanged("SampleProperty"); + } + } + } + + + + public event PropertyChangedEventHandler PropertyChanged; + private void NotifyPropertyChanged(String propertyName) + { + PropertyChangedEventHandler handler = PropertyChanged; + if (null != handler) + { + handler(this, new PropertyChangedEventArgs(propertyName)); + } + } + } +} diff --git a/WindowsPhone/WeatherInformation/WeatherInformation/WeatherInformation.csproj b/WindowsPhone/WeatherInformation/WeatherInformation/WeatherInformation.csproj index 9bd64e9..fbf314e 100644 --- a/WindowsPhone/WeatherInformation/WeatherInformation/WeatherInformation.csproj +++ b/WindowsPhone/WeatherInformation/WeatherInformation/WeatherInformation.csproj @@ -122,8 +122,12 @@ True AppResources.resx + + SettingsPage.xaml + + @@ -142,6 +146,14 @@ Designer MSBuild:Compile + + MSBuild:Compile + Designer + + + Designer + MSBuild:Compile + @@ -180,6 +192,7 @@ + ..\packages\Newtonsoft.Json.6.0.3\lib\portable-net45+wp80+win8+wpa81\Newtonsoft.Json.dll -- 2.1.4