示例#1
0
        protected override void OnMouseClick(MouseEventArgs e)
        {
            var range = ItemIndexesInView().ToList();

            if (range.Count == 0)
            {
                return;
            }

            var top    = range.Min();
            var bottom = range.Max();
            var pos    = OffsetMousePosition;

            for (int i = 0; i <= Items.Count; i++)
            {
                Rectangle checkRect = new Rectangle(0, i * ItemHeight, Consts.CheckBoxSize + 5, ItemHeight);
                if (checkRect.Contains(pos))
                {
                    Items[i].Checked = !Items[i].Checked;
                    CheckChanged?.Invoke(this, new ListItemChangedEventArgs(Items[i]));
                }
            }

            Invalidate();
            base.OnMouseClick(e);
        }
        private void checkedList_ItemCheck(object sender, ItemCheckEventArgs e)
        {
            if (_ignoreCheck)
            {
                e.NewValue = e.CurrentValue; return;
            }

            if (e.NewValue == CheckState.Checked)
            {
                if (!_checkedItems.Contains(_checkedListBox.Items[e.Index]))
                {
                    _checkedItems.Add(_checkedListBox.Items[e.Index]);
                }
            }
            else
            {
                _checkedItems.Remove(_checkedListBox.Items[e.Index]);
            }
            var text = string.Join(", ", _checkedItems.Select(item => $"[{item.GetType().GetProperty(this.DisplayMember)?.GetValue(item)}]").ToArray());

            Text = HtmlDecode ? WebUtility.HtmlDecode(text) : text;
            try
            {
                CheckChanged?.Invoke(this, _checkedItems);
            }
            catch (Exception)
            {
                //throw;
            }
        }
示例#3
0
        public override void Update()
        {
            bool currentValue = IsChecked;

            if (currentValue != _prevValue)
            {
                CheckChanged?.Invoke(this, new CheckChangedEventArgs(currentValue));
                _prevValue = currentValue;
            }
        }
 /// <summary>
 /// Default Constructor
 /// </summary>
 public CheckBox()
 {
     this.Orientation = StackOrientation.Horizontal;
     this.Margin      = new Thickness(10, 0);
     this.Padding     = new Thickness(10);
     this.Spacing     = 10;
     this.Children.Add(new Grid {
         Children = { boxBackground, boxSelected }
     });
     this.Children.Add(lblOption);
     this.GestureRecognizers.Add(new TapGestureRecognizer
     {
         Command = new Command(() => { IsChecked = !IsChecked; CheckChanged?.Invoke(this, new EventArgs()); CheckChangedCommand?.Execute(this.IsChecked); }),
     });
 }
示例#5
0
 /// <summary>
 /// Default Constructor
 /// </summary>
 public CheckBox()
 {
     this.Orientation      = StackOrientation.Horizontal;
     this.Padding          = new Thickness(0, 10);
     this.Spacing          = 10;
     boxBackground.Content = boxSelected;
     this.Children.Add(boxBackground);
     //this.Children.Add(new Grid { Children = { boxBackground, boxSelected }, MinimumWidthRequest = 35 });
     this.Children.Add(lblOption);
     this.GestureRecognizers.Add(new TapGestureRecognizer
     {
         Command = new Command(() => { if (IsDisabled)
                                       {
                                           return;
                                       }
                                       IsChecked = !IsChecked; CheckChanged?.Invoke(this, new EventArgs()); CheckChangedCommand?.Execute(this.IsChecked); ValidationChanged?.Invoke(this, new EventArgs()); }),
     });
 }
示例#6
0
        /// <summary>
        /// Handler for CheckChanged event.
        /// </summary>
        protected virtual void onCheckChanged(ControlBase control, EventArgs Args)
        {
            if (checkBox.IsChecked)
            {
                if (Checked != null)
                {
                    Checked.Invoke(this, EventArgs.Empty);
                }
            }
            else
            {
                if (UnChecked != null)
                {
                    UnChecked.Invoke(this, EventArgs.Empty);
                }
            }

            if (CheckChanged != null)
            {
                CheckChanged.Invoke(this, EventArgs.Empty);
            }
        }
