WeatherInformation, Windows Phone 8 implementation
authorGustavo Martin <gu.martinm@gmail.com>
Thu, 5 Jun 2014 05:28:23 +0000 (07:28 +0200)
committerGustavo Martin <gu.martinm@gmail.com>
Thu, 5 Jun 2014 05:28:23 +0000 (07:28 +0200)
WindowsPhone/WeatherInformation/WeatherInformation/MainPage.xaml
WindowsPhone/WeatherInformation/WeatherInformation/MainPage.xaml.cs
WindowsPhone/WeatherInformation/WeatherInformation/MapPage.xaml
WindowsPhone/WeatherInformation/WeatherInformation/MapPage.xaml.cs
WindowsPhone/WeatherInformation/WeatherInformation/SampleData/SettingsViewModelSampleData.xaml [new file with mode: 0644]
WindowsPhone/WeatherInformation/WeatherInformation/SettingsPage.xaml [new file with mode: 0644]
WindowsPhone/WeatherInformation/WeatherInformation/SettingsPage.xaml.cs [new file with mode: 0644]
WindowsPhone/WeatherInformation/WeatherInformation/ViewModels/SettingsViewModel.cs [new file with mode: 0644]
WindowsPhone/WeatherInformation/WeatherInformation/WeatherInformation.csproj

index 8c1626b..79e4893 100644 (file)
@@ -81,7 +81,7 @@
             </phone:PivotItem>
 
             <!--Elemento Pivot dos-->
-            <phone:PivotItem Header="second">
+            <phone:PivotItem Header="current">
                 <!--Lista de líneas dobles sin ajuste de texto-->
                 <phone:LongListSelector Margin="0,0,-12,0" ItemsSource="{Binding ForecastItems}">
                     <phone:LongListSelector.ItemTemplate>
index d53481a..d07378d 100644 (file)
@@ -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
index c7d1ae2..04fc57f 100644 (file)
@@ -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">
 
index 2862df7..0dde759 100644 (file)
@@ -44,11 +44,7 @@ namespace WeatherInformation
                 IsolatedStorageSettings.ApplicationSettings.Save();
             }
 
