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

📄 picturebox.cs

📁 是用c#实现的一个有关于报表设计的程序代码
💻 CS
📖 第 1 页 / 共 2 页
字号:
				{
					mRegion.X = mRegion.X - value + mRegion.Width;
					mRegion.Width = value;									
				}
				else if (this.HorizontalAlignment == ICustomPaint.HorizontalAlignmentTypes.Center)
				{
					mRegion.X = mRegion.X - value/2 + mRegion.Width/2;
					mRegion.Width = value;									
				}
			}
		}


		/// <summary>
		///  Gets or sets the height of the PictureBox
		/// </summary>
		[Description("The height of the element.")]
		public override int Height
		{
			get {return mRegion.Height;}
			set 
			{
				if (this.VerticalAlignment == ICustomPaint.VerticalAlignmentTypes.None || this.VerticalAlignment == ICustomPaint.VerticalAlignmentTypes.Top)
					mRegion.Height = value;
				else if (this.VerticalAlignment == ICustomPaint.VerticalAlignmentTypes.Bottom)
				{
					mRegion.Y = mRegion.Y - value + mRegion.Height;
					mRegion.Height = value;									
				}
				else if (this.VerticalAlignment == ICustomPaint.VerticalAlignmentTypes.Middle)
				{
					mRegion.Y = mRegion.Y - value/2 + mRegion.Height/2;
					mRegion.Height = value;									
				}
			}
		}


		/// <summary>
		///  Gets or sets the horizontal alignment of the PictureBox
		/// </summary>
		[Description("Horizontal alignment in the page, relative to margins. This property overrides element coordinates.")]
		public override ICustomPaint.HorizontalAlignmentTypes HorizontalAlignment
		{
			get {return this.horizontalAlignment;}
			set 
			{
				this.horizontalAlignment = value;
				switch (this.horizontalAlignment)
				{
					case ICustomPaint.HorizontalAlignmentTypes.Center:
						mRegion.X = (document.DefaultPageSettings.Bounds.Width-document.Margins.Right+document.Margins.Left)/2 - Width/2;
						break;

					case ICustomPaint.HorizontalAlignmentTypes.Right:
						mRegion.X = document.DefaultPageSettings.Bounds.Right - document.Margins.Right - Width;
						break;

					case ICustomPaint.HorizontalAlignmentTypes.Left:
						mRegion.X = document.Margins.Left;
						break;
				}
			}
		}


		/// <summary>
		///  Gets or sets the TextField repeatability over multiple pages
		/// </summary>
		/// <remarks>
		/// The TextField's repeatability setting governs how whether it is repeated
		/// over multiple pages, only on the first page, or only on the last page.
		/// </remarks>
		[Description("This controls repeatability of the TextField over multiple pages.")]
		public override ICustomPaint.ObjectRepeatabilityTypes ObjectRepeatability
		{
			get
			{
				return this.objectRepeatability;
			}
			set
			{
				this.objectRepeatability = value;
			}
		}


		/// <summary>
		/// Gets/Sets whether the PictureBox is selectable in the design pane of the DaReport Designer
		/// </summary>
		/// <remarks>If set to true, then the PictureBox is not selectable in the DaReport Designer application
		/// design pane. It is still selectable in the tree view listing of objects.
		/// </remarks>
		[Description("Sets whether the PictureBox can be selected in the design pane.")]
		public override bool Selectable
		{
			get { return this.mSelectable; }
			set { this.mSelectable=value; }
		}


		/// <summary>
		///  Gets or sets the vertical alignment of the PictureBox
		/// </summary>
		[Description("Vertical alignment in the page, relative to margins. This property overrides element coordinates.")]
		public override ICustomPaint.VerticalAlignmentTypes VerticalAlignment
		{
			get {return this.verticalAlignment;}
			set 
			{
				this.verticalAlignment = value;
				switch (this.verticalAlignment)
				{
					case ICustomPaint.VerticalAlignmentTypes.Middle:
						mRegion.Y = (document.DefaultPageSettings.Bounds.Height-document.Margins.Bottom+document.Margins.Top)/2 - Height/2;
						break;

					case ICustomPaint.VerticalAlignmentTypes.Bottom:
						mRegion.Y = document.DefaultPageSettings.Bounds.Bottom - document.Margins.Bottom - Height;
						break;

					case ICustomPaint.VerticalAlignmentTypes.Top:
						mRegion.Y = document.Margins.Top;
						break;
				}
			}
		}


		#endregion

		#region Private Functions

		private void Load(string filename)
		{
			try
			{
				string imageFile = document.DocRoot;
				if (filename.StartsWith(Path.DirectorySeparatorChar.ToString()))
					imageFile += filename;
				else
					imageFile += Path.DirectorySeparatorChar.ToString() + filename;

				mImage = new Bitmap(imageFile);
				mFilename = filename;
			}
			catch(Exception)
			{
				mImage = null;
				mFilename = filename;
			}
		}


		#endregion

		#region Creator and Destructor

		/// <summary>
		/// Initializes a new instance of the PictureBox class.
		/// </summary>
		/// <param name="x">x-position of the new PictureBox</param>
		/// <param name="y">y-position of the new PictureBox</param>
		/// <param name="width">Width of the new PictureBox</param>
		/// <param name="height">Height of the new PictureBox</param>
		/// <param name="parent">Parent of the new PictureBox</param>
		public PictureBox(int x,int y, int width, int height, DaPrintDocument parent)
		{
			document = parent;
			mRegion = new Rectangle(x,y,width,height);
		}


		/// <summary>
		/// Releases all resources used by this PictureBox object.
		/// </summary>
		public void Dispose()
		{
			if (mImage!=null)
				mImage.Dispose();
		}


		#endregion

		#region ICustomPaint Members

		/// <summary>
		/// Paints the PictureBox
		/// </summary>
		/// <param name="g">The Graphics object to draw</param>
		/// <remarks>Causes the PictureBox to be painted to the screen.</remarks>
		public override void Paint(Graphics g)
		{
			
			if (mImage != null)
			{
				if (mDoStretch)
				{
					g.DrawImage(mImage,mRegion,0,0,mImage.Width,mImage.Height,GraphicsUnit.Pixel);
				}
				else
				{
					g.DrawImage(mImage,mRegion,0,0,mRegion.Width,mRegion.Height,GraphicsUnit.Pixel);
				}

				if ( mBorderWidth > 0 )
				{
					g.DrawRectangle( new Pen(mBorderColor,mBorderWidth),mRegion);
				}
			}
		}


		/// <summary>
		/// Gets the region of the current PictureBox
		/// </summary>
		/// <returns>System.Drawing.Rectangle</returns>
		public override Rectangle GetRegion()
		{
			return mRegion;
		}


		/// <summary>
		/// Clones the structure of the PictureBox, including all properties
		/// </summary>
		/// <returns><see cref="daReport.ChartBox">daReport.ChartBox</see></returns>
		public override object Clone()
		{
			PictureBox tmp = new PictureBox(0,0,0,0,document);
			tmp.X = this.X;
			tmp.Y = this.Y;
			tmp.Width = this.Width;
			tmp.Height = this.Height;
			tmp.BorderWidth = this.BorderWidth;
			tmp.BorderColor = this.BorderColor;
			tmp.Stretch = this.Stretch;
			tmp.ImageFile = this.ImageFile;
			return tmp;
		}


		/*
		*** not sure this is used
		public void AdjustPosition(Rectangle page){}
		*/
		

		#endregion
	}
}

⌨️ 快捷键说明

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