예제 #1
0
        /// <summary>
        /// Adds a combo box style item.
        /// </summary>
        /// <param name="item">The item.</param>
        /// <returns>The added ComboBox.</returns>
        public override object Add(CheckBoxActionItem item)
        {
            var strip = GetOrCreateStrip(item.GroupCaption);

            var checkbx = new CheckBox();

            checkbx.Checked = item.Checked;
            checkbx.Text    = item.Caption;

            /*checkbx.CheckedChanged += (sender, args) =>
             * {
             *  item.PropertyChanged -= CheckBoxItemPropertyChanged;
             *  item.Checked = checkbx.Checked;
             *  item.PropertyChanged += CheckBoxItemPropertyChanged;
             * };*/

            var snapCheckContHost = new ToolStripControlHost(checkbx);

            snapCheckContHost.ToolTipText = item.ToolTipText;
            snapCheckContHost.ImageKey    = item.Key;

            CheckBox checkbxHosted = (CheckBox)snapCheckContHost.Control;

            checkbxHosted.CheckedChanged += (sender, args) =>
            {
                item.PropertyChanged         -= CheckBoxItemPropertyChanged;
                item.Checked                  = checkbx.Checked;
                snapCheckContHost.ToolTipText = item.ToolTipText;
                item.PropertyChanged         += CheckBoxItemPropertyChanged;
            };

            strip?.Items.Add(snapCheckContHost);

            // strip?.Items.Add((checkbx);
            item.PropertyChanged += CheckBoxItemPropertyChanged;
            return(checkbx);
        }
예제 #2
0
 /// <summary>
 /// Adds the specified checkbox item.
 /// </summary>
 /// <param name="item">The item.</param>
 /// <returns>The added item.</returns>
 public abstract object Add(CheckBoxActionItem item);