Пример #1
0
 public static void _drawBroken(Line2I nLine, Graphics nGraphics, RGB nRGB, bool nStart = true)
 {
     Color color_ = nRGB._getColor();
     Pen pen_ = new Pen(color_);
     float length_ = nLine._length();
     if (length_ < 6)
     {
         nGraphics.DrawLine(pen_, nLine._begX(), nLine._begY(), nLine._endX(), nLine._endY());
         return;
     }
     Point2I point_ = nLine._vector();
     PointF f = new PointF();
     f.X = point_._getX() / length_;
     f.Y = point_._getY() / length_;
     if (nStart)
     {
         for (int i = 0; i < (length_ - 1); i += 8)
         {
             Point beg_ = new Point();
             beg_.X = (int)(i * f.X + nLine._begX());
             beg_.Y = (int)(i * f.Y + nLine._begY());
             int k = i + 3;
             Point end_ = new Point();
             end_.X = (int)(k * f.X + nLine._begX());
             end_.Y = (int)(k * f.Y + nLine._begY());
             nGraphics.DrawLine(pen_, beg_, end_);
         }
     }
     else
     {
         for (int i = 0; i < (length_ - 1); i += 8)
         {
             Point beg_ = new Point();
             int l = i + 5;
             beg_.X = (int)(l * f.X + nLine._begX());
             beg_.Y = (int)(l * f.Y + nLine._begY());
             Point end_ = new Point();
             int k = i;
             end_.X = (int)(k * f.X + nLine._begX());
             end_.Y = (int)(k * f.Y + nLine._begY());
             nGraphics.DrawLine(pen_, beg_, end_);
         }
     }
 }
