aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--EventMaker/EventMaker/Model/EventCatalogSingleton.cs105
-rw-r--r--EventMaker/EventMaker/Package.appxmanifest2
-rw-r--r--EventMaker/EventMaker/ViewModel/EventViewModel.cs8
3 files changed, 110 insertions, 5 deletions
diff --git a/EventMaker/EventMaker/Model/EventCatalogSingleton.cs b/EventMaker/EventMaker/Model/EventCatalogSingleton.cs
index df5d30c..26a5d90 100644
--- a/EventMaker/EventMaker/Model/EventCatalogSingleton.cs
+++ b/EventMaker/EventMaker/Model/EventCatalogSingleton.cs
@@ -1,4 +1,8 @@
-using System.Collections.ObjectModel;
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Linq;
+using System.Linq.Expressions;
namespace EventMaker.Model
{
@@ -40,6 +44,105 @@ namespace EventMaker.Model
Events[index] = eventToUpdate;
Persistency.PersistencyService.SaveEventsAsJsonAsync(Events);
}
+
+ public void Sort(string sortValue)
+ {
+ bool sorted;
+ switch (sortValue)
+ {
+ case "date (ascending)":
+ do
+ {
+ sorted = false;
+ for (int i = 0; i < Events.Count - 1; i++)
+ {
+ if (Events[i].DateTime > Events[i + 1].DateTime)
+ {
+ Events.Move(i, i + 1);
+ sorted = true;
+ }
+ }
+ } while (sorted);
+ break;
+ case "date (descending)":
+ do
+ {
+ sorted = false;
+ for (int i = 0; i < Events.Count - 1; i++)
+ {
+ if (Events[i].DateTime < Events[i + 1].DateTime)
+ {
+ Events.Move(i, i + 1);
+ sorted = true;
+ }
+ }
+ } while (sorted);
+ break;
+
+ case "name (ascending)":
+ do
+ {
+ sorted = false;
+ for (int i = 0; i < Events.Count - 1; i++)
+ {
+ if (string.CompareOrdinal(Events[i].Name, Events[i + 1].Name) == 1)
+ {
+ Events.Move(i, i + 1);
+ sorted = true;
+ }
+ }
+ } while (sorted);
+ break;
+
+ case "name (descending)":
+ do
+ {
+ sorted = false;
+ for (int i = 0; i < Events.Count - 1; i++)
+ {
+ if (string.CompareOrdinal(Events[i].Name, Events[i + 1].Name) == -1)
+ {
+ Events.Move(i, i + 1);
+ sorted = true;
+ }
+ }
+ } while (sorted);
+ break;
+
+ case "place (ascending)":
+ do
+ {
+ sorted = false;
+ for (int i = 0; i < Events.Count - 1; i++)
+ {
+ if (string.CompareOrdinal(Events[i].Place, Events[i + 1].Place) == 1)
+ {
+ Events.Move(i, i + 1);
+ sorted = true;
+ }
+ }
+ } while (sorted);
+ break;
+
+ case "place (descending)":
+ do
+ {
+ sorted = false;
+ for (int i = 0; i < Events.Count - 1; i++)
+ {
+ if (string.CompareOrdinal(Events[i].Place, Events[i + 1].Place) == -1)
+ {
+ Events.Move(i, i + 1);
+ sorted = true;
+ }
+ }
+ } while (sorted);
+ break;
+ }
+
+ }
+
+
public ObservableCollection<Event> Events { get; set; }
}
}
diff --git a/EventMaker/EventMaker/Package.appxmanifest b/EventMaker/EventMaker/Package.appxmanifest
index 38122f1..e15f125 100644
--- a/EventMaker/EventMaker/Package.appxmanifest
+++ b/EventMaker/EventMaker/Package.appxmanifest
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Package xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10" xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest" xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10" IgnorableNamespaces="uap mp">
- <Identity Name="MarcinZelent.EventMaker" Publisher="CN=Marcin" Version="1.0.0.0" />
+ <Identity Name="MarcinZelent.EventMaker" Publisher="CN=Marcin" Version="1.2.0.0" />
<mp:PhoneIdentity PhoneProductId="f247422f-81c6-4fd4-82da-72b8ed9681a2" PhonePublisherId="00000000-0000-0000-0000-000000000000" />
<Properties>
<DisplayName>Event Maker</DisplayName>
diff --git a/EventMaker/EventMaker/ViewModel/EventViewModel.cs b/EventMaker/EventMaker/ViewModel/EventViewModel.cs
index 7178ace..b72672b 100644
--- a/EventMaker/EventMaker/ViewModel/EventViewModel.cs
+++ b/EventMaker/EventMaker/ViewModel/EventViewModel.cs
@@ -12,10 +12,10 @@ namespace EventMaker.ViewModel
public class EventViewModel : INotifyPropertyChanged
{
private static Event _eventTemplate = new Event();
- private static string _selectedSortValue = "date added";
+ private static string _selectedSortValue = "date (ascending)";
public EventCatalogSingleton EventCatalogSingleton { get; set; } = EventCatalogSingleton.Instance;
public static int SelectedEventIndex { get; set; }
- public static ObservableCollection<string> SortValues { get; set; } = new ObservableCollection<string>() {"name","date","place","date added"};
+ public static ObservableCollection<string> SortValues { get; set; } = new ObservableCollection<string>() {"date (ascending)","date (descending)"/*, "name (ascending)","name (descending)" ,"place (ascending)", "place (descending)"*/ };
public static DateTimeOffset Date { get; set; } = DateTimeOffset.Now;
public static TimeSpan Time { get; set; }
public ICommand CreateEventCommand { get; set; }
@@ -59,6 +59,7 @@ namespace EventMaker.ViewModel
EventTemplate.DateTime = new DateTime(Date.Year, Date.Month, Date.Day, Time.Hours, Time.Minutes, Time.Seconds);
EventCatalogSingleton.Add(EventTemplate);
CleanTemplate();
+ SortEvents();
}
private void DeleteEvent()
@@ -89,7 +90,8 @@ namespace EventMaker.ViewModel
private void SortEvents()
{
- EventCatalogSingleton.Events.Move(0, 1);
+ EventCatalogSingleton.Sort(SelectedSortValue);
+ OnPropertyChanged(nameof(EventCatalogSingleton));
}
public event PropertyChangedEventHandler PropertyChanged;