PageRenderTime 11ms CodeModel.GetById 7ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 1ms

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