diff --git a/PocketSharp.Examples/PocketSharp.WP8/App.xaml.cs b/PocketSharp.Examples/PocketSharp.WP8/App.xaml.cs index fb2a7f5..57784d2 100644 --- a/PocketSharp.Examples/PocketSharp.WP8/App.xaml.cs +++ b/PocketSharp.Examples/PocketSharp.WP8/App.xaml.cs @@ -1,13 +1,12 @@ -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.Controls; using Microsoft.Phone.Shell; using PocketSharp.WP8.Resources; using PocketSharp.WP8.ViewModels; +using System; +using System.Diagnostics; +using System.Windows; +using System.Windows.Markup; +using System.Windows.Navigation; namespace PocketSharp.WP8 { diff --git a/PocketSharp.WP7/App.xaml b/PocketSharp.WP7/App.xaml new file mode 100644 index 0000000..96a9a98 --- /dev/null +++ b/PocketSharp.WP7/App.xaml @@ -0,0 +1,19 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/PocketSharp.WP7/App.xaml.cs b/PocketSharp.WP7/App.xaml.cs new file mode 100644 index 0000000..5467dc2 --- /dev/null +++ b/PocketSharp.WP7/App.xaml.cs @@ -0,0 +1,151 @@ +using Microsoft.Phone.Controls; +using Microsoft.Phone.Shell; +using PocketSharp.WP7.ViewModels; +using System.Windows; +using System.Windows.Navigation; + +namespace PocketSharp.WP7 +{ + 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 PhoneApplicationFrame RootFrame { get; private set; } + + /// + /// Constructor for the Application object. + /// + public App() + { + // Global handler for uncaught exceptions. + UnhandledException += Application_UnhandledException; + + // Standard Silverlight initialization + InitializeComponent(); + + // Phone-specific initialization + InitializePhoneApplication(); + + // Show graphics profiling information while debugging. + if (System.Diagnostics.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 to GPU with a colored overlay. + //Application.Current.Host.Settings.EnableCacheVisualization = true; + + // Disable the application idle detection by setting the UserIdleDetectionMode property of the + // application's PhoneApplicationService object to Disabled. + // 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) + { + } + + // 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) + { + } + + // 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 (System.Diagnostics.Debugger.IsAttached) + { + // A navigation has failed; break into the debugger + System.Diagnostics.Debugger.Break(); + } + } + + // Code to execute on Unhandled Exceptions + private void Application_UnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e) + { + if (System.Diagnostics.Debugger.IsAttached) + { + // An unhandled exception has occurred; break into the debugger + System.Diagnostics.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; + + // 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; + } + + #endregion + } +} \ No newline at end of file diff --git a/PocketSharp.WP7/ApplicationIcon.png b/PocketSharp.WP7/ApplicationIcon.png new file mode 100644 index 0000000..5859393 Binary files /dev/null and b/PocketSharp.WP7/ApplicationIcon.png differ diff --git a/PocketSharp.WP7/Background.png b/PocketSharp.WP7/Background.png new file mode 100644 index 0000000..e46f21d Binary files /dev/null and b/PocketSharp.WP7/Background.png differ diff --git a/PocketSharp.WP7/MainPage.xaml b/PocketSharp.WP7/MainPage.xaml new file mode 100644 index 0000000..2db2405 --- /dev/null +++ b/PocketSharp.WP7/MainPage.xaml @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/PocketSharp.WP7/MainPage.xaml.cs b/PocketSharp.WP7/MainPage.xaml.cs new file mode 100644 index 0000000..cc6fb60 --- /dev/null +++ b/PocketSharp.WP7/MainPage.xaml.cs @@ -0,0 +1,22 @@ +using Microsoft.Phone.Controls; +using System.Windows; + +namespace PocketSharp.WP7 +{ + public partial class MainPage : PhoneApplicationPage + { + // Constructor + public MainPage() + { + InitializeComponent(); + + // Set the data context of the LongListSelector control to the sample data + DataContext = App.ViewModel; + } + + private async void Button_Click(object sender, RoutedEventArgs e) + { + await App.ViewModel.LoadData(); + } + } +} \ No newline at end of file diff --git a/PocketSharp.WP7/PocketSharp.WP7.csproj b/PocketSharp.WP7/PocketSharp.WP7.csproj new file mode 100644 index 0000000..29e454b --- /dev/null +++ b/PocketSharp.WP7/PocketSharp.WP7.csproj @@ -0,0 +1,152 @@ + + + + Debug + AnyCPU + 10.0.20506 + 2.0 + {6F542037-C48B-4EC5-A326-DDBEBF5FDFA2} + {C089C8C0-30E0-4E22-80C0-CE093F111A43};{fae04ec0-301f-11d3-bf4b-00c04f79efbc} + Library + Properties + PocketSharp.WP7 + PocketSharp.WP7 + v4.0 + $(TargetFrameworkVersion) + WindowsPhone71 + Silverlight + true + + + true + true + PocketSharp.WP7.xap + Properties\AppManifest.xml + PocketSharp.WP7.App + true + 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 + + + + + + ..\packages\Microsoft.Bcl.Async.1.0.165\lib\sl4-windowsphone71\Microsoft.Threading.Tasks.dll + + + ..\packages\Microsoft.Bcl.Async.1.0.165\lib\sl4-windowsphone71\Microsoft.Threading.Tasks.Extensions.dll + + + ..\packages\Microsoft.Bcl.Async.1.0.165\lib\sl4-windowsphone71\Microsoft.Threading.Tasks.Extensions.Phone.dll + + + ..\packages\Microsoft.Bcl.1.1.3\lib\sl4-windowsphone71\System.IO.dll + + + ..\packages\Microsoft.Net.Http.2.2.18\lib\sl4-windowsphone71\System.Net.Http.dll + + + ..\packages\Microsoft.Net.Http.2.2.18\lib\sl4-windowsphone71\System.Net.Http.Extensions.dll + + + ..\packages\Microsoft.Net.Http.2.2.18\lib\sl4-windowsphone71\System.Net.Http.Primitives.dll + + + ..\packages\Microsoft.Bcl.1.1.3\lib\sl4-windowsphone71\System.Runtime.dll + + + ..\packages\Microsoft.Bcl.1.1.3\lib\sl4-windowsphone71\System.Threading.Tasks.dll + + + + + + + + + + + App.xaml + + + MainPage.xaml + + + + + + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + + + + + + + + PreserveNewest + + + PreserveNewest + + + + + + {817200C3-A327-4E35-9B5F-63A51C088577} + PocketSharp + + + + + + + + + + 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.WP7/Properties/AppManifest.xml b/PocketSharp.WP7/Properties/AppManifest.xml new file mode 100644 index 0000000..6712a11 --- /dev/null +++ b/PocketSharp.WP7/Properties/AppManifest.xml @@ -0,0 +1,6 @@ + + + + diff --git a/PocketSharp.WP7/Properties/AssemblyInfo.cs b/PocketSharp.WP7/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..b102d2b --- /dev/null +++ b/PocketSharp.WP7/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.WP7")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("PocketSharp.WP7")] +[assembly: AssemblyCopyright("Copyright © 2014")] +[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("775e1575-245f-45be-85f8-e6289b22b330")] + +// 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.WP7/Properties/WMAppManifest.xml b/PocketSharp.WP7/Properties/WMAppManifest.xml new file mode 100644 index 0000000..79314b5 --- /dev/null +++ b/PocketSharp.WP7/Properties/WMAppManifest.xml @@ -0,0 +1,35 @@ + + + + + ApplicationIcon.png + + + + + + + + + + + + + + + + + + + + + + + Background.png + 0 + PocketSharp.WP7 + + + + + diff --git a/PocketSharp.WP7/SplashScreenImage.jpg b/PocketSharp.WP7/SplashScreenImage.jpg new file mode 100644 index 0000000..353b192 Binary files /dev/null and b/PocketSharp.WP7/SplashScreenImage.jpg differ diff --git a/PocketSharp.WP7/ViewModels/ItemViewModel.cs b/PocketSharp.WP7/ViewModels/ItemViewModel.cs new file mode 100644 index 0000000..fef68cb --- /dev/null +++ b/PocketSharp.WP7/ViewModels/ItemViewModel.cs @@ -0,0 +1,102 @@ +using System; +using System.ComponentModel; + +namespace PocketSharp.WP7.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.WP7/ViewModels/MainViewModel.cs b/PocketSharp.WP7/ViewModels/MainViewModel.cs new file mode 100644 index 0000000..c0fceb6 --- /dev/null +++ b/PocketSharp.WP7/ViewModels/MainViewModel.cs @@ -0,0 +1,106 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.Diagnostics; +using System.Threading.Tasks; + +namespace PocketSharp.WP7.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 "test"; + } + } + + public bool IsDataLoaded + { + get; + private set; + } + + /// + /// Creates and adds a few ItemViewModel objects into the Items collection. + /// + public async Task LoadData() + { + // !! please don't misuse this account !! + PocketClient client = new PocketClient( + consumerKey: "15396-f6f92101d72c8e270a6c9bb3", + callbackUri: "http://frontendplay.com", + accessCode: "80acf6c5-c198-03c0-b94c-e74402" + ); + + List items = null; + + try + { + items = await client.Get(); + + 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.WP7/packages.config b/PocketSharp.WP7/packages.config new file mode 100644 index 0000000..53ce557 --- /dev/null +++ b/PocketSharp.WP7/packages.config @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/PocketSharp.sln b/PocketSharp.sln index 97a0641..56b83a8 100644 --- a/PocketSharp.sln +++ b/PocketSharp.sln @@ -22,6 +22,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{19DD45 .nuget\NuGet.targets = .nuget\NuGet.targets EndProjectSection EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PocketSharp.WP7", "PocketSharp.WP7\PocketSharp.WP7.csproj", "{6F542037-C48B-4EC5-A326-DDBEBF5FDFA2}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -83,6 +85,16 @@ Global {CA3C491B-A8CA-426C-A0BB-E91636767467}.Release|Any CPU.Build.0 = Release|Any CPU {CA3C491B-A8CA-426C-A0BB-E91636767467}.Release|ARM.ActiveCfg = Release|Any CPU {CA3C491B-A8CA-426C-A0BB-E91636767467}.Release|x86.ActiveCfg = Release|Any CPU + {6F542037-C48B-4EC5-A326-DDBEBF5FDFA2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6F542037-C48B-4EC5-A326-DDBEBF5FDFA2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6F542037-C48B-4EC5-A326-DDBEBF5FDFA2}.Debug|Any CPU.Deploy.0 = Debug|Any CPU + {6F542037-C48B-4EC5-A326-DDBEBF5FDFA2}.Debug|ARM.ActiveCfg = Debug|Any CPU + {6F542037-C48B-4EC5-A326-DDBEBF5FDFA2}.Debug|x86.ActiveCfg = Debug|Any CPU + {6F542037-C48B-4EC5-A326-DDBEBF5FDFA2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6F542037-C48B-4EC5-A326-DDBEBF5FDFA2}.Release|Any CPU.Build.0 = Release|Any CPU + {6F542037-C48B-4EC5-A326-DDBEBF5FDFA2}.Release|Any CPU.Deploy.0 = Release|Any CPU + {6F542037-C48B-4EC5-A326-DDBEBF5FDFA2}.Release|ARM.ActiveCfg = Release|Any CPU + {6F542037-C48B-4EC5-A326-DDBEBF5FDFA2}.Release|x86.ActiveCfg = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -91,5 +103,6 @@ Global {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} + {6F542037-C48B-4EC5-A326-DDBEBF5FDFA2} = {AFD4E3F1-B23C-4924-BA5B-D917FBADB8FA} EndGlobalSection EndGlobal