/V2.2/trunk/ChartControls/themes/generic.xaml

# · XAML · 241 lines · 232 code · 9 blank · 0 comment · 0 complexity · e0fb2d30bf1f3e0e32cb7d3edbe8edfc MD5 · raw file

  1. <ResourceDictionary
  2. xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  3. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  4. xmlns:local="clr-namespace:StockTraderRI.ChartControls"
  5. >
  6. <local:ColorConverter x:Key="ColorConverter"/>
  7. <Pen x:Key="AxisPen" Thickness="1.0" Brush="Black"/>
  8. <Style x:Key="{x:Type local:ChartLines}" TargetType="{x:Type local:ChartLines}">
  9. <Setter Property="ClipToBounds" Value="True"/>
  10. </Style>
  11. <Style x:Key="{x:Type local:DiscreteAxis}" TargetType="{x:Type local:DiscreteAxis}">
  12. <Setter Property="Template">
  13. <Setter.Value>
  14. <ControlTemplate>
  15. <ItemsPresenter/>
  16. </ControlTemplate>
  17. </Setter.Value>
  18. </Setter>
  19. <Setter Property="ItemsPanel">
  20. <Setter.Value>
  21. <ItemsPanelTemplate>
  22. <local:DiscreteAxisPanel Orientation="{Binding RelativeSource={RelativeSource AncestorType={x:Type local:DiscreteAxis}}, Path=Orientation}"
  23. TickMarksLength="{Binding RelativeSource={RelativeSource AncestorType={x:Type local:DiscreteAxis}}, Path=TickLength}"/>
  24. </ItemsPanelTemplate>
  25. </Setter.Value>
  26. </Setter>
  27. <Setter Property="Orientation" Value="Horizontal"/>
  28. </Style>
  29. <Style x:Key="{x:Type local:ContinuousAxis}" TargetType="{x:Type local:ContinuousAxis}">
  30. <Setter Property="Template">
  31. <Setter.Value>
  32. <ControlTemplate>
  33. <ItemsPresenter/>
  34. </ControlTemplate>
  35. </Setter.Value>
  36. </Setter>
  37. <Setter Property="ItemsPanel">
  38. <Setter.Value>
  39. <ItemsPanelTemplate>
  40. <local:ContinuousAxisPanel Orientation="{Binding RelativeSource={RelativeSource AncestorType={x:Type local:ContinuousAxis}}, Path=Orientation}"/>
  41. </ItemsPanelTemplate>
  42. </Setter.Value>
  43. </Setter>
  44. <Setter Property="ReferenceLineSeperation" Value="50.0"/>
  45. </Style>
  46. <Style x:Key="{x:Type local:LineChart}" TargetType="{x:Type local:LineChart}">
  47. <Setter Property="Template">
  48. <Setter.Value>
  49. <ControlTemplate TargetType="{x:Type local:LineChart}">
  50. <Border Background="{TemplateBinding Background}"
  51. BorderThickness="{TemplateBinding BorderThickness}"
  52. BorderBrush="{TemplateBinding BorderBrush}">
  53. <Grid>
  54. <Grid.RowDefinitions>
  55. <RowDefinition Height="Auto"/>
  56. <RowDefinition/>
  57. </Grid.RowDefinitions>
  58. <Grid.ColumnDefinitions>
  59. <ColumnDefinition/>
  60. </Grid.ColumnDefinitions>
  61. <ContentPresenter ContentSource="Title" HorizontalAlignment="Center"/>
  62. <Grid Grid.Row="1">
  63. <Grid.RowDefinitions>
  64. <RowDefinition/>
  65. <RowDefinition Height="Auto"/>
  66. <RowDefinition Height="Auto"/>
  67. </Grid.RowDefinitions>
  68. <Grid.ColumnDefinitions>
  69. <ColumnDefinition Width="Auto"/>
  70. <ColumnDefinition Width="Auto"/>
  71. <ColumnDefinition/>
  72. </Grid.ColumnDefinitions>
  73. <Grid.Resources>
  74. <local:ValueExtractor x:Key="extractor" Items="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Items}"
  75. ValuePath="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=ValuePath}"/>
  76. <local:LabelExtractor x:Key="labelextractor" Items="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Items}"
  77. LabelPath="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=LabelPath}"/>
  78. </Grid.Resources>
  79. <local:DiscreteAxis Name="HAxis" Grid.Row="1" Grid.Column="2"
  80. ItemsSource="{Binding Source={StaticResource labelextractor}, Path=Labels}"
  81. ItemTemplate="{TemplateBinding LabelAxisItemTemplate}"
  82. ItemTemplateSelector="{TemplateBinding LabelAxisItemTemplateSelector}"
  83. TickLength="{TemplateBinding TickLength}"/>
  84. <local:ContinuousAxis Name="VAxis" Grid.Row="0" Grid.Column="1"
  85. SourceValues="{Binding Source={StaticResource extractor}, Path=Values}"
  86. ItemTemplate="{TemplateBinding ValueAxisItemTemplate}"
  87. ItemTemplateSelector="{TemplateBinding ValueAxisItemTemplateSelector}"/>
  88. <local:ChartLines Grid.Row="0" Grid.Column="2"
  89. VerticalAxisTickPositions="{Binding ElementName=VAxis, Path=TickPositions}"
  90. HorizontalAxisTickPositions="{Binding ElementName=HAxis, Path=TickPositions}"
  91. HorizontalAxis="{Binding ElementName=VAxis, Path=Origin}"
  92. VerticalAxis="{Binding ElementName=HAxis, Path=Origin}"
  93. DrawVerticalAxisTickMarks="{TemplateBinding ShowValueAxisTicks}"
  94. DrawHorizontalAxisTickMarks="{TemplateBinding ShowLabelAxisTicks}"
  95. DrawVerticalAxisReferenceLines="{TemplateBinding ShowValueAxisReferenceLines}"
  96. DrawHorizontalAxisReferenceLines="{TemplateBinding ShowLabelAxisReferenceLines}"
  97. ReferenceLinePen="{TemplateBinding ReferenceLinePen}"
  98. TickMarksLength="{TemplateBinding TickLength}"
  99. ClipToBounds="true"/>
  100. <ItemsPresenter Grid.Row="0" Grid.Column="2"
  101. local:LineChartPanel.XValues="{Binding ElementName=HAxis, Path=TickPositions}"
  102. local:LineChartPanel.YValues="{Binding ElementName=VAxis, Path=Values}"
  103. local:LineChartPanel.HorizontalAxis="{Binding ElementName=VAxis, Path=Origin}"
  104. ClipToBounds="true"/>
  105. <ContentPresenter Grid.Row="2" Grid.Column="2" HorizontalAlignment="Center" VerticalAlignment="Center"
  106. ContentSource="LabelAxisTitle"/>
  107. <ContentPresenter Grid.Row="0" Grid.Column="0" HorizontalAlignment="Center" VerticalAlignment="Center"
  108. ContentSource="ValueAxisTitle"/>
  109. </Grid>
  110. </Grid>
  111. </Border>
  112. </ControlTemplate>
  113. </Setter.Value>
  114. </Setter>
  115. <Setter Property="ItemsPanel">
  116. <Setter.Value>
  117. <ItemsPanelTemplate>
  118. <local:LineChartPanel XValues="{TemplateBinding local:LineChartPanel.XValues}"
  119. YValues="{TemplateBinding local:LineChartPanel.YValues}"
  120. HorizontalAxis="{TemplateBinding local:LineChartPanel.HorizontalAxis}"
  121. LinePen="{Binding RelativeSource={RelativeSource AncestorType={x:Type local:LineChart}}, Path=LinePen}"
  122. AreaBrush="{Binding RelativeSource={RelativeSource AncestorType={x:Type local:LineChart}}, Path=AreaBrush}"
  123. IsSmoothOutline="{Binding RelativeSource={RelativeSource AncestorType={x:Type local:LineChart}}, Path=IsSmoothOutline}"/>
  124. </ItemsPanelTemplate>
  125. </Setter.Value>
  126. </Setter>
  127. <Setter Property="ItemTemplate">
  128. <Setter.Value>
  129. <DataTemplate>
  130. <Rectangle Fill="{Binding RelativeSource={RelativeSource AncestorType={x:Type ContentControl}}, Converter={StaticResource ColorConverter}}"
  131. Width="5" Height="5" Opacity="0.8"/>
  132. </DataTemplate>
  133. </Setter.Value>
  134. </Setter>
  135. <Setter Property="TickLength" Value="5.0"/>
  136. <Setter Property="LinePen" Value="{StaticResource AxisPen}"/>
  137. <Setter Property="ReferenceLinePen" Value="{StaticResource AxisPen}"/>
  138. <Setter Property="IsSmoothOutline" Value="False"/>
  139. <Setter Property="ShowLabelAxisTicks" Value="True"/>
  140. <Setter Property="ShowLabelAxisReferenceLines" Value="False"/>
  141. <Setter Property="ShowValueAxisTicks" Value="True"/>
  142. <Setter Property="ShowValueAxisReferenceLines" Value="True"/>
  143. </Style>
  144. <Style x:Key="{x:Type local:PieChart}" TargetType="{x:Type local:PieChart}">
  145. <Setter Property="ItemsPanel">
  146. <Setter.Value>
  147. <ItemsPanelTemplate>
  148. <local:PiePanel Values="{TemplateBinding local:PiePanel.Values}"/>
  149. </ItemsPanelTemplate>
  150. </Setter.Value>
  151. </Setter>
  152. <Setter Property="Template">
  153. <Setter.Value>
  154. <ControlTemplate TargetType="{x:Type local:PieChart}">
  155. <Border Background="{TemplateBinding Background}"
  156. BorderThickness="{TemplateBinding BorderThickness}"
  157. BorderBrush="{TemplateBinding BorderBrush}">
  158. <Grid>
  159. <Grid.RowDefinitions>
  160. <RowDefinition Height="Auto"/>
  161. <RowDefinition/>
  162. </Grid.RowDefinitions>
  163. <Grid.ColumnDefinitions>
  164. <ColumnDefinition/>
  165. </Grid.ColumnDefinitions>
  166. <ContentPresenter ContentSource="Title" HorizontalAlignment="Center"/>
  167. <Grid Grid.Row="1">
  168. <Grid.RowDefinitions>
  169. <RowDefinition/>
  170. <RowDefinition Height="Auto"/>
  171. </Grid.RowDefinitions>
  172. <Grid.ColumnDefinitions>
  173. <ColumnDefinition/>
  174. <ColumnDefinition Width="Auto"/>
  175. </Grid.ColumnDefinitions>
  176. <Grid.Resources>
  177. <local:ValueExtractor x:Key="extractor" Items="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Items}"
  178. ValuePath="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=ValuePath}"/>
  179. <local:LabelExtractor x:Key="labelextractor" Items="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Items}"
  180. LabelPath="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=LabelPath}"/>
  181. </Grid.Resources>
  182. <ContentPresenter Grid.Row="1" Grid.Column="0" ContentSource="ValueTitle"/>
  183. <ContentPresenter Grid.Row="1" Grid.Column="1" ContentSource="LabelTitle"/>
  184. <ItemsPresenter Grid.Row="0" Grid.Column="0" local:PiePanel.Values="{Binding Source={StaticResource extractor}, Path=Values}"/>
  185. <ItemsControl Grid.Row="0" Grid.Column="1" HorizontalAlignment="Left" VerticalAlignment="Center"
  186. ItemsSource="{Binding Source={StaticResource labelextractor}, Path=Labels}"
  187. ItemTemplate="{TemplateBinding LegendItemTemplate}"
  188. ItemTemplateSelector="{TemplateBinding LegendItemTemplateSelector}"/>
  189. </Grid>
  190. </Grid>
  191. </Border>
  192. </ControlTemplate>
  193. </Setter.Value>
  194. </Setter>
  195. <Setter Property="ItemContainerStyle">
  196. <Setter.Value>
  197. <Style TargetType="{x:Type local:ChartItem}">
  198. <Setter Property="Template">
  199. <Setter.Value>
  200. <ControlTemplate TargetType="{x:Type local:ChartItem}">
  201. <local:ClipWedge WedgeAngle ="{TemplateBinding local:PiePanel.WedgeAngle}"
  202. BeginFigurePoint ="{TemplateBinding local:PiePanel.BeginFigurePoint}"
  203. LineToPoint="{TemplateBinding local:PiePanel.LineToPoint}"
  204. Content="{TemplateBinding Content}"
  205. ContentTemplate="{TemplateBinding ContentTemplate}">
  206. </local:ClipWedge>
  207. </ControlTemplate>
  208. </Setter.Value>
  209. </Setter>
  210. </Style>
  211. </Setter.Value>
  212. </Setter>
  213. <Setter Property="ItemTemplate">
  214. <Setter.Value>
  215. <DataTemplate>
  216. <Rectangle Fill="{Binding RelativeSource={RelativeSource AncestorType={x:Type ContentControl}, AncestorLevel=2}, Converter={StaticResource ColorConverter}}"
  217. Opacity="0.8"/>
  218. </DataTemplate>
  219. </Setter.Value>
  220. </Setter>
  221. <Setter Property="LegendItemTemplate">
  222. <Setter.Value>
  223. <DataTemplate>
  224. <StackPanel Orientation="Horizontal">
  225. <TextBlock Height="20" Width="20" Background="{Binding RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource ColorConverter}}"/>
  226. <TextBlock Text="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Content}"/>
  227. </StackPanel>
  228. </DataTemplate>
  229. </Setter.Value>
  230. </Setter>
  231. </Style>
  232. </ResourceDictionary>