1
0
mirror of https://github.com/XFox111/GUTSchedule.git synced 2026-04-22 06:58:01 +03:00

Code cleanup and optimizing

This commit is contained in:
Michael Gordeev
2020-03-14 09:23:24 +03:00
parent 79d58c0e12
commit 15cb370209
11 changed files with 30 additions and 114 deletions
+3 -50
View File
@@ -1,11 +1,10 @@
using System; using System;
using System.Linq; using System.Linq;
using Windows.ApplicationModel;
using Windows.ApplicationModel.Activation; using Windows.ApplicationModel.Activation;
using Windows.UI.Popups; using Windows.UI.Popups;
using Windows.UI.Xaml; using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Navigation; using GUTSchedule.UWP.Pages;
namespace GUTSchedule.UWP namespace GUTSchedule.UWP
{ {
@@ -26,14 +25,12 @@ namespace GUTSchedule.UWP
Windows.Globalization.ApplicationLanguages.PrimaryLanguageOverride = "en"; Windows.Globalization.ApplicationLanguages.PrimaryLanguageOverride = "en";
InitializeComponent(); InitializeComponent();
Suspending += OnSuspending;
UnhandledException += OnError; UnhandledException += OnError;
} }
private async void OnError(object sender, UnhandledExceptionEventArgs e) private async void OnError(object sender, UnhandledExceptionEventArgs e)
{ {
e.Handled = true; e.Handled = true;
await new MessageDialog(e.Message, e.GetType().ToString()).ShowAsync(); await new MessageDialog(e.Message, e.GetType().ToString()).ShowAsync();
} }
@@ -44,60 +41,16 @@ namespace GUTSchedule.UWP
/// <param name="e">Details about the launch request and process.</param> /// <param name="e">Details about the launch request and process.</param>
protected override void OnLaunched(LaunchActivatedEventArgs e) 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)) if (!(Window.Current.Content is Frame rootFrame))
{ Window.Current.Content = rootFrame = new Frame();
// 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;
}
if (e.PrelaunchActivated == false) if (e.PrelaunchActivated == false)
{ {
if (rootFrame.Content == null) 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); rootFrame.Navigate(typeof(MainPage), e.Arguments);
}
// Ensure the current window is active
Window.Current.Activate(); Window.Current.Activate();
} }
} }
/// <summary>
/// Invoked when Navigation to a certain page fails
/// </summary>
/// <param name="sender">The Frame which failed navigation</param>
/// <param name="e">Details about the navigation failure</param>
void OnNavigationFailed(object sender, NavigationFailedEventArgs e)
{
throw new Exception("Failed to load Page " + e.SourcePageType.FullName);
}
/// <summary>
/// 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.
/// </summary>
/// <param name="sender">The source of the suspend request.</param>
/// <param name="e">Details about the suspend request.</param>
private void OnSuspending(object sender, SuspendingEventArgs e)
{
var deferral = e.SuspendingOperation.GetDeferral();
//TODO: Save application state and stop any background activity
deferral.Complete();
}
} }
} }
@@ -1,5 +1,5 @@
<ContentDialog <ContentDialog
x:Class="GUTSchedule.UWP.ClearCalendarControl" x:Class="GUTSchedule.UWP.Controls.ClearCalendarControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
@@ -1,7 +1,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Controls;
namespace GUTSchedule.UWP namespace GUTSchedule.UWP.Controls
{ {
public sealed partial class ClearCalendarControl : ContentDialog public sealed partial class ClearCalendarControl : ContentDialog
{ {
@@ -124,17 +124,17 @@
<RestoreProjectStyle>PackageReference</RestoreProjectStyle> <RestoreProjectStyle>PackageReference</RestoreProjectStyle>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Compile Include="AboutPage.xaml.cs"> <Compile Include="Pages\AboutPage.xaml.cs">
<DependentUpon>AboutPage.xaml</DependentUpon> <DependentUpon>AboutPage.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="App.xaml.cs"> <Compile Include="App.xaml.cs">
<DependentUpon>App.xaml</DependentUpon> <DependentUpon>App.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="Calendar.cs" /> <Compile Include="Calendar.cs" />
<Compile Include="ClearCalendarControl.xaml.cs"> <Compile Include="Controls\ClearCalendarControl.xaml.cs">
<DependentUpon>ClearCalendarControl.xaml</DependentUpon> <DependentUpon>ClearCalendarControl.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="MainPage.xaml.cs"> <Compile Include="Pages\MainPage.xaml.cs">
<DependentUpon>MainPage.xaml</DependentUpon> <DependentUpon>MainPage.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
@@ -199,15 +199,15 @@
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType> <SubType>Designer</SubType>
</ApplicationDefinition> </ApplicationDefinition>
<Page Include="AboutPage.xaml"> <Page Include="Pages\AboutPage.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</Page> </Page>
<Page Include="ClearCalendarControl.xaml"> <Page Include="Controls\ClearCalendarControl.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</Page> </Page>
<Page Include="MainPage.xaml"> <Page Include="Pages\MainPage.xaml">
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType> <SubType>Designer</SubType>
</Page> </Page>
@@ -219,9 +219,6 @@
<PackageReference Include="Microsoft.Services.Store.Engagement"> <PackageReference Include="Microsoft.Services.Store.Engagement">
<Version>10.1901.28001</Version> <Version>10.1901.28001</Version>
</PackageReference> </PackageReference>
<PackageReference Include="Newtonsoft.Json">
<Version>12.0.3</Version>
</PackageReference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\GUTSchedule\GUTSchedule.csproj"> <ProjectReference Include="..\GUTSchedule\GUTSchedule.csproj">
@@ -1,16 +1,14 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Package <Package
xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10" xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10"
xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest" xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest"
xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10" xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"
xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"
IgnorableNamespaces="uap mp"> IgnorableNamespaces="uap mp">
<Identity <Identity
Name="53949MichaelXFoxGordeev.GUT.Schedule" Name="53949MichaelXFoxGordeev.GUT.Schedule"
Publisher="CN=FD7A34DD-FE4D-4D7D-9D33-2DA9EBBE7725" Publisher="CN=FD7A34DD-FE4D-4D7D-9D33-2DA9EBBE7725"
Version="2020.222.1.0" /> Version="2020.313.2.0" />
<mp:PhoneIdentity PhoneProductId="ea5f6ab0-1992-40f5-b89c-11fc3a97ae9f" PhonePublisherId="00000000-0000-0000-0000-000000000000"/> <mp:PhoneIdentity PhoneProductId="ea5f6ab0-1992-40f5-b89c-11fc3a97ae9f" PhonePublisherId="00000000-0000-0000-0000-000000000000"/>
@@ -1,5 +1,5 @@
<Page <Page
x:Class="GUTSchedule.UWP.AboutPage" x:Class="GUTSchedule.UWP.Pages.AboutPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
@@ -1,20 +1,18 @@
using Microsoft.Services.Store.Engagement; using Microsoft.Services.Store.Engagement;
using Newtonsoft.Json;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Net.Http; using System.Net.Http;
using Windows.ApplicationModel; using Windows.ApplicationModel;
using Windows.ApplicationModel.Resources; using Windows.Data.Json;
using Windows.System; using Windows.System;
using Windows.UI.Xaml; using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Documents; using Windows.UI.Xaml.Documents;
namespace GUTSchedule.UWP namespace GUTSchedule.UWP.Pages
{ {
public sealed partial class AboutPage : Page public sealed partial class AboutPage : Page
{ {
private readonly ResourceLoader resources = ResourceLoader.GetForCurrentView();
public AboutPage() public AboutPage()
{ {
InitializeComponent(); InitializeComponent();
@@ -39,11 +37,11 @@ namespace GUTSchedule.UWP
HttpResponseMessage response = await client.SendAsync(request); HttpResponseMessage response = await client.SendAsync(request);
string resposeContent = await response.Content.ReadAsStringAsync(); string resposeContent = await response.Content.ReadAsStringAsync();
dynamic parsedResponse = JsonConvert.DeserializeObject(resposeContent); JsonObject parsedResponse = JsonObject.Parse(resposeContent);
foreach (var i in parsedResponse) foreach (var i in parsedResponse)
if (i.type == "User" && ((string)i.login).ToLower() != "xfox111") if (i.Value.GetObject()["type"].GetString() == "User" && i.Value.GetObject()["login"].GetString().ToLower() != "xfox111")
contributorsList.Add((string)i.login); contributorsList.Add(i.Value.GetObject()["login"].GetString());
request.Dispose(); request.Dispose();
client.Dispose(); client.Dispose();
@@ -1,5 +1,5 @@
<Page <Page
x:Class="GUTSchedule.UWP.MainPage" x:Class="GUTSchedule.UWP.Pages.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
@@ -1,4 +1,5 @@
using GUTSchedule.Models; using GUTSchedule.Models;
using GUTSchedule.UWP.Controls;
using System; using System;
using Windows.Security.Credentials; using Windows.Security.Credentials;
using Windows.System; using Windows.System;
@@ -15,7 +16,7 @@ using Microsoft.Services.Store.Engagement;
using Windows.ApplicationModel; using Windows.ApplicationModel;
using Windows.ApplicationModel.Core; using Windows.ApplicationModel.Core;
namespace GUTSchedule.UWP namespace GUTSchedule.UWP.Pages
{ {
public sealed partial class MainPage : Page public sealed partial class MainPage : Page
{ {
@@ -277,7 +278,3 @@ namespace GUTSchedule.UWP
} }
} }
} }
// TODO: Reminder prefs broken
// TODO: Calendar prefs broken
// TODO: Faculty prefs broken
@@ -1,16 +1,15 @@
using System.Reflection; using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following // General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information // set of attributes. Change these attribute values to modify the information
// associated with an assembly. // associated with an assembly.
[assembly: AssemblyTitle("GUT.Schedule.UWP")] [assembly: AssemblyTitle("GUT.Schedule")]
[assembly: AssemblyDescription("")] [assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")] [assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")] [assembly: AssemblyCompany("Michael \"XFox\" Gordeev")]
[assembly: AssemblyProduct("GUT.Schedule.UWP")] [assembly: AssemblyProduct("GUT.Schedule")]
[assembly: AssemblyCopyright("Copyright © 2020")] [assembly: AssemblyCopyright("Copyright ©2020 Michael \"XFox\" Gordeev")]
[assembly: AssemblyTrademark("")] [assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")] [assembly: AssemblyCulture("")]
@@ -1,31 +1,5 @@
<!--
This file contains Runtime Directives used by .NET Native. The defaults here are suitable for most
developers. However, you can modify these parameters to modify the behavior of the .NET Native
optimizer.
Runtime Directives are documented at https://go.microsoft.com/fwlink/?LinkID=391919
To fully enable reflection for App1.MyClass and all of its public/private members
<Type Name="App1.MyClass" Dynamic="Required All"/>
To enable dynamic creation of the specific instantiation of AppClass<T> over System.Int32
<TypeInstantiation Name="App1.AppClass" Arguments="System.Int32" Activate="Required Public" />
Using the Namespace directive to apply reflection policy to all the types in a particular namespace
<Namespace Name="DataClasses.ViewModels" Serialize="All" />
-->
<Directives xmlns="http://schemas.microsoft.com/netfx/2013/01/metadata"> <Directives xmlns="http://schemas.microsoft.com/netfx/2013/01/metadata">
<Application> <Application>
<!--
An Assembly element with Name="*Application*" applies to all assemblies in
the application package. The asterisks are not wildcards.
-->
<Assembly Name="*Application*" Dynamic="Required All" /> <Assembly Name="*Application*" Dynamic="Required All" />
<!-- Add your application specific runtime directives here. -->
</Application> </Application>
</Directives> </Directives>