aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Scripting/Tango.Scripting.IDE/Themes/MenuDict.xaml
blob: f51a50b50274983edcfac157193f8e0dbb96540b (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
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:local="clr-namespace:Tango.Scripting.IDE.Themes">


    <Style x:Key="TangoMenuStyle" TargetType="{x:Type Menu}">
        <Setter Property="OverridesDefaultStyle"  Value="True" />
        <Setter Property="Background" Value="{DynamicResource Menu.Background}"/>
        <Setter Property="FontFamily" Value="{DynamicResource {x:Static SystemFonts.MenuFontFamilyKey}}"/>
        <Setter Property="FontSize" Value="{DynamicResource {x:Static SystemFonts.MenuFontSizeKey}}"/>
        <Setter Property="FontStyle" Value="{DynamicResource {x:Static SystemFonts.MenuFontStyleKey}}"/>
        <Setter Property="FontWeight" Value="{DynamicResource {x:Static SystemFonts.MenuFontWeightKey}}"/>
        <Setter Property="Foreground" Value="{DynamicResource Menu.Foreground}"/>
        <Setter Property="VerticalContentAlignment" Value="Center"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Menu}">
                    <Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="1" Background="{TemplateBinding Background}" Padding="{TemplateBinding Padding}" SnapsToDevicePixels="true">
                        <ItemsPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Style.Resources>
            <Style TargetType="{x:Type MenuItem}">
                <Setter Property="OverridesDefaultStyle"  Value="True" />
                <Style.Triggers>
                    <Trigger Property="Role"  Value="TopLevelHeader">
                        <Setter Property="Template"   Value="{DynamicResource {x:Static MenuItem.TopLevelHeaderTemplateKey}}" />
                        <Setter Property="Grid.IsSharedSizeScope"  Value="true" />
                    </Trigger>
                    <Trigger Property="Role"  Value="TopLevelItem">
                        <Setter Property="Template" Value="{DynamicResource {x:Static MenuItem.TopLevelItemTemplateKey}}" />
                    </Trigger>
                    <Trigger Property="Role" Value="SubmenuHeader">
                        <Setter Property="Template" Value="{DynamicResource {x:Static MenuItem.SubmenuHeaderTemplateKey}}" />
                    </Trigger>
                    <Trigger Property="Role"  Value="SubmenuItem">
                        <Setter Property="Template"  Value="{DynamicResource {x:Static MenuItem.SubmenuItemTemplateKey}}" />
                    </Trigger>
                </Style.Triggers>
            </Style>
            <Style TargetType="TextBlock">
                <Setter Property="TextWrapping" Value="Wrap"></Setter>
            </Style>
        </Style.Resources>
    </Style>
    <Geometry x:Key="Checkmark">M 0,5.1 L 1.7,5.2 L 3.4,7.1 L 8,0.4 L 9.2,0 L 3.3,10.8 Z</Geometry>
    <!-- TopLevelHeader -->
    <ControlTemplate x:Key="{x:Static MenuItem.TopLevelHeaderTemplateKey}"  TargetType="{x:Type MenuItem}">
        <Grid x:Name="Border" Background="Transparent" Margin="0,2,0,2">
            
            <Rectangle x:Name="Bg" Fill="Transparent" />
            <Rectangle x:Name="Inner_Border" Margin="4" Fill="Transparent"/>
            <ContentPresenter Margin="8,2,8,2" ContentSource="Header"  RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
            <Popup x:Name="Popup"  Placement="Bottom"  IsOpen="{TemplateBinding IsSubmenuOpen}"  AllowsTransparency="True" Focusable="False"  PopupAnimation="Fade" HorizontalOffset="2">
                <Border x:Name="SubmenuBorder" BorderBrush="{DynamicResource MenuItemHighlightedBackground}" BorderThickness="1" Background="{DynamicResource Menu.Background}" Padding="2" Margin="0,0,8,8">
                    <Border.Effect>
                        <DropShadowEffect BlurRadius="6" Opacity="0.5" ShadowDepth="4" Direction="330"/>
                    </Border.Effect>
                    <Grid RenderOptions.ClearTypeHint="Enabled" Background="Transparent">
                        <ItemsPresenter x:Name="ItemsPresenter" KeyboardNavigation.DirectionalNavigation="Cycle" Grid.IsSharedSizeScope="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" KeyboardNavigation.TabNavigation="Cycle"/>
                    </Grid>
                </Border>
            </Popup>
        </Grid>
        <ControlTemplate.Triggers>
            <Trigger Property="IsSuspendingPopupAnimation"   Value="true">
                <Setter TargetName="Popup"    Property="PopupAnimation"  Value="None" />
            </Trigger>
            <Trigger Property="IsHighlighted"   Value="true">
                <Setter Property="Fill"  TargetName="Bg" Value="{DynamicResource Menu.Submenu.MouseOverColor}"/>
            </Trigger>
            <Trigger SourceName="Popup" Property="AllowsTransparency"  Value="True">
                <Setter TargetName="SubmenuBorder"  Property="CornerRadius"  Value="0,0,0,0" />
                <Setter TargetName="SubmenuBorder"  Property="Padding" Value="0,0,0,3" />
            </Trigger>
            <Trigger Property="IsEnabled"    Value="False">
                <Setter Property="Foreground" Value="{DynamicResource Menu.Disable.Foreground}"/>
            </Trigger>
            <Trigger Property="IsSubmenuOpen" Value="true">
                <Setter Property="Background"  TargetName="Border" Value="{DynamicResource Menu.Submenu.Background}"/>
                <Setter Property="Fill"  TargetName="Bg" Value="{DynamicResource Menu.Submenu.Background}"/>
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

    <!-- TopLevelItem -->
    <ControlTemplate x:Key="{x:Static MenuItem.TopLevelItemTemplateKey}"   TargetType="{x:Type MenuItem}" >
        <Grid SnapsToDevicePixels="true" Background="Transparent" Margin="0,2,0,2">
            <Rectangle x:Name="Bg" Fill="Transparent" />
            <Rectangle x:Name="InnerBorder" Margin="4" Fill="Transparent"/>
            <!--<DockPanel>
                    <ContentPresenter x:Name="Icon" ContentSource="Icon" Margin="4,0,6,0" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="Center"/>
                    <Path x:Name="GlyphPanel" Data="{StaticResource Checkmark}" Fill="{TemplateBinding Foreground}" FlowDirection="LeftToRight" Margin="7,0,0,0" Visibility="Collapsed" VerticalAlignment="Center"/>-->
            <ContentPresenter ContentSource="Header" Margin="8,2,8,2" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
            <!--</DockPanel>-->
        </Grid>
        <ControlTemplate.Triggers>
            <Trigger Property="IsHighlighted"  Value="true">
                <Setter Property="Fill" TargetName="Bg"  Value="{DynamicResource Menu.Submenu.MouseOverColor}"/>
            </Trigger>
            <Trigger Property="IsEnabled" Value="False">
                <Setter Property="Foreground" Value="{DynamicResource Menu.Disable.Foreground}"/>
            </Trigger>
            <Trigger Property="IsKeyboardFocused" Value="true">
                <Setter Property="Fill" TargetName="Bg"  Value="{DynamicResource Menu.Submenu.MouseOverColor}"/>
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>
    <ControlTemplate x:Key="{x:Static MenuItem.SubmenuHeaderTemplateKey}" TargetType="MenuItem">
        <Grid SnapsToDevicePixels="true" Background="{DynamicResource Menu.Submenu.Background}" x:Name="_grid" MinHeight="22">
            <Rectangle x:Name="Bg"  Fill="Transparent" />
            <Rectangle x:Name="Inner_Border" Margin="4" Fill="Transparent"/>
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition  SharedSizeGroup="Icon" Width="Auto" MinWidth="20"/>
                    <ColumnDefinition Width="*" MinWidth="60"/>
                    <ColumnDefinition SharedSizeGroup="MenuItemIGTColumnGroup" Width="Auto" MinWidth="60"/>
                    <ColumnDefinition Width="13" />
                </Grid.ColumnDefinitions>
                <ContentPresenter x:Name="Iconh" ContentSource="Icon" Margin="3" VerticalAlignment="Center" Grid.Column="0"/>
                <ContentPresenter x:Name="HeaderHost" Margin="3,0,3,0" Grid.Column="1" VerticalAlignment="Center" ContentSource="Header" RecognizesAccessKey="True" TextOptions.TextFormattingMode="Display" />
                <TextBlock Grid.Column="2" Margin="10,0,0,0" Text="{TemplateBinding InputGestureText}" VerticalAlignment="Center"/>
                <Path x:Name="RightArrow" Grid.Column="3" HorizontalAlignment="Center" VerticalAlignment="Center" Data="M 0 0 L 0 7 L 4 3.5 Z" Fill="{DynamicResource Grip.Submenu.Background.Static}" Margin="8,0,0,0"/>
                <Popup x:Name="popup" PlacementTarget="{Binding ElementName=_grid}" Placement="Right" HorizontalOffset="0" AllowsTransparency="True" Focusable="False" PopupAnimation="Fade">
                    <Border x:Name="SubmenuBorder" SnapsToDevicePixels="True" Background="{DynamicResource Menu.Submenu.Background}" BorderThickness="1" BorderBrush="{DynamicResource MenuItemHighlightedBackground}" Margin="0,0,10,10">
                        <Border.Effect>
                            <DropShadowEffect BlurRadius="6" Opacity="0.5" ShadowDepth="4" Direction="330" />
                        </Border.Effect>
                        <ItemsPresenter x:Name="_items" />
                    </Border>
                </Popup>
            </Grid>
        </Grid>
        <!--</Border>-->
        <ControlTemplate.Triggers>
            <Trigger Property="IsHighlighted" Value="True" >
                <Setter Property="Visibility" Value="Visible" TargetName="_items" />
                <Setter Property="IsOpen" Value="True" TargetName="popup" />
                <Setter Property="Fill"  TargetName="Bg" Value="{DynamicResource Menu.Submenu.MouseOverColor}"/>
                <Setter Property="Fill"  TargetName="Inner_Border" Value="{DynamicResource Menu.Submenu.MouseOverColor}"/>
                <Setter TargetName="RightArrow" Property="Fill" Value="{DynamicResource Grip.Submenu.Background.Selected}"/>
                
            </Trigger>
            <Trigger Property="IsEnabled"  Value="False">
                <Setter Property="Foreground" Value="{DynamicResource Menu.Disable.Foreground}"/>
            </Trigger>
            <Trigger Property="IsSubmenuOpen" Value="true">
                <Setter Property="Fill"  TargetName="Bg" Value="{DynamicResource Menu.Submenu.MouseOverColor}"/>
                <Setter Property="Fill"  TargetName="Inner_Border" Value="{DynamicResource Menu.Submenu.MouseOverColor}"/>
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>
    <ControlTemplate x:Key="{x:Static MenuItem.SubmenuItemTemplateKey}" TargetType="MenuItem">
        <Grid SnapsToDevicePixels="true"  Background="{DynamicResource Menu.Submenu.Background}" MinHeight="22">
            <Rectangle x:Name="Bg" Fill="Transparent" />
            <Rectangle x:Name="InnerBorder" Margin="4"/>
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" MinWidth="24" SharedSizeGroup="IconGroup"/>
                    <ColumnDefinition Width="Auto" MinWidth="60" />
                    <ColumnDefinition SharedSizeGroup="MenuItemIGTColumnGroup" Width="Auto" MinWidth="60"/>
                    <ColumnDefinition Width="20" />
                </Grid.ColumnDefinitions>
                <ContentPresenter x:Name="Icon" ContentSource="Icon" Margin="{TemplateBinding Padding}" />
                <ContentPresenter Grid.Column="1" VerticalAlignment="Center" ContentSource="Header" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
                <TextBlock Grid.Column="2" Margin="10,0,0,0" Text="{TemplateBinding InputGestureText}" VerticalAlignment="Center"/>
            </Grid>
        </Grid>
        <ControlTemplate.Triggers>
            <Trigger Property="IsHighlighted" Value="True">
                <Setter Property="Fill" TargetName="Bg" Value="{DynamicResource Menu.Submenu.MouseOverColor}"/>
            </Trigger>
            <Trigger Property="Icon" Value="{x:Null}">
                <Setter TargetName="Icon" Property="Visibility" Value="Collapsed" />
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

    <Style x:Key="{x:Static MenuItem.SeparatorStyleKey}" TargetType="{x:Type Separator}">
        <Setter Property="Height" Value="1" />
        <Setter Property="Margin"   Value="20,0,2,0" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Separator}">
                    <Border BorderThickness="1" BorderBrush="{DynamicResource Submenu.MouseOverColor}" />
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="{x:Type ContextMenu}">
        <Setter Property="SnapsToDevicePixels" Value="True" />
        <Setter Property="OverridesDefaultStyle"  Value="True" />
        <Setter Property="Grid.IsSharedSizeScope" Value="true" />
        <Setter Property="HasDropShadow" Value="True" />
        <Setter Property="Foreground" Value="{DynamicResource ControlTextBrush}"></Setter>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ContextMenu}">
                    <Border x:Name="Border" Background="{DynamicResource Background.Static}"  BorderThickness="1" BorderBrush="{DynamicResource Inactive.Selection}">
                        <Border.Effect>
                            <DropShadowEffect Color="Black" Direction="135"  Opacity="0.8" ShadowDepth="2"/>
                        </Border.Effect>
                        <StackPanel IsItemsHost="True"  KeyboardNavigation.DirectionalNavigation="Cycle"/>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="true">
                            <Setter TargetName="Border" Property="Background" Value="{DynamicResource Menu.Submenu.Background}" />
                            <Setter TargetName="Border" Property="BorderBrush" Value="{DynamicResource ContextMenu.MouseOverColor}" />
                        </Trigger>
                        <Trigger Property="HasDropShadow"  Value="true">
                            <Setter TargetName="Border"  Property="Padding" Value="0,3,0,3" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Style.Resources>
            <Style TargetType="{x:Type MenuItem}">
                <Setter Property="Background" Value="{DynamicResource Menu.Submenu.Background}"></Setter>
                <Setter Property="Foreground" Value="{DynamicResource ControlTextBrush}"></Setter>
                <Setter Property="Margin" Value="1,0,1,0"></Setter>
            </Style>
        </Style.Resources>
    </Style>
    
