diff options
author | marcinzelent <marcin@zelent.net> | 2017-02-10 18:04:27 +0100 |
---|---|---|
committer | marcinzelent <marcin@zelent.net> | 2017-02-10 18:04:27 +0100 |
commit | f52930630c37349c6de49b8b1d103ba91c9de384 (patch) | |
tree | 78768d34417c729a10b15432c5bf6da96809766b | |
parent | 1a23ae92dfe4e6589fbc50e56993b8b965e21bcb (diff) |
Fixed bug which caused taking values to new event from previously edited event.
-rw-r--r-- | EventMaker/EventMaker/View/EventPage.xaml | 2 | ||||
-rw-r--r-- | EventMaker/EventMaker/ViewModel/EventViewModel.cs | 16 |
2 files changed, 12 insertions, 6 deletions
diff --git a/EventMaker/EventMaker/View/EventPage.xaml b/EventMaker/EventMaker/View/EventPage.xaml index 7b4166a..a5a5faa 100644 --- a/EventMaker/EventMaker/View/EventPage.xaml +++ b/EventMaker/EventMaker/View/EventPage.xaml @@ -94,7 +94,7 @@ <CommandBar.Content> <Grid/> </CommandBar.Content> - <AppBarButton Icon="Add" Label="Add Event"> + <AppBarButton Icon="Add" Label="Add Event" Command="{Binding CleanTemplateCommand}"> <interactivity:Interaction.Behaviors> <core:EventTriggerBehavior EventName="Click"> <core:NavigateToPageAction TargetPage="EventMaker.View.CreateEventPage"/> diff --git a/EventMaker/EventMaker/ViewModel/EventViewModel.cs b/EventMaker/EventMaker/ViewModel/EventViewModel.cs index d10ea79..77b4b94 100644 --- a/EventMaker/EventMaker/ViewModel/EventViewModel.cs +++ b/EventMaker/EventMaker/ViewModel/EventViewModel.cs @@ -11,7 +11,7 @@ namespace EventMaker.ViewModel public class EventViewModel : INotifyPropertyChanged { private static Event _eventTemplate = new Event(); - public EventCatalogSingleton EventCatalogSingleton { get; set; } + public EventCatalogSingleton EventCatalogSingleton { get; set; } = EventCatalogSingleton.Instance; public static int SelectedEventIndex { get; set; } public static DateTimeOffset Date { get; set; } = DateTimeOffset.Now; public static TimeSpan Time { get; set; } @@ -19,6 +19,7 @@ namespace EventMaker.ViewModel public ICommand DeleteEventCommand { get; set; } public ICommand LoadEventCommand { get; set; } public ICommand UpdateEventCommand { get; set; } + public ICommand CleanTemplateCommand { get; set; } public Event EventTemplate { @@ -32,19 +33,18 @@ namespace EventMaker.ViewModel public EventViewModel() { - EventCatalogSingleton = EventCatalogSingleton.Instance; CreateEventCommand = new RelayCommand(CreateEvent); DeleteEventCommand = new RelayCommand(DeleteEvent); LoadEventCommand = new RelayCommand(LoadEvent); UpdateEventCommand = new RelayCommand(UpdateEvent); + CleanTemplateCommand = new RelayCommand(CleanTemplate); } private void CreateEvent() { EventTemplate.DateTime = new DateTime(Date.Year, Date.Month, Date.Day, Time.Hours, Time.Minutes, Time.Seconds); EventCatalogSingleton.Add(EventTemplate); - EventTemplate=new Event(); - Date=DateTimeOffset.Now; + CleanTemplate(); } private void DeleteEvent() @@ -63,8 +63,14 @@ namespace EventMaker.ViewModel { EventTemplate.DateTime = new DateTime(Date.Year, Date.Month, Date.Day, Time.Hours, Time.Minutes, Time.Seconds); EventCatalogSingleton.Update(SelectedEventIndex,EventTemplate); - EventTemplate=new Event(); + CleanTemplate(); + } + + private void CleanTemplate() + { + EventTemplate = new Event(); Date = DateTimeOffset.Now; + Time = TimeSpan.Zero; } public event PropertyChangedEventHandler PropertyChanged; |