public void Draw() { const int WM_SETREDRAW = 0x000B; SendMessage(Handle, WM_SETREDRAW, 0, IntPtr.Zero); // supress redrawing TransformParams tr = new TransformParams(0, 0, m_scale_factor); int width = (int)Math.Ceiling(tr.Transform(m_canvas_size.Width)); int height = (int)Math.Ceiling(tr.Transform(m_canvas_size.Height)); if (m_drawable_object == null) { PrepareBitmap(MAIN_LAYER, width, height); SetupCanvas(width, height); picBoxCanvas.Image = canvas_view.Bitmap; } else { BitmapInfo main_layer = PrepareBitmap(MAIN_LAYER, width, height); m_drawable_object.Draw(main_layer.Graphics, tr); SetupCanvas(width, height); picBoxCanvas.Image = canvas_view.Bitmap; } SendMessage(Handle, WM_SETREDRAW, 1, IntPtr.Zero); // resume redrawing AutoScroll = true; // update scrollbars Refresh(); // repaint control }
public static bool IsObjectAt(float ptX, float ptY, TransformParams t, float x1, float y1, float x2, float y2, ref float dist) { Utils.ThrowException(t == null ? new ArgumentNullException("t") : null); Vector2DF pt1 = t.Transform(new Vector2DF(x1, y1)); Vector2DF pt2 = t.Transform(new Vector2DF(x2, y2)); return(VisualizationUtils.TestLineHit(new Vector2DF(ptX, ptY), pt1, pt2, mHitDist, ref dist)); }
public static bool IsObjectAt(float pt_x, float pt_y, TransformParams tr, float x1, float y1, float x2, float y2, ref float dist) { Utils.ThrowException(tr.NotSet ? new ArgumentValueException("tr") : null); Vector2D pt1 = tr.Transform(new Vector2D(x1, y1)); Vector2D pt2 = tr.Transform(new Vector2D(x2, y2)); return(VisualizationUtils.TestLineHit(new Vector2D(pt_x, pt_y), pt1, pt2, m_hit_dist, ref dist)); }
public void Transform(TransformParams tr) { Utils.ThrowException(tr.NotSet ? new ArgumentValueException("tr") : null); for (int i = 0; i < m_rects.Count; i++) { m_rects[i] = tr.Transform(m_rects[i]); } m_bounding_box = tr.Transform(m_bounding_box); }
public void Transform(TransformParams tr) { Utils.ThrowException(tr == null ? new ArgumentNullException("tr") : null); for (int i = 0; i < mRects.Count; i++) { mRects[i] = tr.Transform(mRects[i]); } mBoundingBox = tr.Transform(mBoundingBox); }
public override IDrawableObject GetObjectAt(float x, float y, TransformParams t, ref float dist) { Utils.ThrowException(t == null ? new ArgumentNullException("t") : null); float width = t.Transform(mWidth); float height = t.Transform(mHeight); Vector2DF pos = t.Transform(new Vector2DF(mX - mWidth / 2f, mY - mHeight / 2f)); return(VisualizationUtils.PointInsideRect(x, y, new RectangleF(pos.X, pos.Y, width, height)) ? this : null); }
public static bool IsObjectAt(Image image, float x, float y, float ptX, float ptY, TransformParams t) { Utils.ThrowException(t == null ? new ArgumentNullException("t") : null); // TODO: other exceptions float width = t.Transform(image.Width); float height = t.Transform(image.Height); Vector2DF pos = t.Transform(new Vector2DF(x, y)); return(VisualizationUtils.PointInsideRect(ptX, ptY, new RectangleF(pos.X, pos.Y, width, height))); }
public static void Draw(float x1, float y1, float x2, float y2, Graphics g, Pen pen, TransformParams t) { Utils.ThrowException(g == null ? new ArgumentNullException("g") : null); Utils.ThrowException(pen == null ? new ArgumentNullException("pen") : null); Utils.ThrowException(t == null ? new ArgumentNullException("t") : null); Vector2DF pt1 = t.Transform(new Vector2DF(x1, y1)); Vector2DF pt2 = t.Transform(new Vector2DF(x2, y2)); g.DrawLine(pen, pt1, pt2); }
public static void Draw(float x1, float y1, float x2, float y2, Graphics gfx, Pen pen, TransformParams tr) { Utils.ThrowException(gfx == null ? new ArgumentNullException("gfx") : null); Utils.ThrowException(pen == null ? new ArgumentNullException("pen") : null); Utils.ThrowException(tr.NotSet ? new ArgumentValueException("tr") : null); Vector2D pt1 = tr.Transform(new Vector2D(x1, y1)); Vector2D pt2 = tr.Transform(new Vector2D(x2, y2)); gfx.DrawLine(pen, pt1, pt2); }
public override void Draw(Graphics g, TransformParams t) { Utils.ThrowException(g == null ? new ArgumentNullException("g") : null); Utils.ThrowException(t == null ? new ArgumentNullException("t") : null); Vector2DF pos = t.Transform(new Vector2DF(mX - mWidth / 2f, mY - mHeight / 2f)); using (Font font = new Font(mFont.FontFamily, t.Transform(mFont.Size), mFont.Style)) { g.DrawString(mLabel, font, mBrush, pos.X, pos.Y, StringFormat.GenericTypographic); } }
public static void Draw(Image image, float x, float y, Graphics g, TransformParams t) { Utils.ThrowException(g == null ? new ArgumentNullException("g") : null); Utils.ThrowException(t == null ? new ArgumentNullException("t") : null); // TODO: throw other exceptions float width = t.Transform(image.Width); float height = t.Transform(image.Height); Vector2DF pos = t.Transform(new Vector2DF(x, y)); PixelOffsetMode pixelOffsetMode = g.PixelOffsetMode; g.PixelOffsetMode = PixelOffsetMode.Half; g.DrawImage(image, pos.X, pos.Y, width, height); g.PixelOffsetMode = pixelOffsetMode; }
public static void Draw(float x1, float y1, float x2, float y2, Graphics g, Pen pen, TransformParams t, BoundingArea.ReadOnly boundingArea) { #if !NO_PARTIAL_RENDERING Utils.ThrowException(g == null ? new ArgumentNullException("g") : null); Utils.ThrowException(pen == null ? new ArgumentNullException("pen") : null); Utils.ThrowException(t == null ? new ArgumentNullException("t") : null); Utils.ThrowException(boundingArea == null ? new ArgumentNullException("boundingArea") : null); Vector2DF pt1 = t.Transform(new Vector2DF(x1, y1)); Vector2DF pt2 = t.Transform(new Vector2DF(x2, y2)); Vector2DF isectPt1 = new Vector2DF(); Vector2DF isectPt2 = new Vector2DF(); BoundingArea inflatedArea = boundingArea.GetWritableCopy(); inflatedArea.Inflate(pen.Width / 2f + 5f, pen.Width / 2f + 5f); ArrayList <KeyDat <float, PointInfo> > points = new ArrayList <KeyDat <float, PointInfo> >(); foreach (RectangleF rect in inflatedArea.Rectangles) { if (LineIntersectRectangle(pt1, pt2, rect, ref isectPt1, ref isectPt2)) { float distPt1 = (pt1 - isectPt1).GetLength(); float distPt2 = (pt1 - isectPt2).GetLength(); bool startPt1 = distPt1 < distPt2; points.Add(new KeyDat <float, PointInfo>(distPt1, new PointInfo(isectPt1, startPt1))); points.Add(new KeyDat <float, PointInfo>(distPt2, new PointInfo(isectPt2, !startPt1))); } } points.Sort(); int refCount = 0; int startIdx = 0; for (int i = 0; i < points.Count; i++) { PointInfo pointInfo = points[i].Dat; if (pointInfo.IsStartPoint) { refCount++; } else { refCount--; if (refCount == 0) { g.DrawLine(pen, points[startIdx].Dat.Point, pointInfo.Point); startIdx = i + 1; } } } #else Draw(x1, y1, x2, y2, g, pen, t); #endif }
public static void Draw(float x, float y, float r_x, float r_y, Graphics gfx, Pen pen, Brush brush, TransformParams tr) { Utils.ThrowException(gfx == null ? new ArgumentNullException("gfx") : null); Utils.ThrowException(pen == null ? new ArgumentNullException("pen") : null); Utils.ThrowException(brush == null ? new ArgumentNullException("brush") : null); Utils.ThrowException(tr.NotSet ? new ArgumentValueException("tr") : null); x -= r_x; y -= r_y; Vector2D center = tr.Transform(new Vector2D(x, y)); float d_x = tr.Transform(2f * r_x); float d_y = tr.Transform(2f * r_y); lock (brush) { gfx.FillEllipse(brush, center.X, center.Y, d_x, d_y); } lock (pen) { gfx.DrawEllipse(pen, center.X, center.Y, d_x, d_y); } }
public static void Draw(float x, float y, float rX, float rY, Graphics g, Pen pen, Brush brush, TransformParams t) { Utils.ThrowException(g == null ? new ArgumentNullException("g") : null); Utils.ThrowException(pen == null ? new ArgumentNullException("pen") : null); Utils.ThrowException(brush == null ? new ArgumentNullException("brush") : null); Utils.ThrowException(t == null ? new ArgumentNullException("t") : null); x -= rX; y -= rY; Vector2DF center = t.Transform(new Vector2DF(x, y)); float dX = t.Transform(2f * rX); float dY = t.Transform(2f * rY); g.FillEllipse(brush, center.X, center.Y, dX, dY); g.DrawEllipse(pen, center.X, center.Y, dX, dY); }
public static void Draw(float x, float y, float rX, float rY, Graphics gfx, Pen pen, Brush brush, TransformParams tr) { Utils.ThrowException(gfx == null ? new ArgumentNullException("gfx") : null); Utils.ThrowException(pen == null ? new ArgumentNullException("pen") : null); Utils.ThrowException(brush == null ? new ArgumentNullException("brush") : null); Utils.ThrowException(tr.NotSet ? new ArgumentValueException("tr") : null); x -= rX; y -= rY; VectorF center = tr.Transform(new VectorF(x, y)); float dX = tr.Transform(2f * rX); float dY = tr.Transform(2f * rY); lock (brush) { gfx.FillEllipse(brush, center.X, center.Y, dX, dY); } lock (pen) { gfx.DrawEllipse(pen, center.X, center.Y, dX, dY); } }
public static bool IsObjectAt(float pt_x, float pt_y, TransformParams tr, float c_x, float c_y, float r_x, float r_y) { Utils.ThrowException(tr.NotSet ? new ArgumentValueException("tr") : null); Vector2D center = tr.Transform(new Vector2D(c_x, c_y)); Vector2D pt = new Vector2D(pt_x, pt_y); if (pt == center) { return(true); } float angle = (pt - center).GetAngle(); float x = (float)Math.Cos(angle) * tr.Transform(r_x); float y = (float)Math.Sin(angle) * tr.Transform(r_y); float r = new Vector2D(x, y).GetLength(); return((center - pt).GetLength() <= r); }
public static bool IsObjectAt(float ptX, float ptY, TransformParams tr, float cX, float cY, float rX, float rY) { Utils.ThrowException(tr.NotSet ? new ArgumentValueException("tr") : null); VectorF center = tr.Transform(new VectorF(cX, cY)); VectorF pt = new VectorF(ptX, ptY); if (pt == center) { return(true); } float angle = (pt - center).GetAngle(); float x = (float)Math.Cos(angle) * tr.Transform(rX); float y = (float)Math.Sin(angle) * tr.Transform(rY); float r = new VectorF(x, y).GetLength(); return((center - pt).GetLength() <= r); }