using System.Drawing; using SMath.Manager; using SMath.Controls; using SMath.Math; using SMath.Drawing; namespace CheckBoxPlugin { class CheckBoxCanvas : RegionEvaluable { private bool flag; /// /// Defines whether Checkbox is checked or not. /// internal bool Checked { get { return this.flag; } set { if (this.flag != value) { this.flag = value; base.CreateHistoryStep(); } } } public CheckBoxCanvas(SessionProfile sessionProfile) : base(sessionProfile) { base.Size = new Size(22, 22); } public CheckBoxCanvas(CheckBoxCanvas region) : base(region) { } public override void OnPaint(PaintEventOptions e) { base.OnPaint(e); e.Graphics.FillRectangle(Checked ? ColorBrushes.Black : ColorBrushes.LightGray, e.ClipRectangle.X + 1, e.ClipRectangle.Y + 1, this.InnerBounds.Width - 2, this.InnerBounds.Height - 2); } public override void OnMouseDown(MouseEventOptions e) { this.Checked = !this.Checked; Invalidate(); base.OnMouseDown(e); } public override void OnCommandSend(string value) { if (value == " ") { this.Checked = !this.Checked; // Request evaluation as soon as value changed RequestEvaluation(); Invalidate(); return; } base.OnCommandSend(value); } public override RegionBase Clone() { return new CheckBoxCanvas(this); } public override void OnEvaluation(Store store) { // Container handles all requests for evaluation } } }