aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/FSE/Modules/Tango.FSE.Diagnostics/Controls/DiagnosticsGrid.cs
blob: 45b6d9a36c61ae0242bd61a453e1f12006d13a5e (plain)
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using Tango.FSE.Diagnostics.Project;

namespace Tango.FSE.Diagnostics.Controls
{
    public class DiagnosticsGrid : Grid
    {
        public List<DiagnosticsProjectTabColumnDefinition> Columns
        {
            get { return (List<DiagnosticsProjectTabColumnDefinition>)GetValue(ColumnsProperty); }
            set { SetValue(ColumnsProperty, value); }
        }
        public static readonly DependencyProperty ColumnsProperty =
            DependencyProperty.Register("Columns", typeof(List<DiagnosticsProjectTabColumnDefinition>), typeof(DiagnosticsGrid), new PropertyMetadata(null, (d, e) => (d as DiagnosticsGrid).LoadDefinitions()));

        public List<DiagnosticsProjectTabRowDefinition> Rows
        {
            get { return (List<DiagnosticsProjectTabRowDefinition>)GetValue(RowsProperty); }
            set { SetValue(RowsProperty, value); }
        }
        public static readonly DependencyProperty RowsProperty =
            DependencyProperty.Register("Rows", typeof(List<DiagnosticsProjectTabRowDefinition>), typeof(DiagnosticsGrid), new PropertyMetadata(null, (d, e) => (d as DiagnosticsGrid).LoadDefinitions()));

        private void LoadDefinitions()
        {
            if (Rows != null && Columns != null)
            {
                ColumnDefinitions.Clear();
                RowDefinitions.Clear();

                foreach (var column in Columns)
                {
                    ColumnDefinitions.Add(new ColumnDefinition() { Width = column.Width });
                }

                foreach (var row in Rows)
                {
                    RowDefinitions.Add(new RowDefinition() { Height = row.Height });
                }
            }
        }
    }
}