Click here to Skip to main content
15,891,976 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.2K   4K   81  
Provides the component model along with base components to assemble charts.
// <copyright file="ItemVisual.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. OpenWPFChart Item Visual's abstract base class.</summary>
// <revision>$Id: ItemVisual.cs 18093 2009-03-16 04:15:06Z unknown $</revision>

using System;
using System.ComponentModel; // For ISupportInitialize
using System.Diagnostics;
using System.Windows;
using System.Windows.Media;

namespace OpenWPFChart.Parts
{
	/// <summary>
	/// OpenWPFChart Item Visual's abstract base class.
	/// </summary>
	public abstract class ItemVisual : DrawingVisual
	{
		#region Dependency properties
		#region ItemDataView
		/// <summary>
		/// Identifies the ItemDataView dependency property.
		/// </summary>
		public static readonly DependencyProperty ItemDataViewProperty
			= Item.ItemDataViewProperty.AddOwner(typeof(ItemVisual));
		/// <summary>
		/// Gets or sets the ItemDataView property.
		/// </summary>
		/// <value>ItemData value</value>
		public ItemDataView ItemDataView
		{
			get { return (ItemDataView)GetValue(ItemDataViewProperty); }
			set { SetValue(ItemDataViewProperty, value); }
		}
		#endregion ItemData
		#endregion Dependency properties

		/// <summary>
		/// Render Curve Visual.
		/// </summary>
		protected internal abstract void Render();

		/// <summary>
		/// Checks the 'pt' is inside the area. All coordinates come in pixels.
		/// </summary>
		/// <param name="pt">The pt.</param>
		/// <param name="area">The area.</param>
		/// <returns>
		/// 	<c>true</c> if the specified pt is inside the area; otherwise, <c>false</c>.
		/// </returns>
		protected static bool isInsideArea(Point pt, Size area)
		{
			Debug.Assert(area.Width >= 0, "area.Width >= 0");
			Debug.Assert(area.Height >= 0, "area.Height >= 0");
			if (pt.X < 0 || pt.X > area.Width || pt.Y < 0 || pt.Y > area.Height)
				return false;
			return 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)


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