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
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
// <copyright file="PointMarkerDialog.xaml.cs" company="Oleg V. Polikarpotchkin">
// Copyright © 2008 Oleg V. Polikarpotchkin. All Right Reserved
// </copyright>
// <author>Oleg V. Polikarpotchkin</author>
// <email>ov-p@yandex.ru</email>
// <date>2008-12-23</date>
// <summary>OpenWPFChart library. Dialog to select a PointMarker from internal list.</summary>
// <revision>$Id: PointMarkerDialog.xaml.cs 18093 2009-03-16 04:15:06Z unknown $</revision>

using System.ComponentModel;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;

namespace OpenWPFChart.Helpers
{
	/// <summary>
	/// Dialog to select a PointMarker from internal list.
	/// </summary>
	public partial class PointMarkerDialog : Window, INotifyPropertyChanged
	{
		public PointMarkerDialog(Color color)
		{
			InitializeComponent();

			strokeColor = color;
			fillColor = color;
			DataContext = this;
		}

		/// <summary>
		/// Gets the marker geometry.
		/// </summary>
		/// <value>The marker geometry.</value>
		public Geometry MarkerGeometry
		{
			get 
			{
				if (btnOK.IsEnabled)
					return lbxMarkers.SelectedItem as Geometry;
				else
					return null; 
			}
		}

		Color strokeColor;
		/// <summary>
		/// Gets or sets the marker stroke color.
		/// </summary>
		/// <value>The color of the marker stroke.</value>
		public Color MarkerStrokeColor
		{
			get { return strokeColor; }
			set
			{
				if (strokeColor != value)
				{
					strokeColor = value;
					Notify("MarkerStrokeColor");
				}
			}
		}

		Color fillColor;
		/// <summary>
		/// Gets or sets the marker fill color.
		/// </summary>
		/// <value>The color of the marker fill.</value>
		public Color MarkerFillColor
		{
			get { return fillColor; }
			set
			{
				if (fillColor != value)
				{
					fillColor = value;
					Notify("MarkerFillColor");
				}
			}
		}

		/// <summary>
		/// Selects the color with System.Windows.Forms.ColorDialog.
		/// </summary>
		/// <param name="color">The WPF color.</param>
		/// <returns></returns>
		private static Color selectColor(Color color)
		{
			System.Windows.Forms.ColorDialog dlg = new System.Windows.Forms.ColorDialog();
			dlg.Color = System.Drawing.Color.FromArgb(color.A, color.R, color.G, color.B);
			if (dlg.ShowDialog() != System.Windows.Forms.DialogResult.OK)
				return color;
			return Color.FromArgb(dlg.Color.A, dlg.Color.R, dlg.Color.G, dlg.Color.B);
		}

		private void lbxMarkers_SelectionChanged(object sender, SelectionChangedEventArgs e)
		{
			btnOK.IsEnabled = true;
		}

		private void btnMarkerStrokeColor_Click(object sender, RoutedEventArgs e)
		{
			MarkerStrokeColor = selectColor(MarkerStrokeColor);
		}

		private void btnMarkerFillColor_Click(object sender, RoutedEventArgs e)
		{
			MarkerFillColor = selectColor(MarkerFillColor);
		}

		/// <summary>
		/// Handles the Click event of the btnOK control.
		/// </summary>
		/// <param name="sender">The source of the event.</param>
		/// <param name="e">The <see cref="System.Windows.RoutedEventArgs"/> instance containing the event data.</param>
		private void btnOK_Click(object sender, RoutedEventArgs e)
		{
			DialogResult = true;
		}

		#region INotifyPropertyChanged Members
		public event PropertyChangedEventHandler PropertyChanged;
		void Notify(string prop)
		{
			if (PropertyChanged != null)
			{
				PropertyChanged(this, new PropertyChangedEventArgs(prop));
			}
		}
		#endregion
	}
}

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)

About the Author

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

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