diff --git a/PocketSharp.Examples/PocketSharp.WP8/App.xaml b/PocketSharp.Examples/PocketSharp.WP8/App.xaml new file mode 100644 index 0000000..15936fe --- /dev/null +++ b/PocketSharp.Examples/PocketSharp.WP8/App.xaml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/PocketSharp.Examples/PocketSharp.WP8/App.xaml.cs b/PocketSharp.Examples/PocketSharp.WP8/App.xaml.cs new file mode 100644 index 0000000..fb2a7f5 --- /dev/null +++ b/PocketSharp.Examples/PocketSharp.WP8/App.xaml.cs @@ -0,0 +1,247 @@ +using System; +using System.Diagnostics; +using System.Resources; +using System.Windows; +using System.Windows.Markup; +using System.Windows.Navigation; +using Microsoft.Phone.Controls; +using Microsoft.Phone.Shell; +using PocketSharp.WP8.Resources; +using PocketSharp.WP8.ViewModels; + +namespace PocketSharp.WP8 +{ + public partial class App : Application + { + private static MainViewModel viewModel = null; + + /// + /// A static ViewModel used by the views to bind against. + /// + /// The MainViewModel object. + public static MainViewModel ViewModel + { + get + { + // Delay creation of the view model until necessary + if (viewModel == null) + viewModel = new MainViewModel(); + + return viewModel; + } + } + + /// + /// Provides easy access to the root frame of the Phone Application. + /// + /// The root frame of the Phone Application. + public static PhoneApplicationFrame RootFrame { get; private set; } + + /// + /// Constructor for the Application object. + /// + public App() + { + // Global handler for uncaught exceptions. + UnhandledException += Application_UnhandledException; + + // Standard XAML initialization + InitializeComponent(); + + // Phone-specific initialization + InitializePhoneApplication(); + + // Language display initialization + InitializeLanguage(); + + // Show graphics profiling information while debugging. + if (Debugger.IsAttached) + { + // Display the current frame rate counters. + Application.Current.Host.Settings.EnableFrameRateCounter = true; + + // Show the areas of the app that are being redrawn in each frame. + //Application.Current.Host.Settings.EnableRedrawRegions = true; + + // Enable non-production analysis visualization mode, + // which shows areas of a page that are handed off GPU with a colored overlay. + //Application.Current.Host.Settings.EnableCacheVisualization = true; + + // Prevent the screen from turning off while under the debugger by disabling + // the application's idle detection. + // Caution:- Use this under debug mode only. Application that disables user idle detection will continue to run + // and consume battery power when the user is not using the phone. + PhoneApplicationService.Current.UserIdleDetectionMode = IdleDetectionMode.Disabled; + } + } + + // Code to execute when the application is launching (eg, from Start) + // This code will not execute when the application is reactivated + private void Application_Launching(object sender, LaunchingEventArgs e) + { + } + + // Code to execute when the application is activated (brought to foreground) + // This code will not execute when the application is first launched + private void Application_Activated(object sender, ActivatedEventArgs e) + { + // Ensure that application state is restored appropriately + if (!App.ViewModel.IsDataLoaded) + { + App.ViewModel.LoadData(); + } + } + + // Code to execute when the application is deactivated (sent to background) + // This code will not execute when the application is closing + private void Application_Deactivated(object sender, DeactivatedEventArgs e) + { + // Ensure that required application state is persisted here. + } + + // Code to execute when the application is closing (eg, user hit Back) + // This code will not execute when the application is deactivated + private void Application_Closing(object sender, ClosingEventArgs e) + { + } + + // Code to execute if a navigation fails + private void RootFrame_NavigationFailed(object sender, NavigationFailedEventArgs e) + { + if (Debugger.IsAttached) + { + // A navigation has failed; break into the debugger + Debugger.Break(); + } + } + + // Code to execute on Unhandled Exceptions + private void Application_UnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e) + { + if (Debugger.IsAttached) + { + // An unhandled exception has occurred; break into the debugger + Debugger.Break(); + } + } + + #region Phone application initialization + + // Avoid double-initialization + private bool phoneApplicationInitialized = false; + + // Do not add any additional code to this method + private void InitializePhoneApplication() + { + if (phoneApplicationInitialized) + return; + + // Create the frame but don't set it as RootVisual yet; this allows the splash + // screen to remain active until the application is ready to render. + RootFrame = new PhoneApplicationFrame(); + RootFrame.Navigated += CompleteInitializePhoneApplication; + + // Handle navigation failures + RootFrame.NavigationFailed += RootFrame_NavigationFailed; + + // Handle reset requests for clearing the backstack + RootFrame.Navigated += CheckForResetNavigation; + + // Ensure we don't initialize again + phoneApplicationInitialized = true; + } + + // Do not add any additional code to this method + private void CompleteInitializePhoneApplication(object sender, NavigationEventArgs e) + { + // Set the root visual to allow the application to render + if (RootVisual != RootFrame) + RootVisual = RootFrame; + + // Remove this handler since it is no longer needed + RootFrame.Navigated -= CompleteInitializePhoneApplication; + } + + private void CheckForResetNavigation(object sender, NavigationEventArgs e) + { + // If the app has received a 'reset' navigation, then we need to check + // on the next navigation to see if the page stack should be reset + if (e.NavigationMode == NavigationMode.Reset) + RootFrame.Navigated += ClearBackStackAfterReset; + } + + private void ClearBackStackAfterReset(object sender, NavigationEventArgs e) + { + // Unregister the event so it doesn't get called again + RootFrame.Navigated -= ClearBackStackAfterReset; + + // Only clear the stack for 'new' (forward) and 'refresh' navigations + if (e.NavigationMode != NavigationMode.New && e.NavigationMode != NavigationMode.Refresh) + return; + + // For UI consistency, clear the entire page stack + while (RootFrame.RemoveBackEntry() != null) + { + ; // do nothing + } + } + + #endregion + + // Initialize the app's font and flow direction as defined in its localized resource strings. + // + // To ensure that the font of your application is aligned with its supported languages and that the + // FlowDirection for each of those languages follows its traditional direction, ResourceLanguage + // and ResourceFlowDirection should be initialized in each resx file to match these values with that + // file's culture. For example: + // + // AppResources.es-ES.resx + // ResourceLanguage's value should be "es-ES" + // ResourceFlowDirection's value should be "LeftToRight" + // + // AppResources.ar-SA.resx + // ResourceLanguage's value should be "ar-SA" + // ResourceFlowDirection's value should be "RightToLeft" + // + // For more info on localizing Windows Phone apps see http://go.microsoft.com/fwlink/?LinkId=262072. + // + private void InitializeLanguage() + { + try + { + // Set the font to match the display language defined by the + // ResourceLanguage resource string for each supported language. + // + // Fall back to the font of the neutral language if the Display + // language of the phone is not supported. + // + // If a compiler error is hit then ResourceLanguage is missing from + // the resource file. + RootFrame.Language = XmlLanguage.GetLanguage(AppResources.ResourceLanguage); + + // Set the FlowDirection of all elements under the root frame based + // on the ResourceFlowDirection resource string for each + // supported language. + // + // If a compiler error is hit then ResourceFlowDirection is missing from + // the resource file. + FlowDirection flow = (FlowDirection)Enum.Parse(typeof(FlowDirection), AppResources.ResourceFlowDirection); + RootFrame.FlowDirection = flow; + } + catch + { + // If an exception is caught here it is most likely due to either + // ResourceLangauge not being correctly set to a supported language + // code or ResourceFlowDirection is set to a value other than LeftToRight + // or RightToLeft. + + if (Debugger.IsAttached) + { + Debugger.Break(); + } + + throw; + } + } + } +} \ No newline at end of file diff --git a/PocketSharp.Examples/PocketSharp.WP8/Assets/AlignmentGrid.png b/PocketSharp.Examples/PocketSharp.WP8/Assets/AlignmentGrid.png new file mode 100644 index 0000000..f7d2e97 Binary files /dev/null and b/PocketSharp.Examples/PocketSharp.WP8/Assets/AlignmentGrid.png differ diff --git a/PocketSharp.Examples/PocketSharp.WP8/Assets/ApplicationIcon.png b/PocketSharp.Examples/PocketSharp.WP8/Assets/ApplicationIcon.png new file mode 100644 index 0000000..7d95d4e Binary files /dev/null and b/PocketSharp.Examples/PocketSharp.WP8/Assets/ApplicationIcon.png differ diff --git a/PocketSharp.Examples/PocketSharp.WP8/Assets/Tiles/FlipCycleTileLarge.png b/PocketSharp.Examples/PocketSharp.WP8/Assets/Tiles/FlipCycleTileLarge.png new file mode 100644 index 0000000..e0c59ac Binary files /dev/null and b/PocketSharp.Examples/PocketSharp.WP8/Assets/Tiles/FlipCycleTileLarge.png differ diff --git a/PocketSharp.Examples/PocketSharp.WP8/Assets/Tiles/FlipCycleTileMedium.png b/PocketSharp.Examples/PocketSharp.WP8/Assets/Tiles/FlipCycleTileMedium.png new file mode 100644 index 0000000..e93b89d Binary files /dev/null and b/PocketSharp.Examples/PocketSharp.WP8/Assets/Tiles/FlipCycleTileMedium.png differ diff --git a/PocketSharp.Examples/PocketSharp.WP8/Assets/Tiles/FlipCycleTileSmall.png b/PocketSharp.Examples/PocketSharp.WP8/Assets/Tiles/FlipCycleTileSmall.png new file mode 100644 index 0000000..550b1b5 Binary files /dev/null and b/PocketSharp.Examples/PocketSharp.WP8/Assets/Tiles/FlipCycleTileSmall.png differ diff --git a/PocketSharp.Examples/PocketSharp.WP8/Assets/Tiles/IconicTileMediumLarge.png b/PocketSharp.Examples/PocketSharp.WP8/Assets/Tiles/IconicTileMediumLarge.png new file mode 100644 index 0000000..686e6b5 Binary files /dev/null and b/PocketSharp.Examples/PocketSharp.WP8/Assets/Tiles/IconicTileMediumLarge.png differ diff --git a/PocketSharp.Examples/PocketSharp.WP8/Assets/Tiles/IconicTileSmall.png b/PocketSharp.Examples/PocketSharp.WP8/Assets/Tiles/IconicTileSmall.png new file mode 100644 index 0000000..d4b5ede Binary files /dev/null and b/PocketSharp.Examples/PocketSharp.WP8/Assets/Tiles/IconicTileSmall.png differ diff --git a/PocketSharp.Examples/PocketSharp.WP8/DetailsPage.xaml b/PocketSharp.Examples/PocketSharp.WP8/DetailsPage.xaml new file mode 100644 index 0000000..c82ad09 --- /dev/null +++ b/PocketSharp.Examples/PocketSharp.WP8/DetailsPage.xaml @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/PocketSharp.Examples/PocketSharp.WP8/DetailsPage.xaml.cs b/PocketSharp.Examples/PocketSharp.WP8/DetailsPage.xaml.cs new file mode 100644 index 0000000..6547da7 --- /dev/null +++ b/PocketSharp.Examples/PocketSharp.WP8/DetailsPage.xaml.cs @@ -0,0 +1,55 @@ +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; +using PocketSharp.WP8.Resources; + +namespace PocketSharp.WP8 +{ + public partial class DetailsPage : PhoneApplicationPage + { + // Constructor + public DetailsPage() + { + InitializeComponent(); + + // Sample code to localize the ApplicationBar + //BuildLocalizedApplicationBar(); + } + + // When page is navigated to set data context to selected item in list + protected override void OnNavigatedTo(NavigationEventArgs e) + { + if (DataContext == null) + { + string selectedIndex = ""; + if (NavigationContext.QueryString.TryGetValue("selectedItem", out selectedIndex)) + { + int index = int.Parse(selectedIndex); + DataContext = App.ViewModel.Items[index]; + } + } + } + + // Sample code for building a localized ApplicationBar + //private void BuildLocalizedApplicationBar() + //{ + // // Set the page's ApplicationBar to a new instance of ApplicationBar. + // ApplicationBar = new ApplicationBar(); + + // // Create a new button and set the text value to the localized string from AppResources. + // ApplicationBarIconButton appBarButton = new ApplicationBarIconButton(new Uri("/Assets/AppBar/appbar.add.rest.png", UriKind.Relative)); + // appBarButton.Text = AppResources.AppBarButtonText; + // ApplicationBar.Buttons.Add(appBarButton); + + // // Create a new menu item with the localized string from AppResources. + // ApplicationBarMenuItem appBarMenuItem = new ApplicationBarMenuItem(AppResources.AppBarMenuItemText); + // ApplicationBar.MenuItems.Add(appBarMenuItem); + //} + } +} \ No newline at end of file diff --git a/PocketSharp.Examples/PocketSharp.WP8/LocalizedStrings.cs b/PocketSharp.Examples/PocketSharp.WP8/LocalizedStrings.cs new file mode 100644 index 0000000..8fa12be --- /dev/null +++ b/PocketSharp.Examples/PocketSharp.WP8/LocalizedStrings.cs @@ -0,0 +1,14 @@ +using PocketSharp.WP8.Resources; + +namespace PocketSharp.WP8 +{ + /// + /// Provides access to string resources. + /// + public class LocalizedStrings + { + private static AppResources _localizedResources = new AppResources(); + + public AppResources LocalizedResources { get { return _localizedResources; } } + } +} \ No newline at end of file diff --git a/PocketSharp.Examples/PocketSharp.WP8/MainPage.xaml b/PocketSharp.Examples/PocketSharp.WP8/MainPage.xaml new file mode 100644 index 0000000..dbcbb88 --- /dev/null +++ b/PocketSharp.Examples/PocketSharp.WP8/MainPage.xaml @@ -0,0 +1,72 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/PocketSharp.Examples/PocketSharp.WP8/MainPage.xaml.cs b/PocketSharp.Examples/PocketSharp.WP8/MainPage.xaml.cs new file mode 100644 index 0000000..3ebd49a --- /dev/null +++ b/PocketSharp.Examples/PocketSharp.WP8/MainPage.xaml.cs @@ -0,0 +1,69 @@ +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; +using PocketSharp.WP8.Resources; +using PocketSharp.WP8.ViewModels; +using System.Threading.Tasks; + +namespace PocketSharp.WP8 +{ + public partial class MainPage : PhoneApplicationPage + { + // Constructor + public MainPage() + { + InitializeComponent(); + + // Set the data context of the LongListSelector control to the sample data + DataContext = App.ViewModel; + + // Sample code to localize the ApplicationBar + //BuildLocalizedApplicationBar(); + } + + // Load data for the ViewModel Items + protected async override void OnNavigatedTo(NavigationEventArgs e) + { + if (!App.ViewModel.IsDataLoaded) + { + await App.ViewModel.LoadData(); + } + } + + // Handle selection changed on LongListSelector + private void MainLongListSelector_SelectionChanged(object sender, SelectionChangedEventArgs e) + { + // If selected item is null (no selection) do nothing + if (MainLongListSelector.SelectedItem == null) + return; + + // Navigate to the new page + NavigationService.Navigate(new Uri("/DetailsPage.xaml?selectedItem=" + (MainLongListSelector.SelectedItem as ItemViewModel).ID, UriKind.Relative)); + + // Reset selected item to null (no selection) + MainLongListSelector.SelectedItem = null; + } + + // Sample code for building a localized ApplicationBar + //private void BuildLocalizedApplicationBar() + //{ + // // Set the page's ApplicationBar to a new instance of ApplicationBar. + // ApplicationBar = new ApplicationBar(); + + // // Create a new button and set the text value to the localized string from AppResources. + // ApplicationBarIconButton appBarButton = new ApplicationBarIconButton(new Uri("/Assets/AppBar/appbar.add.rest.png", UriKind.Relative)); + // appBarButton.Text = AppResources.AppBarButtonText; + // ApplicationBar.Buttons.Add(appBarButton); + + // // Create a new menu item with the localized string from AppResources. + // ApplicationBarMenuItem appBarMenuItem = new ApplicationBarMenuItem(AppResources.AppBarMenuItemText); + // ApplicationBar.MenuItems.Add(appBarMenuItem); + //} + } +} \ No newline at end of file diff --git a/PocketSharp.Examples/PocketSharp.WP8/PocketSharp.WP8.csproj b/PocketSharp.Examples/PocketSharp.WP8/PocketSharp.WP8.csproj new file mode 100644 index 0000000..c48ea9a --- /dev/null +++ b/PocketSharp.Examples/PocketSharp.WP8/PocketSharp.WP8.csproj @@ -0,0 +1,199 @@ + + + + Debug + AnyCPU + 10.0.20506 + 2.0 + {47721A56-2128-4C5A-8B92-995FFC353304} + {C089C8C0-30E0-4E22-80C0-CE093F111A43};{fae04ec0-301f-11d3-bf4b-00c04f79efbc} + Library + Properties + PocketSharp.WP8 + PocketSharp.WP8 + WindowsPhone + v8.0 + $(TargetFrameworkVersion) + true + + + true + true + PocketSharp.WP8_$(Configuration)_$(Platform).xap + Properties\AppManifest.xml + PocketSharp.WP8.App + true + 11.0 + 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 + + + true + full + false + Bin\x86\Debug + DEBUG;TRACE;SILVERLIGHT;WINDOWS_PHONE + true + true + prompt + 4 + + + pdbonly + true + Bin\x86\Release + TRACE;SILVERLIGHT;WINDOWS_PHONE + true + true + prompt + 4 + + + true + full + false + Bin\ARM\Debug + DEBUG;TRACE;SILVERLIGHT;WINDOWS_PHONE + true + true + prompt + 4 + + + pdbonly + true + Bin\ARM\Release + TRACE;SILVERLIGHT;WINDOWS_PHONE + true + true + prompt + 4 + + + + App.xaml + + + + DetailsPage.xaml + + + MainPage.xaml + + + + True + True + AppResources.resx + + + + + + + Designer + MSBuild:Compile + + + MSBuild:Compile + Designer + + + Designer + MSBuild:Compile + + + MSBuild:Compile + Designer + + + + + + Designer + + + + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + + + PublicResXFileCodeGenerator + AppResources.Designer.cs + + + + + {817200C3-A327-4E35-9B5F-63A51C088577} + PocketSharp + + + + + ..\..\packages\Microsoft.Bcl.Async.1.0.16\lib\wp8\Microsoft.Threading.Tasks.dll + + + ..\..\packages\Microsoft.Bcl.Async.1.0.16\lib\wp8\Microsoft.Threading.Tasks.Extensions.dll + + + ..\..\packages\Microsoft.Bcl.Async.1.0.16\lib\wp8\Microsoft.Threading.Tasks.Extensions.Phone.dll + + + + + + + + + + This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + \ No newline at end of file diff --git a/PocketSharp.Examples/PocketSharp.WP8/Properties/AppManifest.xml b/PocketSharp.Examples/PocketSharp.WP8/Properties/AppManifest.xml new file mode 100644 index 0000000..6712a11 --- /dev/null +++ b/PocketSharp.Examples/PocketSharp.WP8/Properties/AppManifest.xml @@ -0,0 +1,6 @@ + + + + diff --git a/PocketSharp.Examples/PocketSharp.WP8/Properties/AssemblyInfo.cs b/PocketSharp.Examples/PocketSharp.WP8/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..6a65418 --- /dev/null +++ b/PocketSharp.Examples/PocketSharp.WP8/Properties/AssemblyInfo.cs @@ -0,0 +1,37 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Resources; + +// 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("PocketSharp.WP8")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("PocketSharp.WP8")] +[assembly: AssemblyCopyright("Copyright © 2013")] +[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("d4c30306-fbff-4433-8299-ecb70af9cfb6")] + +// 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")] +[assembly: NeutralResourcesLanguageAttribute("en-US")] diff --git a/PocketSharp.Examples/PocketSharp.WP8/Properties/WMAppManifest.xml b/PocketSharp.Examples/PocketSharp.WP8/Properties/WMAppManifest.xml new file mode 100644 index 0000000..466033d --- /dev/null +++ b/PocketSharp.Examples/PocketSharp.WP8/Properties/WMAppManifest.xml @@ -0,0 +1,38 @@ + + + + + + Assets\ApplicationIcon.png + + + + + + + + + + + + + + Assets\Tiles\FlipCycleTileSmall.png + 0 + Assets\Tiles\FlipCycleTileMedium.png + PocketSharp.WP8 + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/PocketSharp.Examples/PocketSharp.WP8/Resources/AppResources.Designer.cs b/PocketSharp.Examples/PocketSharp.WP8/Resources/AppResources.Designer.cs new file mode 100644 index 0000000..f13dc10 --- /dev/null +++ b/PocketSharp.Examples/PocketSharp.WP8/Resources/AppResources.Designer.cs @@ -0,0 +1,138 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.17626 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace PocketSharp.WP8.Resources +{ + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + public class AppResources + { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal AppResources() + { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + public static global::System.Resources.ResourceManager ResourceManager + { + get + { + if (object.ReferenceEquals(resourceMan, null)) + { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("PocketSharp.WP8.Resources.AppResources", typeof(AppResources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + public static global::System.Globalization.CultureInfo Culture + { + get + { + return resourceCulture; + } + set + { + resourceCulture = value; + } + } + + /// + /// Looks up a localized string similar to LeftToRight. + /// + public static string ResourceFlowDirection + { + get + { + return ResourceManager.GetString("ResourceFlowDirection", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to us-EN. + /// + public static string ResourceLanguage + { + get + { + return ResourceManager.GetString("ResourceLanguage", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to MY APPLICATION. + /// + public static string ApplicationTitle + { + get + { + return ResourceManager.GetString("ApplicationTitle", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Sample Runtime Property Value. + /// + public static string SampleProperty + { + get + { + return ResourceManager.GetString("SampleProperty", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to button text. + /// + public static string AppBarButtonText + { + get + { + return ResourceManager.GetString("AppBarButtonText", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to menu item. + /// + public static string AppBarMenuItemText + { + get + { + return ResourceManager.GetString("AppBarMenuItemText", resourceCulture); + } + } + } +} \ No newline at end of file diff --git a/PocketSharp.Examples/PocketSharp.WP8/Resources/AppResources.resx b/PocketSharp.Examples/PocketSharp.WP8/Resources/AppResources.resx new file mode 100644 index 0000000..e9e87c6 --- /dev/null +++ b/PocketSharp.Examples/PocketSharp.WP8/Resources/AppResources.resx @@ -0,0 +1,140 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + LeftToRight + Controls the FlowDirection for all elements in the RootFrame. Set to the traditional direction of this resource file's language + + + en-US + Controls the Language and ensures that the font for all elements in the RootFrame aligns with the app's language. Set to the language code of this resource file's language. + + + MY APPLICATION + + + Sample Runtime Property Value + + + add + + + Menu Item + + \ No newline at end of file diff --git a/PocketSharp.Examples/PocketSharp.WP8/SampleData/MainViewModelSampleData.xaml b/PocketSharp.Examples/PocketSharp.WP8/SampleData/MainViewModelSampleData.xaml new file mode 100644 index 0000000..7975612 --- /dev/null +++ b/PocketSharp.Examples/PocketSharp.WP8/SampleData/MainViewModelSampleData.xaml @@ -0,0 +1,16 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/PocketSharp.Examples/PocketSharp.WP8/ViewModels/ItemViewModel.cs b/PocketSharp.Examples/PocketSharp.WP8/ViewModels/ItemViewModel.cs new file mode 100644 index 0000000..df0b93a --- /dev/null +++ b/PocketSharp.Examples/PocketSharp.WP8/ViewModels/ItemViewModel.cs @@ -0,0 +1,109 @@ +using System; +using System.ComponentModel; +using System.Diagnostics; +using System.Net; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Animation; + +namespace PocketSharp.WP8.ViewModels +{ + public class ItemViewModel : INotifyPropertyChanged + { + private string _id; + /// + /// Sample ViewModel property; this property is used to identify the object. + /// + /// + public string ID + { + get + { + return _id; + } + set + { + if (value != _id) + { + _id = value; + NotifyPropertyChanged("ID"); + } + } + } + + private string _lineOne; + /// + /// Sample ViewModel property; this property is used in the view to display its value using a Binding. + /// + /// + public string LineOne + { + get + { + return _lineOne; + } + set + { + if (value != _lineOne) + { + _lineOne = value; + NotifyPropertyChanged("LineOne"); + } + } + } + + private string _lineTwo; + /// + /// Sample ViewModel property; this property is used in the view to display its value using a Binding. + /// + /// + public string LineTwo + { + get + { + return _lineTwo; + } + set + { + if (value != _lineTwo) + { + _lineTwo = value; + NotifyPropertyChanged("LineTwo"); + } + } + } + + private string _lineThree; + /// + /// Sample ViewModel property; this property is used in the view to display its value using a Binding. + /// + /// + public string LineThree + { + get + { + return _lineThree; + } + set + { + if (value != _lineThree) + { + _lineThree = value; + NotifyPropertyChanged("LineThree"); + } + } + } + + public event PropertyChangedEventHandler PropertyChanged; + private void NotifyPropertyChanged(String propertyName) + { + PropertyChangedEventHandler handler = PropertyChanged; + if (null != handler) + { + handler(this, new PropertyChangedEventArgs(propertyName)); + } + } + } +} \ No newline at end of file diff --git a/PocketSharp.Examples/PocketSharp.WP8/ViewModels/MainViewModel.cs b/PocketSharp.Examples/PocketSharp.WP8/ViewModels/MainViewModel.cs new file mode 100644 index 0000000..e23909c --- /dev/null +++ b/PocketSharp.Examples/PocketSharp.WP8/ViewModels/MainViewModel.cs @@ -0,0 +1,110 @@ +using System; +using System.Collections.ObjectModel; +using System.ComponentModel; +using PocketSharp.WP8.Resources; +using PocketSharp; +using System.Collections.Generic; +using System.Threading.Tasks; +using System.Diagnostics; + +namespace PocketSharp.WP8.ViewModels +{ + public class MainViewModel : INotifyPropertyChanged + { + public MainViewModel() + { + this.Items = new ObservableCollection(); + } + + /// + /// A collection for ItemViewModel objects. + /// + public ObservableCollection Items { get; private set; } + + private string _sampleProperty = "Sample Runtime Property Value"; + /// + /// Sample ViewModel property; this property is used in the view to display its value using a Binding + /// + /// + public string SampleProperty + { + get + { + return _sampleProperty; + } + set + { + if (value != _sampleProperty) + { + _sampleProperty = value; + NotifyPropertyChanged("SampleProperty"); + } + } + } + + /// + /// Sample property that returns a localized string + /// + public string LocalizedSampleProperty + { + get + { + return AppResources.SampleProperty; + } + } + + public bool IsDataLoaded + { + get; + private set; + } + + /// + /// Creates and adds a few ItemViewModel objects into the Items collection. + /// + public async Task LoadData() + { + // User: pocketsharp-tests + // PW: pocketsharp + // !! please don't misuse this account !! + PocketClient client = new PocketClient( + consumerKey: "15396-f6f92101d72c8e270a6c9bb3", + callbackUri: "http://frontendplay.com", + accessCode: "2c62cd50-b78a-5558-918b-65adae" + ); + + List items = null; + + try + { + items = await client.Retrieve().ConfigureAwait(false); + + items.ForEach(item => + { + this.Items.Add(new ItemViewModel() + { + ID = item.ID.ToString(), + LineOne = item.Title, + LineTwo = item.Uri.ToString() + }); + }); + } + catch (PocketException ex) + { + Debug.WriteLine(ex.Message); + } + + this.IsDataLoaded = true; + } + + public event PropertyChangedEventHandler PropertyChanged; + private void NotifyPropertyChanged(String propertyName) + { + PropertyChangedEventHandler handler = PropertyChanged; + if (null != handler) + { + handler(this, new PropertyChangedEventArgs(propertyName)); + } + } + } +} \ No newline at end of file diff --git a/PocketSharp.sln b/PocketSharp.sln index 45fdd64..b08fc53 100644 --- a/PocketSharp.sln +++ b/PocketSharp.sln @@ -11,29 +11,77 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PocketSharp.Wpf", "PocketSh EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "PocketSharp.Examples", "PocketSharp.Examples", "{AFD4E3F1-B23C-4924-BA5B-D917FBADB8FA}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PocketSharp.Silverlight", "PocketSharp.Examples\PocketSharp.Silverlight\PocketSharp.Silverlight.csproj", "{656345D2-AF4C-4F88-9C9F-EBF54D7691DB}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PocketSharp.WP8", "PocketSharp.Examples\PocketSharp.WP8\PocketSharp.WP8.csproj", "{47721A56-2128-4C5A-8B92-995FFC353304}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU + Debug|ARM = Debug|ARM + Debug|x86 = Debug|x86 Release|Any CPU = Release|Any CPU + Release|ARM = Release|ARM + Release|x86 = Release|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {F1CEA363-7039-40BA-9744-0071F46BB90C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {F1CEA363-7039-40BA-9744-0071F46BB90C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F1CEA363-7039-40BA-9744-0071F46BB90C}.Debug|ARM.ActiveCfg = Debug|Any CPU + {F1CEA363-7039-40BA-9744-0071F46BB90C}.Debug|x86.ActiveCfg = Debug|Any CPU {F1CEA363-7039-40BA-9744-0071F46BB90C}.Release|Any CPU.ActiveCfg = Release|Any CPU {F1CEA363-7039-40BA-9744-0071F46BB90C}.Release|Any CPU.Build.0 = Release|Any CPU + {F1CEA363-7039-40BA-9744-0071F46BB90C}.Release|ARM.ActiveCfg = Release|Any CPU + {F1CEA363-7039-40BA-9744-0071F46BB90C}.Release|x86.ActiveCfg = Release|Any CPU {817200C3-A327-4E35-9B5F-63A51C088577}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {817200C3-A327-4E35-9B5F-63A51C088577}.Debug|Any CPU.Build.0 = Debug|Any CPU + {817200C3-A327-4E35-9B5F-63A51C088577}.Debug|ARM.ActiveCfg = Debug|Any CPU + {817200C3-A327-4E35-9B5F-63A51C088577}.Debug|x86.ActiveCfg = Debug|Any CPU {817200C3-A327-4E35-9B5F-63A51C088577}.Release|Any CPU.ActiveCfg = Release|Any CPU {817200C3-A327-4E35-9B5F-63A51C088577}.Release|Any CPU.Build.0 = Release|Any CPU + {817200C3-A327-4E35-9B5F-63A51C088577}.Release|ARM.ActiveCfg = Release|Any CPU + {817200C3-A327-4E35-9B5F-63A51C088577}.Release|x86.ActiveCfg = Release|Any CPU {775569C2-987F-4AC4-8BA5-A315A21ED1B7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {775569C2-987F-4AC4-8BA5-A315A21ED1B7}.Debug|Any CPU.Build.0 = Debug|Any CPU + {775569C2-987F-4AC4-8BA5-A315A21ED1B7}.Debug|ARM.ActiveCfg = Debug|Any CPU + {775569C2-987F-4AC4-8BA5-A315A21ED1B7}.Debug|x86.ActiveCfg = Debug|Any CPU {775569C2-987F-4AC4-8BA5-A315A21ED1B7}.Release|Any CPU.ActiveCfg = Release|Any CPU {775569C2-987F-4AC4-8BA5-A315A21ED1B7}.Release|Any CPU.Build.0 = Release|Any CPU + {775569C2-987F-4AC4-8BA5-A315A21ED1B7}.Release|ARM.ActiveCfg = Release|Any CPU + {775569C2-987F-4AC4-8BA5-A315A21ED1B7}.Release|x86.ActiveCfg = Release|Any CPU + {656345D2-AF4C-4F88-9C9F-EBF54D7691DB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {656345D2-AF4C-4F88-9C9F-EBF54D7691DB}.Debug|Any CPU.Build.0 = Debug|Any CPU + {656345D2-AF4C-4F88-9C9F-EBF54D7691DB}.Debug|ARM.ActiveCfg = Debug|Any CPU + {656345D2-AF4C-4F88-9C9F-EBF54D7691DB}.Debug|x86.ActiveCfg = Debug|Any CPU + {656345D2-AF4C-4F88-9C9F-EBF54D7691DB}.Release|Any CPU.ActiveCfg = Release|Any CPU + {656345D2-AF4C-4F88-9C9F-EBF54D7691DB}.Release|Any CPU.Build.0 = Release|Any CPU + {656345D2-AF4C-4F88-9C9F-EBF54D7691DB}.Release|ARM.ActiveCfg = Release|Any CPU + {656345D2-AF4C-4F88-9C9F-EBF54D7691DB}.Release|x86.ActiveCfg = Release|Any CPU + {47721A56-2128-4C5A-8B92-995FFC353304}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {47721A56-2128-4C5A-8B92-995FFC353304}.Debug|Any CPU.Build.0 = Debug|Any CPU + {47721A56-2128-4C5A-8B92-995FFC353304}.Debug|Any CPU.Deploy.0 = Debug|Any CPU + {47721A56-2128-4C5A-8B92-995FFC353304}.Debug|ARM.ActiveCfg = Debug|ARM + {47721A56-2128-4C5A-8B92-995FFC353304}.Debug|ARM.Build.0 = Debug|ARM + {47721A56-2128-4C5A-8B92-995FFC353304}.Debug|ARM.Deploy.0 = Debug|ARM + {47721A56-2128-4C5A-8B92-995FFC353304}.Debug|x86.ActiveCfg = Debug|x86 + {47721A56-2128-4C5A-8B92-995FFC353304}.Debug|x86.Build.0 = Debug|x86 + {47721A56-2128-4C5A-8B92-995FFC353304}.Debug|x86.Deploy.0 = Debug|x86 + {47721A56-2128-4C5A-8B92-995FFC353304}.Release|Any CPU.ActiveCfg = Release|Any CPU + {47721A56-2128-4C5A-8B92-995FFC353304}.Release|Any CPU.Build.0 = Release|Any CPU + {47721A56-2128-4C5A-8B92-995FFC353304}.Release|Any CPU.Deploy.0 = Release|Any CPU + {47721A56-2128-4C5A-8B92-995FFC353304}.Release|ARM.ActiveCfg = Release|ARM + {47721A56-2128-4C5A-8B92-995FFC353304}.Release|ARM.Build.0 = Release|ARM + {47721A56-2128-4C5A-8B92-995FFC353304}.Release|ARM.Deploy.0 = Release|ARM + {47721A56-2128-4C5A-8B92-995FFC353304}.Release|x86.ActiveCfg = Release|x86 + {47721A56-2128-4C5A-8B92-995FFC353304}.Release|x86.Build.0 = Release|x86 + {47721A56-2128-4C5A-8B92-995FFC353304}.Release|x86.Deploy.0 = Release|x86 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection GlobalSection(NestedProjects) = preSolution {775569C2-987F-4AC4-8BA5-A315A21ED1B7} = {AFD4E3F1-B23C-4924-BA5B-D917FBADB8FA} + {656345D2-AF4C-4F88-9C9F-EBF54D7691DB} = {AFD4E3F1-B23C-4924-BA5B-D917FBADB8FA} + {47721A56-2128-4C5A-8B92-995FFC353304} = {AFD4E3F1-B23C-4924-BA5B-D917FBADB8FA} EndGlobalSection EndGlobal