From 15cb370209ccdee404d378bcd4eb1fdca7774a0d Mon Sep 17 00:00:00 2001 From: Michael Gordeev Date: Sat, 14 Mar 2020 09:23:24 +0300 Subject: [PATCH] Code cleanup and optimizing --- GUT.Schedule/GUTSchedule.UWP/App.xaml.cs | 53 ++----------------- .../{ => Controls}/ClearCalendarControl.xaml | 2 +- .../ClearCalendarControl.xaml.cs | 2 +- .../GUTSchedule.UWP/GUTSchedule.UWP.csproj | 15 +++--- .../GUTSchedule.UWP/Package.appxmanifest | 4 +- .../{ => Pages}/AboutPage.xaml | 2 +- .../{ => Pages}/AboutPage.xaml.cs | 14 +++-- .../GUTSchedule.UWP/{ => Pages}/MainPage.xaml | 2 +- .../{ => Pages}/MainPage.xaml.cs | 9 ++-- .../Properties/AssemblyInfo.cs | 9 ++-- .../GUTSchedule.UWP/Properties/Default.rd.xml | 32 ++--------- 11 files changed, 30 insertions(+), 114 deletions(-) rename GUT.Schedule/GUTSchedule.UWP/{ => Controls}/ClearCalendarControl.xaml (93%) rename GUT.Schedule/GUTSchedule.UWP/{ => Controls}/ClearCalendarControl.xaml.cs (93%) rename GUT.Schedule/GUTSchedule.UWP/{ => Pages}/AboutPage.xaml (98%) rename GUT.Schedule/GUTSchedule.UWP/{ => Pages}/AboutPage.xaml.cs (86%) rename GUT.Schedule/GUTSchedule.UWP/{ => Pages}/MainPage.xaml (99%) rename GUT.Schedule/GUTSchedule.UWP/{ => Pages}/MainPage.xaml.cs (98%) diff --git a/GUT.Schedule/GUTSchedule.UWP/App.xaml.cs b/GUT.Schedule/GUTSchedule.UWP/App.xaml.cs index 48d2ada..34fe26a 100644 --- a/GUT.Schedule/GUTSchedule.UWP/App.xaml.cs +++ b/GUT.Schedule/GUTSchedule.UWP/App.xaml.cs @@ -1,11 +1,10 @@ using System; using System.Linq; -using Windows.ApplicationModel; using Windows.ApplicationModel.Activation; using Windows.UI.Popups; using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; -using Windows.UI.Xaml.Navigation; +using GUTSchedule.UWP.Pages; namespace GUTSchedule.UWP { @@ -26,14 +25,12 @@ namespace GUTSchedule.UWP Windows.Globalization.ApplicationLanguages.PrimaryLanguageOverride = "en"; InitializeComponent(); - Suspending += OnSuspending; UnhandledException += OnError; } private async void OnError(object sender, UnhandledExceptionEventArgs e) { e.Handled = true; - await new MessageDialog(e.Message, e.GetType().ToString()).ShowAsync(); } @@ -44,60 +41,16 @@ namespace GUTSchedule.UWP /// Details about the launch request and process. protected override void OnLaunched(LaunchActivatedEventArgs e) { - // Do not repeat app initialization when the Window already has content, - // just ensure that the window is active if (!(Window.Current.Content is Frame rootFrame)) - { - // Create a Frame to act as the navigation context and navigate to the first page - rootFrame = new Frame(); - - rootFrame.NavigationFailed += OnNavigationFailed; - - if (e.PreviousExecutionState == ApplicationExecutionState.Terminated) - { - //TODO: Load state from previously suspended application - } - - // Place the frame in the current Window - Window.Current.Content = rootFrame; - } + Window.Current.Content = rootFrame = new Frame(); if (e.PrelaunchActivated == false) { if (rootFrame.Content == null) - { - // When the navigation stack isn't restored navigate to the first page, - // configuring the new page by passing required information as a navigation - // parameter rootFrame.Navigate(typeof(MainPage), e.Arguments); - } - // Ensure the current window is active + Window.Current.Activate(); } } - - /// - /// Invoked when Navigation to a certain page fails - /// - /// The Frame which failed navigation - /// Details about the navigation failure - void OnNavigationFailed(object sender, NavigationFailedEventArgs e) - { - throw new Exception("Failed to load Page " + e.SourcePageType.FullName); - } - - /// - /// Invoked when application execution is being suspended. Application state is saved - /// without knowing whether the application will be terminated or resumed with the contents - /// of memory still intact. - /// - /// The source of the suspend request. - /// Details about the suspend request. - private void OnSuspending(object sender, SuspendingEventArgs e) - { - var deferral = e.SuspendingOperation.GetDeferral(); - //TODO: Save application state and stop any background activity - deferral.Complete(); - } } } diff --git a/GUT.Schedule/GUTSchedule.UWP/ClearCalendarControl.xaml b/GUT.Schedule/GUTSchedule.UWP/Controls/ClearCalendarControl.xaml similarity index 93% rename from GUT.Schedule/GUTSchedule.UWP/ClearCalendarControl.xaml rename to GUT.Schedule/GUTSchedule.UWP/Controls/ClearCalendarControl.xaml index 2a8ca7c..04fab68 100644 --- a/GUT.Schedule/GUTSchedule.UWP/ClearCalendarControl.xaml +++ b/GUT.Schedule/GUTSchedule.UWP/Controls/ClearCalendarControl.xaml @@ -1,5 +1,5 @@ PackageReference - + AboutPage.xaml App.xaml - + ClearCalendarControl.xaml - + MainPage.xaml @@ -199,15 +199,15 @@ MSBuild:Compile Designer - + Designer MSBuild:Compile - + Designer MSBuild:Compile - + MSBuild:Compile Designer @@ -219,9 +219,6 @@ 10.1901.28001 - - 12.0.3 - diff --git a/GUT.Schedule/GUTSchedule.UWP/Package.appxmanifest b/GUT.Schedule/GUTSchedule.UWP/Package.appxmanifest index f0e242d..64eacff 100644 --- a/GUT.Schedule/GUTSchedule.UWP/Package.appxmanifest +++ b/GUT.Schedule/GUTSchedule.UWP/Package.appxmanifest @@ -1,16 +1,14 @@  - + Version="2020.313.2.0" /> diff --git a/GUT.Schedule/GUTSchedule.UWP/AboutPage.xaml b/GUT.Schedule/GUTSchedule.UWP/Pages/AboutPage.xaml similarity index 98% rename from GUT.Schedule/GUTSchedule.UWP/AboutPage.xaml rename to GUT.Schedule/GUTSchedule.UWP/Pages/AboutPage.xaml index c46b1f3..5cb776e 100644 --- a/GUT.Schedule/GUTSchedule.UWP/AboutPage.xaml +++ b/GUT.Schedule/GUTSchedule.UWP/Pages/AboutPage.xaml @@ -1,5 +1,5 @@  Frame.GoBack(); } -} +} \ No newline at end of file diff --git a/GUT.Schedule/GUTSchedule.UWP/MainPage.xaml b/GUT.Schedule/GUTSchedule.UWP/Pages/MainPage.xaml similarity index 99% rename from GUT.Schedule/GUTSchedule.UWP/MainPage.xaml rename to GUT.Schedule/GUTSchedule.UWP/Pages/MainPage.xaml index e5a3067..d540420 100644 --- a/GUT.Schedule/GUTSchedule.UWP/MainPage.xaml +++ b/GUT.Schedule/GUTSchedule.UWP/Pages/MainPage.xaml @@ -1,5 +1,5 @@  - - To enable dynamic creation of the specific instantiation of AppClass over System.Int32 - - - Using the Namespace directive to apply reflection policy to all the types in a particular namespace - ---> - - - - - - - - - - + + + \ No newline at end of file