forked from PKRoma/LinqSudokuSolver
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Marker.cs
39 lines (36 loc) · 1.21 KB
/
Marker.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
using System.Windows.Controls;
using System.Windows.Markup;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
namespace SilverlightSudokuHelper
{
internal class Marker : UserControl
{
private Canvas _root;
private Rectangle _background;
private Rectangle _border;
private Storyboard _pulse;
public Marker(string resourceName)
{
// Initialize from XAML and get references to child elements
_root = XamlReader.Load(Utility.GetXamlResource(resourceName)) as Canvas;
_background = _root.FindName("Background") as Rectangle;
_border = _root.FindName("Border") as Rectangle;
_pulse = _root.FindName("Pulse") as Storyboard; // May fail
Content = _root;
}
public void Layout()
{
// Update the child element dimensions according to the parent
_background.Width = Width;
_background.Height = Height;
_border.Width = Width;
_border.Height = Height;
if (null != _pulse)
{
// Play the pulse animation if present
_pulse.Begin();
}
}
}
}