From 0acc90b861f174c5406b35ac8144e91ec58f87a2 Mon Sep 17 00:00:00 2001 From: marcinzelent Date: Mon, 6 Feb 2017 14:03:17 +0100 Subject: Improved UI, done some cleaning. --- EventMaker/EventMaker.sln | 22 +++ EventMaker/EventMaker/App.xaml | 1 - EventMaker/EventMaker/App.xaml.cs | 45 ++++- .../EventMaker/Converter/DateTimeConverter.cs | 4 - EventMaker/EventMaker/EventMaker.csproj | 1 - EventMaker/EventMaker/Handler/EventHandler.cs | 3 +- .../EventMaker/Model/EventCatalogSingleton.cs | 19 +-- .../EventMaker/Persistency/PersistencyService.cs | 20 +-- EventMaker/EventMaker/View/CreateEventPage.xaml | 188 ++++++++++++++++++--- EventMaker/EventMaker/View/CreateEventPage.xaml.cs | 31 +--- EventMaker/EventMaker/View/EventPage.xaml | 24 ++- EventMaker/EventMaker/View/EventPage.xaml.cs | 31 +--- EventMaker/EventMaker/ViewModel/EventViewModel.cs | 28 +-- EventMaker/EventMaker/project.json | 1 + 14 files changed, 265 insertions(+), 153 deletions(-) diff --git a/EventMaker/EventMaker.sln b/EventMaker/EventMaker.sln index b59177a..d08ee73 100644 --- a/EventMaker/EventMaker.sln +++ b/EventMaker/EventMaker.sln @@ -5,16 +5,21 @@ VisualStudioVersion = 14.0.25420.1 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EventMaker", "EventMaker\EventMaker.csproj", "{9E8CD427-C53A-444D-A1EE-946AC995E288}" EndProject +Project("{F088123C-0E9E-452A-89E6-6BA2F21D5CAC}") = "SSD for Feb 14", "\\VBOXSVR\Shared\SSD-for-Feb-14\SSD for Feb 14\SSD for Feb 14\SSD for Feb 14.modelproj", "{C76081FA-571F-4781-9CE4-A60A0470CBE4}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU Debug|ARM = Debug|ARM Debug|x64 = Debug|x64 Debug|x86 = Debug|x86 + Release|Any CPU = Release|Any CPU Release|ARM = Release|ARM Release|x64 = Release|x64 Release|x86 = Release|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution + {9E8CD427-C53A-444D-A1EE-946AC995E288}.Debug|Any CPU.ActiveCfg = Debug|x86 {9E8CD427-C53A-444D-A1EE-946AC995E288}.Debug|ARM.ActiveCfg = Debug|ARM {9E8CD427-C53A-444D-A1EE-946AC995E288}.Debug|ARM.Build.0 = Debug|ARM {9E8CD427-C53A-444D-A1EE-946AC995E288}.Debug|ARM.Deploy.0 = Debug|ARM @@ -24,6 +29,7 @@ Global {9E8CD427-C53A-444D-A1EE-946AC995E288}.Debug|x86.ActiveCfg = Debug|x86 {9E8CD427-C53A-444D-A1EE-946AC995E288}.Debug|x86.Build.0 = Debug|x86 {9E8CD427-C53A-444D-A1EE-946AC995E288}.Debug|x86.Deploy.0 = Debug|x86 + {9E8CD427-C53A-444D-A1EE-946AC995E288}.Release|Any CPU.ActiveCfg = Release|x86 {9E8CD427-C53A-444D-A1EE-946AC995E288}.Release|ARM.ActiveCfg = Release|ARM {9E8CD427-C53A-444D-A1EE-946AC995E288}.Release|ARM.Build.0 = Release|ARM {9E8CD427-C53A-444D-A1EE-946AC995E288}.Release|ARM.Deploy.0 = Release|ARM @@ -33,6 +39,22 @@ Global {9E8CD427-C53A-444D-A1EE-946AC995E288}.Release|x86.ActiveCfg = Release|x86 {9E8CD427-C53A-444D-A1EE-946AC995E288}.Release|x86.Build.0 = Release|x86 {9E8CD427-C53A-444D-A1EE-946AC995E288}.Release|x86.Deploy.0 = Release|x86 + {C76081FA-571F-4781-9CE4-A60A0470CBE4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C76081FA-571F-4781-9CE4-A60A0470CBE4}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C76081FA-571F-4781-9CE4-A60A0470CBE4}.Debug|ARM.ActiveCfg = Debug|Any CPU + {C76081FA-571F-4781-9CE4-A60A0470CBE4}.Debug|ARM.Build.0 = Debug|Any CPU + {C76081FA-571F-4781-9CE4-A60A0470CBE4}.Debug|x64.ActiveCfg = Debug|Any CPU + {C76081FA-571F-4781-9CE4-A60A0470CBE4}.Debug|x64.Build.0 = Debug|Any CPU + {C76081FA-571F-4781-9CE4-A60A0470CBE4}.Debug|x86.ActiveCfg = Debug|Any CPU + {C76081FA-571F-4781-9CE4-A60A0470CBE4}.Debug|x86.Build.0 = Debug|Any CPU + {C76081FA-571F-4781-9CE4-A60A0470CBE4}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C76081FA-571F-4781-9CE4-A60A0470CBE4}.Release|Any CPU.Build.0 = Release|Any CPU + {C76081FA-571F-4781-9CE4-A60A0470CBE4}.Release|ARM.ActiveCfg = Release|Any CPU + {C76081FA-571F-4781-9CE4-A60A0470CBE4}.Release|ARM.Build.0 = Release|Any CPU + {C76081FA-571F-4781-9CE4-A60A0470CBE4}.Release|x64.ActiveCfg = Release|Any CPU + {C76081FA-571F-4781-9CE4-A60A0470CBE4}.Release|x64.Build.0 = Release|Any CPU + {C76081FA-571F-4781-9CE4-A60A0470CBE4}.Release|x86.ActiveCfg = Release|Any CPU + {C76081FA-571F-4781-9CE4-A60A0470CBE4}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/EventMaker/EventMaker/App.xaml b/EventMaker/EventMaker/App.xaml index 14e9c2e..5b48429 100644 --- a/EventMaker/EventMaker/App.xaml +++ b/EventMaker/EventMaker/App.xaml @@ -2,7 +2,6 @@ x:Class="EventMaker.App" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" - xmlns:local="using:EventMaker" RequestedTheme="Light"> diff --git a/EventMaker/EventMaker/App.xaml.cs b/EventMaker/EventMaker/App.xaml.cs index 175a092..70e9070 100644 --- a/EventMaker/EventMaker/App.xaml.cs +++ b/EventMaker/EventMaker/App.xaml.cs @@ -1,6 +1,7 @@ using System; using Windows.ApplicationModel; using Windows.ApplicationModel.Activation; +using Windows.UI.Core; using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Navigation; @@ -10,7 +11,7 @@ namespace EventMaker /// /// Provides application-specific behavior to supplement the default Application class. /// - sealed partial class App : Application + sealed partial class App { /// /// Initializes the singleton application object. This is the first line of authored code @@ -18,8 +19,8 @@ namespace EventMaker /// public App() { - this.InitializeComponent(); - this.Suspending += OnSuspending; + InitializeComponent(); + Suspending += OnSuspending; } /// @@ -32,7 +33,7 @@ namespace EventMaker #if DEBUG if (System.Diagnostics.Debugger.IsAttached) { - this.DebugSettings.EnableFrameRateCounter = true; + DebugSettings.EnableFrameRateCounter = true; } #endif Frame rootFrame = Window.Current.Content as Frame; @@ -45,6 +46,8 @@ namespace EventMaker rootFrame = new Frame(); rootFrame.NavigationFailed += OnNavigationFailed; + rootFrame.Navigated += OnNavigated; + if (e.PreviousExecutionState == ApplicationExecutionState.Terminated) { @@ -53,6 +56,16 @@ namespace EventMaker // Place the frame in the current Window Window.Current.Content = rootFrame; + + // Register a handler for BackRequested events and set the + // visibility of the Back button + SystemNavigationManager.GetForCurrentView().BackRequested += OnBackRequested; + + SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = + rootFrame.CanGoBack ? + AppViewBackButtonVisibility.Visible : + AppViewBackButtonVisibility.Collapsed; + } if (e.PrelaunchActivated == false) @@ -62,7 +75,7 @@ namespace EventMaker // 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(EventPage), e.Arguments); + rootFrame.Navigate(typeof(View.EventPage), e.Arguments); } // Ensure the current window is active Window.Current.Activate(); @@ -79,6 +92,16 @@ namespace EventMaker throw new Exception("Failed to load Page " + e.SourcePageType.FullName); } + private void OnNavigated(object sender, NavigationEventArgs e) + { + // Each time a navigation event occurs, update the Back button's visibility + SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = + ((Frame)sender).CanGoBack ? + AppViewBackButtonVisibility.Visible : + AppViewBackButtonVisibility.Collapsed; + } + + /// /// Invoked when application execution is being suspended. Application state is saved /// without knowing whether the application will be terminated or resumed with the contents @@ -92,5 +115,17 @@ namespace EventMaker //TODO: Save application state and stop any background activity deferral.Complete(); } + + private void OnBackRequested(object sender, BackRequestedEventArgs e) + { + Frame rootFrame = Window.Current.Content as Frame; + + if (rootFrame.CanGoBack) + { + e.Handled = true; + rootFrame.GoBack(); + } + } + } } diff --git a/EventMaker/EventMaker/Converter/DateTimeConverter.cs b/EventMaker/EventMaker/Converter/DateTimeConverter.cs index e6990e0..9ee35ef 100644 --- a/EventMaker/EventMaker/Converter/DateTimeConverter.cs +++ b/EventMaker/EventMaker/Converter/DateTimeConverter.cs @@ -1,8 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace EventMaker.Converter { diff --git a/EventMaker/EventMaker/EventMaker.csproj b/EventMaker/EventMaker/EventMaker.csproj index c69fcc8..422fe79 100644 --- a/EventMaker/EventMaker/EventMaker.csproj +++ b/EventMaker/EventMaker/EventMaker.csproj @@ -142,7 +142,6 @@ MSBuild:Compile - 14.0 diff --git a/EventMaker/EventMaker/Handler/EventHandler.cs b/EventMaker/EventMaker/Handler/EventHandler.cs index 7050bcd..ab1e2a3 100644 --- a/EventMaker/EventMaker/Handler/EventHandler.cs +++ b/EventMaker/EventMaker/Handler/EventHandler.cs @@ -1,5 +1,4 @@ -using EventMaker.Annotations; -using EventMaker.Model; +using EventMaker.Model; using EventMaker.ViewModel; namespace EventMaker.Handler diff --git a/EventMaker/EventMaker/Model/EventCatalogSingleton.cs b/EventMaker/EventMaker/Model/EventCatalogSingleton.cs index feeeea9..ffce7a4 100644 --- a/EventMaker/EventMaker/Model/EventCatalogSingleton.cs +++ b/EventMaker/EventMaker/Model/EventCatalogSingleton.cs @@ -1,26 +1,25 @@ using System.Collections.ObjectModel; -using System; namespace EventMaker.Model { public class EventCatalogSingleton { - private static EventCatalogSingleton instance; - private ObservableCollection _events; + private static EventCatalogSingleton _instance; + private EventCatalogSingleton() { - _events = new ObservableCollection(); + Events = new ObservableCollection(); LoadEventsAsync(); } public static EventCatalogSingleton Instance { get { - if (instance == null) + if (_instance == null) { - instance = new EventCatalogSingleton(); + _instance = new EventCatalogSingleton(); } - return instance; + return _instance; } } public void Add(Event newEvent) @@ -37,10 +36,6 @@ namespace EventMaker.Model Events.Remove(eventToBeRemoved); Persistency.PersistencyService.SaveEventsAsJsonAsync(Events); } - public ObservableCollection Events - { - get { return _events; } - set { _events = value; } - } + public ObservableCollection Events { get; set; } } } diff --git a/EventMaker/EventMaker/Persistency/PersistencyService.cs b/EventMaker/EventMaker/Persistency/PersistencyService.cs index 4c78911..a3b7808 100644 --- a/EventMaker/EventMaker/Persistency/PersistencyService.cs +++ b/EventMaker/EventMaker/Persistency/PersistencyService.cs @@ -1,39 +1,33 @@ using EventMaker.Model; using Newtonsoft.Json; using System; -using System.Collections.Generic; using System.Collections.ObjectModel; using System.IO; -using System.Linq; -using System.Text; using System.Threading.Tasks; using Windows.Storage; -using Windows.Storage.Pickers; -using Windows.Storage.Streams; -using Windows.UI.Xaml.Controls; namespace EventMaker.Persistency { class PersistencyService { - private static StorageFolder localFolder = ApplicationData.Current.LocalFolder; - private static StorageFile eventsFile; + private static readonly StorageFolder LocalFolder = ApplicationData.Current.LocalFolder; + private static StorageFile _eventsFile; public static async void SaveEventsAsJsonAsync(ObservableCollection events) { - eventsFile = await localFolder.CreateFileAsync("events.json",CreationCollisionOption.OpenIfExists); - File.WriteAllText(eventsFile.Path, JsonConvert.SerializeObject(events)); + _eventsFile = await LocalFolder.CreateFileAsync("events.json",CreationCollisionOption.OpenIfExists); + File.WriteAllText(_eventsFile.Path, JsonConvert.SerializeObject(events)); } public static async Task> LoadEventsFromJsonAsync() { try { - eventsFile = await localFolder.GetFileAsync("events.json"); + _eventsFile = await LocalFolder.GetFileAsync("events.json"); } catch(FileNotFoundException) { - eventsFile = await localFolder.CreateFileAsync("events.json", CreationCollisionOption.OpenIfExists); + _eventsFile = await LocalFolder.CreateFileAsync("events.json", CreationCollisionOption.OpenIfExists); } - return JsonConvert.DeserializeObject>(File.ReadAllText(eventsFile.Path)); + return JsonConvert.DeserializeObject>(File.ReadAllText(_eventsFile.Path)); } } diff --git a/EventMaker/EventMaker/View/CreateEventPage.xaml b/EventMaker/EventMaker/View/CreateEventPage.xaml index 9cd3cef..a4e453e 100644 --- a/EventMaker/EventMaker/View/CreateEventPage.xaml +++ b/EventMaker/EventMaker/View/CreateEventPage.xaml @@ -1,45 +1,177 @@  - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - + + +