PlotView.xaml 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  1. <UserControl x:Class="Aitex.UI.Charting.View.PlotView"
  2. xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  3. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  4. xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
  5. xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  6. xmlns:sciChart="http://schemas.abtsoftware.co.uk/scichart"
  7. xmlns:conv="clr-namespace:Aitex.UI.Charting.Converter"
  8. mc:Ignorable="d"
  9. d:DesignHeight="408" d:DesignWidth="880" FontFamily="Arial,SimSun" FontSize="11">
  10. <UserControl.Resources>
  11. <Style TargetType="{x:Type Label}">
  12. <Setter Property="Foreground" Value="Black"/>
  13. </Style>
  14. <conv:Visibility2boolConverter x:Key="vis2bool" />
  15. <conv:MouseWheelZoomXConverter x:Key="mouseWheelZoomXConverter"/>
  16. <conv:MouseWheelZoomYConverter x:Key="mouseWheelZoomYConverter"/>
  17. <conv:boolReverseConverter x:Key="boolReverseConverter"/>
  18. <conv:bool2VisibilityConverter x:Key="bool2VisibilityConverter"/>
  19. <conv:PanEnableConverter x:Key="panEnableConverter"/>
  20. <conv:Bools2BoolConverter x:Key="bools2BoolConverter"/>
  21. <conv:RolloverDataTimeConverter x:Key="rolloverDataTimeConverter"/>
  22. <conv:RolloverDataValueConverter x:Key="rolloverDataValueConverter"/>
  23. <conv:ColorToBrushConverter x:Key="ColorToBrushConverter"/>
  24. <conv:RolloverDataPointerInfoConverter x:Key="rolloverDataPointerInfoConverter"/>
  25. <!-- Template for the RolloverModifier tooltip to display AxisInfo collection (result of hit test) -->
  26. <ControlTemplate x:Key="RolloverLabelTemplate" TargetType="sciChart:TemplatableControl">
  27. <Border Background="#AAFFFFFF" BorderBrush="{Binding SeriesColor, Converter={StaticResource ColorToBrushConverter}}" BorderThickness="2" CornerRadius="5">
  28. <StackPanel Margin="5">
  29. <TextBlock FontSize="12" FontWeight="Bold" Foreground="{Binding SeriesColor, Converter={StaticResource ColorToBrushConverter}}" Text="{Binding SeriesName}"/>
  30. <TextBlock FontSize="11" Foreground="{Binding SeriesColor, Converter={StaticResource ColorToBrushConverter}}">
  31. <TextBlock.Text>
  32. <MultiBinding Converter="{StaticResource rolloverDataPointerInfoConverter}">
  33. <Binding Path="XValue"/>
  34. <Binding Path="Value"/>
  35. <Binding Path="RenderableSeries"/>
  36. </MultiBinding>
  37. </TextBlock.Text>
  38. </TextBlock>
  39. </StackPanel>
  40. </Border>
  41. </ControlTemplate>
  42. </UserControl.Resources>
  43. <Grid Name="chartingView_Top">
  44. <Grid.RowDefinitions>
  45. <RowDefinition Height="auto" />
  46. <RowDefinition Height="400*" />
  47. </Grid.RowDefinitions>
  48. <StackPanel Grid.Row="0" Height="22" Orientation="Horizontal" Background="LightGray">
  49. <Button Width="115" BorderThickness="0.1" Padding="0" IsTabStop="False"
  50. Focusable="False" Command="{Binding CommonViewModel.Switch2DataCfgViewCommand}"
  51. ToolTip="{DynamicResource GlobalLableConfigDataInfo}" Name="dataButton">
  52. <Button.Content>
  53. <StackPanel Orientation="Horizontal">
  54. <Image Source="/DataAnalysisControl;component/Charting/Images/Data.png" Stretch="Fill" Height="16" Width="16" HorizontalAlignment="Left" />
  55. <Label Content="{DynamicResource GlobalLableConfigData}" VerticalContentAlignment="Center" Padding="0" />
  56. </StackPanel>
  57. </Button.Content>
  58. </Button>
  59. <Button Width="75" BorderThickness="0.1" Padding="0" IsTabStop="False" Click="showAllButton_Click"
  60. Focusable="False"
  61. ToolTip=" {DynamicResource GlobalLableDisplayAllData} " Name="showAllButton">
  62. <Button.Content>
  63. <StackPanel Orientation="Horizontal">
  64. <Image Source="/DataAnalysisControl;component/Charting/Images/zoom_all.png" Stretch="Fill" Height="16" Width="16" HorizontalAlignment="Left" />
  65. <Label Content=" 1:1 " VerticalContentAlignment="Center" Padding="0" />
  66. </StackPanel>
  67. </Button.Content>
  68. </Button>
  69. <ToggleButton Width="75" BorderThickness="0.1" Padding="0" IsTabStop="False"
  70. Focusable="False" IsChecked="True"
  71. ToolTip="{DynamicResource GlobalLableDisplayValueInfo}" Name="rolloverButton">
  72. <ToggleButton.Content>
  73. <StackPanel Orientation="Horizontal">
  74. <Image Source="/DataAnalysisControl;component/Charting/Images/legend.png" Stretch="Fill" Height="16" Width="16" HorizontalAlignment="Left" />
  75. <Label Content="{DynamicResource GlobalLableDisplayValue}" VerticalContentAlignment="Center" Padding="0" />
  76. </StackPanel>
  77. </ToggleButton.Content>
  78. </ToggleButton>
  79. <ToggleButton Width="75" BorderThickness="0.1" Padding="0" IsTabStop="False" x:Name="toggleVerticalLine"
  80. Focusable="False"
  81. ToolTip=""
  82. Command="{Binding ToggleVerticalLineCommand}" CommandParameter="{Binding ElementName=vertical_Line1,Path=IsHidden}">
  83. <ToggleButton.IsChecked>
  84. <MultiBinding Converter="{StaticResource bools2BoolConverter}">
  85. <Binding ElementName="vertical_Line1" Path="IsHidden" Mode="OneWay"/>
  86. <Binding ElementName="vertical_Line2" Path="IsHidden" Mode="OneWay"/>
  87. </MultiBinding>
  88. </ToggleButton.IsChecked>
  89. <ToggleButton.Content>
  90. <StackPanel Orientation="Horizontal">
  91. <Image Source="/DataAnalysisControl;component/Charting/Images/VerticalLine.png" Stretch="Fill" Height="16" Width="16" HorizontalAlignment="Left" />
  92. <Label Content="{DynamicResource GlobalLableDisplayRuler}" VerticalContentAlignment="Center" Padding="0" />
  93. </StackPanel>
  94. </ToggleButton.Content>
  95. </ToggleButton>
  96. <ToggleButton Width="90" BorderThickness="0.1" Padding="0" IsTabStop="False" Focusable="False" Command="{Binding ToggleXWheelZoomCommand}"
  97. ToolTip="{DynamicResource GlobalLableZoomXInfo}">
  98. <ToggleButton.IsChecked>
  99. <MultiBinding Converter="{StaticResource mouseWheelZoomXConverter}" Mode="OneWay">
  100. <Binding ElementName="mouseWheelZoomModifier" Path="XyDirection"/>
  101. <Binding ElementName="mouseWheelZoomModifier" Path="IsEnabled"/>
  102. </MultiBinding>
  103. </ToggleButton.IsChecked>
  104. <ToggleButton.Content>
  105. <StackPanel Orientation="Horizontal">
  106. <Image Source="/DataAnalysisControl;component/Charting/Images/ZoomX.png" Stretch="Fill" Height="16" Width="16" HorizontalAlignment="Left" />
  107. <Label Content="{DynamicResource GlobalLableZoomX}" VerticalContentAlignment="Center" Padding="0" />
  108. </StackPanel>
  109. </ToggleButton.Content>
  110. </ToggleButton>
  111. <ToggleButton Width="90" BorderThickness="0.1" Padding="0" IsTabStop="False" Focusable="False" Command="{Binding ToggleYWheelZoomCommand}"
  112. ToolTip="{DynamicResource GlobalLableZoomYInfo}">
  113. <ToggleButton.IsChecked>
  114. <MultiBinding Converter="{StaticResource mouseWheelZoomYConverter}" Mode="OneWay">
  115. <Binding ElementName="mouseWheelZoomModifier" Path="XyDirection"/>
  116. <Binding ElementName="mouseWheelZoomModifier" Path="IsEnabled"/>
  117. </MultiBinding>
  118. </ToggleButton.IsChecked>
  119. <ToggleButton.Content>
  120. <StackPanel Orientation="Horizontal">
  121. <Image Source="/DataAnalysisControl;component/Charting/Images/ZoomY.png" Stretch="Fill" Height="16" Width="16" HorizontalAlignment="Left" />
  122. <Label Content="{DynamicResource GlobalLableZoomY}" VerticalContentAlignment="Center" Padding="0" />
  123. </StackPanel>
  124. </ToggleButton.Content>
  125. </ToggleButton>
  126. <ToggleButton Width="75" BorderThickness="0.1" Padding="0" IsTabStop="False" Focusable="False" Command="{Binding ToggleOverViewPanel}" IsChecked="{Binding IsOverViewPanelVisable,Mode=OneWay}"
  127. ToolTip="{DynamicResource GlobalLablePreviewWindowInfo}">
  128. <ToggleButton.Content>
  129. <StackPanel Orientation="Horizontal">
  130. <Image Source="/DataAnalysisControl;component/Charting/Images/x_overview.png" Stretch="Fill" Height="19" Width="19" HorizontalAlignment="Left" />
  131. <Label Content="{DynamicResource GlobalLablePreviewWindow}" VerticalContentAlignment="Center" Padding="0" />
  132. </StackPanel>
  133. </ToggleButton.Content>
  134. </ToggleButton>
  135. <ToggleButton Width="75" BorderThickness="0.1" Padding="0" IsTabStop="False" Focusable="False" IsChecked="{Binding CommonViewModel.IsDataConfigVisiable,Mode=OneWay}" Command="{Binding CommonViewModel.ToggleDataDisplayPanelCommand}"
  136. ToolTip="{DynamicResource GlobalLableDatasetInfo}">
  137. <ToggleButton.Content>
  138. <StackPanel Orientation="Horizontal">
  139. <Image Source="/DataAnalysisControl;component/Charting/Images/data_config.png" Stretch="Fill" Height="16" Width="16" HorizontalAlignment="Left" />
  140. <Label Content="{DynamicResource GlobalLableDataset}" VerticalContentAlignment="Center" Padding="0" />
  141. </StackPanel>
  142. </ToggleButton.Content>
  143. </ToggleButton>
  144. </StackPanel>
  145. <Grid Name="chartingView_Top_RightRenderingView" Grid.Row="1">
  146. <Grid.RowDefinitions>
  147. <RowDefinition Height="500*" />
  148. <RowDefinition Height="{Binding OverViewPanelHeight}" />
  149. </Grid.RowDefinitions>
  150. <!-- Create the chart surface -->
  151. <sciChart:SciChartSurface Name="sciChart" RenderableSeries="{Binding CommonViewModel.RenderableSeries}"
  152. sciChart:ThemeManager.Theme="ExpressionLight"
  153. ClipToBounds="False"
  154. Padding="0,0,3,0"
  155. MouseDoubleClick="sciChart_MouseDoubleClick"
  156. DebugWhyDoesntSciChartRender="False">
  157. <!-- Create an X Axis -->
  158. <sciChart:SciChartSurface.XAxis>
  159. <sciChart:DateTimeAxis DrawMinorTicks="True"
  160. DrawMinorGridLines="True"
  161. Margin="0,0,0,0"
  162. SubDayTextFormatting="MM/dd HH:mm:ss"
  163. TitleFontSize="10"
  164. TextFormatting="yyyy/MM/dd HH:mm:ss"
  165. Id="DefaultAxisId"/>
  166. </sciChart:SciChartSurface.XAxis>
  167. <!-- Create a Y Axis -->
  168. <sciChart:SciChartSurface.YAxis>
  169. <sciChart:NumericAxis DrawMinorTicks="True"
  170. DrawMinorGridLines="True"
  171. AxisAlignment="Right"
  172. Id="DefaultAxisId">
  173. <sciChart:NumericAxis.GrowBy>
  174. <sciChart:DoubleRange Min="0.1" Max="0.1"/>
  175. </sciChart:NumericAxis.GrowBy>
  176. </sciChart:NumericAxis>
  177. </sciChart:SciChartSurface.YAxis>
  178. <!-- Vertical Lines Annotations-->
  179. <sciChart:SciChartSurface.Annotations>
  180. <sciChart:VerticalLineAnnotation x:Name="vertical_Line1" X1="{Binding CommonViewModel.Time1,Mode=TwoWay}" X2="{Binding CommonViewModel.Time1,Mode=TwoWay}" Stroke="Red" VerticalAlignment="Stretch" ShowLabel="True" StrokeThickness="1.5" IsEditable="True" LabelTextFormatting="yyyy/MM/dd HH:mm:ss" IsHidden="True" LabelPlacement="Top" FontSize="10" />
  181. <sciChart:VerticalLineAnnotation x:Name="vertical_Line2" X1="{Binding CommonViewModel.Time2,Mode=TwoWay}" X2="{Binding CommonViewModel.Time2,Mode=TwoWay}" Stroke="Purple" VerticalAlignment="Stretch" ShowLabel="True" StrokeThickness="1.5" IsEditable="True" LabelTextFormatting="yyyy/MM/dd HH:mm:ss" IsHidden="True" LabelPlacement="Bottom" FontSize="10" />
  182. </sciChart:SciChartSurface.Annotations>
  183. <!-- Specify interactivity modifiers -->
  184. <sciChart:SciChartSurface.ChartModifier>
  185. <sciChart:ModifierGroup ExecuteOn="MouseDoubleClick">
  186. <!-- Provides selection of series and custom styling to the selected series -->
  187. <sciChart:SeriesSelectionModifier ExecuteOn="MouseLeftButton" ReceiveHandledEvents="True">
  188. <sciChart:SeriesSelectionModifier.SelectedSeriesStyle>
  189. <Style TargetType="sciChart:BaseRenderableSeries">
  190. <Setter Property="SeriesColor" Value="Red"/>
  191. <Setter Property="PointMarkerTemplate">
  192. <Setter.Value>
  193. <ControlTemplate>
  194. <Ellipse Fill="#FFAA00AA" Stroke="Red" Width="8" Height="8"/>
  195. </ControlTemplate>
  196. </Setter.Value>
  197. </Setter>
  198. </Style>
  199. </sciChart:SeriesSelectionModifier.SelectedSeriesStyle>
  200. </sciChart:SeriesSelectionModifier>
  201. <sciChart:RubberBandXyZoomModifier x:Name="rubberBandZoomModifier" IsEnabled="True"
  202. IsXAxisOnly="False"
  203. ZoomExtentsY="False"
  204. IsAnimated="True" ExecuteOn="MouseLeftButton" ReceiveHandledEvents="True" />
  205. <!--<sciChart:ZoomExtentsModifier x:Name="zoomExtentsModifier" ExecuteOn="MouseDoubleClick"/>-->
  206. <!-- Provides a data source for the legend control -->
  207. <sciChart:LegendModifier GetLegendDataFor="AllSeries" x:Name="legendModifier"/>
  208. <!--<sciChart:RubberBandXyZoomModifier IsEnabled="True" IsXAxisOnly="True"/>-->
  209. <!--<sciChart:CursorModifier IsEnabled="True"
  210. ShowAxisLabels="True"
  211. ShowTooltip="True" />-->
  212. <!--自由平移-->
  213. <sciChart:ZoomPanModifier x:Name="zoomPanModifier" IsEnabled="True" ExecuteOn="MouseRightButton" ClipModeX="None" />
  214. <!--移动鼠标时动态显示当前数据值-->
  215. <sciChart:RolloverModifier x:Name="rolloverModifier"
  216. UseInterpolation="False" FontSize="9" IsEnabled="True"
  217. DrawVerticalLine="False" FontFamily="Arial,SimSun"
  218. SnapsToDevicePixels="False"
  219. TooltipLabelTemplate="{StaticResource RolloverLabelTemplate}" ShowAxisLabels="False" />
  220. <!--<sciChart:LegendModifier x:Name="legendModifier" GetLegendDataFor="AllSeries"/>-->
  221. <!--<sciChart:RubberBandXyZoomModifier IsXAxisOnly="True"/>-->
  222. <!--<sciChart:XAxisDragModifier/>-->
  223. <!--<sciChart:YAxisDragModifier/>-->
  224. <!--<sciChart:ZoomExtentsModifier ExecuteOn="MouseDoubleClick"/>--> <!--双击自动显示全部视图-->
  225. <!--<sciChart:ZoomPanModifier ExecuteOn="MouseLeftButton"/>-->
  226. <!--
  227. <sciChart:XAxisDragModifier x:Name="xAxisDragModifier" IsEnabled="True" ClipModeX="None"/>
  228. <sciChart:YAxisDragModifier x:Name="yAxisRightDragmodifier" IsEnabled="True" YAxisId="DefaultAxisId"/>
  229. -->
  230. <sciChart:MouseWheelZoomModifier x:Name="mouseWheelZoomModifier" XyDirection="XDirection"/> <!--滚轮滚动进行缩放操作-->
  231. <!--
  232. <sciChart:ZoomPanModifier ReceiveHandledEvents="True"></sciChart:ZoomPanModifier>
  233. <sciChart:ZoomExtentsModifier ExecuteOn="MouseDoubleClick"/>
  234. -->
  235. </sciChart:ModifierGroup>
  236. </sciChart:SciChartSurface.ChartModifier>
  237. </sciChart:SciChartSurface>
  238. <sciChart:SciChartLegend x:Name="legendControl" Visibility="Hidden"
  239. Grid.Row="0" Margin="5,5" ShowVisibilityCheckboxes="True"
  240. LegendData="{Binding LegendData, ElementName=legendModifier, Mode=OneWay}"
  241. FontSize="10" FontWeight="Light" />
  242. <sciChart:SciChartOverview Grid.Row="1"
  243. ParentSurface="{Binding ElementName=sciChart}"
  244. SelectedRange="{Binding ElementName=sciChart, Path=XAxis.VisibleRange, Mode=TwoWay}"
  245. sciChart:ThemeManager.Theme="ExpressionLight" BorderThickness="0,1,0,0" />
  246. <!-- Define a panel to display rollover results -->
  247. <Border BorderBrush="#55000000" BorderThickness="2" Background="#77FFFFFF"
  248. VerticalAlignment="Top" CornerRadius="5"
  249. Margin="5,5,50,0" Padding="2" HorizontalAlignment="Left"
  250. Visibility="{Binding ElementName=rolloverButton,Path=IsChecked,Converter={StaticResource bool2VisibilityConverter}}">
  251. <ItemsControl DataContext="{Binding ElementName=rolloverModifier}"
  252. ItemsSource="{Binding SeriesData.SeriesInfo}">
  253. <ItemsControl.ItemTemplate>
  254. <DataTemplate>
  255. <Grid Height="13" Opacity="0.9">
  256. <Grid.ColumnDefinitions>
  257. <ColumnDefinition Width="20"/>
  258. <ColumnDefinition Width="126"/>
  259. <ColumnDefinition Width="110"/>
  260. <ColumnDefinition Width="*"/>
  261. </Grid.ColumnDefinitions>
  262. <TextBlock Grid.Column="0" Background="{Binding SeriesColor, Converter={StaticResource ColorToBrushConverter}}" Text=" " Margin="0" Height="8" />
  263. <TextBlock Grid.Column="1" Text="{Binding XValue,Converter={StaticResource rolloverDataTimeConverter}}" Margin="0" FontSize="9" FontFamily="Arial,SimSun" />
  264. <TextBlock Grid.Column="2" Margin="0" FontSize="9" FontFamily="Arial,SimSun">
  265. <TextBlock.Text>
  266. <MultiBinding Converter="{StaticResource rolloverDataValueConverter}">
  267. <Binding Path="Value"/>
  268. <Binding Path="RenderableSeries"/>
  269. </MultiBinding>
  270. </TextBlock.Text>
  271. </TextBlock>
  272. <TextBlock Grid.Column="3" Text="{Binding SeriesName}" Margin="0" FontSize="9" FontFamily="Arial,SimSun" HorizontalAlignment="Left"/>
  273. </Grid>
  274. </DataTemplate>
  275. </ItemsControl.ItemTemplate>
  276. </ItemsControl>
  277. </Border>
  278. </Grid>
  279. </Grid>
  280. </UserControl>