protected virtual EditorButtonObjectInfoArgs PrepareButton(ButtonsPanelInfo viewInfo, Graphics g, Rectangle bounds, EditorButtonObjectInfoArgs button) { g = GraphicsInfo.Default.AddGraphics(g); try { var min = ObjectPainter.CalcObjectMinBounds(g, viewInfo.Painter, button); button.Bounds = min; } finally { GraphicsInfo.Default.ReleaseGraphics(); } return(button); }
public ButtonsPanelInfo Init() { var viewInfo = new ButtonsPanelInfo(); viewInfo.Painter = EditorButtonHelper.GetPainter(BorderStyles.Default, LookAndFeel); foreach (var button in Buttons) { var bi = new EditorButtonObjectInfoArgs(button, Appearance.Clone() as AppearanceObject, true); bi.BuiltIn = false; bi.FillBackground = true; viewInfo.ButtonsInfo.Add(bi); } return(viewInfo); }
public ButtonsPanelInfo Prepare(Graphics g, ButtonsPanelInfo viewInfo, Rectangle bounds) { if (viewInfo.Bounds == bounds && viewInfo.IsReady) { return(viewInfo); } if (viewInfo.ButtonsInfo.Count == 0) { viewInfo.Bounds = Rectangle.Empty; viewInfo.IsReady = false; return(viewInfo); } var maxSize = Size.Empty; viewInfo.Bounds = bounds; foreach (var button in viewInfo.ButtonsInfo) { var bi = PrepareButton(viewInfo, g, bounds, button); maxSize.Width = Math.Max(maxSize.Width, bi.Bounds.Width); maxSize.Height = Math.Max(maxSize.Height, bi.Bounds.Height); } var centerY = bounds.Y + Padding.Top; var totalWidth = 0; var lastX = bounds.X + Padding.Left; foreach (var button in viewInfo.ButtonsInfo) { var bb = button.Bounds; bb.Height = maxSize.Height; if (button.Button.Width < 1) { bb.Width = maxSize.Width; } bb.Y = centerY; bb.X = lastX; button.Bounds = bb; viewInfo.Painter.CalcObjectBounds(button); lastX = bb.Right + Indent; totalWidth += bb.Width; } totalWidth += (viewInfo.ButtonsInfo.Count - 1) * Indent + Padding.Horizontal; viewInfo.Width = totalWidth; viewInfo.Height = maxSize.Height + Padding.Vertical; UpdateAlignment(viewInfo); viewInfo.IsReady = true; return(viewInfo); }
protected virtual void UpdateAlignment(ButtonsPanelInfo viewInfo) { if (viewInfo.ButtonsInfo.Count == 0 || viewInfo.Height < 1) { return; } var delta = Point.Empty; if (viewInfo.Width < viewInfo.Bounds.Width) { if (HAlignment == HorzAlignment.Center) { delta.X = RectangleHelper.GetCenterBounds(viewInfo.Bounds, new Size(viewInfo.Width, 1)).X - viewInfo.Bounds.X; } if (HAlignment == HorzAlignment.Far) { delta.X = viewInfo.Bounds.Width - viewInfo.Width; } } if (viewInfo.Height < viewInfo.Bounds.Height) { if (VAlignment == VertAlignment.Center) { delta.Y = RectangleHelper.GetCenterBounds(viewInfo.Bounds, new Size(1, viewInfo.Height)).Y - viewInfo.Bounds.Y; } if (VAlignment == VertAlignment.Bottom) { delta.Y = viewInfo.Bounds.Height - viewInfo.Height; } } if (!delta.IsEmpty) { foreach (var b in viewInfo.ButtonsInfo) { b.OffsetContent(delta.X, delta.Y); } } }
public ButtonsPanelInfoEventsProvider(ButtonsPanelInfo info, Control control) { this.control = control; this.info = info; }
public void Draw(GraphicsCache cache, ButtonsPanelInfo viewInfo) { viewInfo.Draw(cache); }