/// <summary> /// Draw a border and drag handles around the control, on mouse down and up. /// </summary> /// <param name="sender"></param> private void DrawControlBorder(object sender) { Control control = (Control)sender; //define the border to be drawn, it will be offset by DRAG_HANDLE_SIZE / 2 //around the control, so when the drag handles are drawn they will be seem //connected in the middle. Rectangle Border = new Rectangle( new Point(control.Location.X - DRAG_HANDLE_SIZE / 2, control.Location.Y - DRAG_HANDLE_SIZE / 2), new Size(control.Size.Width + DRAG_HANDLE_SIZE, control.Size.Height + DRAG_HANDLE_SIZE)); //define the 8 drag handles, that has the size of DRAG_HANDLE_SIZE Rectangle NW = new Rectangle( new Point(control.Location.X - DRAG_HANDLE_SIZE, control.Location.Y - DRAG_HANDLE_SIZE), new Size(DRAG_HANDLE_SIZE, DRAG_HANDLE_SIZE)); Rectangle N = new Rectangle( new Point(control.Location.X + control.Width / 2 - DRAG_HANDLE_SIZE / 2, control.Location.Y - DRAG_HANDLE_SIZE), new Size(DRAG_HANDLE_SIZE, DRAG_HANDLE_SIZE)); Rectangle NE = new Rectangle( new Point(control.Location.X + control.Width, control.Location.Y - DRAG_HANDLE_SIZE), new Size(DRAG_HANDLE_SIZE, DRAG_HANDLE_SIZE)); Rectangle W = new Rectangle( new Point(control.Location.X - DRAG_HANDLE_SIZE, control.Location.Y + control.Height / 2 - DRAG_HANDLE_SIZE / 2), new Size(DRAG_HANDLE_SIZE, DRAG_HANDLE_SIZE)); Rectangle E = new Rectangle( new Point(control.Location.X + control.Width, control.Location.Y + control.Height / 2 - DRAG_HANDLE_SIZE / 2), new Size(DRAG_HANDLE_SIZE, DRAG_HANDLE_SIZE)); Rectangle SW = new Rectangle( new Point(control.Location.X - DRAG_HANDLE_SIZE, control.Location.Y + control.Height), new Size(DRAG_HANDLE_SIZE, DRAG_HANDLE_SIZE)); Rectangle S = new Rectangle( new Point(control.Location.X + control.Width / 2 - DRAG_HANDLE_SIZE / 2, control.Location.Y + control.Height), new Size(DRAG_HANDLE_SIZE, DRAG_HANDLE_SIZE)); Rectangle SE = new Rectangle( new Point(control.Location.X + control.Width, control.Location.Y + control.Height), new Size(DRAG_HANDLE_SIZE, DRAG_HANDLE_SIZE)); //get the form graphic Graphics g = this.CreateGraphics(); //draw the border and drag handles ControlPaint.DrawBorder(g, Border, Color.Gray, ButtonBorderStyle.Dotted); ControlPaint.DrawGrabHandle(g, NW, true, true); ControlPaint.DrawGrabHandle(g, N, true, true); ControlPaint.DrawGrabHandle(g, NE, true, true); ControlPaint.DrawGrabHandle(g, W, true, true); ControlPaint.DrawGrabHandle(g, E, true, true); ControlPaint.DrawGrabHandle(g, SW, true, true); ControlPaint.DrawGrabHandle(g, S, true, true); ControlPaint.DrawGrabHandle(g, SE, true, true); g.Dispose(); }
void Shape.Draw(Graphics g, int order) { if (m_resizedImage == null) { return; } if (m_tempScale != 1.0f) { float newWidth = m_resizedImage.Width * m_tempScale; float newHeight = m_resizedImage.Height * m_tempScale; g.DrawImage(m_resizedImage, new RectangleF( (int)(m_fpoints[0].X + m_tempOffset.X - (newWidth - m_resizedImage.Width) * m_pivotX), (int)(m_fpoints[0].Y + m_tempOffset.Y - (newHeight - m_resizedImage.Height) * m_pivotY), (int)newWidth, (int)newHeight)); } else { // g.DrawImage(m_resizedImage, (int)(m_fpoints[0].X + m_tempOffset.X + 0.5f), (int)(m_fpoints[0].Y + m_tempOffset.Y + 0.5f)); g.DrawImage(m_resizedImage, (m_fpoints[0].X + m_tempOffset.X), (m_fpoints[0].Y + m_tempOffset.Y)); } if (Selected) { Rectangle border = new Rectangle((int)(m_fpoints[0].X + m_realBounds.X + m_tempOffset.X), (int)(m_fpoints[0].Y + m_realBounds.Y + m_tempOffset.Y), m_realBounds.Width, m_realBounds.Height); ControlPaint.DrawBorder(g, border, System.Drawing.Color.Black, ButtonBorderStyle.Dashed); if (Scalable) { Rectangle NW = new Rectangle(border.X - HANDLE_SIZE / 2, border.Y - HANDLE_SIZE / 2, HANDLE_SIZE, HANDLE_SIZE); Rectangle NE = new Rectangle(border.X + border.Width - HANDLE_SIZE - 1 + HANDLE_SIZE / 2, border.Y - HANDLE_SIZE / 2, HANDLE_SIZE, HANDLE_SIZE); Rectangle SW = new Rectangle(border.X - HANDLE_SIZE / 2, border.Y + border.Height - HANDLE_SIZE - 1 + HANDLE_SIZE / 2, HANDLE_SIZE, HANDLE_SIZE); Rectangle SE = new Rectangle(border.X + border.Width - HANDLE_SIZE - 1 + HANDLE_SIZE / 2, border.Y + border.Height - HANDLE_SIZE - 1 + HANDLE_SIZE / 2, HANDLE_SIZE, HANDLE_SIZE); ControlPaint.DrawGrabHandle(g, NW, true, true); ControlPaint.DrawGrabHandle(g, NE, true, true); ControlPaint.DrawGrabHandle(g, SW, true, true); ControlPaint.DrawGrabHandle(g, SE, true, true); } if (Movable) { Rectangle center = new Rectangle(border.X + border.Width / 2 - MOVE_HANDLE_SIZE / 2, border.Y + border.Height / 2 - MOVE_HANDLE_SIZE / 2, MOVE_HANDLE_SIZE, MOVE_HANDLE_SIZE); ControlPaint.DrawContainerGrabHandle(g, center); } if (Rotatable) { Rectangle pivot = new Rectangle((int)(m_fpoints[0].X + m_resizedImage.Width / 2 - ROTATE_HANDLE_SIZE / 2 + m_tempOffset.X - ROTATE_HANDLE_OFFSET), (int)(m_fpoints[0].Y + m_resizedImage.Height / 2 - ROTATE_HANDLE_SIZE / 2 + m_tempOffset.Y - ROTATE_HANDLE_OFFSET), ROTATE_HANDLE_SIZE, ROTATE_HANDLE_SIZE); ControlPaint.DrawGrabHandle(g, pivot, false, true); } } }
private void picturebox_Paint(object sender, PaintEventArgs e) { var g = e.Graphics; if (SourceBitmap == null) { var im = g.InterpolationMode; g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.High; var sm = g.SmoothingMode; g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality; g.DrawLine(Pens.Red, 0, 0, picturebox.Width, picturebox.Height); g.DrawLine(Pens.Red, picturebox.Width, 0, 0, picturebox.Height); g.InterpolationMode = im; g.SmoothingMode = sm; return; } var sel = ScreenSelection; var pc = _selection.Location.Add(new PointF(_selection.Size.Width / 2, _selection.Size.Height / 2)).ToPoint(); Point hl = new Point(5, 0), vl = new Point(0, 5); float a = 0f; if (a != 0) { var bmp = ScaledBitmap; float hw = bmp.Width / 2f; float hh = bmp.Height / 2f; g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality; g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic; g.TranslateTransform(hw, hh); g.RotateTransform(a); g.TranslateTransform(-hw, -hh); g.DrawImage(bmp, 0, 0); g.ResetTransform(); } // start with image else { g.DrawImage(ScaledBitmap, 0, 0); } // draw selection box g.DrawXORRectangle(Pens.Black, sel); // draw drag handle ControlPaint.DrawGrabHandle(g, new Rectangle(sel.Right - 3, sel.Bottom - 3, 7, 7), false, true); // draw centre crosshair g.DrawXORLine(Pens.Black, pc.Subtract(hl), pc.Add(hl)); g.DrawXORLine(Pens.Black, pc.Subtract(vl), pc.Add(vl)); }
public void RenderSelection(CanvasPaintArgs e) { Rectangle obounds = shape.GetBounds(); Rectangle ibounds = shape.GetBounds(); obounds.Inflate(1, 1); ibounds.Inflate(-1, -1); ControlPaint.DrawGrabHandle(e.g, new Rectangle((int)shape.X - 3, (int)shape.Y - 3, 6, 6), true, true); ControlPaint.DrawGrabHandle(e.g, new Rectangle((int)shape.X2 - 3, (int)shape.Y2 - 3, 6, 6), true, true); ControlPaint.DrawSelectionFrame(e.g, true, obounds, ibounds, Color.Transparent); }
protected override void OnPaintAdornments(PaintEventArgs pe) { var label = Control as BaseLineItem; if (SelectionService != null) { if (SelectionService.GetComponentSelected(label)) { // Paint grab handles. var grapRectangle = GetHandle(label.FromPoint); ControlPaint.DrawGrabHandle(pe.Graphics, grapRectangle, true, true); grapRectangle = GetHandle(label.ToPoint); ControlPaint.DrawGrabHandle(pe.Graphics, grapRectangle, true, true); } } }
/// <summary> Draw Border and Drag Handles around a specified control </summary> private static void DrawControlBorder(object sender) { Control control = (Control)sender; int HANDLE_SIZE = 5, HANDLE_HALF_SIZE = (HANDLE_SIZE / 2); using (Graphics g = control.CreateGraphics()) { Rectangle Border = new Rectangle( new Point(control.Location.X - HANDLE_HALF_SIZE, control.Location.Y - HANDLE_HALF_SIZE), new Size(control.Size.Width + HANDLE_SIZE, control.Size.Height + HANDLE_SIZE)); //define the 8 drag handles, that has the size of DRAG_HANDLE_SIZE Size gripSize = new Size(HANDLE_SIZE, HANDLE_SIZE); int x, y = control.Location.Y; x = control.Location.X + (control.Width / 2) - HANDLE_HALF_SIZE; Rectangle N = new Rectangle(new Point(x, y - HANDLE_SIZE), gripSize); Rectangle S = new Rectangle(new Point(x, y + control.Height), gripSize); x = control.Location.X - HANDLE_SIZE; Rectangle W = new Rectangle(new Point(x, y + (control.Height / 2) - HANDLE_HALF_SIZE), gripSize); Rectangle SW = new Rectangle(new Point(x, y + control.Height), gripSize); Rectangle NW = new Rectangle(new Point(x, y - HANDLE_SIZE), gripSize); x = control.Location.X + control.Width; Rectangle NE = new Rectangle(new Point(x, y - HANDLE_SIZE), gripSize); Rectangle E = new Rectangle(new Point(x, y + (control.Height / 2) - HANDLE_HALF_SIZE), gripSize); Rectangle SE = new Rectangle(new Point(x, y + control.Height), gripSize); //draw the border and drag handles { ControlPaint.DrawBorder(g, Border, Color.Gray, ButtonBorderStyle.Dotted); ControlPaint.DrawGrabHandle(g, NW, true, true); ControlPaint.DrawGrabHandle(g, N, true, true); ControlPaint.DrawGrabHandle(g, NE, true, true); ControlPaint.DrawGrabHandle(g, W, true, true); ControlPaint.DrawGrabHandle(g, E, true, true); ControlPaint.DrawGrabHandle(g, SW, true, true); ControlPaint.DrawGrabHandle(g, S, true, true); ControlPaint.DrawGrabHandle(g, SE, true, true); } } }
/////////////////////////////////////////////////////////////////////////////// // Public methods // /////////////////////////////////////////////////////////////////////////////// #region PUBLICMETHODS /// <summary> /// Draws this grab handle to the given graphics context /// </summary> /// <param name="g">A <see cref="Graphics"/> to draw the grab handle to.</param> public void Draw(Graphics g) { if (this.handlePosition == HandlePosition.Center) { RectangleF centerPoint = new RectangleF(this.Location, this.Size); g.FillEllipse(new SolidBrush(Color.White), centerPoint); g.DrawEllipse(new Pen(Color.Black), centerPoint); } else { ControlPaint.DrawGrabHandle( g, new Rectangle((int)this.location.X, (int)this.location.Y, this.size.Width, this.size.Height), true, true); } }
private void PnlDraw_Paint(object sender, PaintEventArgs e) { Stopwatch watch = new Stopwatch(); watch.Start(); e.Graphics.InterpolationMode = InterpolationMode.NearestNeighbor; //e.Graphics.SmoothingMode = SmoothingMode.AntiAlias; if (selectionRect.Width != 0 || selectionRect.Height != 0) { //path.AddRectangle(Helper.WriteText(e.Graphics, // string.Format("{0} x {1}", selectionRect.Width, selectionRect.Height), Rectangle.Round(selectionRect))); // Draw grabhandles around the rectangle if (drawHandles) { foreach (GrabHandle handle in Enum.GetValues(typeof(GrabHandle))) { if (handle == GrabHandle.None) { continue; } var rect = rectangles[handle]; rect.X = Helper.GetRectangleBounds(selectionRect, handle, 6f).X; rect.Y = Helper.GetRectangleBounds(selectionRect, handle, 6f).Y; ControlPaint.DrawGrabHandle(e.Graphics, Rectangle.Round(rect), true, true); e.Graphics.ExcludeClip(Rectangle.Round(rect)); rectangles[handle] = rect; } } // Draw border around the rectangle if (drawBorders) { ControlPaint.DrawBorder(e.Graphics, Rectangle.Round(selectionRect), Color.White, ButtonBorderStyle.Solid); ControlPaint.DrawBorder(e.Graphics, Rectangle.Round(selectionRect), Color.Black, ButtonBorderStyle.Dashed); } } //else // path.AddRectangle(Helper.WriteText(e.Graphics, "Select area", PointToClient(new Point(Cursor.Position.X, Cursor.Position.Y)), 20)); e.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit; e.Graphics.SmoothingMode = SmoothingMode.AntiAlias; // Assets now support undo foreach (Asset asset in assets) { if (asset.Shape == Shape.ArrowLine) { using (var pen = new Pen(asset.Color, asset.BorderWidth) { StartCap = LineCap.Round }) using (AdjustableArrowCap bigArrow = new AdjustableArrowCap(5, 5)) { pen.CustomEndCap = bigArrow; e.Graphics.DrawLine(pen, asset.LineStart, asset.LineEnd); } } else if (asset.Shape == Shape.Line) { using (var pen = new Pen(asset.Color, asset.BorderWidth) { StartCap = LineCap.Round, EndCap = LineCap.Round }) e.Graphics.DrawLine(pen, asset.LineStart, asset.LineEnd); } else if (asset.Shape == Shape.Circle) { using (var pen = new Pen(asset.Color, asset.BorderWidth) { StartCap = LineCap.Round, EndCap = LineCap.Round }) e.Graphics.DrawEllipse(pen, asset.Rectangle); } else if (asset.Shape == Shape.Rectangle) { using (var pen = new Pen(asset.Color, asset.BorderWidth) { StartCap = LineCap.Flat, EndCap = LineCap.Flat }) e.Graphics.DrawRectangle(pen, asset.Rectangle.X, asset.Rectangle.Y, asset.Rectangle.Width, asset.Rectangle.Height); } else if (asset.Shape == Shape.Pen) { if (asset.Points.Count > 1) { using (var pen = new Pen(asset.Color, asset.BorderWidth) { StartCap = LineCap.Round, EndCap = LineCap.Round }) e.Graphics.DrawCurve(pen, asset.Points.ToArray()); } } } // Draw current assets on mouse down using (var pen = new Pen(toolbox.SelectedColor, currBorderWidth) { StartCap = LineCap.Round, EndCap = LineCap.Round }) { if (mouseDown) { if (currDrawingTool == DrawingTool.Rectangle) { e.Graphics.DrawRectangle(pen, currAsset.Rectangle.X, currAsset.Rectangle.Y, currAsset.Rectangle.Width, currAsset.Rectangle.Height); } else if (currDrawingTool == DrawingTool.Circle) { e.Graphics.DrawEllipse(pen, currAsset.Rectangle); } else if (currDrawingTool == DrawingTool.Pen) { if (currAsset.Points.Count > 1) { e.Graphics.DrawCurve(pen, currAsset.Points.ToArray()); } } else if (currDrawingTool == DrawingTool.Line) { e.Graphics.DrawLine(pen, currAsset.LineStart, currAsset.LineEnd); } else if (currDrawingTool == DrawingTool.ArrowLine) { using (AdjustableArrowCap bigArrow = new AdjustableArrowCap(5, 5)) { pen.CustomEndCap = bigArrow; e.Graphics.DrawLine(pen, currAsset.LineStart, currAsset.LineEnd); } } } } if (currDrawingTool == DrawingTool.Text) { } // Draw tip of the Mouse if (currDrawingTool != DrawingTool.Arrow) { e.Graphics.DrawEllipse(Pens.Black, new RectangleF(PointToClient(Point.Round(new PointF(Cursor.Position.X - currBorderWidth / 2, Cursor.Position.Y - currBorderWidth / 2))), new SizeF(currBorderWidth, currBorderWidth))); } path.AddRectangle(new Rectangle(new Point(50, 50), new Size(100, 100))); watch.Stop(); Helper.WriteText(e.Graphics, watch.Elapsed.TotalMilliseconds.ToString(), PointToClient(new Point(50, 50)), 0); }
public virtual void OnPaint(PaintEventArgs e) { ControlPaint.DrawGrabHandle(e.Graphics, GetBounds(), true, true); }
private void DrawControlBorder(object sender) { var control = (Control)sender; if (control == null) { return; } var border = new Rectangle( new Point(control.Location.X - DRAG_HANDLE_SIZE / 2, control.Location.Y - DRAG_HANDLE_SIZE / 2), new Size(control.Size.Width + DRAG_HANDLE_SIZE, control.Size.Height + DRAG_HANDLE_SIZE)); var NW = new Rectangle( new Point(control.Location.X - DRAG_HANDLE_SIZE, control.Location.Y - DRAG_HANDLE_SIZE), new Size(DRAG_HANDLE_SIZE, DRAG_HANDLE_SIZE)); var N = new Rectangle( new Point(control.Location.X + control.Width / 2 - DRAG_HANDLE_SIZE / 2, control.Location.Y - DRAG_HANDLE_SIZE), new Size(DRAG_HANDLE_SIZE, DRAG_HANDLE_SIZE)); var NE = new Rectangle( new Point(control.Location.X + control.Width, control.Location.Y - DRAG_HANDLE_SIZE), new Size(DRAG_HANDLE_SIZE, DRAG_HANDLE_SIZE)); var W = new Rectangle( new Point(control.Location.X - DRAG_HANDLE_SIZE, control.Location.Y + control.Height / 2 - DRAG_HANDLE_SIZE / 2), new Size(DRAG_HANDLE_SIZE, DRAG_HANDLE_SIZE)); var E = new Rectangle( new Point(control.Location.X + control.Width, control.Location.Y + control.Height / 2 - DRAG_HANDLE_SIZE / 2), new Size(DRAG_HANDLE_SIZE, DRAG_HANDLE_SIZE)); var SW = new Rectangle( new Point(control.Location.X - DRAG_HANDLE_SIZE, control.Location.Y + control.Height), new Size(DRAG_HANDLE_SIZE, DRAG_HANDLE_SIZE)); var S = new Rectangle( new Point(control.Location.X + control.Width / 2 - DRAG_HANDLE_SIZE / 2, control.Location.Y + control.Height), new Size(DRAG_HANDLE_SIZE, DRAG_HANDLE_SIZE)); var SE = new Rectangle( new Point(control.Location.X + control.Width, control.Location.Y + control.Height), new Size(DRAG_HANDLE_SIZE, DRAG_HANDLE_SIZE)); //get the form graphic var g = pnControls.CreateGraphics(); //draw the border and drag handles ControlPaint.DrawBorder(g, border, Color.Gray, ButtonBorderStyle.Dotted); ControlPaint.DrawGrabHandle(g, NW, true, true); ControlPaint.DrawGrabHandle(g, N, true, true); ControlPaint.DrawGrabHandle(g, NE, true, true); ControlPaint.DrawGrabHandle(g, W, true, true); ControlPaint.DrawGrabHandle(g, E, true, true); ControlPaint.DrawGrabHandle(g, SW, true, true); ControlPaint.DrawGrabHandle(g, S, true, true); ControlPaint.DrawGrabHandle(g, SE, true, true); g.Dispose(); }
private void paintSplitter(object sender, PaintEventArgs e) { var splitter = sender as SplitContainer; ControlPaint.DrawGrabHandle(e.Graphics, splitter.SplitterRectangle, true, true); }
private void DrawGrabHandles(Graphics gfx) { GraphicsState state = gfx.Save(); gfx.TranslateTransform(this.Bounds.X, this.Bounds.Y); for (int i = 0; i < _handles.Length; i++) { _handles[i].Width = BORDER_SIZE; _handles[i].Height = BORDER_SIZE; } SelectionRules rules = this.SelectionRules; bool primarySelection = this.PrimarySelection; bool enabled = false; _handles[(int)GrabHandle.TopLeft].Location = new Point(0, 0); if (this.CheckSelectionRules(rules, SelectionRules.TopSizeable | SelectionRules.LeftSizeable)) { enabled = true; } ControlPaint.DrawGrabHandle(gfx, _handles[(int)GrabHandle.TopLeft], primarySelection, enabled); enabled = false; _handles[(int)GrabHandle.TopMiddle].Location = new Point((this.Bounds.Width - BORDER_SIZE) / 2, 0); if (this.CheckSelectionRules(rules, SelectionRules.TopSizeable)) { enabled = true; } ControlPaint.DrawGrabHandle(gfx, _handles[(int)GrabHandle.TopMiddle], primarySelection, enabled); enabled = false; _handles[(int)GrabHandle.TopRight].Location = new Point(this.Bounds.Width - BORDER_SIZE, 0); if (this.CheckSelectionRules(rules, SelectionRules.TopSizeable | SelectionRules.RightSizeable)) { enabled = true; } ControlPaint.DrawGrabHandle(gfx, _handles[(int)GrabHandle.TopRight], primarySelection, enabled); enabled = false; _handles[(int)GrabHandle.Right].Location = new Point(this.Bounds.Width - BORDER_SIZE, (this.Bounds.Height - BORDER_SIZE) / 2); if (this.CheckSelectionRules(rules, SelectionRules.RightSizeable)) { enabled = true; } ControlPaint.DrawGrabHandle(gfx, _handles[(int)GrabHandle.Right], primarySelection, enabled); enabled = false; _handles[(int)GrabHandle.BottomRight].Location = new Point(this.Bounds.Width - BORDER_SIZE, this.Bounds.Height - BORDER_SIZE); if (this.CheckSelectionRules(rules, SelectionRules.BottomSizeable | SelectionRules.RightSizeable)) { enabled = true; } ControlPaint.DrawGrabHandle(gfx, _handles[(int)GrabHandle.BottomRight], primarySelection, enabled); enabled = false; _handles[(int)GrabHandle.BottomMiddle].Location = new Point((this.Bounds.Width - BORDER_SIZE) / 2, this.Bounds.Height - BORDER_SIZE); if (this.CheckSelectionRules(rules, SelectionRules.BottomSizeable)) { enabled = true; } ControlPaint.DrawGrabHandle(gfx, _handles[(int)GrabHandle.BottomMiddle], primarySelection, enabled); enabled = false; _handles[(int)GrabHandle.BottomLeft].Location = new Point(0, this.Bounds.Height - BORDER_SIZE); if (this.CheckSelectionRules(rules, SelectionRules.BottomSizeable | SelectionRules.LeftSizeable)) { enabled = true; } ControlPaint.DrawGrabHandle(gfx, _handles[(int)GrabHandle.BottomLeft], primarySelection, enabled); enabled = false; _handles[(int)GrabHandle.Left].Location = new Point(0, (this.Bounds.Height - BORDER_SIZE) / 2); if (this.CheckSelectionRules(rules, SelectionRules.LeftSizeable)) { enabled = true; } ControlPaint.DrawGrabHandle(gfx, _handles[(int)GrabHandle.Left], primarySelection, enabled); gfx.Restore(state); }