Пример #2
0
 public static void _runDraw(Line2I nLine, Graphics nGraphics, RGB nRGB, string nStyle, int nWidth = 1, Image nImage = null, string nName = null, FONT nFont = null)
 {
     PenCapProvider penCapProvider_ = __singleton<PenCapProvider>._instance();
     Color color_ = nRGB._getColor();
     Pen pen_ = new Pen(color_, nWidth);
     if ("multiEnd" == nStyle)
     {
         pen_.CustomEndCap = penCapProvider_._getMultiCap();
     }
     else if ("multiBeg" == nStyle)
     {
         pen_.CustomStartCap = penCapProvider_._getMultiCap();
     }
     else if ("multiMulti" == nStyle)
     {
         pen_.CustomStartCap = penCapProvider_._getMultiCap();
         pen_.CustomEndCap = penCapProvider_._getMultiCap();
     }
     else if ("multiAggr" == nStyle)
     {
         pen_.CustomStartCap = penCapProvider_._getMultiCap();
         pen_.CustomEndCap = penCapProvider_._getAggrCap();
     }
     else if ("multiInh" == nStyle)
     {
         pen_.CustomStartCap = penCapProvider_._getMultiCap();
         pen_.CustomEndCap = penCapProvider_._getInhCap();
     }
     else if ("multiSingle" == nStyle)
     {
         pen_.CustomStartCap = penCapProvider_._getMultiCap();
         pen_.CustomEndCap = penCapProvider_._getSingleCap();
     }
     else if ("aggrEnd" == nStyle)
     {
         pen_.CustomEndCap = penCapProvider_._getAggrCap();
     }
     else if ("aggrBeg" == nStyle)
     {
         pen_.CustomStartCap = penCapProvider_._getAggrCap();
     }
     else if ("aggrMulti" == nStyle)
     {
         pen_.CustomStartCap = penCapProvider_._getAggrCap();
         pen_.CustomEndCap = penCapProvider_._getMultiCap();
     }
     else if ("aggrAggr" == nStyle)
     {
         pen_.CustomStartCap = penCapProvider_._getAggrCap();
         pen_.CustomEndCap = penCapProvider_._getAggrCap();
     }
     else if ("aggrInh" == nStyle)
     {
         pen_.CustomStartCap = penCapProvider_._getAggrCap();
         pen_.CustomEndCap = penCapProvider_._getInhCap();
     }
     else if ("aggrSingle" == nStyle)
     {
         pen_.CustomStartCap = penCapProvider_._getAggrCap();
         pen_.CustomEndCap = penCapProvider_._getSingleCap();
     }
     else if ("inhEnd" == nStyle)
     {
         pen_.CustomEndCap = penCapProvider_._getInhCap();
     }
     else if ("inhBeg" == nStyle)
     {
         pen_.CustomStartCap = penCapProvider_._getInhCap();
     }
     else if ("inhMulti" == nStyle)
     {
         pen_.CustomStartCap = penCapProvider_._getInhCap();
         pen_.CustomEndCap = penCapProvider_._getMultiCap();
     }
     else if ("inhAggr" == nStyle)
     {
         pen_.CustomStartCap = penCapProvider_._getInhCap();
         pen_.CustomEndCap = penCapProvider_._getAggrCap();
     }
     else if ("inhInh" == nStyle)
     {
         pen_.CustomStartCap = penCapProvider_._getInhCap();
         pen_.CustomEndCap = penCapProvider_._getInhCap();
     }
     else if ("inhSingle" == nStyle)
     {
         pen_.CustomStartCap = penCapProvider_._getInhCap();
         pen_.CustomEndCap = penCapProvider_._getSingleCap();
     }
     else if ("singleEnd" == nStyle)
     {
         pen_.CustomEndCap = penCapProvider_._getSingleCap();
     }
     else if ("singleBeg" == nStyle)
     {
         pen_.CustomStartCap = penCapProvider_._getSingleCap();
     }
     else if ("singleMulti" == nStyle)
     {
         pen_.CustomStartCap = penCapProvider_._getSingleCap();
         pen_.CustomEndCap = penCapProvider_._getMultiCap();
     }
     else if ("singleAggr" == nStyle)
     {
         pen_.CustomStartCap = penCapProvider_._getSingleCap();
         pen_.CustomEndCap = penCapProvider_._getAggrCap();
     }
     else if ("singleInh" == nStyle)
     {
         pen_.CustomStartCap = penCapProvider_._getSingleCap();
         pen_.CustomEndCap = penCapProvider_._getInhCap();
     }
     else if ("singleSingle" == nStyle)
     {
         pen_.CustomStartCap = penCapProvider_._getSingleCap();
         pen_.CustomEndCap = penCapProvider_._getSingleCap();
     }
     else
     {
     }
     GraphicsState graphicsState_ = nGraphics.Save();
     nGraphics.SmoothingMode = SmoothingMode.HighQuality;
     nGraphics.DrawLine(pen_, nLine._begX(), nLine._begY(), nLine._endX(), nLine._endY());
     nGraphics.Restore(graphicsState_);
     Rect2I rect_ = new Rect2I(nLine._getBeg(), nLine._getEnd());
     Point2I imagePoint_ = nLine._begPoint();
     if (null == imagePoint_)
     {
         return;
     }
     if (nLine._begX() < nLine._endX())
     {
         imagePoint_._offset(3, 0);
     }
     else
     {
         imagePoint_._offset(-3, 0);
     }
     if (nLine._begY() < nLine._endY())
     {
         imagePoint_._offset(0, 3);
     }
     else
     {
         imagePoint_._offset(0, -3);
     }
     nGraphics.DrawImage(nImage, imagePoint_._getX(), imagePoint_._getY(), 12, 12);
     if (null == nName || "" == nName)
     {
         return;
     }
     int h_ = rect_._getHeight();
     if (h_ < 18)
     {
         return;
     }
     Point2I center_ = rect_._centerPoint();
     int x_ = center_._getX() - 50;
     int y_ = center_._getY() - 9;
     int w_ = 100;
     int hx_ = 18;
     Rect2I rect0_ = new Rect2I(x_, y_, w_, hx_);
     Graphicsos._drawString(nName, rect0_, nGraphics, nFont);
 }
Пример #3
0
        bool _intersectWithY(Line2I nLine)
        {
            int x_ = default(int);
            int x0_ = default(int);
            int x1_ = mPoint._getY();
            int x2_ = mPoint._getY() + mSize._getHeight();
            if (((nLine._begY() < x1_) && (nLine._endY() > x1_)) || ((nLine._begY() > x1_) && (nLine._endY() < x1_)))
            {
                x_ = x1_;
            }

            if (((nLine._begY() < x2_) && (nLine._endY() > x2_)) || ((nLine._begY() > x2_) && (nLine._endY() < x2_)))
            {
                x0_ = x2_;
            }
            if ((x_ == default(int)) && (x0_ == default(int)))
            {
                return false;
            }
            int y1_ = mPoint._getX();
            int y2_ = mPoint._getX() + mSize._getWidth();

            int y_ = default(int);
            if (x_ != default(int))
            {
                y_ = nLine._xPoint(x_);
            }

            int y0_ = default(int);
            if (x0_ != default(int))
            {
                y0_ = nLine._xPoint(x0_);
            }

            if ((y_ > y1_) && (y_ < y2_))
            {
                return true;
            }

            if ((y0_ > y1_) && (y0_ < y2_))
            {
                return true;
            }
            return false;
        }