Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

OpenWPFChart: assembling charts from components: Part I - Parts

, 19 Mar 2009 CPOL
Provides the component model along with base components to assemble charts.
SourceCode.zip
trunk
ChartControls
ChartControls.csproj.user
OpenWPFChart.Chart.Icon.png
OpenWPFChart.WellLogChart.Icon.png
Properties
Themes
ChartHelpers
AxisPropertiesDialog
ChartHelpers.csproj.user
ChartScaleControl
FontChooser
ItemPropertiesDialog
Properties
ChartParts
Axes
ChartParts.csproj.user
Grid
Items
Data
DataView
Elements
Visuals
NumericalRecipes
Properties
Scales
ChartParts.vsmdi
SampleDataFiles
WellLog
Samples
ControlSamples
ColumnChartControlSample
Properties
Settings.settings
CurveChartControlSample
Properties
Settings.settings
WellLogControlSample
Properties
Settings.settings
DirectCompositionSamples
BasicSample
Properties
Settings.settings
TemperatureSample
Properties
Settings.settings
WellLogSample
Properties
Settings.settings
<!--
OpenWPFChart library ChartLegend control default style.
Copyright Oleg V. Polikarpotchkin 2008-2009
-->
<!--revision $Id: ChartLegend.Generic.xaml 18093 2009-03-16 04:15:06Z unknown $-->
<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:sys="clr-namespace:System;assembly=mscorlib"
    xmlns:parts="clr-namespace:OpenWPFChart.Parts;assembly=OpenWPFChart.Parts"
    xmlns:local="clr-namespace:OpenWPFChart.Controls">
	
	<!-- Chart Control Style -->
	<Style TargetType="{x:Type local:ChartLegend}">
		<Style.Resources>
			<!-- Legend Items Templates -->
			<DataTemplate DataType="{x:Type parts:SampledCurveDataView}">
				<Grid Margin="3" ShowGridLines="False">
					<Grid.ColumnDefinitions>
						<ColumnDefinition Width="Auto" SharedSizeGroup="ItemName"/>
						<ColumnDefinition Width="30"/>
						<ColumnDefinition Width="Auto" SharedSizeGroup="PointMarker"/>
					</Grid.ColumnDefinitions>

					<TextBlock Text="{Binding Path=ItemData.ItemName}" VerticalAlignment="Center"/>
					<Rectangle Grid.Column="1" 
						Fill="{Binding Path=Pen.Brush}" Height="2"
						VerticalAlignment="Center" HorizontalAlignment="Stretch"
						Margin="5"/>
					<Image Grid.Column="2" Stretch="None" HorizontalAlignment="Left" VerticalAlignment="Center">
						<Image.Source>
							<DrawingImage>
								<DrawingImage.Drawing>
									<Binding Path="PointMarker"/>
								</DrawingImage.Drawing>
							</DrawingImage>
						</Image.Source>
					</Image>
				</Grid>
			</DataTemplate>
			<DataTemplate DataType="{x:Type parts:CurveDataView}">
				<Grid Margin="3" ShowGridLines="False">
					<Grid.ColumnDefinitions>
						<ColumnDefinition Width="Auto" SharedSizeGroup="ItemName"/>
						<ColumnDefinition Width="30"/>
					</Grid.ColumnDefinitions>

					<TextBlock Text="{Binding Path=ItemData.ItemName}" VerticalAlignment="Center"/>
					<Border Grid.Column="1" 
						BorderBrush="{Binding Path=Pen.Brush}" BorderThickness="2"
						VerticalAlignment="Center" HorizontalAlignment="Stretch"
						Margin="5"/>
				</Grid>
			</DataTemplate>
			<DataTemplate DataType="{x:Type parts:ScatteredPointsDataView}">
				<Grid Margin="3" ShowGridLines="False">
					<Grid.ColumnDefinitions>
						<ColumnDefinition Width="Auto" SharedSizeGroup="ItemName"/>
						<ColumnDefinition Width="Auto" SharedSizeGroup="PointMarker"/>
					</Grid.ColumnDefinitions>

					<TextBlock Text="{Binding Path=ItemData.ItemName}" VerticalAlignment="Center"/>
					<Image Grid.Column="1" Margin="5" Stretch="None" 
						   HorizontalAlignment="Left" VerticalAlignment="Center">
						<Image.Source>
							<DrawingImage>
								<DrawingImage.Drawing>
									<Binding Path="PointMarker"/>
								</DrawingImage.Drawing>
							</DrawingImage>
						</Image.Source>
					</Image>
				</Grid>
			</DataTemplate>			
			<DataTemplate DataType="{x:Type parts:ItemDataView}">
				<TextBlock Text="{Binding Path=ItemData.ItemName}" VerticalAlignment="Center" Margin="3"/>
			</DataTemplate>
		</Style.Resources>
		
		<Setter Property="Grid.IsSharedSizeScope" Value="True"/>
		
		<!-- ChartLegend Control Template -->
		<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="{x:Type local:ChartLegend}">
					<Border Name="Bd"
							BorderThickness="{TemplateBinding Border.BorderThickness}" 
							BorderBrush="{TemplateBinding Border.BorderBrush}" 
							CornerRadius="{TemplateBinding Border.CornerRadius}" 
							Background="{TemplateBinding Panel.Background}" 
							SnapsToDevicePixels="True">
						<ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto"
								Padding="{TemplateBinding Control.Padding}" Focusable="False">
							<StackPanel>
								<!-- Legend Title -->
								<TextBlock Text="{TemplateBinding Title}" Margin="3" FontWeight="Bold"/>
								<!-- Legend items -->
								<ItemsPresenter SnapsToDevicePixels="{TemplateBinding UIElement.SnapsToDevicePixels}" />
							</StackPanel>
						</ScrollViewer>
					</Border>
					
					<ControlTemplate.Triggers>
						<Trigger Property="UIElement.IsEnabled">
							<Trigger.Value>
								<sys:Boolean>False</sys:Boolean>
							</Trigger.Value>
							<Setter Property="Panel.Background" TargetName="Bd">
								<Setter.Value>
									<DynamicResource ResourceKey="{x:Static SystemColors.ControlBrushKey}" />
								</Setter.Value>
							</Setter>
						</Trigger>
					</ControlTemplate.Triggers>
				</ControlTemplate>
			</Setter.Value>
		</Setter>
	</Style>
</ResourceDictionary>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Oleg V. Polikarpotchkin
Team Leader
Russian Federation Russian Federation
No Biography provided

| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.141220.1 | Last Updated 19 Mar 2009
Article Copyright 2009 by Oleg V. Polikarpotchkin
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid