www.pudn.com > OA-FlowDefine.rar > OptionsDialog.cs


using System; 
using System.Drawing; 
using System.Collections; 
using System.ComponentModel; 
using System.Windows.Forms; 
 
namespace FlowCharter 
{ 
	///  
	/// Summary description for OptionsDialog. 
	///  
	public class OptionsDialog : System.Windows.Forms.Form 
	{ 
		private System.Windows.Forms.Label _backColorLabel; 
		private System.Windows.Forms.Label _nodeColorLabel; 
		private System.Windows.Forms.CheckBox _showAnchorsCheck; 
		private System.Windows.Forms.Label _anchorColorLabel; 
		private System.Windows.Forms.Label _anchorStyleLabel; 
		private System.Windows.Forms.GroupBox _anchorsGroup; 
		private System.Windows.Forms.Button _cancelBtn; 
		private System.Windows.Forms.Button _okBtn; 
		private System.Windows.Forms.ToolBar _anchorStyleToolbar; 
		private System.Windows.Forms.ImageList _anchorStyleImageList; 
		private System.Windows.Forms.ToolBarButton _circleBtn; 
		private System.Windows.Forms.ToolBarButton _rectBtn; 
		private System.Windows.Forms.ToolBarButton _xBtn; 
		private System.ComponentModel.IContainer components; 
		private System.Windows.Forms.Label _connectorColorLabel; 
		private System.Windows.Forms.PictureBox _lowerPane; 
		private System.Windows.Forms.Panel _buttonPanel; 
		private System.Windows.Forms.Label _anchorColorHidden; 
		private System.Windows.Forms.Label _backColorHidden; 
		private System.Windows.Forms.Label _nodeColorHidden; 
		private System.Windows.Forms.Label _connectorColorHidden; 
 
		private FlowCharter.ColorPicker _anchorColorPicker; 
		private FlowCharter.ColorPicker _backColorPicker; 
		private FlowCharter.ColorPicker _nodeColorPicker; 
		private FlowCharter.ColorPicker _connectorColorPicker; 
 
		private bool _showGrid; 
		private Color _backColor; 
		private Color _nodeColor; 
		private Color _connectorColor; 
 
		private bool _showAnchors; 
		private Color _anchorColor; 
		private System.Windows.Forms.ColorDialog _colorDialog; 
		private System.Windows.Forms.CheckBox _showGridCheck; 
		private int _anchorStyle; 
 
 
		public bool ShowGrid 
		{ 
			get { return _showGrid; } 
			set { _showGrid = value; } 
		} 
		public Color BackgroundColor 
		{ 
			get { return _backColor; } 
			set { _backColor = value; } 
		} 
		public Color NodeColor 
		{ 
			get { return _nodeColor; } 
			set { _nodeColor = value; } 
		} 
		public Color ConnectorColor 
		{ 
			get { return _connectorColor; } 
			set { _connectorColor = value; } 
		} 
 
		public bool ShowAnchors 
		{ 
			get { return _showAnchors; } 
			set { _showAnchors = value; } 
		} 
		public Color AnchorColor 
		{ 
			get { return _anchorColor; } 
			set { _anchorColor = value; } 
		} 
		public int AnchorStyle 
		{ 
			get { return _anchorStyle; } 
			set { _anchorStyle = value; } 
		} 
 
 
		public OptionsDialog() 
		{ 
			// 
			// Required for Windows Form Designer support 
			// 
			InitializeComponent(); 
		} 
 
