/DualityEditor/Controls/ToolStrip/ToolStripCheckBox.cs
http://duality.googlecode.com/ · C# · 57 lines · 51 code · 5 blank · 1 comment · 1 complexity · ba486184824109fc0b7e2ef1344dfaa5 MD5 · raw file
- using System;
- using System.Windows.Forms;
- using System.Windows.Forms.Design;
-
- namespace DualityEditor.Controls.ToolStrip
- {
- [ToolStripItemDesignerAvailability(ToolStripItemDesignerAvailability.ToolStrip | ToolStripItemDesignerAvailability.StatusStrip)]
- public class ToolStripCheckBox : ToolStripControlHost
- {
- private CheckBox checkBox = null;
-
- public event EventHandler CheckedChanged
- {
- add { this.checkBox.CheckedChanged += value; }
- remove { this.checkBox.CheckedChanged -= value; }
- }
- public event EventHandler CheckStateChanged
- {
- add { this.checkBox.CheckStateChanged += value; }
- remove { this.checkBox.CheckStateChanged -= value; }
- }
-
- public override string Text
- {
- get { return this.checkBox.Text; }
- set
- {
- this.checkBox.Text = value;
- this.UpdateAutoSize();
- }
- }
- public bool Checked
- {
- get { return this.checkBox.Checked; }
- set { this.checkBox.Checked = value; }
- }
- public CheckState CheckState
- {
- get { return this.checkBox.CheckState; }
- set { this.checkBox.CheckState = value; }
- }
-
- public ToolStripCheckBox() : base(new CheckBox())
- {
- // Set up the FlowLayouPanel.
- this.checkBox = (CheckBox)base.Control;
- this.checkBox.AutoSize = true;
- }
-
- protected void UpdateAutoSize()
- {
- if (!this.AutoSize) return;
- this.AutoSize = false;
- this.AutoSize = true;
- }
- }
- }