mirror of
https://github.com/clubby789/OWClock.git
synced 2025-12-11 20:15:31 +01:00
Sort new events
This commit is contained in:
parent
0f42436f3e
commit
35da26d4be
@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace Clock
|
||||
{
|
||||
@ -12,6 +13,7 @@ namespace Clock
|
||||
public void AddEvent(float timestamp, string name)
|
||||
{
|
||||
eventList.Add(new TimeEvent(timestamp, name));
|
||||
eventList.Sort(SortTimestamp);
|
||||
Save();
|
||||
}
|
||||
|
||||
@ -23,7 +25,13 @@ namespace Clock
|
||||
public static EventFile LoadSaveFile()
|
||||
{
|
||||
var save = OWClock.Helper.Storage.Load<EventFile>(_fileName);
|
||||
save.eventList.Sort(SortTimestamp);
|
||||
return save ?? new EventFile();
|
||||
}
|
||||
|
||||
private static int SortTimestamp(TimeEvent e1, TimeEvent e2)
|
||||
{
|
||||
return e1.Timestamp.CompareTo(e2.Timestamp);
|
||||
}
|
||||
}
|
||||
}
|
||||
BIN
ClockLib/Release.zip
Normal file
BIN
ClockLib/Release.zip
Normal file
Binary file not shown.
@ -5,11 +5,11 @@
|
||||
"Name": "Loop start"
|
||||
},
|
||||
{
|
||||
"Timestamp": 15.0,
|
||||
"Timestamp": 30.0,
|
||||
"Name": "Event happens"
|
||||
},
|
||||
{
|
||||
"Timestamp": 30.0,
|
||||
"Timestamp": 15.0,
|
||||
"Name": "Another one happens"
|
||||
},
|
||||
{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user