</ResourceDictionary>
/span>(line.TextLines[0], VisualYPosition.TextTop); drawingContext.DrawEllipse(Foreground, new Pen(Brushes.Gainsboro, 1), new Point(10, y - textView.VerticalOffset + 8), 6, 6); if (b.IsActive) { drawingContext.DrawImage(_arrowBitmap, new Rect(6, y - textView.VerticalOffset + 2.5, 8.5, 10)); } } } } } protected override void OnTextViewChanged(TextView oldTextView, TextView newTextView) { if (oldTextView != null) { oldTextView.VisualLinesChanged -= TextViewVisualLinesChanged; } base.OnTextViewChanged(oldTextView, newTextView); if (newTextView != null) { newTextView.VisualLinesChanged += TextViewVisualLinesChanged; // find the text area belonging to the new text view textArea = newTextView.Services.GetService(typeof(TextArea)) as TextArea; } else { textArea = null; } InvalidateVisual(); } protected override void OnDocumentChanged(TextDocument oldDocument, TextDocument newDocument) { if (oldDocument != null) { PropertyChangedEventManager.RemoveListener(oldDocument, this, "LineCount"); } base.OnDocumentChanged(oldDocument, newDocument); if (newDocument != null) { PropertyChangedEventManager.AddListener(newDocument, this, "LineCount"); } OnDocumentLineCountChanged(); } protected virtual bool ReceiveWeakEvent(Type managerType, object sender, EventArgs e) { if (managerType == typeof(PropertyChangedEventManager)) { OnDocumentLineCountChanged(); return true; } return false; } bool IWeakEventListener.ReceiveWeakEvent(Type managerType, object sender, EventArgs e) { return ReceiveWeakEvent(managerType, sender, e); } private void OnDocumentLineCountChanged() { int documentLineCount = Document != null ? Document.LineCount : 1; int newLength = documentLineCount.ToString(CultureInfo.CurrentCulture).Length; foreach (var breakPoint in BreakPoints.ToList()) { if (breakPoint.LineNumber > documentLineCount) { BreakPoints.Remove(breakPoint); } else { try { var line = Document.GetLineByNumber(breakPoint.LineNumber); if (line != null) { String lineText = Document.GetText(line.Offset, line.Length); if (!IsBreakPointValid(lineText)) { BreakPoints.Remove(breakPoint); } } } catch { } } } // The margin looks too small when there is only one digit, so always reserve space for // at least two digits if (newLength < 2) newLength = 2; if (newLength != maxLineNumberLength) { maxLineNumberLength = newLength; InvalidateMeasure(); } } private void TextViewVisualLinesChanged(object sender, EventArgs e) { InvalidateVisual(); } protected override HitTestResult HitTestCore(PointHitTestParameters hitTestParameters) { // accept clicks even when clicking on the background return new PointHitTestResult(this, hitTestParameters.HitPoint); } private VisualLine GetLineNumberByMousePosition(MouseEventArgs e) { Point pos = e.GetPosition(TextView); pos.X = 0; pos.Y += TextView.VerticalOffset; VisualLine vl = TextView.GetVisualLineFromVisualTop(pos.Y); return vl; } private bool IsBreakPointValid(String lineText) { if (lineText.EndsWith(";") && !lineText.StartsWith("using")) { return true; } return false; } protected override void OnPreviewMouseMove(MouseEventArgs e) { base.OnPreviewMouseMove(e); if (_editor.DisableBreakPoints) { Cursor = Cursors.No; } else { Cursor = Cursors.Arrow; } } protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e) { base.OnMouseLeftButtonDown(e); if (_editor.DisableBreakPoints) { return; } try { if (!e.Handled && TextView != null && textArea != null) { e.Handled = true; textArea.Focus(); var visualLine = GetLineNumberByMousePosition(e); int? lineNumber = visualLine != null ? (int?)visualLine.FirstDocumentLine.LineNumber : null; if (lineNumber != null) { var breakPoint = BreakPoints.FirstOrDefault(x => x.LineNumber == lineNumber.Value); if (breakPoint != null) { BreakPoints.Remove(breakPoint); } else { var lineText = Document.GetText(visualLine.FirstDocumentLine.Offset, visualLine.FirstDocumentLine.Length).Trim(); if (IsBreakPointValid(lineText)) { BreakPoint newBreakPoint = new BreakPoint(); newBreakPoint.LineNumber = lineNumber.Value; BreakPoints.Add(newBreakPoint); } } } } } catch (Exception ex) { Debug.WriteLine(ex); } } } }