|
16
|
1 |
using System; |
|
|
2 |
using System.Windows; |
|
|
3 |
using System.Windows.Controls; |
|
|
4 |
using System.Windows.Documents; |
|
|
5 |
using System.Windows.Ink; |
|
|
6 |
using System.Windows.Input; |
|
|
7 |
using System.Windows.Media; |
|
|
8 |
using System.Windows.Media.Animation; |
|
|
9 |
using System.Windows.Shapes; |
|
|
10 |
using System.Windows.Data; |
|
|
11 |
namespace Iri.Modernisation.Controls.View |
|
|
12 |
{ |
|
|
13 |
public partial class HeaderProductionPartControler : UserControl |
|
|
14 |
{ |
|
|
15 |
|
|
27
|
16 |
public bool HighLighted |
|
|
17 |
{ |
|
|
18 |
get { return (bool)GetValue(HighLightProperty); } |
|
|
19 |
set { |
|
|
20 |
|
|
|
21 |
SetValue(HighLightProperty, value); |
|
|
22 |
} |
|
|
23 |
} |
|
16
|
24 |
|
|
27
|
25 |
// Using a DependencyProperty as the backing store for HighLight. This enables animation, styling, binding, etc... |
|
|
26 |
public static readonly DependencyProperty HighLightProperty = |
|
|
27 |
DependencyProperty.Register("HighLighted", typeof(bool), typeof(HeaderProductionPartControler), new PropertyMetadata(new PropertyChangedCallback(HighLightChange))); |
|
|
28 |
private static void HighLightChange(DependencyObject sender, DependencyPropertyChangedEventArgs e) |
|
16
|
29 |
{ |
|
27
|
30 |
|
|
|
31 |
if((bool)e.NewValue) |
|
|
32 |
{ |
|
|
33 |
((HeaderProductionPartControler)sender).Select(); |
|
|
34 |
} |
|
|
35 |
else |
|
|
36 |
{ |
|
|
37 |
((HeaderProductionPartControler)sender).UnSelect(); |
|
|
38 |
} |
|
|
39 |
} |
|
|
40 |
public bool Active |
|
|
41 |
{ |
|
|
42 |
get { return (bool)GetValue(ActiveProperty); } |
|
16
|
43 |
set |
|
|
44 |
{ |
|
|
45 |
|
|
27
|
46 |
|
|
|
47 |
SetValue(ActiveProperty, value); |
|
16
|
48 |
if (value) |
|
|
49 |
{ |
|
27
|
50 |
Activate(); |
|
|
51 |
if (HighLighted) |
|
|
52 |
{ |
|
|
53 |
Select(); |
|
|
54 |
} |
|
16
|
55 |
} |
|
|
56 |
else |
|
|
57 |
{ |
|
|
58 |
} |
|
|
59 |
} |
|
|
60 |
} |
|
|
61 |
|
|
|
62 |
// Using a DependencyProperty as the backing store for IsActive. This enables animation, styling, binding, etc... |
|
27
|
63 |
public static readonly DependencyProperty ActiveProperty = |
|
|
64 |
DependencyProperty.Register("Active", typeof(bool), typeof(HeaderProductionPartControler), new PropertyMetadata(new PropertyChangedCallback(ItemsSourceChanged))); |
|
|
65 |
private static void ItemsSourceChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) |
|
|
66 |
{ |
|
|
67 |
|
|
|
68 |
((HeaderProductionPartControler)sender).Active =(bool)e.NewValue; |
|
|
69 |
} |
|
|
70 |
|
|
16
|
71 |
|
|
|
72 |
|
|
|
73 |
|
|
|
74 |
public String Text |
|
|
75 |
{ |
|
|
76 |
get { return (String)GetValue(TextProperty); } |
|
|
77 |
set |
|
|
78 |
{ SetValue(TextProperty, value); |
|
|
79 |
textBlock.Text = value; |
|
|
80 |
} |
|
|
81 |
} |
|
|
82 |
|
|
|
83 |
// Using a DependencyProperty as the backing store for Text. This enables animation, styling, binding, etc... |
|
|
84 |
public static readonly DependencyProperty TextProperty = |
|
|
85 |
DependencyProperty.Register("Text", typeof(String), typeof(HeaderProductionPartControler), new PropertyMetadata("")); |
|
|
86 |
|
|
|
87 |
|
|
|
88 |
|
|
|
89 |
public HeaderProductionPartControler() |
|
|
90 |
{ |
|
|
91 |
// Required to initialize variables |
|
|
92 |
InitializeComponent(); |
|
27
|
93 |
|
|
16
|
94 |
_activated = false; |
|
|
95 |
_finished= false; |
|
|
96 |
|
|
|
97 |
|
|
|
98 |
|
|
|
99 |
|
|
|
100 |
} |
|
|
101 |
|
|
|
102 |
private bool _activated; |
|
|
103 |
private bool _finished; |
|
|
104 |
|
|
27
|
105 |
public void Activate() |
|
16
|
106 |
{ |
|
|
107 |
if(!_activated && !_finished) |
|
|
108 |
{ |
|
|
109 |
VisualStateManager.GoToState(this,"Available",true); |
|
|
110 |
_activated=true; |
|
|
111 |
} |
|
|
112 |
|
|
|
113 |
} |
|
|
114 |
|
|
|
115 |
public void UnSelect() |
|
|
116 |
{ |
|
27
|
117 |
if (_activated && !_finished) |
|
|
118 |
{ |
|
|
119 |
VisualStateManager.GoToState(this, "Available", true); |
|
|
120 |
} |
|
16
|
121 |
} |
|
|
122 |
private void Button_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e) |
|
|
123 |
{ |
|
|
124 |
|
|
|
125 |
|
|
|
126 |
} |
|
|
127 |
|
|
|
128 |
private void but_Click(object sender, System.Windows.RoutedEventArgs e) |
|
|
129 |
{ |
|
|
130 |
|
|
|
131 |
if(_activated) |
|
|
132 |
{ |
|
38
|
133 |
Clicked(this, new EventArgs()); |
|
|
134 |
|
|
|
135 |
|
|
16
|
136 |
} |
|
|
137 |
} |
|
38
|
138 |
public void Finish() |
|
|
139 |
{ |
|
|
140 |
VisualStateManager.GoToState(this,"Finished",true); |
|
|
141 |
if (HeaderProductionPartFinished!=null) |
|
|
142 |
{ |
|
|
143 |
HeaderProductionPartFinished(this, new HeaderProductionPartControlerEventArgs(this)); |
|
|
144 |
} |
|
|
145 |
_finished = true; |
|
|
146 |
} |
|
|
147 |
public event EventHandler Clicked; |
|
16
|
148 |
public void Select() |
|
|
149 |
{ |
|
|
150 |
if (_activated && !_finished) |
|
|
151 |
{ |
|
|
152 |
VisualStateManager.GoToState(this, "Selected", true); |
|
|
153 |
} |
|
|
154 |
} |
|
|
155 |
private void textBlock_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e) |
|
|
156 |
{ |
|
|
157 |
if (_activated && !_finished) |
|
|
158 |
{ |
|
|
159 |
if (HeaderProductionPartSelected != null) |
|
|
160 |
HeaderProductionPartSelected(this, new HeaderProductionPartControlerEventArgs(this)); |
|
|
161 |
} |
|
|
162 |
} |
|
|
163 |
public event EventHandler<HeaderProductionPartControlerEventArgs> HeaderProductionPartFinished; |
|
|
164 |
public event EventHandler<HeaderProductionPartControlerEventArgs> HeaderProductionPartSelected; |
|
|
165 |
} |
|
|
166 |
|
|
|
167 |
public class HeaderProductionPartControlerEventArgs : EventArgs |
|
|
168 |
{ |
|
|
169 |
public object sender { get; set; } |
|
|
170 |
public HeaderProductionPartControlerEventArgs(object psender) |
|
|
171 |
{ |
|
|
172 |
sender = psender; |
|
|
173 |
} |
|
|
174 |
|
|
|
175 |
} |
|
|
176 |
} |