-
Notifications
You must be signed in to change notification settings - Fork 124
/
Copy pathCustomIntellisense.xaml
338 lines (334 loc) · 15.7 KB
/
CustomIntellisense.xaml
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
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
<democommon:DemoControl
x:Class="syncfusion.syntaxeditordemos.wpf.CustomIntellisense"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:democommon="clr-namespace:syncfusion.demoscommon.wpf;assembly=syncfusion.demoscommon.wpf"
xmlns:interactivity="http://schemas.microsoft.com/xaml/behaviors"
xmlns:local="clr-namespace:syncfusion.syntaxeditordemos.wpf"
xmlns:skinManager="clr-namespace:Syncfusion.SfSkinManager;assembly=Syncfusion.SfSkinManager.WPF"
xmlns:syncfusion="http://schemas.syncfusion.com/wpf"
xmlns:system="clr-namespace:System;assembly=mscorlib"
x:Name="window">
<democommon:DemoControl.DataContext>
<local:CustomIntellisenseViewModel />
</democommon:DemoControl.DataContext>
<Grid>
<Grid.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/syncfusion.syntaxeditordemos.wpf;component/Assets/syntaxeditor/PathIcon.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Grid.Resources>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Menu x:Name="Mainmenu"
Grid.ColumnSpan="2"
Height="25" Padding="0,2,0,0"
BorderBrush="LightGray"
BorderThickness="0,0,0,2">
<MenuItem
Background="Transparent"
Margin="0,0,8,0"
Header="_File" Height="24">
<MenuItem Command="{x:Static syncfusion:EditCommands.New}" CommandTarget="{Binding ElementName=editText}" />
<MenuItem Command="{x:Static syncfusion:EditCommands.Open}" CommandTarget="{Binding ElementName=editText}" />
<MenuItem Command="{x:Static syncfusion:EditCommands.Save}" CommandTarget="{Binding ElementName=editText}" />
<MenuItem Command="{x:Static syncfusion:EditCommands.SaveAs}" CommandTarget="{Binding ElementName=editText}" />
</MenuItem>
<MenuItem
Margin="8,0,8,0"
Background="Transparent"
Header="_Edit">
<MenuItem Command="{x:Static syncfusion:EditCommands.Undo}" CommandTarget="{Binding ElementName=editText}" />
<MenuItem Command="{x:Static syncfusion:EditCommands.Redo}" CommandTarget="{Binding ElementName=editText}" />
<MenuItem Command="{x:Static syncfusion:EditCommands.Cut}" CommandTarget="{Binding ElementName=editText}" />
<MenuItem Command="{x:Static syncfusion:EditCommands.Copy}" CommandTarget="{Binding ElementName=editText}" />
<MenuItem Command="{x:Static syncfusion:EditCommands.Paste}" CommandTarget="{Binding ElementName=editText}" />
<MenuItem Command="{x:Static syncfusion:EditCommands.SelectAll}" CommandTarget="{Binding ElementName=editText}" />
<MenuItem Header="Find and Replace">
<MenuItem Command="{x:Static syncfusion:EditCommands.Find}" CommandTarget="{Binding ElementName=editText}" />
<MenuItem Command="{x:Static syncfusion:EditCommands.Replace}" CommandTarget="{Binding ElementName=editText}" />
</MenuItem>
</MenuItem>
<MenuItem Margin="8,0,8,0" Header="Options">
<MenuItem
Header="Accepts Tab"
IsCheckable="True"
IsChecked="{Binding ElementName=editText, Path=AcceptsTab}" />
<MenuItem
Header="Is ReadOnly"
IsCheckable="True"
IsChecked="{Binding ElementName=editText, Path=IsReadOnly}" />
<MenuItem
Header="Show Line Number"
IsCheckable="True"
IsChecked="{Binding ElementName=editText, Path=ShowLineNumber}" />
<MenuItem
Header="Show Default Context Menu"
IsCheckable="True"
IsChecked="{Binding ElementName=editText, Path=ShowDefaultContextMenu}" />
</MenuItem>
</Menu>
<ToolBar
x:Name="Toolbar"
Grid.Row="1"
Grid.ColumnSpan="1"
Margin="-1">
<Button
Margin="4,4,4,4"
Height="24"
Command="{x:Static syncfusion:EditCommands.New}"
CommandTarget="{Binding ElementName=editText}"
ToolTip="New"
Content="{StaticResource New}">
</Button>
<Button
Margin="4,4,4,4"
Height="24"
Command="{x:Static syncfusion:EditCommands.Open}"
CommandTarget="{Binding ElementName=editText}"
ToolTip="Open"
Content="{StaticResource Open}">
</Button>
<Button
Margin="4,4,4,4"
Height="24"
Command="{x:Static syncfusion:EditCommands.Save}"
CommandTarget="{Binding ElementName=editText}"
ToolTip="Save"
Content="{StaticResource Save}">
</Button>
<Separator />
<Button
Margin="4,4,4,4"
Height="24"
Command="{x:Static syncfusion:EditCommands.Cut}"
CommandTarget="{Binding ElementName=editText}"
ToolTip="Cut"
ToolTipService.ShowOnDisabled="True"
Content="{StaticResource Cut}">
</Button>
<Button
Margin="4,4,4,4"
Height="24"
Command="{x:Static syncfusion:EditCommands.Copy}"
CommandTarget="{Binding ElementName=editText}"
ToolTip="Copy"
ToolTipService.ShowOnDisabled="True"
Content="{StaticResource Copy}">
</Button>
<Button
Margin="4,4,4,4"
Height="24"
Command="{x:Static syncfusion:EditCommands.Paste}"
CommandTarget="{Binding ElementName=editText}"
ToolTip="Paste"
ToolTipService.ShowOnDisabled="True"
Content="{StaticResource Paste}">
</Button>
<Separator />
<Button
Margin="4,4,4,4"
Height="24"
Command="{x:Static syncfusion:EditCommands.Undo}"
CommandTarget="{Binding ElementName=editText}"
ToolTip="Undo"
ToolTipService.ShowOnDisabled="True"
Content="{StaticResource Undo}">
</Button>
<Button
Margin="4,4,4,4"
Height="24"
Command="{x:Static syncfusion:EditCommands.Redo}"
CommandTarget="{Binding ElementName=editText}"
ToolTip="Redo"
ToolTipService.ShowOnDisabled="True"
Content="{StaticResource Redo}">
</Button>
<Separator />
<ComboBox
Name="fontlist"
Grid.Column="1"
Width="120"
Margin="4,4,4,4"
Height="24"
ItemsSource="{x:Static Fonts.SystemFontFamilies}"
SelectedItem="{Binding SelectedItem}"
ToolTip="Font" />
<ComboBox
Name="fontsize"
Grid.Row="1"
Grid.Column="1"
Margin="4,0,4,0"
Height="24"
SelectedIndex="2"
ToolTip="Font size">
<system:Double>10</system:Double>
<system:Double>12</system:Double>
<system:Double>13</system:Double>
<system:Double>14</system:Double>
<system:Double>15</system:Double>
<system:Double>16</system:Double>
<system:Double>17</system:Double>
<system:Double>18</system:Double>
<system:Double>20</system:Double>
</ComboBox>
<Separator />
<Button
Margin="4,4,4,4"
Height="24"
Command="{x:Static syncfusion:EditCommands.DecreaseIndent}"
CommandTarget="{Binding ElementName=editText}"
ToolTip="Decrease indent"
Content="{StaticResource DecreaseIndent}">
</Button>
<Button
Margin="4,4,4,4"
Height="24"
Command="{x:Static syncfusion:EditCommands.IncreaseIndent}"
CommandTarget="{Binding ElementName=editText}"
ToolTip="Increase indent"
Content="{StaticResource IncreaseIndent}">
</Button>
<Separator />
<Button
Margin="4,4,4,4"
Height="24"
Command="{x:Static syncfusion:EditCommands.CommentSelection}"
CommandTarget="{Binding ElementName=editText}"
ToolTip="Comment out the selected lines">
<Image
MaxWidth="16"
MaxHeight="16"
Source="/Syncfusion.Edit.Wpf;component/Resources/comment.png" />
</Button>
<Button
Margin="4,4,4,4"
Height="24"
Command="{x:Static syncfusion:EditCommands.UncommentSelection}"
CommandTarget="{Binding ElementName=editText}"
ToolTip="Uncomment the selected lines">
<Image
MaxWidth="16"
MaxHeight="16"
Source="/Syncfusion.Edit.Wpf;component/Resources/uncomment.png" />
</Button>
</ToolBar>
<!-- Adding EditControl to the application -->
<syncfusion:EditControl
Name="editText"
Grid.Row="2"
DocumentLanguage="Text"
EnableOutlining="False"
FontFamily="{Binding SelectedItem}"
FontSize="{Binding SelectedItem, ElementName=fontsize}"
IntellisenseCustomItemsSource="{Binding ItemsSource}"
IntellisenseMode="Custom"
ShowLineNumber="False">
<interactivity:Interaction.Triggers>
<interactivity:EventTrigger EventName="Loaded">
<interactivity:InvokeCommandAction Command="{Binding EditCommand}" CommandParameter="{Binding ElementName=editText}" />
</interactivity:EventTrigger>
</interactivity:Interaction.Triggers>
</syncfusion:EditControl>
<Grid Grid.Row="3" MaxHeight="150">
<Border BorderBrush="{x:Static SystemColors.ActiveCaptionBrush}" BorderThickness="1">
<Expander
x:Name="expander"
Margin="2"
HorizontalAlignment="Stretch"
ExpandDirection="Down"
IsExpanded="True">
<Expander.Header>
<TextBlock
HorizontalAlignment="Stretch"
FontWeight="Bold"
Text="IntelliSense Properties" />
</Expander.Header>
<Border
Margin="2"
BorderBrush="{x:Static SystemColors.ActiveCaptionBrush}"
BorderThickness="1">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<TextBlock Margin="3" Text="Enable IntelliSense" />
<CheckBox
Grid.Column="1"
Margin="3"
HorizontalAlignment="Left"
Content=""
IsChecked="{Binding ElementName=editText, Path=EnableIntellisense}" />
<TextBlock
Grid.Row="0"
Grid.Column="2"
Margin="3"
Text="Custom IntelliSense Items" />
<ListBox
x:Name="intellisenseItems"
Grid.Row="0"
Grid.RowSpan="3"
Grid.Column="3"
Margin="3"
ItemsSource="{Binding Path=IntellisenseCustomItemsSource, ElementName=editText}">
<ListBox.ItemTemplate>
<DataTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Image
MaxWidth="16"
MaxHeight="16"
Margin="3"
Source="{Binding Icon}" />
<TextBlock
Grid.Column="1"
Margin="3"
Text="{Binding Text}" />
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<StackPanel
Grid.RowSpan="2"
Grid.Column="4"
Margin="3"
VerticalAlignment="Center">
<Button
x:Name="btnAddItem"
Margin="4,0,4,0"
Height="24"
Command="{Binding AddItemCommnad}"
CommandParameter="{Binding ElementName=intellisenseItems}"
Content="Add Item" />
<Button
x:Name="btnRemoveItem"
Margin="4,0,4,0"
Height="24"
Command="{Binding RemoveItemCommand}"
CommandParameter="{Binding ElementName=intellisenseItems}"
Content="Remove Item" />
</StackPanel>
</Grid>
</Border>
</Expander>
</Border>
</Grid>
</Grid>
</democommon:DemoControl>