-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMainViewModel.cs
74 lines (67 loc) · 2.13 KB
/
MainViewModel.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
using System.Windows.Media.Imaging;
using System.Collections.Generic;
using System.ComponentModel;
namespace PolygonEditor
{
public enum States
{
PolygonAdd, Edit,
OrthogonalOne, OrthogonalTwo
}
public class MainViewModel : INotifyPropertyChanged
{
private WriteableBitmap _polygonBitmap;
public WriteableBitmap PolygonBitmap
{
get { return _polygonBitmap; }
set { SetField(ref _polygonBitmap, value, "PolygonBitmap"); }
}
string _state;
public string ActualState
{
get { return _state; }
set { SetField(ref _state, value, "ActualState"); }
}
States _st;
public States state
{
get { return _st; }
set
{
_st = value;
switch (value)
{
case States.Edit:
ActualState = "Tryb Edycji";
break;
case States.PolygonAdd:
ActualState = "Tryb dodawania wielokąta";
break;
case States.OrthogonalOne:
case States.OrthogonalTwo:
ActualState = "Tryb krawędzi prostopadłych\n Wybierz dwie krawędzie.";
break;
}
}
}
public MainViewModel()
{
ActualState = "Dodaj pierwszy wielokąt";
}
#region Property Changed
public event PropertyChangedEventHandler PropertyChanged;
protected virtual void OnPropertyChanged(string propertyName)
{
PropertyChangedEventHandler handler = PropertyChanged;
if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
}
protected bool SetField<T>(ref T field, T value, string propertyName)
{
if (EqualityComparer<T>.Default.Equals(field, value)) return false;
field = value;
OnPropertyChanged(propertyName);
return true;
}
#endregion
}
}