ScriptEditControl.xaml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. <UserControl x:Class="TeamAAS_VP.Controls.ScriptEditControl"
  2. xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  3. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  4. xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  5. xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
  6. xmlns:b="http://schemas.microsoft.com/xaml/behaviors"
  7. xmlns:sys="clr-namespace:System;assembly=mscorlib"
  8. xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
  9. xmlns:avalonEdit="http://icsharpcode.net/sharpdevelop/avalonedit"
  10. xmlns:AvalonEdit="clr-namespace:ICSharpCode.AvalonEdit;assembly=ICSharpCode.AvalonEdit"
  11. xmlns:local="clr-namespace:TeamAAS_VP.Controls"
  12. xmlns:lex="http://wpflocalizeextension.codeplex.com"
  13. lex:LocalizeDictionary.DesignCulture="zh-CN"
  14. lex:ResxLocalizationProvider.DefaultAssembly="TeamAAS-VP"
  15. lex:ResxLocalizationProvider.DefaultDictionary="Lang"
  16. mc:Ignorable="d"
  17. d:DesignHeight="450"
  18. d:DesignWidth="1000"
  19. d:Background="White">
  20. <Grid>
  21. <Grid.RowDefinitions>
  22. <RowDefinition Height="auto" />
  23. <RowDefinition Height="*" />
  24. <RowDefinition Height="100" />
  25. </Grid.RowDefinitions>
  26. <ToolBar Grid.Row="0">
  27. <ToolBar.Resources>
  28. <Style TargetType="{x:Type Image}">
  29. <Style.Triggers>
  30. <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type ButtonBase}, AncestorLevel=1}, Path=IsEnabled}"
  31. Value="False">
  32. <Setter Property="Opacity"
  33. Value="0.30" />
  34. </DataTrigger>
  35. </Style.Triggers>
  36. </Style>
  37. </ToolBar.Resources>
  38. <Button x:Name="btn1"
  39. Click="Button_Click"
  40. ToolTip="{lex:Loc 打开脚本文件}">
  41. <Image Source="pack://application:,,,/TeamAAS-VP;component/Resources/Images/Open.png"
  42. Height="16" />
  43. </Button>
  44. <Button x:Name="btn2"
  45. Click="Button_Click_1"
  46. ToolTip="{lex:Loc 保存脚本}">
  47. <Image Source="pack://application:,,,/TeamAAS-VP;component/Resources/Images/Save.png"
  48. Height="16" />
  49. </Button>
  50. <Button x:Name="btn3"
  51. Click="Button_Click_2"
  52. ToolTip="{lex:Loc 另存为}">
  53. <Image Source="pack://application:,,,/TeamAAS-VP;component/Resources/Images/SaveAs.png"
  54. Height="16" />
  55. </Button>
  56. <Separator />
  57. <Button x:Name="btn4"
  58. Command="Cut"
  59. ToolTip="{lex:Loc 剪切}">
  60. <Image Source="pack://application:,,,/TeamAAS-VP;component/Resources/Images/Cut.png"
  61. Height="16" />
  62. </Button>
  63. <Button x:Name="btn5"
  64. Command="Copy"
  65. ToolTip="{lex:Loc 复制}">
  66. <Image Source="pack://application:,,,/TeamAAS-VP;component/Resources/Images/Copy.png"
  67. Height="16" />
  68. </Button>
  69. <Button x:Name="btn6"
  70. Command="Paste"
  71. ToolTip="{lex:Loc 粘贴}">
  72. <Image Source="pack://application:,,,/TeamAAS-VP;component/Resources/Images/Paste.png"
  73. Height="16" />
  74. </Button>
  75. <Button x:Name="btn7"
  76. Command="Delete"
  77. ToolTip="{lex:Loc 删除}">
  78. <Image Source="pack://application:,,,/TeamAAS-VP;component/Resources/Images/Delete.png"
  79. Height="16" />
  80. </Button>
  81. <Separator />
  82. <Button x:Name="btn8"
  83. Command="Undo"
  84. ToolTip="{lex:Loc 撤销}">
  85. <Image Source="pack://application:,,,/TeamAAS-VP;component/Resources/Images/Undo.png"
  86. Height="16" />
  87. </Button>
  88. <Button x:Name="btn9"
  89. Command="Redo"
  90. ToolTip="{lex:Loc 重做}">
  91. <Image Source="pack://application:,,,/TeamAAS-VP;component/Resources/Images/Redo.png"
  92. Height="16" />
  93. </Button>
  94. <Separator />
  95. <Button x:Name="btn10"
  96. Click="Button_Click_3">
  97. <Image Source="pack://application:,,,/TeamAAS-VP;component/Resources/Images/FontAdd.png"
  98. Height="16" />
  99. </Button>
  100. <Button x:Name="btn11"
  101. Click="Button_Click_4">
  102. <Image Source="pack://application:,,,/TeamAAS-VP;component/Resources/Images/FontSubtract.png"
  103. Height="16" />
  104. </Button>
  105. <Separator />
  106. <ToggleButton x:Name="btnWordWrap"
  107. IsChecked="{Binding ElementName=textEditor,Path=WordWrap}"
  108. Style="{StaticResource MaterialDesignFlatToggleButton}">
  109. <Image Source="pack://application:,,,/TeamAAS-VP;component/Resources/Images/WordWrap.png"
  110. Height="16" />
  111. </ToggleButton>
  112. <ToggleButton x:Name="btnShowLineNumbers"
  113. IsChecked="{Binding ElementName=textEditor,Path=ShowLineNumbers}"
  114. Style="{StaticResource MaterialDesignFlatToggleButton}">
  115. <TextBlock Width="16"
  116. TextAlignment="Center">#</TextBlock>
  117. </ToggleButton>
  118. <ToggleButton x:Name="btnShowEndOfLine"
  119. IsChecked="{Binding ElementName=textEditor,Path=Options.ShowEndOfLine}"
  120. Style="{StaticResource MaterialDesignFlatToggleButton}">
  121. <TextBlock Width="16"
  122. TextAlignment="Center">¶</TextBlock>
  123. </ToggleButton>
  124. <Separator />
  125. <Button x:Name="btn12"
  126. Click="Button_Click_5"
  127. ToolTip="{lex:Loc 编译}"
  128. materialDesign:ButtonProgressAssist.IsIndeterminate="{Binding IsCompile,UpdateSourceTrigger=PropertyChanged,Converter={StaticResource InvertBooleanConverter}}"
  129. materialDesign:ButtonProgressAssist.IsIndicatorVisible="{Binding IsCompile,UpdateSourceTrigger=PropertyChanged,Converter={StaticResource InvertBooleanConverter}}"
  130. materialDesign:ButtonProgressAssist.Value="-1"
  131. Background="Transparent"
  132. BorderBrush="Transparent"
  133. Style="{StaticResource MaterialDesignOutlinedDarkButton}">
  134. <Image Source="pack://application:,,,/TeamAAS-VP;component/Resources/Images/compile.png"
  135. Height="16" />
  136. </Button>
  137. </ToolBar>
  138. <Border Grid.Row="1"
  139. BorderThickness="1,1,1,0">
  140. <Border.BorderBrush>
  141. <VisualBrush>
  142. <VisualBrush.Visual>
  143. <Rectangle StrokeDashArray="4 2"
  144. Stroke="Gray"
  145. StrokeThickness="1"
  146. Width="{Binding RelativeSource={RelativeSource AncestorType={x:Type Border}}, Path=ActualWidth}"
  147. Height="{Binding RelativeSource={RelativeSource AncestorType={x:Type Border}}, Path=ActualHeight}" />
  148. </VisualBrush.Visual>
  149. </VisualBrush>
  150. </Border.BorderBrush>
  151. <avalonEdit:TextEditor Name="textEditor"
  152. FontFamily="{StaticResource CodeFont}"
  153. WordWrap="True"
  154. SyntaxHighlighting="C#"
  155. LineNumbersForeground="Black"
  156. ShowLineNumbers="True">
  157. </avalonEdit:TextEditor>
  158. </Border>
  159. <GridSplitter Grid.Row="2"
  160. Height="4"
  161. VerticalAlignment="Top"
  162. HorizontalAlignment="Stretch" />
  163. <Border Grid.Row="2"
  164. BorderThickness="1,0,1,1">
  165. <Border.BorderBrush>
  166. <VisualBrush>
  167. <VisualBrush.Visual>
  168. <Rectangle StrokeDashArray="4 2"
  169. Stroke="Gray"
  170. StrokeThickness="1"
  171. Width="{Binding RelativeSource={RelativeSource AncestorType={x:Type Border}}, Path=ActualWidth}"
  172. Height="{Binding RelativeSource={RelativeSource AncestorType={x:Type Border}}, Path=ActualHeight}" />
  173. </VisualBrush.Visual>
  174. </VisualBrush>
  175. </Border.BorderBrush>
  176. <ListView x:Name="messagelist"
  177. ScrollViewer.VerticalScrollBarVisibility="Auto"
  178. ScrollViewer.CanContentScroll="False"
  179. BorderThickness="0"
  180. Background="Transparent"
  181. Margin="0,4,0,0"
  182. ScrollViewer.HorizontalScrollBarVisibility="Disabled">
  183. <ListView.Resources>
  184. <Style TargetType="{x:Type GridViewHeaderRowPresenter}">
  185. <Setter Property="FrameworkElement.Visibility"
  186. Value="Collapsed" />
  187. </Style>
  188. </ListView.Resources>
  189. <ListView.ItemContainerStyle>
  190. <Style TargetType="ListViewItem">
  191. <Setter Property="HorizontalContentAlignment"
  192. Value="Left" />
  193. <Setter Property="VerticalContentAlignment"
  194. Value="Top" />
  195. </Style>
  196. </ListView.ItemContainerStyle>
  197. <ListView.ItemTemplate>
  198. <DataTemplate>
  199. <Grid>
  200. <Grid.ColumnDefinitions>
  201. <ColumnDefinition Width="auto" />
  202. <ColumnDefinition Width="auto" />
  203. <ColumnDefinition Width="*" />
  204. </Grid.ColumnDefinitions>
  205. <materialDesign:PackIcon Kind="{Binding Kind}"
  206. Foreground="{Binding FontColol}" />
  207. <TextBlock Grid.Column="1"
  208. TextAlignment="Left"
  209. Foreground="{Binding FontColol}"
  210. Text="{Binding DT,StringFormat={}{0:HH:mm:ss.fff}:}" />
  211. <TextBlock Grid.Column="2"
  212. TextWrapping="Wrap"
  213. TextAlignment="Left"
  214. Foreground="{Binding FontColol}"
  215. Text="{Binding Message}" />
  216. </Grid>
  217. </DataTemplate>
  218. </ListView.ItemTemplate>
  219. </ListView>
  220. </Border>
  221. </Grid>
  222. </UserControl>