|
1 using System; |
|
2 using System.Collections.Generic; |
|
3 using System.Linq; |
|
4 using System.Net; |
|
5 using System.Windows; |
|
6 using System.Windows.Controls; |
|
7 using System.Windows.Documents; |
|
8 using System.Windows.Input; |
|
9 using System.Windows.Media; |
|
10 using System.Windows.Media.Animation; |
|
11 using System.Windows.Shapes; |
|
12 |
|
13 namespace Iri.Modernisation.Controls.View |
|
14 { |
|
15 |
|
16 public partial class ButtonHeaderControl : UserControl |
|
17 { |
|
18 public ButtonHeaderControl() |
|
19 { |
|
20 InitializeComponent(); |
|
21 } |
|
22 private bool _isMouseInside = false; |
|
23 Point tempPoint = new Point(); |
|
24 |
|
25 private void LayoutRoot_MouseMove(object sender, MouseEventArgs e) |
|
26 { |
|
27 _isMouseInside = true; |
|
28 Point p = e.GetPosition(this); |
|
29 tempPoint.X = 1- (p.X / ActualWidth); |
|
30 //tempPoint.Y = p.Y / ActualHeight; |
|
31 tempPoint.Y = 1 - (p.Y / ActualWidth); ; |
|
32 brushLight.Center = tempPoint; |
|
33 brushLight.GradientOrigin = tempPoint; |
|
34 |
|
35 } |
|
36 |
|
37 string _title = String.Empty; |
|
38 |
|
39 /// <summary> |
|
40 /// Title of the toolbar item |
|
41 /// </summary> |
|
42 public string Title |
|
43 { |
|
44 get { return _title; } |
|
45 set { _title = value; } |
|
46 } |
|
47 |
|
48 |
|
49 /// <summary> |
|
50 /// The transition color when we hover over the button |
|
51 /// </summary> |
|
52 public Color TransitionColor |
|
53 { |
|
54 get |
|
55 { |
|
56 return transitionColor.Color; |
|
57 } |
|
58 set |
|
59 { |
|
60 transitionColor.Color = value; |
|
61 transitionSubColor.Color = Color.FromArgb(64, value.R, value.G, value.B); |
|
62 } |
|
63 } |
|
64 |
|
65 /// <summary> |
|
66 /// The source of the image to display for the control |
|
67 /// </summary> |
|
68 public ImageSource ImageSource |
|
69 { |
|
70 get { return imgItem.Source; } |
|
71 set { imgItem.Source = value; } |
|
72 } |
|
73 |
|
74 private void LayoutRoot_MouseEnter(object sender, MouseEventArgs e) |
|
75 { |
|
76 _isMouseInside = true; |
|
77 animEnter.Begin(); |
|
78 } |
|
79 |
|
80 private void LayoutRoot_MouseLeave(object sender, MouseEventArgs e) |
|
81 { |
|
82 _isMouseInside = false; |
|
83 animLeave.Begin(); |
|
84 |
|
85 } |
|
86 |
|
87 /// <summary> |
|
88 /// Uri to navigate to when clicked |
|
89 /// </summary> |
|
90 public string NavigateUri { get; set; } |
|
91 |
|
92 /// <summary> |
|
93 /// true to open link in new window, false to open link in current window |
|
94 /// default is false |
|
95 /// </summary> |
|
96 public bool OpenInNewWindow { get; set; } |
|
97 |
|
98 private void UserControl_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) |
|
99 { |
|
100 if (NavigateUri != null) |
|
101 { |
|
102 if (OpenInNewWindow) |
|
103 { |
|
104 System.Windows.Browser.HtmlPage.Window.Navigate(new Uri(NavigateUri, UriKind.Absolute), "_new"); |
|
105 } |
|
106 else |
|
107 { |
|
108 System.Windows.Browser.HtmlPage.Window.Navigate(new Uri(NavigateUri, UriKind.Absolute)); |
|
109 } |
|
110 } |
|
111 |
|
112 } |
|
113 } |
|
114 } |