using System; using System.Drawing; using System.Windows.Forms; namespace XKRS.UI.Model.Winform { public partial class GridCtrl : UserControl { public Action IsShowGridChanged { get; set; } public Action GridValueChanged { get; set; } public Action GridColorChanged { get; set; } public GridCtrl() { InitializeComponent(); IsChecked = chkShowGrid.Checked; GridValue = tbGridValue.Value; } bool isChecked = false; bool IsChecked { get => isChecked; set { if (isChecked != value) { // IsShowGridChanged?.BeginInvoke(value, null, null); Task.Run(() => IsShowGridChanged.Invoke(value)); } isChecked = value; } } int gridValue = 0; int GridValue { get => gridValue; set { if (gridValue != value) { // GridValueChanged?.BeginInvoke(value, null, null); Task.Run(() => GridValueChanged.Invoke(value)); } gridValue = value; } } private void chkShowGrid_CheckedChanged(object sender, EventArgs e) { IsChecked = chkShowGrid.Checked; } private void tbGridValue_ValueChanged(object sender, EventArgs e) { GridValue = tbGridValue.Value; } private void btnColor_Click(object sender, EventArgs e) { if (colorDialog1.ShowDialog() == DialogResult.OK) { btnColor.BackColor = colorDialog1.Color; // GridColorChanged?.BeginInvoke(btnColor.BackColor, null, null); Task.Run(() => GridColorChanged.Invoke(btnColor.BackColor)); } } } }