aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Controls/TableGrid.cs
blob: 07fd0c4464b880824ee3f3eddf60df0ffffd561f (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
50
51
52
53
54
55
56
57
58
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;

namespace Tango.MachineStudio.Common.Controls
{
    public class TableGrid : Grid
    {
        public TableGrid()
        {
            ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Auto) });
            ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Star) });
            this.Loaded += TableGrid_Loaded;
        }

        private void TableGrid_Loaded(object sender, RoutedEventArgs e)
        {
            InvalidateGrid();
        }

        protected override void OnVisualChildrenChanged(DependencyObject visualAdded, DependencyObject visualRemoved)
        {
            base.OnVisualChildrenChanged(visualAdded, visualRemoved);
        }

        protected override Size ArrangeOverride(Size arrangeSize)
        {
            return base.ArrangeOverride(arrangeSize);
        }

        private void InvalidateGrid()
        {
            RowDefinitions.Clear();
            RowDefinitions.Add(new RowDefinition() { Height = new GridLength(50, GridUnitType.Pixel) });

            int currentRow = 0;

            for (int i = 0; i < Children.Count; i++)
            {
                SetRow(Children[i], currentRow);

                if (i % 2 != 0)
                {
                    SetColumn(Children[i], 1);
                    (Children[i] as FrameworkElement).Margin = new Thickness(20, 0, 0, 0);
                    currentRow++;
                    RowDefinitions.Add(new RowDefinition() { Height = new GridLength(50, GridUnitType.Pixel) });
                }

                (Children[i] as FrameworkElement).VerticalAlignment = VerticalAlignment.Bottom;
            }
        }
    }
}
<Word>HACK</Word> <Word>UNDONE</Word> </Keywords> </RuleSet> <!-- This is the main ruleset. --> <RuleSet> <Span color="Preprocessor"> <Begin>\#</Begin> <RuleSet name="PreprocessorSet"> <Span> <!-- preprocessor directives that allows comments --> <Begin fontWeight="bold"> (define|undef|if|elif|else|endif|line)\b </Begin> <RuleSet> <Span color="Comment" ruleSet="CommentMarkerSet"> <Begin>//</Begin> </Span> </RuleSet> </Span> <Span> <!-- preprocessor directives that don't allow comments --> <Begin fontWeight="bold"> (region|endregion|error|warning|pragma)\b </Begin> </Span> </RuleSet> </Span> <Span color="Comment"> <Begin color="XmlDoc/DocComment">///</Begin> <RuleSet> <Import ruleSet="XmlDoc/DocCommentSet"/> <Import ruleSet="CommentMarkerSet"/> </RuleSet> </Span> <Span color="Comment" ruleSet="CommentMarkerSet"> <Begin>//</Begin> </Span> <Span color="Comment" ruleSet="CommentMarkerSet" multiline="true"> <Begin>/\*</Begin> <End>\*/</End> </Span> <Span color="String"> <Begin>"</Begin> <End>"</End> <RuleSet> <!-- span for escape sequences --> <Span begin="\\" end="."/> </RuleSet> </Span> <Span color="Char"> <Begin>'</Begin> <End>'</End> <RuleSet> <!-- span for escape sequences --> <Span begin="\\" end="."/> </RuleSet> </Span> <Span color="String" multiline="true"> <Begin>@"</Begin> <End>"</End> <RuleSet> <!-- span for escape sequences --> <Span begin='""' end=""/> </RuleSet> </Span> <!-- don't highlight "@int" as keyword --> <Rule> @[\w\d_]+ </Rule> <Keywords color="CustomTypes"> @CUSTOM_TYPES@ </Keywords> <Keywords color="ThisOrBaseReference"> <Word>this</Word> <Word>base</Word> </Keywords> <Keywords color="TypeKeywords"> <Word>as</Word> <Word>is</Word> <Word>new</Word> <Word>sizeof</Word> <Word>typeof</Word> <Word>stackalloc</Word> </Keywords> <Keywords color="TrueFalse"> <Word>true</Word> <Word>false</Word> </Keywords> <Keywords color="Keywords"> <Word>else</Word> <Word>if</Word> <Word>switch</Word> <Word>case</Word> <Word>default</Word> <Word>do</Word> <Word>for</Word> <Word>foreach</Word> <Word>in</Word> <Word>while</Word> <Word>lock</Word> </Keywords> <Keywords color="GotoKeywords"> <Word>break</Word> <Word>continue</Word> <Word>goto</Word> <Word>return</Word> </Keywords> <Keywords color="ContextKeywords"> <Word>yield</Word> <Word>partial</Word> <Word>global</Word> <Word>where</Word> <Word>select</Word> <Word>group</Word> <Word>by</Word> <Word>into</Word> <Word>from</Word> <Word>ascending</Word> <Word>descending</Word> <Word>orderby</Word> <Word>let</Word> <Word>join</Word> <Word>on</Word> <Word>equals</Word> <Word>var</Word> <Word>dynamic</Word> <Word>await</Word> </Keywords> <Keywords color="ExceptionKeywords"> <Word>try</Word> <Word>throw</Word> <Word>catch</Word> <Word>finally</Word> </Keywords> <Keywords color="CheckedKeyword"> <Word>checked</Word> <Word>unchecked</Word> </Keywords> <Keywords color="UnsafeKeywords"> <Word>fixed</Word> <Word>unsafe</Word> </Keywords> <Keywords color="ValueTypes"> <Word>bool</Word> <Word>byte</Word> <Word>char</Word> <Word>decimal</Word> <Word>double</Word> <Word>enum</Word> <Word>float</Word> <Word>int</Word> <Word>long</Word> <Word>sbyte</Word> <Word>short</Word> <Word>struct</Word> <Word>uint</Word> <Word>ushort</Word> <Word>ulong</Word> </Keywords> <Keywords color="ReferenceTypes"> <Word>class</Word> <Word>interface</Word> <Word>delegate</Word> <Word>object</Word> <Word>string</Word> <Word>void</Word> </Keywords> <Keywords color="OperatorKeywords"> <Word>explicit</Word> <Word>implicit</Word> <Word>operator</Word> </Keywords> <Keywords color="ParameterModifiers"> <Word>params</Word> <Word>ref</Word> <Word>out</Word> </Keywords> <Keywords color="Modifiers"> <Word>abstract</Word> <Word>const</Word> <Word>event</Word> <Word>extern</Word> <Word>override</Word> <Word>readonly</Word> <Word>sealed</Word> <Word>static</Word> <Word>virtual</Word> <Word>volatile</Word> <Word>async</Word> </Keywords> <Keywords color="Visibility"> <Word>public</Word> <Word>protected</Word> <Word>private</Word> <Word>internal</Word> </Keywords> <Keywords color="NamespaceKeywords"> <Word>namespace</Word> <Word>using</Word> <Word>include</Word> </Keywords> <Keywords color="GetSetAddRemove"> <Word>get</Word> <Word>set</Word> <Word>add</Word> <Word>remove</Word> </Keywords> <Keywords color="NullOrValueKeywords"> <Word>null</Word> <Word>value</Word> </Keywords> <!-- Mark previous rule--> <Rule color="MethodCall"> \b [\d\w_]+ # an identifier (?=\s*\() # followed by ( </Rule> <!-- Digits --> <Rule color="NumberLiteral"> \b0[xX][0-9a-fA-F]+ # hex number | ( \b\d+(\.[0-9]+)? #number with optional floating point | \.[0-9]+ #or just starting with floating point ) ([eE][+-]?[0-9]+)? # optional exponent </Rule> <Rule color="Punctuation"> [?,.;()\[\]{}+\-/%*&lt;&gt;^+~!|&amp;]+ </Rule> </RuleSet> </SyntaxDefinition>