-
Notifications
You must be signed in to change notification settings - Fork 12
/
MainWindow.xaml.cs
57 lines (47 loc) · 1.08 KB
/
MainWindow.xaml.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
using System;
using System.Windows;
namespace WPFHeatMap
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
cbColors.SelectedIndex = 0;
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{
RenderContent();
}
private void Grid_SizeChanged(object sender, SizeChangedEventArgs e)
{
RenderContent();
}
/// <summary>
/// Renders random heat map
/// </summary>
private void RenderContent()
{
cHeatMap.Clear();
Random rRand = new Random();
// Loop variables
int x;
int y;
byte intense;
// Lets loop few times and create a random point each iteration
for (int i = 0; i < 1000; i++)
{
// Pick random locations and intensity
x = rRand.Next(0, (int)(cHeatMap.ActualWidth - 1));
y = rRand.Next(0, (int)(cHeatMap.ActualHeight - 1));
intense = (byte)rRand.Next(0, 255);
// Add heat point to heat points list
cHeatMap.AddHeatPoint(new HeatPoint(x, y, intense));
}
cHeatMap.Render();
}
}
}