示例#7
0
        /// <summary>
        /// Handler for CheckChanged event.
        /// </summary>
        protected virtual void OnCheckChanged()
        {
            if (IsChecked)
            {
                if (Checked != null)
                {
                    Checked.Invoke(this, EventArgs.Empty);
                }
            }
            else
            {
                if (UnChecked != null)
                {
                    UnChecked.Invoke(this, EventArgs.Empty);
                }
            }

            if (CheckChanged != null)
            {
                CheckChanged.Invoke(this, EventArgs.Empty);
            }
        }
示例#8
0
        /// <summary>
        /// Handler for CheckChanged event.
        /// </summary>
        protected virtual void OnCheckChanged(Base control)
        {
            if (m_CheckBox.IsChecked)
            {
                if (Checked != null)
                {
                    Checked.Invoke(this);
                }
            }
            else
            {
                if (UnChecked != null)
                {
                    UnChecked.Invoke(this);
                }
            }

            if (CheckChanged != null)
            {
                CheckChanged.Invoke(this);
            }
        }
 public void OnCheckboxCheck(int Id, bool Checked)
 {
     CheckChanged?.Invoke(Id, Checked);
     DataChanged?.Invoke();
 }
 private void OnCheckChanged(CheckBox box)
 {
     CheckChanged?.Invoke(this);
     UpdateStyle();
 }
示例#11
0
 private void metroToggle1_CheckedChanged(object sender, EventArgs e)
 {
     CheckChanged?.Invoke(this, e);
 }
示例#12
0
 public virtual void OnCheckChanged(object sender, EventArgs e) => CheckChanged?.Invoke(sender, e);
示例#13
0
        /// <summary>
        /// Default Constructor
        /// </summary>
        public CheckBox()
        {
            InitVisualStates();
            this.Orientation           = StackOrientation.Horizontal;
            this.Padding               = new Thickness(0, 10);
            this.Spacing               = 10;
            this.frmBackground.Content = boxSelected;

            ApplyLabelPosition(LabelPosition);

            this.ApplyIsCheckedAction = ApplyIsChecked;
            this.ApplyIsPressedAction = ApplyIsPressed;
            this.GestureRecognizers.Add(new TapGestureRecognizer
            {
                Command = new Command(() => { if (IsDisabled)
                                              {
                                                  return;
                                              }
                                              IsChecked = !IsChecked; ExecuteCommand(); CheckChanged?.Invoke(this, new EventArgs()); ValidationChanged?.Invoke(this, new EventArgs()); }),
            });
        }
示例#14
0
 private void cb_CheckChanged(object sender, RoutedEventArgs e)
 {
     Checked = cb.IsChecked.HasValue ? cb.IsChecked.Value : false;
     CheckChanged?.Invoke(this);
     e.Handled = true;
 }
示例#15
0
 private void this_MouseDown(object sender, MouseButtonEventArgs e)
 {
     Checked = !Checked;
     CheckChanged?.Invoke(this);
     e.Handled = true;
 }
示例#16
0
 protected virtual void OnCheckChanged(EventArgs e)
 {
     CheckChanged?.Invoke(this, e);
 }
 public void OnCheckboxCheck(int Id, bool Checked)
 => CheckChanged?.Invoke(Id, Checked);
示例#18
0
 private void Chart4CheckBox_CheckedChanged(object sender, EventArgs e)
 {
     CheckChanged?.Invoke(sender, e);
 }
 private protected virtual void OnCheckChanged()
 {
     CheckChanged?.Invoke(this);
 }
示例#20
0
 protected virtual void OnCheckChanged(object sender, EventArgs e)
 {
     CheckChanged?.Invoke(sender, e);
 }
 /// <summary>
 /// Updates the label style.
 /// </summary>
 protected void UpdateStyle()
 {
     CheckChanged?.Invoke(this);
     TextColor = CheckBox.Checked ? Color.White : new Color(0.6f);
 }