Click here to Skip to main content
15,892,746 members
Articles / Desktop Programming / WPF

OpenWPFChart: assembling charts from components: Part I - Parts

Rate me:
Please Sign up or sign in to vote.
4.29/5 (17 votes)
19 Mar 2009CPOL14 min read 82.3K   4K   81  
Provides the component model along with base components to assemble charts.
<Window x:Class="ovp.CurveChart.dlgPointMarker"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:collections="clr-namespace:System.Collections;assembly=mscorlib"
    Title="Select Point Marker" ShowInTaskbar="False"
	SizeToContent="WidthAndHeight" ResizeMode="NoResize" 
	MinWidth="150" MinHeight="100"  WindowStartupLocation="CenterOwner"
	FocusManager.FocusedElement="{Binding ElementName=txtCurveName}"
	BorderBrush="Cornsilk" BorderThickness="10" 
	Background="AliceBlue"
	>

	<Window.Resources>
		<Style TargetType="Label">
			<Setter Property="VerticalAlignment" Value="Center" />
			<Setter Property="Padding" Value="5" />
		</Style>
		<!--<Style TargetType="Button">
			<Setter Property="VerticalAlignment" Value="Center" />
			<Setter Property="Margin" Value="5, 10, 5, 5" />
		</Style>-->
		<Style x:Key="dialogButton" TargetType="Button">
			<Setter Property="VerticalAlignment" Value="Center" />
			<Setter Property="Margin" Value="5, 10, 5, 5" />
			<Setter Property="Width" Value="72" />
		</Style>

		<!-- Marker Geometries -->
		<!--<x:ArrayExtension x:Key="markerShapes" Type="{x:Type Geometry}">
			<EllipseGeometry Center="0,0" RadiusX="4" RadiusY="4"/>
			<RectangleGeometry Rect="-4,-4,8,8"/>
		</x:ArrayExtension>-->
		<collections:ArrayList x:Key="markerShapes">
			<EllipseGeometry Center="0,0" RadiusX="4" RadiusY="4"/>
			<RectangleGeometry Rect="-4,-4,8,8"/>
			<PathGeometry>
				<PathFigure StartPoint="-4,4" IsClosed="True">
					<PolyLineSegment Points="4,4 0,-4" />
				</PathFigure>
			</PathGeometry>
			<PathGeometry>
				<PathFigure StartPoint="-4,-4" IsClosed="True">
					<PolyLineSegment Points="4,-4 0,4" />
				</PathFigure>
			</PathGeometry>
		</collections:ArrayList>
	</Window.Resources>
	
	<Grid>
		<Grid.RowDefinitions>
			<RowDefinition Height="Auto"/>
			<RowDefinition Height="Auto"/>
			<RowDefinition Height="Auto"/>
			<RowDefinition/>
		</Grid.RowDefinitions>
		<Grid.ColumnDefinitions>
			<ColumnDefinition Width="Auto"/>
			<ColumnDefinition/>
		</Grid.ColumnDefinitions>
		
		<Label Target="{Binding ElementName=lbxMarkers}">Marker Gometry</Label>
		<ListBox Grid.Column="1" Name="lbxMarkers" ItemsSource="{StaticResource markerShapes}"
				 SelectionChanged="lbxMarkers_SelectionChanged">
			<ListBox.ItemsPanel>
				<ItemsPanelTemplate>
					<WrapPanel/>
				</ItemsPanelTemplate>
			</ListBox.ItemsPanel>
			
			<ListBox.ItemTemplate>
				<DataTemplate>
					<Path Data="{Binding}" Stroke="Black" Margin="5" />
				</DataTemplate>
			</ListBox.ItemTemplate>
		</ListBox>

		<Label Grid.Row="1" Target="{Binding ElementName=btnMarkerStrokeColor}">Marker Color</Label>
		<Button Grid.Row="1" Grid.Column="1" Name="btnMarkerStrokeColor" Click="btnMarkerStrokeColor_Click" 
				ToolTip="Click to select the Marker Color">
			<Rectangle Width="50" Height="17">
				<Rectangle.Fill>
					<SolidColorBrush Color="{Binding MarkerStrokeColor}"/>
				</Rectangle.Fill>
			</Rectangle>
		</Button>

		<Label Grid.Row="2" Target="{Binding ElementName=btnMarkerFillColor}">Marker Fill Color</Label>
		<Button Grid.Row="2" Grid.Column="1" Name="btnMarkerFillColor" Click="btnMarkerFillColor_Click" 
				ToolTip="Click to select the Marker Fill Color">
			<Rectangle Width="50" Height="17">
				<Rectangle.Fill>
					<SolidColorBrush Color="{Binding MarkerFillColor}"/>
				</Rectangle.Fill>
			</Rectangle>
			
			<!--<Button.Style>
				<Style TargetType="{x:Type Button}" BasedOn="{StaticResource {x:Type Button}}">
					<Style.Triggers>
						<Trigger Value="{x:Type GeometryDrawing}">
							<Trigger.Property>
								<Binding Path="MarkerType" RelativeSource="{RelativeSource FindAncestor, AncestorType={x:Type Window}}"/>
							</Trigger.Property>
							<Setter Property="Visibility" Value="Visible"/>
						</Trigger>
					</Style.Triggers>
				</Style>
			</Button.Style>-->
		</Button>

		<StackPanel Grid.Row="3" Grid.ColumnSpan="2" Orientation="Horizontal" 
					HorizontalAlignment="Right" VerticalAlignment="Bottom">
			<Button Name="btnOK" Click="btnOK_Click" Style="{StaticResource dialogButton}" 
					IsEnabled="False" IsDefault="True">OK</Button>
			<Button Style="{StaticResource dialogButton}" IsCancel="True">Cancel</Button>
		</StackPanel>
	</Grid>
</Window>

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)


Written By
Team Leader
Russian Federation Russian Federation
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions