⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 icustompaint.cs

📁 是用c#实现的一个有关于报表设计的程序代码
💻 CS
字号:
#region License
/*
This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General
Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option)
any later version.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
details.

You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to
the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 
*/
#endregion

using System;
using System.Drawing;
using System.Xml;


namespace daReport
{
	/// <summary>
	/// Class representing the ICustomPaint object.
	/// </summary>
	/// <remarks>
	/// ICustomPaint is the base for all document types and contains some properties and methods
	/// common to all document types.
	/// </remarks>
	public abstract class ICustomPaint : ICloneable
	{
		#region Declarations
		// the parent document of element
		// this reference is mandatory due to handling margins 
		/// <summary>
		/// The <see cref="daReport.DaPrintDocument">DaReport.PrintDocument</see> object
		/// </summary>
		protected DaPrintDocument document = null;

		/// <summary>
		/// Enumeration of possible horizontal alignments for the PrintDocument
		/// </summary>
		public enum HorizontalAlignmentTypes
		{
			/// <summary>No alignment. Manual placement</summary>
			None=0,
			/// <summary>Left Alignment on the page</summary>
			Left,
			/// <summary>Canter Alignment on the page</summary>
			Center,
			/// <summary>Right Alignment on the page</summary>
			Right
		};

		/// <summary>
		/// Enumeration of possible object repeatability states
		/// </summary>
		public enum ObjectRepeatabilityTypes
		{
			/// <summary>Repeat on all pages of the report</summary>
			RepeatOnAllPages=0,
			/// <summary>Only display on the first page of the report</summary>
			OnlyFirstPage=1,
			/// <summary>Only display on the last page of the report</summary>
			OnlyLastPage=2
		};

		/// <summary>
		/// Enumeration of possible vertical alignments for the PrintDocument
		/// </summary>
		public enum VerticalAlignmentTypes
		{
			/// <summary>No alignment. Manual placement</summary>
			None=0,
			/// <summary>Aligns to the top the page</summary>
			Top,
			/// <summary>Aligns to the middle the page</summary>
			Middle,
			/// <summary>Aligns to the bottom the page</summary>
			Bottom
		};
		
		/// <summary>
		/// Horizontal alignment of the object compared to the page
		/// </summary>
		protected HorizontalAlignmentTypes horizontalAlignment = HorizontalAlignmentTypes.None;

		/// <summary>
		/// Repeatability of the current object
		/// </summary>
		protected ObjectRepeatabilityTypes objectRepeatability = ObjectRepeatabilityTypes.RepeatOnAllPages;

		/// <summary>
		/// Vertical alignment of the object compared to the page
		/// </summary>
		protected VerticalAlignmentTypes verticalAlignment = VerticalAlignmentTypes.None;

		#endregion

		#region Public Abstract Declarations

		/// <summary>
		/// When implemented by a class, the object writes it properties to the XMLWriter
		/// </summary>
		public abstract void AddXMLToWriter(ref XmlTextWriter CurrentWriter);

		/// <summary>
		/// When implemented by a class, gets or sets the region the object is contained in.
		/// </summary>
		public abstract Rectangle GetRegion();

		/// <summary>
		/// When implemented by a class, gets or sets the height of the object
		/// </summary>
		public abstract int Height
		{
			get;
			set;
		}


		/// <summary>
		/// When implemented by a class, gets or sets the horizontal alignment of the object
		/// </summary>
		public abstract ICustomPaint.HorizontalAlignmentTypes HorizontalAlignment
		{
			get;
			set; 		
		}


		/// <summary>
		/// When implemented by a class, gets info from the XMLNode for the current object
		/// </summary>
		public abstract void LoadFromXMLNode(XmlNode CurrentNode);

		/// <summary>
		/// When implemented by a class, gets or sets the "repeatability" of the object
		/// </summary>
		public abstract ICustomPaint.ObjectRepeatabilityTypes ObjectRepeatability
		{
			get;
			set;
		}


		/// <summary>
		/// When implemented by a class, the object is painted to the screen.
		/// </summary>
		public abstract void Paint(Graphics g);

		/// <summary>
		/// When implemented by a class, gets or sets whether the object is selectable in the Designer pane
		/// </summary>
		public abstract bool Selectable
		{
			get;
			set; 		
		}


		/// <summary>
		/// When implemented by a class, gets or sets the vertical alignment of the object
		/// </summary>
		public abstract ICustomPaint.VerticalAlignmentTypes VerticalAlignment
		{
			get;
			set; 		
		}


		/// <summary>
		/// When implemented by a class, gets or sets the width of the object
		/// </summary>
		public abstract int Width
		{
			get;
			set;
		}


		/// <summary>
		/// When implemented by a class, gets or sets the x-location of the object
		/// </summary>
		public abstract int X
		{
			get;
			set;
		}

		
		/// <summary>
		/// When implemented by a class, gets or sets the y-location of the object
		/// </summary>
		public abstract int Y
		{
			get;
			set;
		}

		
		#endregion

		#region Public Static Methods

		/// <summary>
		/// Accepts a string and returns a valid
		/// <see cref="ICustomPaint.HorizontalAlignmentTypes">ICustomPaint.HorizontalAlignmentTypes</see>
		/// </summary>
		/// <param name="theAlignment">string value</param>
		/// <returns>
		/// <see cref="ICustomPaint.HorizontalAlignmentTypes">ICustomPaint.HorizontalAlignmentTypes</see>
		/// </returns>
		public static ICustomPaint.HorizontalAlignmentTypes ResolveHorizontalAlignment(string theAlignment)
		{
			if (theAlignment == "Center")
				return ICustomPaint.HorizontalAlignmentTypes.Center;
			else if (theAlignment == "Left")
				return ICustomPaint.HorizontalAlignmentTypes.Left;
			else if (theAlignment == "Right")
				return ICustomPaint.HorizontalAlignmentTypes.Right;
			else
				return ICustomPaint.HorizontalAlignmentTypes.None;						
		}


		/// <summary>
		/// Accepts a string and returns a valid
		/// <see cref="ICustomPaint.ObjectRepeatability">ICustomPaint.ObjectRepeatability</see>
		/// </summary>
		/// <param name="theObjectRepeatability">string value</param>
		/// <returns>
		/// <see cref="ICustomPaint.ObjectRepeatability">ICustomPaint.ObjectRepeatability</see>
		/// </returns>
		public static ICustomPaint.ObjectRepeatabilityTypes ResolveObjectRepeatability(string theObjectRepeatability)
		{
			if (theObjectRepeatability == "RepeatOnAllPages")
				return ICustomPaint.ObjectRepeatabilityTypes.RepeatOnAllPages;
			else if (theObjectRepeatability == "OnlyFirstPage")
				return ICustomPaint.ObjectRepeatabilityTypes.OnlyFirstPage;
			else if (theObjectRepeatability == "OnlyLastPage")
				return ICustomPaint.ObjectRepeatabilityTypes.OnlyLastPage;
			else
				return ICustomPaint.ObjectRepeatabilityTypes.RepeatOnAllPages;
		}


		/// <summary>
		/// Accepts a string and returns a valid
		/// <see cref="ICustomPaint.VerticalAlignmentTypes">ICustomPaint.VerticalAlignmentTypes</see>
		/// </summary>
		/// <param name="theAlignment">string value</param>
		/// <returns>
		/// <see cref="ICustomPaint.VerticalAlignmentTypes">ICustomPaint.VerticalAlignmentTypes</see>
		/// </returns>
		public static ICustomPaint.VerticalAlignmentTypes ResolveVerticalAlignment(string theAlignment)
		{
			if (theAlignment == "Middle")
				return ICustomPaint.VerticalAlignmentTypes.Middle;
			else if (theAlignment == "Top")
				return ICustomPaint.VerticalAlignmentTypes.Top;
			else if (theAlignment == "Bottom")
				return ICustomPaint.VerticalAlignmentTypes.Bottom;
			else
				return ICustomPaint.VerticalAlignmentTypes.None;						
		}

		
		#endregion

		#region ICloneable Members

		// needed for duplicateXXX() functions in design mode
		// the clone object MUST BE deep copy of the original element
		/// <summary>
		/// When implemented by a class, creates a deep copy of the object.
		/// </summary>
		/// <returns></returns>
		public abstract object Clone();		

		#endregion
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -