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 II - Controls

, 26 Mar 2009 CPOL
Chart controls composed from Chart Parts
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
SampleDataFiles
WellLog
Samples
ControlSamples
ColumnChartControlSample
Properties
Settings.settings
CurveChartControlSample
Properties
Settings.settings
r3xyqstb.tmp_proj
WellLogControlSample
Properties
Settings.settings
DirectCompositionSamples
BasicSample
Properties
Settings.settings
TemperatureSample
Properties
Settings.settings
WellLogSample
Properties
Settings.settings
<!--
OpenWPFChart library WellLogChart control default style.
Copyright Oleg V. Polikarpotchkin 2008-2009
-->
<!--revision $Id: WellLogChart.Generic.xaml 19239 2009-03-22 05:52:22Z 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">
	
	<!-- WellLogChart Control Style -->
	<Style TargetType="{x:Type local:WellLogChart}">
		<Style.Resources>
			<!-- Curve templates -->
			<DataTemplate x:Key="polylineTemplate">
				<parts:PolylineSampledCurve ItemDataView="{Binding}"
					ToolTip="{Binding ItemData.ItemName}" 
					ContextMenu="{Binding Path=ContextMenu, 
						RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:WellLogChart}}}"/>
			</DataTemplate>
			<DataTemplate x:Key="bezierTemplate">
				<parts:BezierSampledCurve ItemDataView="{Binding}"
					ToolTip="{Binding ItemData.ItemName}" 
					ContextMenu="{Binding Path=ContextMenu, 
						RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:WellLogChart}}}"/>
			</DataTemplate>
			<DataTemplate x:Key="splineTemplate">
				<parts:SplineSampledCurve ItemDataView="{Binding}"
					ToolTip="{Binding ItemData.ItemName}" 
					ContextMenu="{Binding Path=ContextMenu, 
						RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:WellLogChart}}}"/>
			</DataTemplate>

			<!-- Chart Items Template Selector -->
			<parts:GenericDataTemplateSelector x:Key="chartItemsTemplateSelector">
				<parts:GenericDataTemplateSelectorItem
					PropertyName="VisualCue" 
					Value="{x:Type parts:PolylineSampledCurve}"
					Template="{StaticResource polylineTemplate}"
					TemplatedType="{x:Type parts:SampledCurveDataView}"
					Description="Polyline Sampled Curve"/>
				<parts:GenericDataTemplateSelectorItem
					PropertyName="VisualCue" 
					Value="{x:Type parts:BezierSampledCurve}"
					Template="{StaticResource bezierTemplate}"
					TemplatedType="{x:Type parts:SampledCurveDataView}"
					Description="Bezier Sampled Curve"/>
				<parts:GenericDataTemplateSelectorItem
					PropertyName="VisualCue" 
					Value="{x:Type parts:SplineSampledCurve}"
					Template="{StaticResource splineTemplate}"
					TemplatedType="{x:Type parts:SampledCurveDataView}"
					Description="Spline Sampled Curve"/>
			</parts:GenericDataTemplateSelector>

			<!-- WellLog Header MinMaxValueConverter -->
			<local:EnumerableMinMaxValueConverter x:Key="minMaxValueConverter"/>
			
			<!-- WellLog Header Template -->
			<DataTemplate x:Key="SampledCurveHeaderTemplate">
				<Border BorderThickness="1" BorderBrush="Bisque">
					<Grid HorizontalAlignment="Stretch" ShowGridLines="False">
						<Grid.RowDefinitions>
							<RowDefinition Height="Auto"/>
							<RowDefinition Height="Auto"/>
						</Grid.RowDefinitions>
						<Grid.ColumnDefinitions>
							<ColumnDefinition Width="Auto" SharedSizeGroup="ItemName"/>
							<ColumnDefinition Width="Auto" SharedSizeGroup="MinValue"/>
							<ColumnDefinition/>
							<ColumnDefinition Width="Auto" SharedSizeGroup="MaxValue"/>
						</Grid.ColumnDefinitions>

						<TextBlock Text="{Binding Path=ItemData.ItemName}" VerticalAlignment="Center"/>
						<TextBlock Grid.Column="1" VerticalAlignment="Center" Margin="3,0,0,0"
							   Text="{Binding Path=ItemData.Points, Converter={StaticResource minMaxValueConverter}}"/>
						<Image Grid.Column="2" Stretch="None" HorizontalAlignment="Center"
						   VerticalAlignment="Center">
							<Image.Source>
								<DrawingImage>
									<DrawingImage.Drawing>
										<Binding Path="PointMarker"/>
									</DrawingImage.Drawing>
								</DrawingImage>
							</Image.Source>
						</Image>
						<TextBlock Grid.Column="3" VerticalAlignment="Center"
							Text="{Binding Path=ItemData.Points, Converter={StaticResource minMaxValueConverter}, ConverterParameter=true}"/>
						<Rectangle Grid.Row="1" Grid.ColumnSpan="4" 
							Fill="{Binding Path=Pen.Brush}" Height="2"
							VerticalAlignment="Center" HorizontalAlignment="Stretch"
							Margin="0,5,0,5"/>
					</Grid>
				</Border>
			</DataTemplate>
			
			<local:ItemCountToVisibilityConverter x:Key="itemCountToVisibility"/>
		</Style.Resources>
		
		<!-- Base ListBox ItemsPanel Template -->
		<Setter Property="ItemsPanel">
			<Setter.Value>
				<ItemsPanelTemplate>
					<Canvas />
				</ItemsPanelTemplate>
			</Setter.Value>
		</Setter>

		<!-- Base ListBox ItemContainer Style -->
		<Setter Property="ItemContainerStyle">
			<Setter.Value>
				<Style TargetType="{x:Type ListBoxItem}">
					<Setter Property="Template">
						<Setter.Value>
							<ControlTemplate TargetType="{x:Type ListBoxItem}">
								<ContentPresenter x:Name="ContentHost"/>
								<ControlTemplate.Triggers>
									<Trigger Property="Selector.IsSelected" Value="True">
										<Setter TargetName="ContentHost" Property="BitmapEffect">
											<Setter.Value>
												<DropShadowBitmapEffect Color="Black" Direction="320" 
																		ShadowDepth="5" Softness="0.2" 
																		Opacity="0.8"/>
											</Setter.Value>
										</Setter>
									</Trigger>
								</ControlTemplate.Triggers>
							</ControlTemplate>
						</Setter.Value>
					</Setter>
				</Style>
			</Setter.Value>
		</Setter>

		<!-- Base ListBox ItemTemplateSelector -->
		<Setter Property="ItemTemplateSelector" Value="{StaticResource chartItemsTemplateSelector}"/>

		<!-- WellLogChart Control Template -->
		<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="{x:Type local:WellLogChart}">
					<Border Name="Bd"
							BorderThickness="{TemplateBinding Border.BorderThickness}" 
							BorderBrush="{TemplateBinding Border.BorderBrush}" 
							Background="{TemplateBinding Panel.Background}" 
							Padding="1,1,1,1" 
							SnapsToDevicePixels="True">
						<ScrollViewer
								HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto"
								Padding="{TemplateBinding Control.Padding}" Focusable="False">
							<Grid ShowGridLines="False"
								  Visibility="{Binding RelativeSource={RelativeSource TemplatedParent}, 
									Path=Items.Count, Converter={StaticResource itemCountToVisibility}}">
								<Grid.RowDefinitions>
									<RowDefinition Height="Auto"/>
									<RowDefinition Height="Auto"/>
								</Grid.RowDefinitions>
								<Grid.ColumnDefinitions>
									<ColumnDefinition Width="Auto"/>
									<ColumnDefinition Width="Auto"/>
								</Grid.ColumnDefinitions>

								<!-- WellLogHeader - Horizontal Top WellLog axes -->
								<ListBox Grid.Column="1" VerticalAlignment="Top"
									ItemsSource="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=ItemsSource}"
									ItemTemplate="{StaticResource SampledCurveHeaderTemplate}"
									SelectedItem="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=SelectedItem}"
									HorizontalContentAlignment="Stretch"
									Grid.IsSharedSizeScope="True"/>

								<!-- Vertical Left Depth axis -->
								<Grid Grid.Row="1">
									<Grid.RowDefinitions>
										<RowDefinition Height="Auto"/>
										<RowDefinition/>
									</Grid.RowDefinitions>

									<parts:LinearAxis x:Name="depthAxis" 
										AxisScale="{Binding RelativeSource={RelativeSource TemplatedParent}, 
											Path=SelectedItem.HorizontalScale}"/>
									<TextBlock Grid.Row="1" HorizontalAlignment="Center" 
										Text="{TemplateBinding DepthAxisTitle}"
										Foreground="{Binding RelativeSource={RelativeSource TemplatedParent}, 
											Path=(parts:Axis.Pen).Brush}"/>

									<Grid.LayoutTransform>
										<RotateTransform Angle="90"/>
									</Grid.LayoutTransform>
								</Grid>

								<!-- Chart area -->
								<Grid Grid.Row="1" Grid.Column="1">
									<!--Coordinate grids-->
									<parts:Grid
										HorizontalScale="{Binding RelativeSource={RelativeSource TemplatedParent}, 
											Path=SelectedItem.VerticalScale}"
										VerticalScale="{Binding RelativeSource={RelativeSource TemplatedParent}, 
											Path=SelectedItem.HorizontalScale}"
										GridVisibility="{TemplateBinding VerticalGridVisibility}"
									/>
									<parts:Grid Orientation="Horizontal"
										HorizontalScale="{Binding RelativeSource={RelativeSource TemplatedParent}, 
											Path=SelectedItem.VerticalScale}"
										VerticalScale="{Binding RelativeSource={RelativeSource TemplatedParent}, 
											Path=SelectedItem.HorizontalScale}"
										GridVisibility="{TemplateBinding HorizontalGridVisibility}"
									/>
									<ItemsPresenter SnapsToDevicePixels="{TemplateBinding UIElement.SnapsToDevicePixels}" />
								</Grid>
							</Grid>
						</ScrollViewer>
					</Border>
				</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
Web02 | 2.8.141216.1 | Last Updated 26 Mar 2009
Article Copyright 2009 by Oleg V. Polikarpotchkin
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid