终端一体化运控平台
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

295 lines
20 KiB

  1. <UserControl x:Class="BeDesignerSCADA.Controls.MainCanvasPanel"
  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:local="clr-namespace:BeDesignerSCADA.Controls"
  7. xmlns:s="clr-namespace:BeDesignerSCADA.Converters"
  8. xmlns:icon="http://metro.mahapps.com/winfx/xaml/iconpacks"
  9. xmlns:avae="http://icsharpcode.net/sharpdevelop/avalonedit"
  10. xmlns:ctl="clr-namespace:BeDesignerSCADA.Controls"
  11. xmlns:mypro="http://schemas.xceed.com/wpf/xaml/toolkit"
  12. mc:Ignorable="d"
  13. d:DesignHeight="900" d:DesignWidth="1400">
  14. <UserControl.Resources>
  15. <ResourceDictionary>
  16. <ResourceDictionary.MergedDictionaries>
  17. <ResourceDictionary Source="/BeDesignerSCADA;component/Themes/Styles.xaml" />
  18. <ResourceDictionary Source="/BPASmartClient.SCADAControl;component/Themes/Generic.xaml" />
  19. </ResourceDictionary.MergedDictionaries>
  20. </ResourceDictionary>
  21. </UserControl.Resources>
  22. <Grid x:Name="grid">
  23. <Grid.ColumnDefinitions>
  24. <ColumnDefinition Width="240"/>
  25. <ColumnDefinition/>
  26. <ColumnDefinition Width="350"/>
  27. </Grid.ColumnDefinitions>
  28. <!--左侧选择区域-->
  29. <Grid Background="White" >
  30. <Border BorderThickness="1" BorderBrush="{StaticResource AccentBrush}" Margin="4">
  31. <ListBox x:Name="CtlList" Background="Transparent" ItemTemplate="{DynamicResource ToolBoxStyle}" BorderThickness="0" PreviewMouseMove="CtlList_PreviewMouseMove">
  32. </ListBox>
  33. </Border>
  34. </Grid>
  35. <!--中间控制区域-->
  36. <DockPanel Grid.Column="1">
  37. <!--按钮控制-->
  38. <DockPanel LastChildFill="False" DockPanel.Dock="Top" Height="24" Margin="4 4 4 0">
  39. <Button Margin="0" Width="24" Padding="0" Click="AglinLeftBtn_Click" ToolTip="左对齐">
  40. <icon:PackIconModern Kind="AlignLeft"/>
  41. </Button>
  42. <Button Margin="4 0 0 0" Width="24" Padding="0" Click="AglinRightBtn_Click" ToolTip="右对齐">
  43. <icon:PackIconModern Kind="AlignRight"/>
  44. </Button>
  45. <Button Margin="4 0 0 0" Width="24" Padding="0" Click="AglinCenterBtn_Click" ToolTip="中心对齐">
  46. <icon:PackIconModern Kind="AlignCenter"/>
  47. </Button>
  48. <Button Margin="4 0 0 0" Width="24" Padding="0" Click="AglinTopBtn_Click" ToolTip="上对齐">
  49. <icon:PackIconModern Kind="BorderTop"/>
  50. </Button>
  51. <Button Margin="4 0 0 0" Width="24" Padding="0" Click="AglinBottomBtn_Click" ToolTip="下对齐">
  52. <icon:PackIconModern Kind="BorderBottom"/>
  53. </Button>
  54. <Button Margin="16 0 0 0" Width="24" Padding="0" Click="HorizontalLayoutBtn_Click" ToolTip="水平分布">
  55. <icon:PackIconModern Kind="BorderHorizontal"/>
  56. </Button>
  57. <Button Margin="4 0 0 0" Width="24" Padding="0" Click="VerticalLayoutBtn_Click" ToolTip="垂直分布">
  58. <icon:PackIconModern Kind="BorderVertical"/>
  59. </Button>
  60. <ToggleButton IsChecked="{Binding UseAutoAlignment, ElementName=cav, Mode=TwoWay}" ToolTip="使用对齐网格" Margin="4 0 0 0" Width="24" Padding="0">
  61. <icon:PackIconModern Kind="CellAlign"/>
  62. </ToggleButton>
  63. <Button Margin="16 0 0 0" Width="24" Padding="0" ToolTip="复制" Command="{Binding ElementName=cav, Path=CopySelectItemsCommand}">
  64. <icon:PackIconModern Kind="PageCopy"/>
  65. </Button>
  66. <Button Margin="4 0 0 0" Width="24" Padding="0" ToolTip="粘贴" Command="{Binding ElementName=cav, Path=PasteSelectItemsCommand}">
  67. <icon:PackIconModern Kind="ClipboardPaste"/>
  68. </Button>
  69. <Button Margin="4 0 0 0" Width="24" Padding="0" ToolTip="删除" Command="{Binding ElementName=cav, Path=DeleteSelectItemsCommand}">
  70. <icon:PackIconModern Kind="Delete"/>
  71. </Button>
  72. <Button x:Name="RunBtn" Margin="16 0 0 0" Padding="0" Click="RunBtn_Click" Command="{Binding RunUiCommand}">
  73. <Button.Style>
  74. <Style TargetType="Button">
  75. <Setter Property="Tag" Value="运行"/>
  76. <Setter Property="Content">
  77. <Setter.Value>
  78. <StackPanel Orientation="Horizontal" Margin="8 0">
  79. <icon:PackIconModern Kind="ControlPlay" VerticalAlignment="Center" Foreground="#28B60F" Width="8"/>
  80. <TextBlock Text="运行" Margin="4 0" VerticalAlignment="Center"/>
  81. </StackPanel>
  82. </Setter.Value>
  83. </Setter>
  84. <Style.Triggers>
  85. <DataTrigger Binding="{Binding IsRunning}" Value="True">
  86. <Setter Property="Tag" Value="停止"/>
  87. <Setter Property="Content">
  88. <Setter.Value>
  89. <StackPanel Orientation="Horizontal" Margin="8 0">
  90. <icon:PackIconModern Kind="ControlStop" VerticalAlignment="Center" Foreground="#B60F0F" Width="8"/>
  91. <TextBlock Text="停止" Margin="4 0" VerticalAlignment="Center"/>
  92. </StackPanel>
  93. </Setter.Value>
  94. </Setter>
  95. </DataTrigger>
  96. </Style.Triggers>
  97. </Style>
  98. </Button.Style>
  99. </Button>
  100. <Button x:Name="SaveBtn" Margin="16 0 0 0" Padding="0" Click="SaveBtn_Click">
  101. <StackPanel Orientation="Horizontal" Margin="8 0">
  102. <icon:PackIconModern Kind="Save" VerticalAlignment="Center" Width="12"/>
  103. <TextBlock Text="保存" Margin="4 0" VerticalAlignment="Center"/>
  104. </StackPanel>
  105. </Button>
  106. <Button x:Name="LoadBtn" Margin="4 0 0 0" Padding="0" Click="LoadBtn_Click">
  107. <StackPanel Orientation="Horizontal" Margin="8 0">
  108. <icon:PackIconModern Kind="DiskDownload" VerticalAlignment="Center" Width="14"/>
  109. <TextBlock Text="加载" Margin="4 0" VerticalAlignment="Center"/>
  110. </StackPanel>
  111. </Button>
  112. <Button x:Name="MNBtn" Margin="4 0 0 0" Padding="0" Click="MNBtn_Click">
  113. <StackPanel Orientation="Horizontal" Margin="8 0">
  114. <icon:PackIconModern Kind="MessageSend" VerticalAlignment="Center" Width="14"/>
  115. <TextBlock Text="模拟消息" Margin="4 0" VerticalAlignment="Center"/>
  116. </StackPanel>
  117. </Button>
  118. <ToggleButton x:Name="showCode" Click="showCode_Click" DockPanel.Dock="Right" Margin="4 0 0 0" Padding="4 0">
  119. <icon:Material Kind="FileCode"/>
  120. </ToggleButton>
  121. <Slider DockPanel.Dock="Right" Width="100" Maximum="16" Minimum="1" Margin="4 0 0 0"
  122. HorizontalContentAlignment="Center" Value="{Binding ElementName=cav,Path=GridPxiel}" ></Slider>
  123. <TextBlock DockPanel.Dock="Right" Text="对齐:" VerticalAlignment="Center" Margin="16 0 0 0"/>
  124. </DockPanel>
  125. <!--中间画布-->
  126. <Border BorderThickness="1" BorderBrush="{StaticResource AccentBrush}" Margin="4">
  127. <Border.Background>
  128. <ImageBrush ImageSource="../Images/bj.png" Stretch="UniformToFill"/>
  129. </Border.Background>
  130. <Grid>
  131. <Grid.ColumnDefinitions>
  132. <ColumnDefinition/>
  133. <ColumnDefinition Width="auto"/>
  134. </Grid.ColumnDefinitions>
  135. <ctl:CanvasPanel x:Name="cav" Visibility="{Binding CanvasPanelVisibility}" SelectedItem="{Binding CanSelectedItem,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" AllowDrop="True" RenderTransformOrigin="0.5,0.5" ClipToBounds="True" UseLayoutRounding="True" Focusable="True" SnapsToDevicePixels="True">
  136. <ctl:CanvasPanel.Background>
  137. <VisualBrush TileMode="Tile" Viewport="0,0,20,20" ViewportUnits="Absolute">
  138. <VisualBrush.Visual>
  139. <Rectangle Width="20" Height="20" StrokeDashArray="4,2" StrokeThickness="0.5" Stroke="#CBCBCB">
  140. <Rectangle.Style>
  141. <Style TargetType="{x:Type Rectangle}">
  142. <Style.Triggers>
  143. <DataTrigger Binding="{Binding UseAutoAlignment, RelativeSource={RelativeSource AncestorType={x:Type ctl:CanvasPanel}, Mode=FindAncestor}}" Value="True">
  144. <Setter Property="Visibility" Value="Visible"/>
  145. </DataTrigger>
  146. <DataTrigger Binding="{Binding UseAutoAlignment, RelativeSource={RelativeSource AncestorType={x:Type ctl:CanvasPanel}, Mode=FindAncestor}}" Value="False">
  147. <Setter Property="Visibility" Value="Collapsed"/>
  148. </DataTrigger>
  149. </Style.Triggers>
  150. </Style>
  151. </Rectangle.Style>
  152. </Rectangle>
  153. </VisualBrush.Visual>
  154. </VisualBrush>
  155. </ctl:CanvasPanel.Background>
  156. <ctl:CanvasPanel.RenderTransform>
  157. <TransformGroup>
  158. <TranslateTransform x:Name="CanvasTranslate"/>
  159. </TransformGroup>
  160. </ctl:CanvasPanel.RenderTransform>
  161. </ctl:CanvasPanel>
  162. <ctl:RunCanvas x:Name="runCanvas" Visibility="{Binding RunCanvasVisibility}" />
  163. <avae:TextEditor x:Name="codeEditor" ShowLineNumbers="True" Padding="4" WordWrap="True" IsReadOnly="True" SyntaxHighlighting="XML" BorderThickness="1 0 0 0" BorderBrush="{StaticResource ControlBorderBrush}" Grid.Column="1" Width="480" Visibility="{Binding ElementName=showCode, Path=IsChecked, Converter={x:Static s:BoolToVisibilityConverter.Instance}}"/>
  164. </Grid>
  165. </Border>
  166. </DockPanel>
  167. <GridSplitter HorizontalAlignment="Right" Grid.Column="1" VerticalAlignment="Stretch" Width="5" Background="Transparent"/>
  168. <!--右侧属性栏-->
  169. <Grid Grid.Column="2">
  170. <TabControl SelectedIndex="0">
  171. <TabItem Header="控制协议">
  172. <mypro:PropertyGrid x:Name="kzxy" SelectedObject="{Binding PropeObject}"
  173. Margin="10" ShowAdvancedOptions="True" ShowDescriptionByTooltip="True"
  174. FontSize="14" ShowTitle="False" ShowSortOptions="False" ShowSearchBox="False"
  175. CategoryGroupHeaderTemplate="{DynamicResource Category}">
  176. <mypro:PropertyGrid.EditorDefinitions>
  177. <!--EditorTemplateDefinition可添加多个-->
  178. <!--要修改编辑模板的属性的名称-->
  179. <mypro:EditorTemplateDefinition TargetProperties="点击事件,值改变事件,定时触发,勾选事件,取消勾选事件" >
  180. <mypro:EditorTemplateDefinition.EditingTemplate>
  181. <DataTemplate>
  182. <!--此处可自由发挥-->
  183. <Grid>
  184. <!-- Command生效: DataTemplate的DataContext指代不明确,需要改为父类的DataContext。 参数Value表示原对象-->
  185. <!--Command="{Binding Path=DataContext.PropeSetCommand ,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=xctk:PropertyGrid}}"-->
  186. <!--DataContext="{Binding DataContext, ElementName=window}" Command="{Binding PropeSetCommand}" CommandParameter="{Binding Value,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"-->
  187. <Grid.ColumnDefinitions>
  188. <ColumnDefinition Width="*" x:Name="key"/>
  189. <ColumnDefinition Width="35"/>
  190. </Grid.ColumnDefinitions>
  191. <TextBox Width="{Binding Width, ElementName=key}" Text="{Binding Value,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" TextWrapping="Wrap"></TextBox>
  192. <ToggleButton Grid.Column="1" Height="25" Content="编辑" Width="30" HorizontalAlignment="Left" Click="ToggleButton_Click"></ToggleButton>
  193. </Grid>
  194. </DataTemplate>
  195. </mypro:EditorTemplateDefinition.EditingTemplate>
  196. </mypro:EditorTemplateDefinition>
  197. <mypro:EditorTemplateDefinition TargetProperties="代码过滤脚本" >
  198. <mypro:EditorTemplateDefinition.EditingTemplate>
  199. <DataTemplate>
  200. <!--此处可自由发挥-->
  201. <ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto">
  202. <TextBox Text="{Binding Value,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" AcceptsReturn="True" TextWrapping="Wrap"></TextBox>
  203. </ScrollViewer>
  204. </DataTemplate>
  205. </mypro:EditorTemplateDefinition.EditingTemplate>
  206. </mypro:EditorTemplateDefinition>
  207. <mypro:EditorTemplateDefinition TargetProperties="设备解析变量" >
  208. <mypro:EditorTemplateDefinition.EditingTemplate>
  209. <DataTemplate>
  210. <!--此处可自由发挥-->
  211. <Grid>
  212. <ComboBox Grid.Column="1" Height="25" Width="{Binding Width, ElementName=com}" Text="{Binding Value,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"
  213. ItemsSource="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=Window},Path=DataContext.DevValueList}"
  214. ></ComboBox>
  215. </Grid>
  216. </DataTemplate>
  217. </mypro:EditorTemplateDefinition.EditingTemplate>
  218. </mypro:EditorTemplateDefinition>
  219. <mypro:EditorTemplateDefinition TargetProperties="设备名称" >
  220. <mypro:EditorTemplateDefinition.EditingTemplate>
  221. <DataTemplate>
  222. <!--此处可自由发挥-->
  223. <Grid>
  224. <ComboBox Grid.Column="1" Height="25" Width="{Binding Width, ElementName=com}" Text="{Binding Value,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"
  225. ItemsSource="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=Window},Path=DataContext.DevNameList}"
  226. ></ComboBox>
  227. </Grid>
  228. </DataTemplate>
  229. </mypro:EditorTemplateDefinition.EditingTemplate>
  230. </mypro:EditorTemplateDefinition>
  231. <mypro:EditorTemplateDefinition TargetProperties="文本,文本1,标题,变量,勾选状态" >
  232. <mypro:EditorTemplateDefinition.EditingTemplate>
  233. <DataTemplate>
  234. <!--此处可自由发挥-->
  235. <Grid>
  236. <Grid.RowDefinitions>
  237. <RowDefinition/>
  238. <RowDefinition/>
  239. </Grid.RowDefinitions>
  240. <Grid Margin="0,5,0,5">
  241. <Grid.ColumnDefinitions>
  242. <ColumnDefinition Width="40" />
  243. <ColumnDefinition Width="*" x:Name="key"/>
  244. <ColumnDefinition Width="*" x:Name="Text"/>
  245. </Grid.ColumnDefinitions>
  246. <TextBlock>绑定:</TextBlock>
  247. <ComboBox x:Name="namebox" DropDownOpened="namebox_DropDownOpened" Grid.Column="1" Height="25" IsTextSearchEnabled="True" IsEditable="True" Tag="{Binding Text, ElementName=valuebox}" TextBoxBase.TextChanged="ComboBoxName_TextChanged"
  248. ItemsSource="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=Window},Path=DataContext.DevNameList}">
  249. </ComboBox>
  250. <ComboBox x:Name="valuebox" DropDownOpened="valuebox_DropDownOpened" Grid.Column="2" Height="25" IsTextSearchEnabled="True" IsEditable="True" Tag="{Binding Text, ElementName=namebox}" TextBoxBase.TextChanged="ComboBoxValue_TextChanged"
  251. ItemsSource="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=Window},Path=DataContext.DevValueList}"/>
  252. </Grid>
  253. <TextBox Grid.Row="2" x:Name="wenben" Padding="5" Text="{Binding Value,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" TextWrapping="Wrap"></TextBox>
  254. </Grid>
  255. </DataTemplate>
  256. </mypro:EditorTemplateDefinition.EditingTemplate>
  257. </mypro:EditorTemplateDefinition>
  258. </mypro:PropertyGrid.EditorDefinitions>
  259. </mypro:PropertyGrid>
  260. </TabItem>
  261. <TabItem Header="控件样式">
  262. <mypro:PropertyGrid x:Name="dsdsdsd"
  263. Margin="10" ShowAdvancedOptions="True" ShowDescriptionByTooltip="True"
  264. FontSize="14" ShowTitle="False" ShowSortOptions="False" ShowSearchBox="False"
  265. CategoryGroupHeaderTemplate="{DynamicResource Category}" SelectedObject="{Binding SelectedItem,ElementName=cav,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" />
  266. </TabItem>
  267. </TabControl>
  268. </Grid>
  269. </Grid>
  270. </UserControl>