コード例 #1
0
        protected override void Draw2D(Pi2PictureBox box, Graphics g, Graphics pickGraphics)
        {
            if (ControlPoints.Count >= 2)
            {
                Vec2 p1 = box.PictureToScreen(ControlPoints[0].GetXY());
                Vec2 p2 = box.PictureToScreen(ControlPoints[1].GetXY());

                float x = (float)Math.Min(p1.X, p2.X);
                float y = (float)Math.Min(p1.Y, p2.Y);
                float w = (float)Math.Abs(p2.X - p1.X);
                float h = (float)Math.Abs(p2.Y - p1.Y);

                using (Pen pen = new Pen(Color, (float)LineWidth))
                {
                    g.DrawRectangle(pen, x, y, w, h);

                    if (DrawCenterCross)
                    {
                        float s  = 20;
                        float cx = x + w / 2.0f;
                        float cy = y + h / 2.0f;
                        pen.DashStyle = CenterCrossStyle;
                        g.DrawLine(pen, cx, y - s, cx, y + h + s);
                        g.DrawLine(pen, x - s, cy, x + w + s, cy);
                    }
                }



                using (Pen pen = box.GetPickPen(this))
                    pickGraphics.DrawRectangle(pen, x, y, w, h);
            }
        }
コード例 #2
0
ファイル: LineAnnotations.cs プロジェクト: habi/pi2
        protected override void Draw2D(Pi2PictureBox box, Graphics g, Graphics pickGraphics)
        {
            if (ControlPoints.Count >= 2)
            {
                Vec2 p1 = box.PictureToScreen(ControlPoints[0].GetXY());
                Vec2 p2 = box.PictureToScreen(ControlPoints[1].GetXY());

                using (Pen pen = new Pen(Color, (float)LineWidth))
                    g.DrawLine(pen, p1.ToPointF(), p2.ToPointF());

                using (Pen pen = box.GetPickPen(this))
                    pickGraphics.DrawLine(pen, p1.ToPointF(), p2.ToPointF());
            }
        }
コード例 #3
0
ファイル: LineAnnotations.cs プロジェクト: habi/pi2
        protected override void Draw2D(Pi2PictureBox box, Graphics g, Graphics pickGraphics)
        {
            Vec2 p1 = box.PictureToScreen(new Vec2(box.OriginalWidth / 2.0, 0));
            Vec2 p2 = box.PictureToScreen(new Vec2(box.OriginalWidth / 2.0, box.OriginalHeight));

            Vec2 p3 = box.PictureToScreen(new Vec2(0, box.OriginalHeight / 2.0));
            Vec2 p4 = box.PictureToScreen(new Vec2(box.OriginalWidth, box.OriginalHeight / 2.0));

            using (Pen pen = new Pen(Color, (float)LineWidth))
            {
                g.DrawLine(pen, p1.ToPointF(), p2.ToPointF());
                g.DrawLine(pen, p3.ToPointF(), p4.ToPointF());
            }

            using (Pen pen = box.GetPickPen(this))
            {
                pickGraphics.DrawLine(pen, p1.ToPointF(), p2.ToPointF());
                pickGraphics.DrawLine(pen, p3.ToPointF(), p4.ToPointF());
            }
        }
コード例 #4
0
ファイル: Annotation.cs プロジェクト: habi/pi2
        /// <summary>
        /// Gets line width adjusted for highlighting.
        /// </summary>
        /// <returns></returns>
        //protected double GetLineWidthAdjustedForHighlighting()
        //{
        //    if (!IsHighlighted)
        //        return LineWidth;
        //    else
        //        return 2 * LineWidth;
        //}


        protected void DrawControlPoint(Pi2PictureBox box, Graphics g, Graphics pickGraphics, int pi, int currZ)
        {
            Vec3 p = ControlPoints[pi];

            if (Math.Abs(p.Z - currZ) < 0.5f)
            {
                const float R    = 3;
                Vec2        pos  = box.PictureToScreen(p.GetXY());
                RectangleF  rect = new RectangleF((float)(pos.X - R), (float)(pos.Y - R), 2 * R, 2 * R);
                g.FillRectangle(Brushes.WhiteSmoke, rect);
                g.DrawRectangle(Pens.Black, rect.X, rect.Y, rect.Width, rect.Height);

                using (Brush b = box.GetPickBrush(this, pi))
                    pickGraphics.FillRectangle(b, rect.X, rect.Y, rect.Width, rect.Height);
            }
        }