| author | Matthieu Totet |
| Mon, 23 Nov 2009 14:46:38 +0100 | |
| changeset 8 | 2482ddb44cb6 |
| parent 0 | 249d70e7b32d |
| child 27 | f292db96b050 |
| permissions | -rw-r--r-- |
| 0 | 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 |
||
11 |
namespace Iri.Modernisation.Controls.View |
|
12 |
{ |
|
|
8
2482ddb44cb6
ClickMenuItem modification : path rotation & image display
Matthieu Totet
parents:
0
diff
changeset
|
13 |
public enum ClickMenuItemOrientation { Up = 90, Down = 126 } |
|
2482ddb44cb6
ClickMenuItem modification : path rotation & image display
Matthieu Totet
parents:
0
diff
changeset
|
14 |
public partial class ClickMenuItem : UserControl |
| 0 | 15 |
{ |
|
8
2482ddb44cb6
ClickMenuItem modification : path rotation & image display
Matthieu Totet
parents:
0
diff
changeset
|
16 |
|
| 0 | 17 |
public ImageSource ImageSource { |
18 |
get { return imgItem.Source; } |
|
19 |
set { imgItem.Source = value; } |
|
20 |
} |
|
|
8
2482ddb44cb6
ClickMenuItem modification : path rotation & image display
Matthieu Totet
parents:
0
diff
changeset
|
21 |
|
|
2482ddb44cb6
ClickMenuItem modification : path rotation & image display
Matthieu Totet
parents:
0
diff
changeset
|
22 |
public ClickMenuItemOrientation Orientation |
|
2482ddb44cb6
ClickMenuItem modification : path rotation & image display
Matthieu Totet
parents:
0
diff
changeset
|
23 |
{ |
|
2482ddb44cb6
ClickMenuItem modification : path rotation & image display
Matthieu Totet
parents:
0
diff
changeset
|
24 |
get { return (ClickMenuItemOrientation)GetValue(OrientationProperty); } |
|
2482ddb44cb6
ClickMenuItem modification : path rotation & image display
Matthieu Totet
parents:
0
diff
changeset
|
25 |
set { |
|
2482ddb44cb6
ClickMenuItem modification : path rotation & image display
Matthieu Totet
parents:
0
diff
changeset
|
26 |
SetValue(OrientationProperty, value); |
|
2482ddb44cb6
ClickMenuItem modification : path rotation & image display
Matthieu Totet
parents:
0
diff
changeset
|
27 |
path78339.RenderTransform = new RotateTransform() {Angle=(double)value }; |
|
2482ddb44cb6
ClickMenuItem modification : path rotation & image display
Matthieu Totet
parents:
0
diff
changeset
|
28 |
} |
|
2482ddb44cb6
ClickMenuItem modification : path rotation & image display
Matthieu Totet
parents:
0
diff
changeset
|
29 |
} |
|
2482ddb44cb6
ClickMenuItem modification : path rotation & image display
Matthieu Totet
parents:
0
diff
changeset
|
30 |
|
|
2482ddb44cb6
ClickMenuItem modification : path rotation & image display
Matthieu Totet
parents:
0
diff
changeset
|
31 |
// Using a DependencyProperty as the backing store for Orientation. This enables animation, styling, binding, etc... |
|
2482ddb44cb6
ClickMenuItem modification : path rotation & image display
Matthieu Totet
parents:
0
diff
changeset
|
32 |
public static readonly DependencyProperty OrientationProperty = |
|
2482ddb44cb6
ClickMenuItem modification : path rotation & image display
Matthieu Totet
parents:
0
diff
changeset
|
33 |
DependencyProperty.Register("Orientation", typeof(ClickMenuItemOrientation), typeof(ClickMenuItem), new PropertyMetadata(ClickMenuItemOrientation.Up)); |
|
2482ddb44cb6
ClickMenuItem modification : path rotation & image display
Matthieu Totet
parents:
0
diff
changeset
|
34 |
|
|
2482ddb44cb6
ClickMenuItem modification : path rotation & image display
Matthieu Totet
parents:
0
diff
changeset
|
35 |
|
|
2482ddb44cb6
ClickMenuItem modification : path rotation & image display
Matthieu Totet
parents:
0
diff
changeset
|
36 |
|
| 0 | 37 |
|
38 |
||
39 |
public String Title { get; set; } |
|
40 |
|
|
41 |
public event EventHandler<ClickMenuItemHooverEventArgs> ClickMenuItemHooverSelected; |
|
42 |
public event EventHandler<ClickMenuItemSelectedEventArgs> ClickMenuItemSelected; |
|
43 |
public ClickMenuItem() |
|
44 |
{ |
|
45 |
// Required to initialize variables |
|
46 |
InitializeComponent(); |
|
47 |
} |
|
48 |
||
49 |
private void MouseEnter(object sender, System.Windows.Input.MouseEventArgs e) |
|
50 |
{ |
|
51 |
OnEnter(); |
|
52 |
|
|
53 |
} |
|
54 |
||
55 |
private void OnEnter() |
|
56 |
{ |
|
57 |
if (ClickMenuItemHooverSelected != null) |
|
58 |
{ |
|
59 |
this.ClickMenuItemHooverSelected(this, new ClickMenuItemHooverEventArgs()); |
|
60 |
} |
|
61 |
} |
|
62 |
||
63 |
|
|
64 |
||
65 |
private void UserControl_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) |
|
66 |
{ |
|
67 |
if (ClickMenuItemSelected != null) |
|
68 |
{ |
|
69 |
this.ClickMenuItemSelected(this, new ClickMenuItemSelectedEventArgs()); |
|
70 |
} |
|
71 |
} |
|
72 |
|
|
73 |
} |
|
74 |
public class ClickMenuItemSelectedEventArgs : EventArgs |
|
75 |
{ |
|
76 |
} |
|
77 |
public class ClickMenuItemHooverEventArgs : EventArgs |
|
78 |
{ |
|
79 |
|
|
80 |
public ClickMenuItemHooverEventArgs() |
|
81 |
{ |
|
82 |
|
|
83 |
} |
|
84 |
||
85 |
|
|
86 |
} |
|
87 |
} |