		private void OnLoad(object sender, System.EventArgs e) 
		{ 
			_showGridCheck.Checked = ShowGrid; 
 
			_anchorColorPicker = new ColorPicker(); 
			_anchorColorPicker.Color = AnchorColor; 
			_anchorColorPicker.Location = _anchorColorHidden.Location; 
			_anchorColorPicker.Size = _anchorColorHidden.Size; 
			_anchorColorPicker.Click += new System.EventHandler(this.AnchorColorPicker_OnClick); 
 
			_backColorPicker = new ColorPicker(); 
			_backColorPicker.Color = BackgroundColor; 
			_backColorPicker.Location = _backColorHidden.Location; 
			_backColorPicker.Size = _backColorHidden.Size; 
			_backColorPicker.Click += new System.EventHandler(this.BackColorPicker_OnClick); 
 
			_nodeColorPicker = new ColorPicker(); 
			_nodeColorPicker.Color = NodeColor; 
			_nodeColorPicker.Location = _nodeColorHidden.Location; 
			_nodeColorPicker.Size = _nodeColorHidden.Size; 
			_nodeColorPicker.Click += new System.EventHandler(this.NodeColorPicker_OnClick); 
 
			_connectorColorPicker = new ColorPicker(); 
			_connectorColorPicker.Color = ConnectorColor; 
			_connectorColorPicker.Location = _connectorColorHidden.Location; 
			_connectorColorPicker.Size = _connectorColorHidden.Size; 
			_connectorColorPicker.Click += new System.EventHandler(this.ConnectorColorPicker_OnClick); 
 
			_anchorsGroup.Controls.Add(_anchorColorPicker); 
			this.Controls.Add(_backColorPicker); 
			this.Controls.Add(_nodeColorPicker); 
			this.Controls.Add(_connectorColorPicker); 
 
			// Initialize controls' values 
			_showAnchorsCheck.Checked = ShowAnchors; 
			_circleBtn.Pushed = (AnchorStyle == 0); 
			_rectBtn.Pushed = (AnchorStyle == 1); 
			_xBtn.Pushed = (AnchorStyle == 2); 
		} 
 
		///  
		/// Clean up any resources being used. 
		///  
		protected override void Dispose( bool disposing ) 
		{ 
			if( disposing ) 
			{ 
				if(components != null) 
				{ 
					components.Dispose(); 
				} 
			} 
			base.Dispose( disposing ); 
		} 
 
