using System; using CPF.Drawing; using CPF.ReoGrid.Graphics; using CPF.ReoGrid.Rendering; namespace CPF.ReoGrid.CellTypes { [Serializable] public class RadioButtonCell : CheckBoxCell { public virtual RadioButtonGroup RadioGroup { get { return this.radioGroup; } set { bool flag = value == null; if (flag) { this.RadioGroup = null; } else { bool flag2 = !value.Contains(this); if (flag2) { value.AddRadioButton(this); } this.radioGroup = value; } } } public override bool IsChecked { get { return this.isChecked; } set { bool flag = this.isChecked != value; if (flag) { this.isChecked = value; bool flag2 = this.isChecked && this.radioGroup != null; if (flag2) { foreach (RadioButtonCell radioButtonCell in this.radioGroup.RadioButtons) { bool flag3 = radioButtonCell != this; if (flag3) { radioButtonCell.IsChecked = false; } } } bool flag4 = base.Cell != null && (base.Cell.InnerData as bool?).GetValueOrDefault() != value; if (flag4) { base.Cell.Data = value; } this.RaiseCheckChangedEvent(); } } } public override void ToggleCheckStatus() { bool flag = !this.isChecked || this.radioGroup == null; if (flag) { base.ToggleCheckStatus(); } } protected override void OnContentPaint(CellDrawingContext dc) { IGraphics graphics = dc.Graphics; float x = this.ContentBounds.Center.X; float y = this.ContentBounds.Center.Y; float num = this.ContentBounds.Width / 2f; float num2 = this.ContentBounds.Height / 2f; float num3 = x - num / 2f; float num4 = y - num2 / 2f; Rect rectangle = new Rect(ref num3, ref num4, ref num, ref num2); graphics.DrawEllipse(StaticResources.SystemColor_ControlDark, rectangle); bool isPressed = this.IsPressed; if (isPressed) { graphics.FillEllipse(StaticResources.SystemColor_Control, rectangle); } bool isChecked = this.isChecked; if (isChecked) { float num5 = this.ContentBounds.Width / 4f; float num6 = this.ContentBounds.Height / 4f; num3 = x - num5 / 2f; num4 = y - num6 / 2f; rectangle = new Rect(ref num3, ref num4, ref num5, ref num6); graphics.FillEllipse(StaticResources.SystemColor_WindowText, rectangle); } } public override ICellBody Clone() { return new RadioButtonCell(); } private RadioButtonGroup radioGroup; } }