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
// <copyright file="ItemCountToBoolConverter.cs" company="Oleg V. Polikarpotchkin">
// Copyright © 2008-2009 Oleg V. Polikarpotchkin. All Right Reserved
// </copyright>
// <author>Oleg V. Polikarpotchkin</author>
// <email>ov-p@yandex.ru</email>
// <date>2009-02-03</date>
// <summary>OpenWPFChart library. WellLogSample ChartScales dialog.</summary>
// <revision>$Id: dlgChartScales.xaml.cs 18093 2009-03-16 04:15:06Z unknown $</revision>

using System;
using System.Globalization; // For CultureInfo
using System.ComponentModel; // For INotifyPropertyChanged
using System.Windows;

namespace WellLogSample
{
	/// <summary>
	/// WellLogSample ChartScales dialog.
	/// </summary>
	public partial class dlgChartScales : Window
	{
		/// <summary>
		/// This dialog private data cache.
		/// </summary>
		class DialogData : INotifyPropertyChanged, IDataErrorInfo
		{
			public DialogData(double depthScale, double chartWidth)
			{
				this.depthScale = depthScale;
				this.chartWidth = chartWidth;
			}

			double depthScale;
			public double DepthScale
			{
				get { return depthScale; }
				set
				{
					if (depthScale != value)
					{
						if (value <= 0.0)
							throw new ArgumentException("DepthScale must be positive");
						depthScale = value;
						Notify("DepthScale");
					}
				}
			}

			double chartWidth;
			public double ChartWidth
			{
				get { return chartWidth; }
				set
				{
					if (chartWidth != value)
					{
						if (value <= 0.0)
							throw new ArgumentException("ChartWidth must be positive");
						chartWidth = value;
						Notify("ChartWidth");
					}
				}
			}

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

			#region IDataErrorInfo Members
			string IDataErrorInfo.Error
			{
				get { return null; }
			}

			string IDataErrorInfo.this[string columnName]
			{
				get
				{
					switch (columnName)
					{
						case "DepthScale":
							if (DepthScale <= 0)
								return "DepthScale must be positive";
							break;
						case "ChartWidth":
							if (ChartWidth <= 0)
								return "ChartWidth must be positive";
							break;
					}
					return null;
				}
			}
			#endregion IDataErrorInfo Members
		}

		DialogData data;

		public dlgChartScales(double depthScale, double chartWidth)
		{
			InitializeComponent();

			data = new DialogData(depthScale, chartWidth);
			data.PropertyChanged += data_PropertyChanged;
			DataContext = data;
		}

		/// <summary>
		/// Gets the DepthScale.
		/// </summary>
		/// <value>The DepthScale.</value>
		public double DepthScale
		{
			get { return data.DepthScale; }
		}

		/// <summary>
		/// Gets the ChartWidth.
		/// </summary>
		/// <value>The ChartWidth.</value>
		public double ChartWidth
		{
			get { return data.ChartWidth; }
		}

		/// <summary>
		/// Enable OK button.
		/// Handles the PropertyChanged event of the data control.
		/// </summary>
		/// <param name="sender">The source of the event.</param>
		/// <param name="e">The <see cref="System.ComponentModel.PropertyChangedEventArgs"/> instance containing the event data.</param>
		private void data_PropertyChanged(object sender, PropertyChangedEventArgs e)
		{
			btnOK.IsEnabled = true;
		}

		/// <summary>
		/// Applyes changes and closes.
		/// 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;
		}
	}
}

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.1411023.1 | Last Updated 19 Mar 2009
Article Copyright 2009 by Oleg V. Polikarpotchkin
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid