public EditorBox AddBox(EditorBox editorBox) { DlibObject.Boxes.Add(editorBox.DlibObject); this.Boxes.Add(editorBox); return(editorBox); }
private Rectangle[] GetAnchors(EditorBox box) { /* Anchors */ int anchorSize = 8; // 10px int hAnchorSize = anchorSize / 2; int cX = box.Left + (box.Width / 2); int cY = box.Top + (box.Height / 2); return(new Rectangle[] { // top - left new Rectangle(box.Left - hAnchorSize, box.Top - hAnchorSize, anchorSize, anchorSize), // top - right new Rectangle(box.Left + box.Width - hAnchorSize, box.Top - hAnchorSize, anchorSize, anchorSize), // bottom - left new Rectangle(box.Left - hAnchorSize, box.Top + box.Height - hAnchorSize, anchorSize, anchorSize), // bottom - right new Rectangle(box.Left + box.Width - hAnchorSize, box.Top + box.Height - hAnchorSize, anchorSize, anchorSize), // top - center new Rectangle(cX - hAnchorSize, box.Top - hAnchorSize, anchorSize, anchorSize), // bottom - center new Rectangle(cX - hAnchorSize, box.Top + box.Height - hAnchorSize, anchorSize, anchorSize), // left - center new Rectangle(box.Left - hAnchorSize, cY - anchorSize, anchorSize, anchorSize), // right - center new Rectangle(box.Left + box.Width - hAnchorSize, cY - anchorSize, anchorSize, anchorSize), }); }
public override Bitmap Render(Image prev, EditorBox box) { Bitmap boxMask = new Bitmap(prev); Brush b = new SolidBrush(Color.FromArgb(Opacity, mSelected.R, mSelected.G, mSelected.B)); Brush fc = new SolidBrush(Color.White); Pen bc = (Pen)EditorBox.Pen.Clone(); Rectangle[] anchors = GetAnchors(box); bc.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash; using (Graphics g = Graphics.FromImage(boxMask)) { g.FillRectangle(b, box.Rectangle); g.DrawRectangle(bc, box.Rectangle); bc.DashStyle = System.Drawing.Drawing2D.DashStyle.Solid; g.FillRectangles(fc, anchors); g.DrawRectangles(bc, anchors); } return(boxMask); }
public override Bitmap Render(Image prev, EditorBox box) { Bitmap boxMask = new Bitmap(prev); using (Graphics g = Graphics.FromImage(boxMask)) { g.DrawRectangle(EditorBox.Pen, box.Rectangle); g.DrawString(box.Label, new Font("Verdana", 10.0f), EditorBox.Brush, new PointF(box.Left + box.Width, box.Top)); } return(boxMask); }
public Image GetImage(EditorBox box) { Bitmap region = new Bitmap(box.Width, box.Height); for (int i = box.Left; i < (box.Left + box.Width); i++) { for (int j = box.Top; j < (box.Top + box.Height); j++) { region.SetPixel(i - box.Left, j - box.Top, bmpImage.GetPixel(i, j)); } } return(region); }
public abstract Bitmap Render(Image prev, EditorBox box);