-            bool locationConsentValue;
-            if (IsolatedStorageSettings.ApplicationSettings.TryGetValue<bool>("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 (file)
index 0000000..19b5b85
--- /dev/null
@@ -0,0 +1,12 @@
+<vm:SettingsViewModel
+    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+    xmlns:vm="clr-namespace:WeatherInformation.ViewModels"
+    SampleProperty="Valor de propiedad Sample Text">
+
+    <vm:SettingsViewModel.SettingsItems>
+        <vm:ItemViewModel LineOne="Temperature units" LineTwo="fahrenheit" LineThree="15ºC" LineFour="10ºC" LineFive="/Assets/Tiles/IconicTileMediumLarge.png"/>
+        <vm:ItemViewModel LineOne="Language" LineTwo="spanish" LineThree="16ºC" LineFour="10ºC" LineFive="/Assets/Tiles/IconicTileMediumLarge.png"/>
+    </vm:SettingsViewModel.SettingsItems>
+
+</vm:SettingsViewModel>
\ No newline at end of file
diff --git a/WindowsPhone/WeatherInformation/WeatherInformation/SettingsPage.xaml b/WindowsPhone/WeatherInformation/WeatherInformation/SettingsPage.xaml
new file mode 100644 (file)
index 0000000..fa99662
--- /dev/null
@@ -0,0 +1,44 @@
+<phone:PhoneApplicationPage
+    x:Class="WeatherInformation.SettingsPage"
+    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+    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"
+    mc:Ignorable="d"
+    d:DataContext="{d:DesignData SampleData/SettingsViewModelSampleData.xaml}"
+    FontFamily="{StaticResource PhoneFontFamilyNormal}"
+    FontSize="{StaticResource PhoneFontSizeNormal}"
+    Foreground="{StaticResource PhoneForegroundBrush}"
+    SupportedOrientations="PortraitOrLandscape"  Orientation="Portrait"
+    shell:SystemTray.IsVisible="True">
+
+    <!--LayoutRoot es la cuadrícula raíz donde se coloca todo el contenido de la página-->
+    <Grid x:Name="LayoutRoot" Background="Transparent">
+        <!--Control Pivot-->
+        <phone:Pivot Title="WEATHER INFORMATION">
+            <!--Elemento Pivot uno-->
+            <phone:PivotItem Header="settings">
+                <!--Lista de líneas dobles con ajuste de texto-->
+                <phone:LongListSelector x:Name="SettingsList" Margin="0,0,-12,0" ItemsSource="{Binding SettingsItems}" SelectionChanged="LongListSelector_SelectionChanged">
+                    <phone:LongListSelector.ItemTemplate>
+                        <DataTemplate>
+                            <StackPanel Orientation="Vertical" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="0,10" Tap="StackPanel_Tap">
+                                <TextBlock Text="{Binding LineOne}" TextWrapping="Wrap" Style="{StaticResource PhoneTextExtraLargeStyle}" HorizontalAlignment="Left" VerticalAlignment="Center" FontWeight="Bold"/>
+                                <TextBlock Text="{Binding LineTwo}" TextWrapping="Wrap" Style="{StaticResource PhoneTextExtraLargeStyle}" HorizontalAlignment="Left" VerticalAlignment="Center" FontSize="24"/>
+                            </StackPanel>
+                        </DataTemplate>
+                    </phone:LongListSelector.ItemTemplate>
+                </phone:LongListSelector>
+            </phone:PivotItem>
+
+            <!--Elemento Pivot dos
+            <phone:PivotItem Header="notifications">
+                <Grid/>
+            </phone:PivotItem>
+            -->
+        </phone:Pivot>
+    </Grid>
+    
+</phone:PhoneApplicationPage>
\ 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 (file)
index 0000000..3a91202
--- /dev/null
@@ -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 (file)
index 0000000..c238a6f
--- /dev/null
@@ -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<ItemViewModel>();
+        }
+
+        private string _sampleProperty = "Sample Runtime Property Value";
+
+        public ObservableCollection<ItemViewModel> SettingsItems { get; private set; }
+        /// <summary>
+        /// Propiedad Sample ViewModel; esta propiedad se usa en la vista para mostrar su valor mediante un enlace
+        /// </summary>
+        /// <returns></returns>
+        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));
+            }
+        }
+    }
+}
index 9bd64e9..fbf314e 100644 (file)
       <DesignTime>True</DesignTime>
       <DependentUpon>AppResources.resx</DependentUpon>
     </Compile>
+    <Compile Include="SettingsPage.xaml.cs">
+      <DependentUpon>SettingsPage.xaml</DependentUpon>
+    </Compile>
     <Compile Include="ViewModels\ItemViewModel.cs" />
     <Compile Include="ViewModels\MainViewModel.cs" />
+    <Compile Include="ViewModels\SettingsViewModel.cs" />
   </ItemGroup>
   <ItemGroup>
     <ApplicationDefinition Include="App.xaml">
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
     </Page>
+    <DesignData Include="SampleData\SettingsViewModelSampleData.xaml">
+      <Generator>MSBuild:Compile</Generator>
+      <SubType>Designer</SubType>
+    </DesignData>
+    <Page Include="SettingsPage.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
   </ItemGroup>
   <ItemGroup>
     <None Include="packages.config" />
     </EmbeddedResource>
   </ItemGroup>
   <ItemGroup>
+    <Reference Include="Microsoft.Phone.Controls, Version=8.0.0.0, Culture=neutral, PublicKeyToken=24eec0d8c86cda1e, processorArchitecture=MSIL" />
     <Reference Include="Newtonsoft.Json">
       <HintPath>..\packages\Newtonsoft.Json.6.0.3\lib\portable-net45+wp80+win8+wpa81\Newtonsoft.Json.dll</HintPath>
     </Reference>