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

📄 reportdataitem.cs

📁 c#源代码
💻 CS
字号:
/*
 * Created by SharpDevelop.
 * User: Forstmeier Helmut
 * Date: 13.11.2004
 * Time: 22:48
 * 
 * To change this template use Tools | Options | Coding | Edit Standard Headers.
 */

using System;
using System.Drawing;
using System.ComponentModel;

using SharpReportCore;
using SharpReport.Designer;

namespace SharpReport.ReportItems{
	/// <summary>
	/// This class reads a Column from a DataSource
	/// </summary>
	
	public class ReportDataItem : BaseDataItem ,SharpReport.Designer.IDesignable{
		
		private ReportDbTextControl visualControl;
		bool initDone = false;
		
		#region Constructors
		
		public ReportDataItem() : base(){
			Setup();
			if (base.ColumnName != null) {
				this.visualControl.Text = base.ColumnName;
			} else {
				visualControl.Text = base.UnboundText;
			}	
		}
			
		public ReportDataItem(string columnName):base(columnName){
			Setup();
			visualControl.Text = base.ColumnName;
		}
		
		private void Setup(){
			visualControl = new ReportDbTextControl();

			this.visualControl.Click += new EventHandler(OnControlSelect);
			this.visualControl.VisualControlChanged += new EventHandler (OnControlChanged);
			this.visualControl.BackColorChanged += new EventHandler (OnControlChanged);
			this.visualControl.FontChanged += new EventHandler (OnControlChanged);
			this.visualControl.ForeColorChanged += new EventHandler (OnControlChanged);

			base.PropertyChange += new PropertyChangeEventHandler (BasePropertyChange);
			ItemsHelper.UpdateTextControl (this.visualControl,this);
			this.Text = visualControl.Name;
			GrapFromBase();
			this.initDone = true;
		}
		
		private void GrapFromBase() {
			this.visualControl.SuspendLayout();
			visualControl.StringFormat = base.StandartStringFormat;
			this.visualControl.ResumeLayout();
		}
		
		#endregion
		
		#region overrides
		public override void Dispose() {
			base.Dispose();
			this.visualControl.Dispose();
		}
		#endregion
		
		#region events's
		private void BasePropertyChange (object sender, PropertyChangeEventArgs e){
			if (initDone == true) {
				if (e.UpdateControl) {
					ItemsHelper.UpdateTextBase(this.visualControl,this);
				}
			}
		}
		

		private void OnControlChanged (object sender, EventArgs e) {
			ItemsHelper.UpdateTextControl (this.visualControl,this);
			this.FirePropertyChanged();
		}
		
		public void OnControlSelect(object sender, EventArgs e){
			if (Selected != null)
				Selected(this,e);
		}
		
		/// <summary>
		/// A Property in ReportItem has changed, inform the Designer
		/// to set the View's 'IsDirtyFlag' to true
		/// </summary>
		
		protected void FirePropertyChanged() {
			if ( !base.Suspend) {
				if (PropertyChanged != null) {
					PropertyChanged (this,new EventArgs());
				}
			}
		}
		#endregion
		

		
		#region Property's
		public override Size Size {
			get {
				return base.Size;
			}
			set {
				base.Size = value;
				if (this.visualControl != null) {
					this.visualControl.Size = value;
				}
				this.FirePropertyChanged();
			}
		}
		
		public override Point Location {
			get {
				return base.Location;
			}
			set {
				base.Location = value;
				if (this.visualControl != null) {
					this.visualControl.Location = value;
				}
				this.FirePropertyChanged();
			}
		}
		
		public override Font Font {
			get {
				return base.Font;
			}
			set {
				base.Font = value;
				if (this.visualControl != null) {
					this.visualControl.Font = value;
				}
				this.FirePropertyChanged();
			}
		}
		
		///<summary>
		/// Holds the text to be displayed
		/// </summary>
		
		public override string Text{
			get {
				return base.Text;
			}
			set {
				base.Text = value;
				if (this.visualControl.Text != value) {
					this.visualControl.Text = value;
					this.visualControl.Refresh();
				}
				this.FirePropertyChanged();
			}
		}
		
		#endregion

		
		#region IDesignable
	
		[System.Xml.Serialization.XmlIgnoreAttribute]
		[Browsable(false)]
		public ReportObjectControlBase VisualControl {
			get {
				return visualControl;
			}
		}
	
		public event EventHandler PropertyChanged;
	
		public event SelectedEventHandler Selected;
		#endregion
	}
}

⌨️ 快捷键说明

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