2 // Radegast Metaverse Client
3 // Copyright (c) 2009-2014, Radegast Development Team
4 // All rights reserved.
6 // Redistribution and use in source and binary forms, with or without
7 // modification, are permitted provided that the following conditions are met:
9 // * Redistributions of source code must retain the above copyright notice,
10 // this list of conditions and the following disclaimer.
11 // * Redistributions in binary form must reproduce the above copyright
12 // notice, this list of conditions and the following disclaimer in the
13 // documentation and/or other materials provided with the distribution.
14 // * Neither the name of the application "Radegast", nor the names of its
15 // contributors may be used to endorse or promote products derived from
16 // this software without specific prior written permission.
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21 // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
22 // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24 // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
25 // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26 // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 using System.Windows.Forms;
33 using System.Windows.Forms.Design;
34 using System.ComponentModel;
38 [ToolStripItemDesignerAvailability(
39 ToolStripItemDesignerAvailability.ToolStrip)]
40 public partial class ToolStripCheckBox
41 : ToolStripControlHost
43 public CheckBox CheckBoxControl
47 return Control as CheckBox;
52 /// Is check box ticked
54 [Category("Appearance")]
59 return CheckBoxControl.Checked;
63 CheckBoxControl.Checked = value;
70 [Category("Appearance")]
71 public CheckState CheckState
75 return CheckBoxControl.CheckState;
79 CheckBoxControl.CheckState = value;
86 [Category("Appearance")]
87 public override string Text
91 return CheckBoxControl.Text;
95 CheckBoxControl.Text = value;
100 /// Occurs when check property is changed
103 public event EventHandler CheckedChanged;
106 /// Occurs when check state of the control changes
109 public event EventHandler CheckStateChanged;
111 public ToolStripCheckBox()
112 : base(new CheckBox())
114 CheckBoxControl.MouseHover += new EventHandler(chk_MouseHover);
117 void chk_MouseHover(object sender, EventArgs e)
119 this.OnMouseHover(e);
122 protected override void OnSubscribeControlEvents(Control c)
124 base.OnSubscribeControlEvents(c);
125 ((CheckBox)c).CheckedChanged += new EventHandler(ToolStripCheckBox_CheckedChanged);
126 ((CheckBox)c).CheckStateChanged += new EventHandler(ToolStripCheckBox_CheckStateChanged);
129 protected override void OnUnsubscribeControlEvents(Control c)
131 base.OnUnsubscribeControlEvents(c);
132 ((CheckBox)c).CheckedChanged -= new EventHandler(ToolStripCheckBox_CheckedChanged);
133 ((CheckBox)c).CheckStateChanged -= new EventHandler(ToolStripCheckBox_CheckStateChanged);
136 void ToolStripCheckBox_CheckedChanged(object sender, EventArgs e)
138 if (CheckedChanged != null)
140 CheckedChanged(this, e);
144 void ToolStripCheckBox_CheckStateChanged(object sender, EventArgs e)
146 if (CheckStateChanged != null)
148 CheckStateChanged(this, e);