forked from PKRoma/LinqSudokuSolver
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Utility.cs
29 lines (27 loc) · 1020 Bytes
/
Utility.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
using System;
using System.IO;
using System.Reflection;
using System.Windows.Controls;
namespace SilverlightSudokuHelper
{
internal static class Utility
{
public static string GetXamlResource(string resourceName)
{
// Load XAML from an embedded resource by name
using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceName))
{
using (var reader = new StreamReader(stream))
{
return reader.ReadToEnd();
}
}
}
public static void CenterTextBlock(TextBlock textBlock, double left, double top, double width, double height)
{
// Center a TextBlock within the provided bounds
textBlock.SetValue(Canvas.LeftProperty, Math.Round(left + ((width - textBlock.ActualWidth) / 2)));
textBlock.SetValue(Canvas.TopProperty, Math.Round(top + ((height - textBlock.ActualHeight) / 2)));
}
}
}