-
Notifications
You must be signed in to change notification settings - Fork 0
/
FileTab.xaml
126 lines (122 loc) · 6.07 KB
/
FileTab.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
<TabItem x:Class="CPP_EP.FileTab"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:CPP_EP"
xmlns:conv="clr-namespace:CPP_EP.Converter"
d:DataContext="{d:DesignInstance Type=local:FileTabDataContext}"
mc:Ignorable="d"
Header="{Binding Header, Mode=OneWay}"
DockPanel.Dock="{Binding Alignment, Mode=OneWay}"
HorizontalAlignment="{Binding Alignment, Mode=OneWay}" >
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="{Binding Width, Mode=OneWay}"/>
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Canvas
Grid.Row="0"
Grid.Column="0"
Name="breakPointArea"
MouseDown="BreakPointArea_MouseUp"
Width="{Binding Width, Mode=OneWay}">
<Canvas.Background>
<SolidColorBrush
Color="White"
Opacity="0" />
</Canvas.Background>
</Canvas>
<avalonEdit:TextEditor
Grid.Row="0"
xmlns:avalonEdit="http://icsharpcode.net/sharpdevelop/avalonedit"
xmlns:editing="clr-namespace:ICSharpCode.AvalonEdit.Editing;assembly=ICSharpCode.AvalonEdit"
xmlns:rendering="clr-namespace:ICSharpCode.AvalonEdit.Rendering;assembly=ICSharpCode.AvalonEdit"
Name="textEditor"
FontFamily="Consolas"
SyntaxHighlighting="C++"
FontSize="10pt"
ShowLineNumbers="True"
Grid.Column="1"
PreviewMouseWheel="TextEditor_PreviewMouseWheel"
IsReadOnly="{Binding ReadOnly, Mode=OneWay}">
<avalonEdit:TextEditor.ContextMenu>
<ContextMenu>
<MenuItem Command="Cut" Header="剪切(_T)" />
<MenuItem Command="Copy" Header="复制(_C)" />
<MenuItem Command="Paste" Header="粘贴(_P)" />
<MenuItem Command="Delete" Header="删除(_D)" />
<Separator />
<MenuItem Command="Undo" Header="撤销(_U)" />
<MenuItem Command="Redo" Header="重做(_R)" />
</ContextMenu>
</avalonEdit:TextEditor.ContextMenu>
<avalonEdit:TextEditor.Template>
<ControlTemplate TargetType="{x:Type avalonEdit:TextEditor}">
<Border
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}">
<ScrollViewer
Name="PART_ScrollViewer"
Padding="{TemplateBinding Padding}"
HorizontalContentAlignment="Left"
VerticalContentAlignment="Top"
CanContentScroll="True"
Content="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=TextArea}"
Focusable="False"
HorizontalScrollBarVisibility="Auto"
VerticalScrollBarVisibility="Auto" />
</Border>
<ControlTemplate.Triggers>
<Trigger Property="WordWrap" Value="True">
<Setter TargetName="PART_ScrollViewer" Property="HorizontalScrollBarVisibility" Value="Disabled" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</avalonEdit:TextEditor.Template>
</avalonEdit:TextEditor>
<StatusBar Grid.Row="1" Grid.ColumnSpan="2">
<StatusBarItem HorizontalAlignment="Right">
<Grid>
<Grid.Resources>
<conv:BoolToStringPropConverter x:Key="OverStrikeModeConverter"
TrueValue="覆盖模式"
FalseValue="插入模式" />
<conv:BoolToStringPropConverter x:Key="ReadOnlyModeConverter"
TrueValue="Visible"
FalseValue="Collapsed" />
</Grid.Resources>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0"
Text="{Binding Row, Mode=OneWay}"
MinWidth="36"
Margin="3,0,3,0" />
<TextBlock Grid.Column="1"
Text="{Binding Col, Mode=OneWay}"
MinWidth="36"
Margin="0,0,3,0" />
<TextBlock
Visibility="{Binding NotReadOnly, Converter={StaticResource ReadOnlyModeConverter}, Mode=OneWay}"
Grid.Column="2"
Text="{Binding ElementName=textEditor,Path=TextArea.OverstrikeMode,Converter={StaticResource OverStrikeModeConverter}, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}"
Margin="0,0,3,0" />
<TextBlock
Visibility="{Binding ReadOnly, Converter={StaticResource ReadOnlyModeConverter}, Mode=OneWay}"
Grid.Column="2"
Text="只读模式"
Margin="0,0,3,0" />
</Grid>
</StatusBarItem>
</StatusBar>
</Grid>
</TabItem>