-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMainWindow.xaml.cs
94 lines (75 loc) · 3.02 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
using Syncfusion.Windows.Controls.Cells;
using Syncfusion.Windows.Controls.Grid;
using Syncfusion.Windows.Controls.Scroll;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace WpfApplication1
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
configureGrid();
}
// Help Functions
private void configureGrid()
{
// Setting the number of rows and columns.
grid.Model.RowCount = 10;
grid.Model.ColumnCount = 10;
// Setting the width and height of the cells.
grid.Model.RowHeights.DefaultLineSize = 50;
grid.Model.ColumnWidths.DefaultLineSize = 50;
// Configuring headers
configureHeaders();
grid.SizeChanged += grid_SizeChanged;
grid.Model.QueryCellInfo += Model_QueryCellInfo;
}
void grid_SizeChanged(object sender, SizeChangedEventArgs e)
{
double width = (e.NewSize.Width - grid.Model.ColumnWidths.DefaultLineSize - 1) / (grid.Model.ColumnCount - 1);
double height = (e.NewSize.Height - grid.Model.RowHeights.DefaultLineSize - 1) / (grid.Model.RowCount - 1);
for (int i = 1; i < grid.Model.ColumnCount; ++i)
grid.Model.ColumnWidths[i] = width;
for (int j = 1; j < grid.Model.RowCount; ++j)
grid.Model.RowHeights[j] = height;
}
void Model_QueryCellInfo(object sender, Syncfusion.Windows.Controls.Grid.GridQueryCellInfoEventArgs e)
{
if (e.Cell.RowIndex == 0 && e.Cell.ColumnIndex > 0)
{
e.Style.Text = GridRangeInfo.GetAlphaLabel(e.Cell.ColumnIndex);
e.Style.HorizontalAlignment = HorizontalAlignment.Center;
e.Style.VerticalAlignment = VerticalAlignment.Center;
}
else if (e.Cell.RowIndex > 0 && e.Cell.ColumnIndex == 0)
{
e.Style.Text = e.Cell.RowIndex.ToString();
e.Style.HorizontalAlignment = HorizontalAlignment.Center;
e.Style.VerticalAlignment = VerticalAlignment.Center;
}
}
private void configureHeaders()
{
grid.Model.RowHeights[0] = 25;
grid.Model.ColumnWidths[0] = 25;
grid.Model.HeaderStyle.Background = new SolidColorBrush(Colors.NavajoWhite);
}
}
}