-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathImmitationService.cs
53 lines (47 loc) · 1.3 KB
/
ImmitationService.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading;
using System.Timers;
using ReactiveUI;
using Timer = System.Timers.Timer;
namespace Airports
{
public class ImmitationServiceViewModel : ReactiveObject
{
private DateTime _time;
private TimeSpan TimeToAdd;
private Timer timer;
public DateTime Time
{
get => _time;
private set => this.RaiseAndSetIfChanged(ref _time, value);
}
public ImmitationServiceViewModel(DateTime time, ImmitationSpeed settingsSpeed)
{
Time = time;
var t = (int)settingsSpeed;
TimeToAdd = TimeSpan.FromSeconds(Convert.ToDouble(t));
timer = new Timer(1000);
timer.Elapsed += AddTime;
}
private void AddTime(object sender, ElapsedEventArgs e)
{
Time = Time + TimeToAdd;
}
public void Start()
{
timer.Start();
}
public void Stop()
{
timer.Stop();
}
public void Update(ImmitationSpeed immitationSpeed)
{
var t = (int)immitationSpeed;
TimeToAdd = TimeSpan.FromSeconds(Convert.ToDouble(t));
}
}
}