		#region Windows Form Designer generated code 
		///  
		/// Required method for Designer support - do not modify 
		/// the contents of this method with the code editor. 
		///  
		private void InitializeComponent() 
		{ 
			this.components = new System.ComponentModel.Container(); 
			System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(OptionsDialog)); 
			this._backColorLabel = new System.Windows.Forms.Label(); 
			this._nodeColorLabel = new System.Windows.Forms.Label(); 
			this._connectorColorLabel = new System.Windows.Forms.Label(); 
			this._showAnchorsCheck = new System.Windows.Forms.CheckBox(); 
			this._anchorColorLabel = new System.Windows.Forms.Label(); 
			this._anchorStyleLabel = new System.Windows.Forms.Label(); 
			this._anchorsGroup = new System.Windows.Forms.GroupBox(); 
			this._anchorColorHidden = new System.Windows.Forms.Label(); 
			this._buttonPanel = new System.Windows.Forms.Panel(); 
			this._anchorStyleToolbar = new System.Windows.Forms.ToolBar(); 
			this._circleBtn = new System.Windows.Forms.ToolBarButton(); 
			this._rectBtn = new System.Windows.Forms.ToolBarButton(); 
			this._xBtn = new System.Windows.Forms.ToolBarButton(); 
			this._anchorStyleImageList = new System.Windows.Forms.ImageList(this.components); 
			this._cancelBtn = new System.Windows.Forms.Button(); 
			this._lowerPane = new System.Windows.Forms.PictureBox(); 
			this._okBtn = new System.Windows.Forms.Button(); 
			this._backColorHidden = new System.Windows.Forms.Label(); 
			this._nodeColorHidden = new System.Windows.Forms.Label(); 
			this._connectorColorHidden = new System.Windows.Forms.Label(); 
			this._colorDialog = new System.Windows.Forms.ColorDialog(); 
			this._showGridCheck = new System.Windows.Forms.CheckBox(); 
			this._anchorsGroup.SuspendLayout(); 
			this._buttonPanel.SuspendLayout(); 
			this.SuspendLayout(); 
			//  
			// _backColorLabel 
			//  
			this._backColorLabel.Location = new System.Drawing.Point(8, 42); 
			this._backColorLabel.Name = "_backColorLabel"; 
			this._backColorLabel.Size = new System.Drawing.Size(106, 16); 
			this._backColorLabel.TabIndex = 0; 
			this._backColorLabel.Text = "Background color:"; 
			//  
			// _nodeColorLabel 
			//  
			this._nodeColorLabel.Location = new System.Drawing.Point(8, 66); 
			this._nodeColorLabel.Name = "_nodeColorLabel"; 
			this._nodeColorLabel.Size = new System.Drawing.Size(106, 16); 
			this._nodeColorLabel.TabIndex = 1; 
			this._nodeColorLabel.Text = "Node fill color:"; 
			//  
			// _connectorColorLabel 
			//  
			this._connectorColorLabel.Location = new System.Drawing.Point(8, 90); 
			this._connectorColorLabel.Name = "_connectorColorLabel"; 
			this._connectorColorLabel.Size = new System.Drawing.Size(106, 16); 
			this._connectorColorLabel.TabIndex = 2; 
			this._connectorColorLabel.Text = "Connector fill color:"; 
			//  
			// _showAnchorsCheck 
			//  
			this._showAnchorsCheck.FlatStyle = System.Windows.Forms.FlatStyle.Popup; 
			this._showAnchorsCheck.Location = new System.Drawing.Point(16, 24); 
			this._showAnchorsCheck.Name = "_showAnchorsCheck"; 
			this._showAnchorsCheck.Size = new System.Drawing.Size(104, 16); 
			this._showAnchorsCheck.TabIndex = 4; 
			this._showAnchorsCheck.Text = "Show anchors"; 
			//  
			// _anchorColorLabel 
			//  
			this._anchorColorLabel.Location = new System.Drawing.Point(16, 48); 
			this._anchorColorLabel.Name = "_anchorColorLabel"; 
			this._anchorColorLabel.Size = new System.Drawing.Size(72, 16); 
			this._anchorColorLabel.TabIndex = 5; 
			this._anchorColorLabel.Text = "Anchor color:"; 
			//  
			// _anchorStyleLabel 
			//  
			this._anchorStyleLabel.Location = new System.Drawing.Point(16, 72); 
			this._anchorStyleLabel.Name = "_anchorStyleLabel"; 
			this._anchorStyleLabel.Size = new System.Drawing.Size(72, 16); 
			this._anchorStyleLabel.TabIndex = 5; 
			this._anchorStyleLabel.Text = "Anchor style:"; 
			//  
			// _anchorsGroup 
			//  
			this._anchorsGroup.Controls.AddRange(new System.Windows.Forms.Control[] { 
																						this._anchorColorHidden, 
																						this._buttonPanel, 
																						this._anchorStyleLabel, 
																						this._anchorColorLabel, 
																						this._showAnchorsCheck}); 
			this._anchorsGroup.FlatStyle = System.Windows.Forms.FlatStyle.Flat; 
			this._anchorsGroup.ForeColor = System.Drawing.SystemColors.WindowText; 
			this._anchorsGroup.Location = new System.Drawing.Point(8, 120); 
			this._anchorsGroup.Name = "_anchorsGroup"; 
			this._anchorsGroup.Size = new System.Drawing.Size(185, 100); 
			this._anchorsGroup.TabIndex = 6; 
			this._anchorsGroup.TabStop = false; 
			this._anchorsGroup.Text = "Anchors"; 
			//  
			// _anchorColorHidden 
			//  
			this._anchorColorHidden.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; 
			this._anchorColorHidden.Location = new System.Drawing.Point(96, 42); 
			this._anchorColorHidden.Name = "_anchorColorHidden"; 
			this._anchorColorHidden.Size = new System.Drawing.Size(72, 22); 
			this._anchorColorHidden.TabIndex = 7; 
			this._anchorColorHidden.Visible = false; 
			//  
			// _buttonPanel 
			//  
			this._buttonPanel.Controls.AddRange(new System.Windows.Forms.Control[] { 
																					   this._anchorStyleToolbar}); 
			this._buttonPanel.Location = new System.Drawing.Point(96, 65); 
			this._buttonPanel.Name = "_buttonPanel"; 
			this._buttonPanel.Size = new System.Drawing.Size(72, 27); 
			this._buttonPanel.TabIndex = 6; 
			//  
			// _anchorStyleToolbar 
			//  
			this._anchorStyleToolbar.Appearance = System.Windows.Forms.ToolBarAppearance.Flat; 
			this._anchorStyleToolbar.Buttons.AddRange(new System.Windows.Forms.ToolBarButton[] { 
																								   this._circleBtn, 
																								   this._rectBtn, 
																								   this._xBtn}); 
			this._anchorStyleToolbar.ButtonSize = new System.Drawing.Size(16, 16); 
			this._anchorStyleToolbar.DropDownArrows = true; 
			this._anchorStyleToolbar.ImageList = this._anchorStyleImageList; 
			this._anchorStyleToolbar.Name = "_anchorStyleToolbar"; 
			this._anchorStyleToolbar.ShowToolTips = true; 
			this._anchorStyleToolbar.Size = new System.Drawing.Size(72, 25); 
			this._anchorStyleToolbar.TabIndex = 0; 
			this._anchorStyleToolbar.ButtonClick += new System.Windows.Forms.ToolBarButtonClickEventHandler(this.AnchorStyleToolbar_OnButtonClicked); 
			//  
			// _circleBtn 
			//  
			this._circleBtn.ImageIndex = 0; 
			this._circleBtn.Pushed = true; 
			this._circleBtn.Style = System.Windows.Forms.ToolBarButtonStyle.ToggleButton; 
			this._circleBtn.ToolTipText = "Circle"; 
			//  
			// _rectBtn 
			//  
			this._rectBtn.ImageIndex = 1; 
			this._rectBtn.Style = System.Windows.Forms.ToolBarButtonStyle.ToggleButton; 
			this._rectBtn.ToolTipText = "Rectangle"; 
			//  
			// _xBtn 
			//  
			this._xBtn.ImageIndex = 2; 
			this._xBtn.Style = System.Windows.Forms.ToolBarButtonStyle.ToggleButton; 
			this._xBtn.ToolTipText = "\"x\""; 
			//  
			// _anchorStyleImageList 
			//  
			this._anchorStyleImageList.ColorDepth = System.Windows.Forms.ColorDepth.Depth8Bit; 
			this._anchorStyleImageList.ImageSize = new System.Drawing.Size(16, 16); 
			this._anchorStyleImageList.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("_anchorStyleImageList.ImageStream"))); 
			this._anchorStyleImageList.TransparentColor = System.Drawing.Color.Transparent; 
			//  
			// _cancelBtn 
			//  
			this._cancelBtn.DialogResult = System.Windows.Forms.DialogResult.Cancel; 
			this._cancelBtn.FlatStyle = System.Windows.Forms.FlatStyle.Popup; 
			this._cancelBtn.Location = new System.Drawing.Point(104, 240); 
			this._cancelBtn.Name = "_cancelBtn"; 
			this._cancelBtn.TabIndex = 0; 
			this._cancelBtn.Text = "Cancel"; 
			//  
			// _lowerPane 
			//  
			this._lowerPane.BackColor = System.Drawing.SystemColors.ControlDark; 
			this._lowerPane.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; 
			this._lowerPane.Location = new System.Drawing.Point(8, 232); 
			this._lowerPane.Name = "_lowerPane"; 
			this._lowerPane.Size = new System.Drawing.Size(184, 40); 
			this._lowerPane.TabIndex = 7; 
			this._lowerPane.TabStop = false; 
			//  
			// _okBtn 
			//  
			this._okBtn.DialogResult = System.Windows.Forms.DialogResult.OK; 
			this._okBtn.FlatStyle = System.Windows.Forms.FlatStyle.Popup; 
			this._okBtn.Location = new System.Drawing.Point(24, 240); 
			this._okBtn.Name = "_okBtn"; 
			this._okBtn.TabIndex = 0; 
			this._okBtn.Text = "Ok"; 
			this._okBtn.Click += new System.EventHandler(this.OnOK); 
			//  
			// _backColorHidden 
			//  
			this._backColorHidden.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; 
			this._backColorHidden.Location = new System.Drawing.Point(120, 39); 
			this._backColorHidden.Name = "_backColorHidden"; 
			this._backColorHidden.Size = new System.Drawing.Size(72, 22); 
			this._backColorHidden.TabIndex = 7; 
			this._backColorHidden.Visible = false; 
			//  
			// _nodeColorHidden 
			//  
			this._nodeColorHidden.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; 
			this._nodeColorHidden.Location = new System.Drawing.Point(120, 63); 
			this._nodeColorHidden.Name = "_nodeColorHidden"; 
			this._nodeColorHidden.Size = new System.Drawing.Size(72, 22); 
			this._nodeColorHidden.TabIndex = 7; 
			this._nodeColorHidden.Visible = false; 
			//  
			// _connectorColorHidden 
			//  
			this._connectorColorHidden.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; 
			this._connectorColorHidden.Location = new System.Drawing.Point(120, 87); 
			this._connectorColorHidden.Name = "_connectorColorHidden"; 
			this._connectorColorHidden.Size = new System.Drawing.Size(72, 22); 
			this._connectorColorHidden.TabIndex = 7; 
			this._connectorColorHidden.Visible = false; 
			//  
			// _colorDialog 
			//  
			this._colorDialog.SolidColorOnly = true; 
			//  
			// _showGridCheck 
			//  
			this._showGridCheck.FlatStyle = System.Windows.Forms.FlatStyle.Popup; 
			this._showGridCheck.Location = new System.Drawing.Point(8, 16); 
			this._showGridCheck.Name = "_showGridCheck"; 
			this._showGridCheck.Size = new System.Drawing.Size(104, 16); 
			this._showGridCheck.TabIndex = 4; 
			this._showGridCheck.Text = "Show grid"; 
			//  
			// OptionsDialog 
			//  
			this.AcceptButton = this._okBtn; 
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); 
			this.CancelButton = this._cancelBtn; 
			this.ClientSize = new System.Drawing.Size(202, 279); 
			this.Controls.AddRange(new System.Windows.Forms.Control[] { 
																		  this._anchorsGroup, 
																		  this._connectorColorLabel, 
																		  this._nodeColorLabel, 
																		  this._backColorLabel, 
																		  this._cancelBtn, 
																		  this._okBtn, 
																		  this._lowerPane, 
																		  this._backColorHidden, 
																		  this._nodeColorHidden, 
																		  this._connectorColorHidden, 
																		  this._showGridCheck}); 
			this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; 
			this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); 
			this.MaximizeBox = false; 
			this.MinimizeBox = false; 
			this.Name = "OptionsDialog"; 
			this.ShowInTaskbar = false; 
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; 
			this.Text = "Options"; 
			this.Load += new System.EventHandler(this.OnLoad); 
			this._anchorsGroup.ResumeLayout(false); 
			this._buttonPanel.ResumeLayout(false); 
			this.ResumeLayout(false); 
 
		} 
		#endregion 
 
		private void AnchorStyleToolbar_OnButtonClicked(object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e) 
		{ 
			_circleBtn.Pushed = false; 
			_rectBtn.Pushed = false; 
			_xBtn.Pushed = false; 
 
			e.Button.Pushed = true; 
		} 
 
		private void OnOK(object sender, System.EventArgs e) 
		{ 
			ShowGrid = _showGridCheck.Checked; 
			ShowAnchors = _showAnchorsCheck.Checked; 
			if(_circleBtn.Pushed) AnchorStyle = 0; 
			if(_rectBtn.Pushed) AnchorStyle = 1; 
			if(_xBtn.Pushed) AnchorStyle = 2; 
 
			BackgroundColor = _backColorPicker.Color; 
			NodeColor = _nodeColorPicker.Color; 
			ConnectorColor = _connectorColorPicker.Color; 
			AnchorColor = _anchorColorPicker.Color; 
 
			this.Close(); 
		} 
 
		private void AnchorColorPicker_OnClick(object sender, System.EventArgs e) 
		{ 
			_colorDialog.Color = _anchorColorPicker.Color; 
 
			if(_colorDialog.ShowDialog(this) == DialogResult.OK) 
				_anchorColorPicker.Color = _colorDialog.Color; 
		} 
 
		private void BackColorPicker_OnClick(object sender, System.EventArgs e) 
		{ 
			_colorDialog.Color = _backColorPicker.Color; 
 
			if(_colorDialog.ShowDialog(this) == DialogResult.OK) 
				_backColorPicker.Color = _colorDialog.Color; 
		} 
 
		private void NodeColorPicker_OnClick(object sender, System.EventArgs e) 
		{ 
			_colorDialog.Color = _nodeColorPicker.Color; 
 
			if(_colorDialog.ShowDialog(this) == DialogResult.OK) 
				_nodeColorPicker.Color = _colorDialog.Color; 
		} 
 
		private void ConnectorColorPicker_OnClick(object sender, System.EventArgs e) 
		{ 
			_colorDialog.Color = _connectorColorPicker.Color; 
 
			if(_colorDialog.ShowDialog(this) == DialogResult.OK) 
				_connectorColorPicker.Color = _colorDialog.Color; 
		} 
	} 
}