/// <summary> /// 绘制圆边框 /// </summary> protected virtual void DrawRoundBorder(PaintEventArgs e) { int round = RoundRadius; int width = Width - 1; int height = Height - 1; using (GraphicsPath roundRectPath = GraphicsOrder.CreateRoundRectPath(0, 0, width, height, round)) { using (Brush backBrush = new SolidBrush(ButtonsRenderer.SelectedBackGradient2)) { e.Graphics.FillPath(backBrush, roundRectPath); } using (Pen borderPen = new Pen(ButtonsRenderer.SelectedBorder2)) { e.Graphics.DrawPath(borderPen, roundRectPath); if (CutRoundRect) { e.Graphics.DrawLine(borderPen, 0, height - 1, width, height - 1); using (GraphicsPath roundRect = GraphicsOrder.CreateRoundRectPath(0, 0, width + 1, height, round)) { SetControlRegion(roundRect, this); } } else { SetControlRegion(null, this); } } } }
/// <summary> /// Create forward region path /// </summary> /// <param name="previewSize">preview size</param> /// <returns>back region path</returns> private static GraphicsPath CreateNextRegionPath(Size previewSize) { GraphicsPath regionPath = GraphicsOrder.CreateRoundRectPath(0, 0, previewSize.Width, previewSize.Height, 5); Matrix transformMatrix = new Matrix(); transformMatrix.Shear(0.0F, 0.50F); regionPath.Transform(transformMatrix); return(regionPath); }
/// <summary> /// Create back region path /// </summary> /// <param name="previewSize">preview size</param> /// <returns>back region path</returns> private static GraphicsPath CreateBackRegionPath(Size previewSize) { int dh = ComputePreviewHeightOffset(previewSize); GraphicsPath regionPath = GraphicsOrder.CreateRoundRectPath(0, dh, previewSize.Width, previewSize.Height, 5); Matrix transformMatrix = new Matrix(); transformMatrix.Shear(0.0F, -0.50F); regionPath.Transform(transformMatrix); return(regionPath); }
/// <summary> /// Occurs when visibility of this control changes /// </summary> /// <param name="e">event argument</param> protected override void OnSizeChanged(EventArgs e) { using (GraphicsPath path = GraphicsOrder.CreateRoundRectPath(0, 0, Width, Height, 5)) { Region = new Region(ClientRectangle); Region = new Region(path); } base.OnSizeChanged(e); Invalidate(); }
/// <summary> /// Initialize select current preview /// </summary> /// <param name="containerBounds">container bounds</param> /// <param name="previewSize">preview size</param> /// <param name="selectCurrentPreview">select current preview form</param> private static void InitializeSelectCurrentPreviewForm(Rectangle containerBounds, Size previewSize, Form selectCurrentPreview) { int mainWidth = containerBounds.Width - 2 * (previewSize.Width + 70); int mainHeight = containerBounds.Height / 2; int dh = ComputePreviewHeightOffset(previewSize); selectCurrentPreview.Location = new Point(containerBounds.Left + previewSize.Width + 70, containerBounds.Bottom - dh - mainHeight - 30); selectCurrentPreview.Size = new Size(mainWidth, mainHeight); using (GraphicsPath regionPath = GraphicsOrder.CreateRoundRectPath(0, 0, mainWidth, mainHeight, 5)) { selectCurrentPreview.Visible = false; selectCurrentPreview.Region = null; selectCurrentPreview.Region = new Region(regionPath); } }
/// <summary> /// Show form preview /// </summary> /// <param name="bounds">preview bounds</param> /// <param name="renderer">renderer</param> /// <param name="graphics">graphics</param> public static void ShowFormPreview(Rectangle bounds, PreviewRenderer renderer, Graphics graphics) { using (GraphicsPath path = GraphicsOrder.CreateRoundRectPath(bounds.Left, bounds.Top, bounds.Width - 1, bounds.Height - 1, 5)) { renderer.DrawBackground(bounds, path, graphics); renderer.DrawBorder(bounds.Size, path, graphics); } Rectangle titleBounds = new Rectangle(bounds.Left + 10, bounds.Top + 10, bounds.Width - 21, 24); graphics.SetClip(titleBounds, CombineMode.Replace); renderer.DrawTitle(titleBounds, graphics); Rectangle previewBounds = new Rectangle(bounds.Left + 10, bounds.Top + 40, bounds.Width - 21, bounds.Height - 50); graphics.SetClip(previewBounds, CombineMode.Replace); renderer.DrawPreview(previewBounds, graphics); }
/// <summary> /// 更新面板尺寸 /// </summary> protected void UpdateSize() { if (IsDisposed) { return; } if (CutRoundRect) { using (GraphicsPath roundRect = GraphicsOrder.CreateRoundRectPath(0, 0, Width, Height - 1, RoundRadius)) { SetControlRegion(roundRect, this); } } else { SetControlRegion(null, this); } using (Graphics graphics = CreateGraphics()) { UpdatePositions(graphics, false); } }