|
0
|
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 |
{ |
|
30
|
20 |
|
|
0
|
21 |
InitializeComponent(); |
|
|
22 |
} |
|
30
|
23 |
|
|
0
|
24 |
Point tempPoint = new Point(); |
|
|
25 |
|
|
|
26 |
private void LayoutRoot_MouseMove(object sender, MouseEventArgs e) |
|
|
27 |
{ |
|
30
|
28 |
|
|
0
|
29 |
Point p = e.GetPosition(this); |
|
|
30 |
tempPoint.X = 1- (p.X / ActualWidth); |
|
|
31 |
//tempPoint.Y = p.Y / ActualHeight; |
|
|
32 |
tempPoint.Y = 1 - (p.Y / ActualWidth); ; |
|
|
33 |
brushLight.Center = tempPoint; |
|
|
34 |
brushLight.GradientOrigin = tempPoint; |
|
|
35 |
|
|
|
36 |
} |
|
|
37 |
|
|
|
38 |
string _title = String.Empty; |
|
|
39 |
|
|
4
|
40 |
|
|
0
|
41 |
/// <summary> |
|
|
42 |
/// Title of the toolbar item |
|
|
43 |
/// </summary> |
|
4
|
44 |
|
|
|
45 |
public String Title |
|
0
|
46 |
{ |
|
4
|
47 |
get { return (String)GetValue(TitleProperty);} |
|
|
48 |
set { SetValue(TitleProperty, value); _title = value; } |
|
0
|
49 |
} |
|
|
50 |
|
|
4
|
51 |
// Using a DependencyProperty as the backing store for Title. This enables animation, styling, binding, etc... |
|
|
52 |
public static readonly DependencyProperty TitleProperty = |
|
|
53 |
DependencyProperty.Register("Title", typeof(String), typeof(ButtonHeaderControl), null); |
|
|
54 |
|
|
|
55 |
|
|
|
56 |
|
|
|
57 |
|
|
0
|
58 |
|
|
|
59 |
/// <summary> |
|
|
60 |
/// The transition color when we hover over the button |
|
|
61 |
/// </summary> |
|
|
62 |
public Color TransitionColor |
|
|
63 |
{ |
|
|
64 |
get |
|
|
65 |
{ |
|
|
66 |
return transitionColor.Color; |
|
|
67 |
} |
|
|
68 |
set |
|
|
69 |
{ |
|
|
70 |
transitionColor.Color = value; |
|
|
71 |
transitionSubColor.Color = Color.FromArgb(64, value.R, value.G, value.B); |
|
|
72 |
} |
|
|
73 |
} |
|
|
74 |
|
|
|
75 |
/// <summary> |
|
|
76 |
/// The source of the image to display for the control |
|
|
77 |
/// </summary> |
|
|
78 |
public ImageSource ImageSource |
|
|
79 |
{ |
|
|
80 |
get { return imgItem.Source; } |
|
|
81 |
set { imgItem.Source = value; } |
|
|
82 |
} |
|
|
83 |
|
|
|
84 |
private void LayoutRoot_MouseEnter(object sender, MouseEventArgs e) |
|
|
85 |
{ |
|
30
|
86 |
|
|
0
|
87 |
animEnter.Begin(); |
|
|
88 |
} |
|
|
89 |
|
|
|
90 |
private void LayoutRoot_MouseLeave(object sender, MouseEventArgs e) |
|
|
91 |
{ |
|
30
|
92 |
|
|
0
|
93 |
animLeave.Begin(); |
|
|
94 |
|
|
|
95 |
} |
|
|
96 |
|
|
|
97 |
/// <summary> |
|
|
98 |
/// Uri to navigate to when clicked |
|
|
99 |
/// </summary> |
|
|
100 |
public string NavigateUri { get; set; } |
|
|
101 |
|
|
|
102 |
/// <summary> |
|
|
103 |
/// true to open link in new window, false to open link in current window |
|
|
104 |
/// default is false |
|
|
105 |
/// </summary> |
|
|
106 |
public bool OpenInNewWindow { get; set; } |
|
|
107 |
|
|
|
108 |
private void UserControl_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) |
|
|
109 |
{ |
|
|
110 |
if (NavigateUri != null) |
|
|
111 |
{ |
|
|
112 |
if (OpenInNewWindow) |
|
|
113 |
{ |
|
|
114 |
System.Windows.Browser.HtmlPage.Window.Navigate(new Uri(NavigateUri, UriKind.Absolute), "_new"); |
|
|
115 |
} |
|
|
116 |
else |
|
|
117 |
{ |
|
|
118 |
System.Windows.Browser.HtmlPage.Window.Navigate(new Uri(NavigateUri, UriKind.Absolute)); |
|
|
119 |
} |
|
|
120 |
} |
|
|
121 |
|
|
|
122 |
} |
|
|
123 |
} |
|
|
124 |
} |