// calculation of the switch (toggle thumb) image size protected override Size CalcSwitchSize(ToggleObjectInfoArgs e) { Size size = CalcImageSize(e); return(new Size(10, size.Height)); //original code //return new Size(size.Width * e.SwitchWidth / 100, size.Height); }
protected override void DrawToggleSwitch(ToggleObjectInfoArgs args) { if (args.IsOn) { args.Graphics.FillRectangle(BrushOn, 0, 0, args.Bounds.Width, args.Bounds.Height); } else { args.Graphics.FillRectangle(BrushOff, 0, 0, args.Bounds.Width, args.Bounds.Height); } }
//calculation of the thumb's backing image size protected override Size CalcImageSize(BaseCheckObjectInfoArgs e) { ToggleObjectInfoArgs args = e as ToggleObjectInfoArgs; if (args == null) { return(Size.Empty); } int heigth = args.Appearance.GetFontHeight(e.Cache) + 2 * args.TextMargin; int width = (int)Math.Floor(heigth / PercentRatio); int delta = 50; return(new Size(width > args.MinSize.Width ? width + delta : args.MinSize.Width + delta, heigth > args.MinSize.Height ? heigth : args.MinSize.Height)); //original code //return new Size(width > args.MinSize.Width ? width : args.MinSize.Width , heigth > args.MinSize.Height ? heigth : args.MinSize.Height); }
protected override void DrawContent(ControlGraphicsInfoArgs info) { BaseCheckEditViewInfo vi = info.ViewInfo as BaseCheckEditViewInfo; vi.CheckInfo.Appearance.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; ToggleObjectInfoArgs args = (vi.CheckInfo) as ToggleObjectInfoArgs; if (args.GlyphRect.X == args.SwitchRect.X) { vi.CheckInfo.CaptionRect = new Rectangle(args.SwitchRect.Right, args.SwitchRect.Y, args.SwitchRect.Width + 10, args.SwitchRect.Height); } else if (args.GlyphRect.Right == args.SwitchRect.Right) { vi.CheckInfo.CaptionRect = new Rectangle(args.GlyphRect.X, args.GlyphRect.Y, args.SwitchRect.Width + 10, args.SwitchRect.Height); } base.DrawContent(info); }