Widen() public method

public Widen ( Pen pen ) : void
pen Pen
return void
Beispiel #1
0
        private void Form2_Paint(object sender, PaintEventArgs e)
        {
            //패스 그래디언트
            Point[] pts = { new Point(100, 0), new Point(0, 100), new Point(200, 100) };
            PathGradientBrush B = new PathGradientBrush(pts, WrapMode.Tile);
            e.Graphics.FillRectangle(B, ClientRectangle);

            //패스 그래디언트 끝
            //패스변형
            GraphicsPath Path = new GraphicsPath();
            Path.AddString("한글", new FontFamily("궁서"), 0, 100, new Point(10, 30), new StringFormat());
            //확장 후 외곽선 그리기
            Path.Widen(new Pen(Color.Black, 3));
            e.Graphics.DrawPath(Pens.Black, Path);

            //확장 후 채우기
            Path.Widen(new Pen(Color.Blue, 3));
            e.Graphics.DrawPath(Pens.Black, Path);

            //곡선 펴기
            Path.Flatten(new Matrix(), 12f);
            e.Graphics.DrawPath(Pens.Black, Path);

            //회전
            Matrix M = new Matrix();
            M.Rotate(-10);
            Path.Transform(M);
            e.Graphics.FillPath(Brushes.Blue, Path);

            //휘기
            RectangleF R = Path.GetBounds();
            PointF[] arPoint = new PointF[4];
            arPoint[0] = new PointF(R.Left, R.Top + 30);
            arPoint[1] = new PointF(R.Right, R.Top - 10);
            arPoint[2] = new PointF(R.Left + 10, R.Bottom - 10);
            arPoint[3] = new PointF(R.Right + 30, R.Bottom + 30);

            Path.Warp(arPoint, R);
            e.Graphics.FillPath(Brushes.Blue, Path);

            //클리핑

            //graphicspath path= new graphicspath();
            //path.fillmode = fillmode.winding;
            //path.addellipse(50, 10, 100, 80);
            //path.addellipse(20, 45, 160, 120);
            //e.graphics.fillpath(brushes.white, path);

            //e.graphics.setclip(path);

            //for (int y = 0; y < bottom; y+= 20)
            //{
            //    string str = "눈사람의 모양의클리핑 영역에 글자를 쓴것입니다";
            //    e.graphics.drawstring(str, font, brushes.blue, 0, y);
            //}

            //클리핑 끝
        }
Beispiel #2
0
        private void drawArrow(Point startPoint)
        {
            Rectangle rect  = new Rectangle();
            int       width = 60;

            rect.X      = startPoint.X - width / 2;
            rect.Y      = startPoint.Y - width / 2;
            rect.Width  = width;
            rect.Height = width;
            Console.WriteLine("{0} [{1},{2}]", startPoint.ToString(), rect.X, rect.Y);
            this.BackColor = Color.Red;
            this.Opacity   = 1;


            AdjustableArrowCap triangleCap = new AdjustableArrowCap(3, 2, true);
            Pen myPen = new Pen(Color.Red, 10);

            myPen.CustomEndCap = triangleCap;
            myPen.StartCap     = LineCap.NoAnchor;


            System.Drawing.Drawing2D.GraphicsPath testPath = new System.Drawing.Drawing2D.GraphicsPath();
            testPath.AddLine(new Point(startPoint.X + rect.Width, startPoint.Y + rect.Height), startPoint);
            testPath.Widen(myPen);


            Region region = new Region(rcScreen);

            region.Intersect(testPath);

            this.Region = region;
        }
        public new void Draw(Graphics g, PointF pntDrawOffset, Point pntMouseLocation, MouseButtons mbButtons) {

            GraphicsPath gpSeekPosition = new GraphicsPath();
            gpSeekPosition.AddLine(new PointF(6.0F, 2), new PointF(this.SeekerBounds.Width - this.SeekerPosition * (this.SeekerBounds.Width - 15) - 5, 2));
            gpSeekPosition.Widen(this.m_pOneWidth);
            this.DrawBwShape(g, gpSeekPosition, this.ButtonOpacity, 4.0F, Color.Black, ControlPaint.LightLight(Color.LightSeaGreen));

            if (this.m_isMouseDown == true) {

                if (pntMouseLocation.X < pntDrawOffset.X) {
                    this.SeekerPosition = 0.0F;
                }
                else if (pntMouseLocation.X > pntDrawOffset.X + this.SeekerBounds.Width - 15) {
                    this.SeekerPosition = 1.0F;
                }
                else {
                    this.SeekerPosition = (pntMouseLocation.X - pntDrawOffset.X - 6) / (this.SeekerBounds.Width - 15);
                }
            }

            float xBeginningOffset = pntDrawOffset.X;

            pntDrawOffset.X += this.SeekerPosition * (this.SeekerBounds.Width - 15);

            this.HotSpot = new RectangleF(-pntDrawOffset.X + xBeginningOffset, -15, this.SeekerBounds.Width, 20);

            base.Draw(g, pntDrawOffset, pntMouseLocation, mbButtons);

            gpSeekPosition.Dispose();
        }
Beispiel #4
0
        /// <summary>
        /// Проверяет попадание точки в фигуру
        /// </summary>
        /// <param name="p"></param>
        /// <returns>-1 - нет попадания, 0 - есть попадание, 1 и более - номер опорной точки в которую попал курсор</returns>
        public override int ContainsPoint(Point p)
        {
            if (this.IsSelected)
            {
                for (int i = 1; i <= KeyPoints.Length; i++)
                {
                    if (PaintHelper.GetKeyPointWhiteRect(KeyPoints[i - 1]).Contains(p))
                        return i;
                }
            }

            var path = new GraphicsPath();
            Pen pen = new Pen(DrawSettings.Color, DrawSettings.Thickness);

            Rectangle rect = NormalRectToSquare(PaintHelper.NormalizeRect(StartPoint, EndPoint));
            path.AddEllipse(rect);
            path.Widen(pen);

            Region region = new Region(path);
            pen.Dispose();
            if(region.IsVisible(p))
                return 0;

            Point center = new Point(rect.X + rect.Width / 2, rect.Y + rect.Height / 2);
            double radius = rect.Width / 2;
            float dx = p.X - center.X;
            float dy = p.Y - center.Y;
            if (Math.Sqrt(dx * dx + dy * dy) <= radius)
                return 0;
            return -1;
        }
Beispiel #5
0
 //檢查座標是否圖形內
 public override bool ContainsInShape(int x, int y)
 {
     GraphicsPath path = new GraphicsPath();
     path.FillMode = FillMode.Winding;
     path.AddLine(_locationOfPaintFirstPoint.X + _moveingXOffset, _locationOfPaintFirstPoint.Y + _moveingYOffset,_locationOfPaintEndPoint.X + _moveingXOffset, _locationOfPaintEndPoint.Y + _moveingYOffset);
     path.Widen(_pen);
     return path.IsVisible(x, y);
 }
Beispiel #6
0
        protected override void DrawHighlight(GraphicsPath graphicsPath, Graphics graphics)
        {
            if (Target)
            {
                using (var p = new Pen(Color.Black, 2))
                {
                    graphicsPath.Widen(p);
                }
                return;
            }

            base.DrawHighlight(graphicsPath, graphics);
        }
Beispiel #7
0
        /// <summary>
        /// Проверяет попадание точки в фигуру
        /// </summary>
        /// <param name="p"></param>
        /// <returns>-1 - нет попадания, 0 - есть попадание, 1 и более - номер опорной точки в которую попал курсор</returns>
        public int ContainsPoint(Point p)
        {
            if (this.IsSelected)
            {
                for (int i = 1; i <= KeyPoints.Length; i++)
                {
                    if (PaintHelper.GetKeyPointWhiteRect(KeyPoints[i - 1]).Contains(p))
                        return i;
                }
            }

            var path = new GraphicsPath();
            Pen pen = new Pen(DrawSettings.Color, DrawSettings.Thickness);
            path.AddCurve(points.ToArray());
            path.Widen(pen);
            Region region = new Region(path);
            pen.Dispose();
            if (region.IsVisible(p))
                return 0;
            return -1;
        }
Beispiel #8
0
        public virtual void Draw(Graphics g, Point startPoint, Point endPoint)
        {
            if (startPoint == endPoint)
            {
                return;
            }

            MidPoint = ShapeHelper.GetLineMidPoint(startPoint, endPoint);
            GPath    = new System.Drawing.Drawing2D.GraphicsPath();
            //GPath.AddLine(startPoint, endPoint);

            Point pointA = new Point(startPoint.X + 16, startPoint.Y);
            Point pointB = new Point(endPoint.X - 16, endPoint.Y);

            GPath.AddLine(pointA, pointB);

            // OutOfMemoryException if two points equal
            if (pointA != pointB)
            {
                try
                {
                    GPath.Widen(new Pen(Color.Red, 50F));
                }
                catch
                {
                    // Do nothing
                }
            }

            g.DrawLine(ArrowPen, startPoint, endPoint);
            bool isHorizontal = startPoint.Y == endPoint.Y;
            bool isVertical   = startPoint.X == endPoint.X;

            GPathFinishEnd = new GraphicsPath();
            GPathStartEnd  = new GraphicsPath();

            if ((IsFocused || !ShowEndTextOnlyWhenFocused) || (!string.IsNullOrEmpty(MiddleText) && !ShowMiddleTextOnlyWhenFocused))
            {
                int    textHeight = (int)Math.Ceiling(g.MeasureString("A", Font).Height);
                double angle      = ShapeHelper.GetAngleBetween2PointsInDegrees(startPoint, endPoint);

                if ((IsFocused || !ShowEndTextOnlyWhenFocused) && !String.IsNullOrEmpty(StartText))
                {
                    SizeF textSize   = g.MeasureString(StartText, Font);
                    int   textLength = (int)Math.Ceiling(textSize.Width);
                    Point textPoint  = ShapeHelper.GetPointAlongLine(startPoint, endPoint, 35);

                    if (isHorizontal)
                    {
                        if (startPoint.X < endPoint.X)
                        {
                            textPoint.X  = startPoint.X + 10;
                            textPoint.Y -= textHeight + 2;
                        }
                        else
                        {
                            textPoint.X = startPoint.X - textLength - 5;
                            textPoint.Y = startPoint.Y + 2;
                        }
                    }
                    else if (isVertical)
                    {
                        if (startPoint.Y > endPoint.Y)
                        {
                            textPoint.X = startPoint.X - textLength / 2;
                            textPoint.Y = startPoint.Y - textHeight * 2;
                        }
                        else
                        {
                            textPoint.X = startPoint.X - textLength / 2;
                            textPoint.Y = startPoint.Y + textHeight;
                        }
                    }
                    else
                    {
                        textPoint.X  = textPoint.X - textLength / 2;
                        textPoint.Y -= textHeight / 2;
                    }
                    EndRectangle1 = new Rectangle(textPoint, new Size(textLength, textHeight));

                    if (!isHorizontal && !isVertical)
                    {
                        g.FillRectangle(BackBrush, EndRectangle1);
                    }

                    g.DrawString(StartText, Font, TextBrush, textPoint);
                    GPathFinishEnd.AddRectangle(EndRectangle1);
                    GPathStartImage = new GraphicsPath();

                    if (IsFocused && StartImage != null)
                    {
                        //StartImageRectangle = new Rectangle(EndRectangle1.Left - StartImage.Width - 2, EndRectangle1.Top, StartImage.Width, StartImage.Height);
                        StartImageRectangle = new Rectangle(EndRectangle1.Right + 2, EndRectangle1.Top, StartImage.Width, StartImage.Height);
                        g.FillRectangle(BackBrush, StartImageRectangle);
                        g.DrawImage(StartImage, StartImageRectangle);
                        GPathStartImage.AddRectangle(StartImageRectangle);
                    }
                }
                if ((IsFocused || !ShowEndTextOnlyWhenFocused) && !string.IsNullOrEmpty(EndText))
                {
                    int   textLength = (int)Math.Ceiling(g.MeasureString(EndText, Font).Width);
                    Point textPoint  = ShapeHelper.GetPointAlongLine(endPoint, startPoint, 35);

                    if (isHorizontal)
                    {
                        if (startPoint.X < endPoint.X)
                        {
                            textPoint.X = endPoint.X - textLength - 5;
                            textPoint.Y = endPoint.Y + 2;
                        }
                        else
                        {
                            textPoint.X  = endPoint.X + 10;
                            textPoint.Y -= textHeight + 2;
                        }
                    }
                    else if (isVertical)
                    {
                        if (startPoint.Y > endPoint.Y)
                        {
                            textPoint.X = endPoint.X - textLength / 2;
                            textPoint.Y = endPoint.Y + textHeight;
                        }
                        else
                        {
                            textPoint.X = endPoint.X - textLength / 2;
                            textPoint.Y = endPoint.Y - textHeight * 2;
                        }
                    }
                    else
                    {
                        textPoint.X  = textPoint.X - textLength / 2;
                        textPoint.Y -= textHeight / 2;
                    }
                    EndRectangle2 = new Rectangle(textPoint, new Size(textLength, textHeight));

                    if (!isHorizontal && !isVertical)
                    {
                        g.FillRectangle(BackBrush, EndRectangle2);
                    }

                    g.DrawString(EndText, Font, TextBrush, textPoint);
                    GPathStartEnd.AddRectangle(EndRectangle2);

                    GPathEndImage = new GraphicsPath();

                    if (IsFocused && StartImage != null)
                    {
                        //EndImageRectangle = new Rectangle(EndRectangle2.Right + 2, EndRectangle2.Bottom - EndImage.Height, EndImage.Width, EndImage.Height);
                        EndImageRectangle = new Rectangle(EndRectangle2.Left - EndImage.Width - 2, EndRectangle2.Bottom - EndImage.Height, EndImage.Width, EndImage.Height);
                        g.FillRectangle(BackBrush, EndImageRectangle);
                        g.DrawImage(EndImage, EndImageRectangle);
                        GPathEndImage.AddRectangle(EndImageRectangle);
                    }
                }
                if (!string.IsNullOrEmpty(MiddleText) &&
                    (IsFocused || !ShowMiddleTextOnlyWhenFocused))
                {
                    int   textLength = (int)Math.Ceiling(g.MeasureString(MiddleText, Font).Width);
                    Point textPoint  = MidPoint;

                    if (isHorizontal)
                    {
                        textPoint.X  = textPoint.X - textLength / 2;
                        textPoint.Y -= textHeight + 2;

                        if (MiddleImage != null)
                        {
                            textPoint.Y -= MiddleImage.Height;
                        }
                    }
                    else
                    {
                        textPoint.X  = textPoint.X - textLength / 2;
                        textPoint.Y -= textHeight * MiddleTextLineCount + MiddleImage.Height / 2 + 2;
                    }
                    g.FillRectangle(BackBrush, new Rectangle(textPoint.X, textPoint.Y, textLength, textHeight * MiddleTextLineCount));
                    g.DrawString(MiddleText, Font, TextBrush, textPoint);
                }
            }
            GPathMiddleImage = new System.Drawing.Drawing2D.GraphicsPath();
            Image image;

            if (!IsFocused)
            {
                image = MiddleImage;
            }
            else
            {
                image = MiddleImageFocused != null ? MiddleImageFocused : MiddleImage;
            }

            if (image != null)
            {
                Point imagePos = MidPoint;
                imagePos.Offset(-1 * image.Width / 2, -1 * image.Height / 2);
                MiddleImageRectangle = new Rectangle(imagePos, image.Size);

                g.FillRectangle(BackBrush, MiddleImageRectangle);
                g.DrawImage(image, MiddleImageRectangle);
                GPathMiddleImage.AddRectangle(MiddleImageRectangle);
            }
            //#region Add circles at each end
            //int radius = 20;
            //Point circleCentre = ShapeHelper.GetPointAlongLine(startPoint, endPoint, radius);
            //GPathEnd1.AddPath(ShapeHelper.GetCirclePath(circleCentre, radius), false);
            ////g.DrawPath(new Pen(TextBrush), GPathEnd1);

            //circleCentre = ShapeHelper.GetPointAlongLine(endPoint, startPoint, radius);
            //GPathEnd2.AddPath(ShapeHelper.GetCirclePath(circleCentre, radius), false);
            ////g.DrawPath(new Pen(TextBrush), GPathEnd2);
            //#endregion
        }
Beispiel #9
0
        /// <summary>
        /// Paints the fragment
        /// </summary>
        /// <param name="g"></param>
        public void Paint(Graphics g)
        {
            if (Display == CssConstants.None) 
                return;

            if (Display == CssConstants.TableCell && 
                EmptyCells == CssConstants.Hide &&
                IsSpaceOrEmpty)
                return;

            List<RectangleF> areas = Rectangles.Count == 0 ?
                new List<RectangleF>(new RectangleF[] { Bounds }) :
                new List<RectangleF>(Rectangles.Values);

            RectangleF[] rects = areas.ToArray();
            PointF offset = InitialContainer != null ? InitialContainer.ScrollOffset : PointF.Empty;

            for (int i = 0; i < rects.Length; i++)
            {
                RectangleF actualRect = rects[i]; actualRect.Offset(offset);

				if(CssDefaults.SystemTextDirectionRTL && InitialContainer != null)
					actualRect.Offset(InitialContainer.Bounds.Width - actualRect.Width, 0);

                if (InitialContainer != null && HtmlTag != null && HtmlTag.TagName.Equals("a", StringComparison.CurrentCultureIgnoreCase))
                {
                    if (InitialContainer.LinkRegions.ContainsKey(this)) InitialContainer.LinkRegions.Remove(this);
                    
                    InitialContainer.LinkRegions.Add(this, actualRect);
                }

                PaintBackground(g, actualRect);
                PaintBorder(g, actualRect, i == 0, i == rects.Length - 1);
            }

			if (IsImage)
			{
				RectangleF r = Words[0].Bounds; r.Offset(offset);
				r.Height -= ActualBorderTopWidth + ActualBorderBottomWidth + ActualPaddingTop + ActualPaddingBottom;
				r.Y += ActualBorderTopWidth + ActualPaddingTop;
				//HACK: round rectangle only when necessary
				g.DrawImage(Words[0].Image, Rectangle.Round(r));
			}
			else
			{
				Font f = ActualFont;
				CssBox body = null;
				if (InitialContainer != null && InitialContainer.Boxes.Count > 0)
					body = InitialContainer.Boxes[0];

				using (GraphicsPath gradientPath = new GraphicsPath())
				{
					foreach (CssBoxWord word in Words)
					{
						using (GraphicsPath path = new GraphicsPath())
						{
							// draw with a path instead
							float emSize = g.DpiX * f.SizeInPoints / 72f;
							path.AddString(word.Text, f.FontFamily, (int)f.Style, emSize, new PointF(word.Left - word.LastMeasureOffset.X + offset.X, word.Top + offset.Y), StringFormat.GenericDefault);
							gradientPath.AddString(word.Text, f.FontFamily, (int)f.Style, emSize, new PointF(word.Left - word.LastMeasureOffset.X + offset.X, word.Top + offset.Y), StringFormat.GenericDefault);

							if (body.ActualTextGlowColor.IsEmpty == false)
							{
								// draw a glow around the text
								int glowSize = Convert.ToInt32(emSize / 2.5);
								using (Bitmap glowBitmap = new Bitmap(Convert.ToInt32(word.Width) + glowSize, Convert.ToInt32(word.Height) + glowSize))
								{
									using (Graphics glowGraphics = Graphics.FromImage(glowBitmap))
									{
										using (GraphicsPath glowTextPath = new GraphicsPath())
										{
											// draw only the word in the corner, we'll place it onto the parent graphics in the right location later
											glowTextPath.AddString(word.Text, f.FontFamily, (int)f.Style, emSize, new PointF(0, 0), StringFormat.GenericDefault);
											using (Pen widen = new Pen(System.Drawing.Color.Black, glowSize / 2))
												glowTextPath.Widen(widen);

											using (Brush glowBrush = new SolidBrush(body.ActualTextGlowColor))
												glowGraphics.FillPath(glowBrush, glowTextPath);
										}
										Convolution.BoxFilter boxFilter = new Convolution.BoxFilter();
										// 3 box filters approximate a gaussian blur
										using (Bitmap bm2 = boxFilter.FastBoxBlur(glowBitmap, 4))
										using (Bitmap bm3 = boxFilter.FastBoxBlur(bm2, 4))
										using (Bitmap blurred = boxFilter.FastBoxBlur(bm3, 4))
											g.DrawImage(blurred, word.Left - word.LastMeasureOffset.X + offset.X - 2, word.Top + offset.Y - 2);
									}
								}
							}

							// draw actual text
							if (body.ActualTextGradientColor.IsEmpty)
							{
								using (SolidBrush textBrush = new SolidBrush(CssValue.GetActualColor(Color)))
									g.FillPath(textBrush, path);

								// and then the outline on top of the text
								if (body != null && body.ActualTextOutline > 0 && body.ActualTextOutlineColor.IsEmpty == false)
								{
									using (Pen pen = new Pen(body.ActualTextOutlineColor, body.ActualTextOutline))
										g.DrawPath(pen, path);
								}
							}
						}
					}

					if (body.ActualTextGradientColor.IsEmpty == false)
					{
						using (LinearGradientBrush textBrush = new LinearGradientBrush(body.Bounds, CssValue.GetActualColor(Color), body.ActualTextGradientColor, body.ActualTextGradientAngle))
							g.FillPath(textBrush, gradientPath);

						// and then the outline on top of the text
						if (body != null && body.ActualTextOutline > 0 && body.ActualTextOutlineColor.IsEmpty == false)
						{
							using (Pen pen = new Pen(body.ActualTextOutlineColor, body.ActualTextOutline))
								g.DrawPath(pen, gradientPath);
						}
					}
				}
			}
            for (int i = 0; i < rects.Length; i++)
            {
                RectangleF actualRect = rects[i]; actualRect.Offset(offset);

				if (CssDefaults.SystemTextDirectionRTL && InitialContainer != null)
				{
					switch (TextAlign)
					{
						case CssConstants.Right:
							actualRect.Offset(0 - (InitialContainer.Bounds.Width - actualRect.Width), 0);
							break;
						case CssConstants.Center:
							if(Words.Count > 0)
								actualRect.Offset(0 - actualRect.Width, 0);
							break;
						/*case CssConstants.Justify:*/
						default:
							actualRect.Offset(InitialContainer.Bounds.Width - actualRect.Width, 0);
							break;
					}
				}

                PaintDecoration(g, actualRect, i == 0, i == rects.Length - 1);
            }
            
            foreach (CssBox b in Boxes)
            {
                b.Paint(g);
            }

            CreateListItemBox(g);

            if (ListItemBox != null)
            {
                ListItemBox.Paint(g);
            }
        }
Beispiel #10
0
        public virtual void Draw(Graphics g, Point startPoint, Point endPoint)
        {
            if (startPoint == endPoint)
                return;

            MidPoint = ShapeHelper.GetLineMidPoint(startPoint, endPoint);
            GPath = new System.Drawing.Drawing2D.GraphicsPath();
            //GPath.AddLine(startPoint, endPoint);

            Point pointA = new Point(startPoint.X + 16, startPoint.Y);
            Point pointB = new Point(endPoint.X - 16, endPoint.Y);
            GPath.AddLine(pointA, pointB);

            // OutOfMemoryException if two points equal
            if (pointA != pointB)
                try
                {
                    GPath.Widen(new Pen(Color.Red, 50F));
                }
                catch
                {
                    // Do nothing
                }

            g.DrawLine(ArrowPen, startPoint, endPoint);
            bool isHorizontal = startPoint.Y == endPoint.Y;
            bool isVertical = startPoint.X == endPoint.X;
            GPathFinishEnd = new GraphicsPath();
            GPathStartEnd = new GraphicsPath();

            if ((IsFocused || !ShowEndTextOnlyWhenFocused) || (!string.IsNullOrEmpty(MiddleText) && !ShowMiddleTextOnlyWhenFocused))
            {
                int textHeight = (int)Math.Ceiling(g.MeasureString("A", Font).Height);
                double angle = ShapeHelper.GetAngleBetween2PointsInDegrees(startPoint, endPoint);

                if ((IsFocused || !ShowEndTextOnlyWhenFocused) && !String.IsNullOrEmpty(StartText))
                {
                    SizeF textSize = g.MeasureString(StartText, Font);
                    int textLength = (int)Math.Ceiling(textSize.Width);
                    Point textPoint = ShapeHelper.GetPointAlongLine(startPoint, endPoint, 35);

                    if (isHorizontal)
                    {
                        if (startPoint.X < endPoint.X)
                        {
                            textPoint.X = startPoint.X + 10;
                            textPoint.Y -= textHeight + 2;
                        }
                        else
                        {
                            textPoint.X = startPoint.X - textLength - 5;
                            textPoint.Y = startPoint.Y + 2;
                        }
                    }
                    else if (isVertical)
                    {
                        if (startPoint.Y > endPoint.Y)
                        {
                            textPoint.X = startPoint.X - textLength / 2;
                            textPoint.Y = startPoint.Y - textHeight * 2;
                        }
                        else
                        {
                            textPoint.X = startPoint.X - textLength / 2;
                            textPoint.Y = startPoint.Y + textHeight;
                        }
                    }
                    else
                    {
                        textPoint.X = textPoint.X - textLength / 2;
                        textPoint.Y -= textHeight / 2;
                    }
                    EndRectangle1 = new Rectangle(textPoint, new Size(textLength, textHeight));

                    if (!isHorizontal && !isVertical)
                        g.FillRectangle(BackBrush, EndRectangle1);

                    g.DrawString(StartText, Font, TextBrush, textPoint);
                    GPathFinishEnd.AddRectangle(EndRectangle1);
                    GPathStartImage = new GraphicsPath();

                    if (IsFocused && StartImage != null)
                    {
                        //StartImageRectangle = new Rectangle(EndRectangle1.Left - StartImage.Width - 2, EndRectangle1.Top, StartImage.Width, StartImage.Height);
                        StartImageRectangle = new Rectangle(EndRectangle1.Right + 2, EndRectangle1.Top, StartImage.Width, StartImage.Height);
                        g.FillRectangle(BackBrush, StartImageRectangle);
                        g.DrawImage(StartImage, StartImageRectangle);
                        GPathStartImage.AddRectangle(StartImageRectangle);
                    }
                }
                if ((IsFocused || !ShowEndTextOnlyWhenFocused) && !string.IsNullOrEmpty(EndText))
                {
                    int textLength = (int)Math.Ceiling(g.MeasureString(EndText, Font).Width);
                    Point textPoint = ShapeHelper.GetPointAlongLine(endPoint, startPoint, 35);

                    if (isHorizontal)
                    {
                        if (startPoint.X < endPoint.X)
                        {
                            textPoint.X = endPoint.X - textLength - 5;
                            textPoint.Y = endPoint.Y + 2;
                        }
                        else
                        {
                            textPoint.X = endPoint.X + 10;
                            textPoint.Y -= textHeight + 2;
                        }
                    }
                    else if (isVertical)
                    {
                        if (startPoint.Y > endPoint.Y)
                        {
                            textPoint.X = endPoint.X - textLength / 2;
                            textPoint.Y = endPoint.Y + textHeight;
                        }
                        else
                        {
                            textPoint.X = endPoint.X - textLength / 2;
                            textPoint.Y = endPoint.Y - textHeight * 2;
                        }
                    }
                    else
                    {
                        textPoint.X = textPoint.X - textLength / 2;
                        textPoint.Y -= textHeight / 2;
                    }
                    EndRectangle2 = new Rectangle(textPoint, new Size(textLength, textHeight));

                    if (!isHorizontal && !isVertical)
                        g.FillRectangle(BackBrush, EndRectangle2);

                    g.DrawString(EndText, Font, TextBrush, textPoint);
                    GPathStartEnd.AddRectangle(EndRectangle2);

                    GPathEndImage = new GraphicsPath();

                    if (IsFocused && StartImage != null)
                    {
                        //EndImageRectangle = new Rectangle(EndRectangle2.Right + 2, EndRectangle2.Bottom - EndImage.Height, EndImage.Width, EndImage.Height);
                        EndImageRectangle = new Rectangle(EndRectangle2.Left - EndImage.Width - 2, EndRectangle2.Bottom - EndImage.Height, EndImage.Width, EndImage.Height);
                        g.FillRectangle(BackBrush, EndImageRectangle);
                        g.DrawImage(EndImage, EndImageRectangle);
                        GPathEndImage.AddRectangle(EndImageRectangle);
                    }
                }
                if (!string.IsNullOrEmpty(MiddleText) &&
                    (IsFocused || !ShowMiddleTextOnlyWhenFocused))
                {
                    int textLength = (int)Math.Ceiling(g.MeasureString(MiddleText, Font).Width);
                    Point textPoint = MidPoint;

                    if (isHorizontal)
                    {
                        textPoint.X = textPoint.X - textLength / 2;
                        textPoint.Y -= textHeight + 2;

                        if (MiddleImage != null)
                            textPoint.Y -= MiddleImage.Height;
                    }
                    else
                    {
                        textPoint.X = textPoint.X - textLength / 2;
                        textPoint.Y -= textHeight * MiddleTextLineCount + MiddleImage.Height / 2 + 2;
                    }
                    g.FillRectangle(BackBrush, new Rectangle(textPoint.X, textPoint.Y, textLength, textHeight * MiddleTextLineCount));
                    g.DrawString(MiddleText, Font, TextBrush, textPoint);
                }
            }
            GPathMiddleImage = new System.Drawing.Drawing2D.GraphicsPath();
            Image image;

            if (!IsFocused)
                image = MiddleImage;
            else
                image = MiddleImageFocused != null ? MiddleImageFocused : MiddleImage;

            if (image != null)
            {
                Point imagePos = MidPoint;
                imagePos.Offset(-1 * image.Width / 2, -1 * image.Height / 2);
                MiddleImageRectangle = new Rectangle(imagePos, image.Size);

                g.FillRectangle(BackBrush, MiddleImageRectangle);
                g.DrawImage(image, MiddleImageRectangle);
                GPathMiddleImage.AddRectangle(MiddleImageRectangle);
            }
            //#region Add circles at each end
            //int radius = 20;
            //Point circleCentre = ShapeHelper.GetPointAlongLine(startPoint, endPoint, radius);
            //GPathEnd1.AddPath(ShapeHelper.GetCirclePath(circleCentre, radius), false);
            ////g.DrawPath(new Pen(TextBrush), GPathEnd1);

            //circleCentre = ShapeHelper.GetPointAlongLine(endPoint, startPoint, radius);
            //GPathEnd2.AddPath(ShapeHelper.GetCirclePath(circleCentre, radius), false);
            ////g.DrawPath(new Pen(TextBrush), GPathEnd2);
            //#endregion
        }
Beispiel #11
0
        /// <summary>
        /// Проверяет попадание точки в фигуру
        /// </summary>
        /// <param name="p"></param>
        /// <returns>-1 - нет попадания, 0 - есть попадание, 1 и более - номер опорной точки в которую попал курсор</returns>
        public int ContainsPoint(Point p)
        {
            if (this.IsSelected)
            {
                for (int i = 1; i <= KeyPoints.Length; i++)
                {
                    if (PaintHelper.GetKeyPointWhiteRect(KeyPoints[i - 1]).Contains(p))
                        return i;
                }
            }

            var path = new GraphicsPath();
            Pen pen = new Pen(DrawSettings.Color, DrawSettings.Thickness);
            Rectangle rect = PaintHelper.NormalizeRect(startPoint, endPoint);
            Point p1 = new Point(rect.X, rect.Y + rect.Height);
            Point p2 = new Point(rect.X + rect.Width / 2, rect.Y);
            Point p3 = new Point(rect.X + rect.Width, rect.Y + rect.Height);
            path.AddPolygon(new Point[] { p1, p2, p3 });
            path.Widen(pen);
            Region region = new Region(path);
            pen.Dispose();
            if (region.IsVisible(p))
                return 0;

            if (IsPointInTriangle(p, p1, p2, p3))
                return 0;
            return -1;
        }
Beispiel #12
0
		public override void Paint(Graphics g, IPaintContext paintContext)
		{
			GraphicsState gs = g.Save();
			TransformGraphics(g);

			var bounds = Bounds;
			Pen.SetEnvironment((RectangleF)bounds, BrushX.GetEffectiveMaximumResolution(g, Math.Max(ScaleX, ScaleY)));
			g.DrawLine(Pen, (float)bounds.X, (float)bounds.Y, (float)bounds.Right, (float)bounds.Bottom);

			if (_outlinePen != null && _outlinePen.IsVisible)
			{
				GraphicsPath p = new GraphicsPath();
				p.AddLine((float)bounds.X, (float)bounds.Y, (float)bounds.Right, (float)bounds.Bottom);
				p.Widen(Pen);
				OutlinePen.SetEnvironment((RectangleF)bounds, BrushX.GetEffectiveMaximumResolution(g, Math.Max(ScaleX, ScaleY)));
				g.DrawPath(OutlinePen, p);
			}

			g.Restore(gs);
		}
Beispiel #13
0
		public void Widen_Pen_Matrix_NonInvertible ()
		{
			Matrix matrix = new Matrix (123, 24, 82, 16, 47, 30);
			Assert.IsFalse (matrix.IsInvertible, "!IsInvertible");
			GraphicsPath path = new GraphicsPath ();
			path.Widen (new Pen (Color.Blue), matrix);
			Assert.AreEqual (0, path.PointCount, "Points");
		}
Beispiel #14
0
		public void Widen_SinglePoint ()
		{
			using (GraphicsPath gp = new GraphicsPath ()) {
				gp.AddLines (new Point[1] { new Point (1, 1) });
				// Special case - a line with a single point is valid
				Assert.AreEqual (1, gp.PointCount, "PointCount");
				gp.Widen (Pens.Red);
				// oops ;-)
			}
		}
 /// <summary>
 /// OnPaint will go through the enabled elements (vertical ReminderMessage, GridLines, LineNumbers, BorderLines,
 /// MarginLines) and will draw them if enabled. At the same time, it will build GraphicsPaths for each of those
 /// elements (that are enabled), which will be used in SeeThroughMode (if it's active): the figures in the
 /// GraphicsPaths will form a customized outline for the control by setting them as the Region of the LineNumber
 /// control. Note: the vertical ReminderMessages are only drawn during designtime. 
 /// </summary>
 /// <param name="e"></param>
 protected override void OnPaint(PaintEventArgs e)
 {
     // Build the list of visible LineNumberItems (= pLineNumberItems) first. (doesn't take long, so it can stay in OnPaint)
     UpdateVisibleLineNumberItems();
     base.OnPaint(e);
     // Quality settings
     e.Graphics.TextRenderingHint = pLineNumbersAntiAlias ? TextRenderingHint.AntiAlias : TextRenderingHint.SystemDefault;
     // NOTE: The GraphicsPaths are only used for SeeThroughMode
     // FillMode.Winding: combined outline ( Alternate: XOR'ed outline )
     GraphicsPath gpGridLines = new GraphicsPath(FillMode.Winding);
     GraphicsPath gpBorderLines = new GraphicsPath(FillMode.Winding);
     GraphicsPath gpMarginLines = new GraphicsPath(FillMode.Winding);
     GraphicsPath gpLineNumbers = new GraphicsPath(FillMode.Winding);
     if (DesignMode)
     {
         string reminderToShow = string.Empty;
         if (RTParent == null)
         {
             reminderToShow = "-!- Set ParentRichTextBox -!-";
         }
         else if (pLineNumberItems.Count == 0)
         {
             reminderToShow = "LineNumbers (  " + RTParent.Name + "  )";
         }
         if (reminderToShow.Length > 0)
         {
             e.Graphics.TranslateTransform(Width / 2f, Height / 2f);
             e.Graphics.RotateTransform(-90f);
             StringFormat format = new StringFormat { Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center };
             SizeF textSize = e.Graphics.MeasureString(reminderToShow, Font, new Point(0, 0), format);
             e.Graphics.DrawString(reminderToShow, Font, Brushes.WhiteSmoke, 1f, 1f, format);
             e.Graphics.DrawString(reminderToShow, Font, Brushes.Firebrick, 0f, 0f, format);
             e.Graphics.ResetTransform();
             Rectangle reminderRectangle = new Rectangle((int)Math.Round((Width / 2.0) - (textSize.Height / 2.0)),
                                                          (int)Math.Round((Height / 2.0) - (textSize.Width / 2.0)),
                                                          (int)Math.Round(textSize.Height), (int)Math.Round(textSize.Width));
             gpLineNumbers.AddRectangle(reminderRectangle);
             gpLineNumbers.CloseFigure();
             if (pAutoSizing)
             {
                 reminderRectangle.Inflate((int)Math.Round(textSize.Height * 0.2), (int)Math.Round(textSize.Width * 0.1));
                 pAutoSizingSize = new Size(reminderRectangle.Width, reminderRectangle.Height);
             }
         }
     }
     if (pLineNumberItems.Count > 0)
     {
         // The visible LineNumberItems with their BackgroundGradient and GridLines
         // Loop through every visible LineNumberItem
         using (Pen pen = new Pen(pGridLinesColor, pGridLinesThickness) { DashStyle = pGridLinesStyle })
         {
             StringFormat format = new StringFormat
             {
                 Alignment = StringAlignment.Near,
                 LineAlignment = StringAlignment.Near,
                 FormatFlags =
                     StringFormatFlags.NoClip | StringFormatFlags.NoWrap | StringFormatFlags.FitBlackBox
             };
             for (int i = 0; i <= pLineNumberItems.Count - 1; i++)
             {
                 // Background gradient
                 if (pGradientShow)
                 {
                     using (LinearGradientBrush brush = new LinearGradientBrush(pLineNumberItems[i].Rectangle,
                         pGradientStartColor, pGradientEndColor, pGradientDirection))
                     {
                         e.Graphics.FillRectangle(brush, pLineNumberItems[i].Rectangle);
                     }
                 }
                 // Grid lines
                 if (pGridLinesShow)
                 {
                     e.Graphics.DrawLine(pen, new Point(0, pLineNumberItems[i].Rectangle.Y),
                         new Point(Width, pLineNumberItems[i].Rectangle.Y));
                     Rectangle rect = new Rectangle((int)Math.Round(-pGridLinesThickness), pLineNumberItems[i].Rectangle.Y,
                         (int)Math.Round(Width + (pGridLinesThickness * 2.0)),
                         (int)Math.Round((Height - pLineNumberItems[0].Rectangle.Y) + pGridLinesThickness));
                     gpGridLines.AddRectangle(rect);
                     gpGridLines.CloseFigure();
                 }
                 // Line numbers
                 if (pLineNumbersShow)
                 {
                     string textToShow;
                     if (pLineNumbersShowLeadingZeroes)
                     {
                         textToShow = pLineNumbersShowAsHexadecimal
                                         ? pLineNumberItems[i].LineNumber.ToString("X4")
                                         : pLineNumberItems[i].LineNumber.ToString("D4");
                     }
                     else
                     {
                         textToShow = pLineNumbersShowAsHexadecimal
                                         ? pLineNumberItems[i].LineNumber.ToString("X4")
                                         : pLineNumberItems[i].LineNumber.ToString("D4");
                     }
                     Point point = new Point(0, 0);
                     SizeF textSize = e.Graphics.MeasureString(textToShow, Font, point, format);
                     // Text alignment
                     point = GetAlignmentPoint(textSize, pLineNumberItems[i]);
                     // Text clipping
                     Rectangle itemClipRectangle = new Rectangle(point, textSize.ToSize());
                     if (pLineNumbersClipByItemRectangle)
                     {
                         // If selected, the text will be clipped so that it doesn't spill out of its own
                         // LineNumberItem-area. Only the part of the text inside the LineNumberItem.
                         // Rectangle should be visible, so intersect with the ItemRectangle.
                         // The SetClip method temporary restricts the drawing area of the control for whatever
                         // is drawn next.
                         itemClipRectangle.Intersect(pLineNumberItems[i].Rectangle);
                         e.Graphics.SetClip(itemClipRectangle);
                     }
                     // Text drawing
                     using (SolidBrush brush = new SolidBrush(ForeColor))
                     {
                         e.Graphics.DrawString(textToShow, Font, brush, point, format);
                         e.Graphics.ResetClip();
                     }
                     // The GraphicsPath for the LineNumber is just a rectangle behind the text, to keep the paintingspeed high and avoid ugly artifacts.
                     gpLineNumbers.AddRectangle(itemClipRectangle);
                     gpLineNumbers.CloseFigure();
                 }
             }
             // Grid lines thickness and linestyle in SeeThroughMode. All GraphicsPath lines are drawn as solid to keep the paintingspeed high.
             if (pGridLinesShow)
             {
                 pen.DashStyle = DashStyle.Solid;
                 gpGridLines.Widen(pen);
             }
         }
     }
     Point left = new Point((int)Math.Round(Math.Floor(pBorderLinesThickness / 2.0)),
                              (int)Math.Round(Math.Floor(pBorderLinesThickness / 2.0)));
     Point right = new Point((int)Math.Round(Width - Math.Ceiling(pBorderLinesThickness / 2.0)),
                               (int)Math.Round(Height - Math.Ceiling(pBorderLinesThickness / 2.0)));
     // Border lines
     Point[] borderLinesPoints = new Point[5];
     borderLinesPoints[0] = new Point(left.X, left.Y);
     borderLinesPoints[1] = new Point(right.X, left.Y);
     borderLinesPoints[2] = new Point(right.X, right.Y);
     borderLinesPoints[3] = new Point(left.X, right.Y);
     borderLinesPoints[4] = new Point(left.X, left.Y);
     if (pBorderLinesShow)
     {
         using (Pen pen = new Pen(pBorderLinesColor, pBorderLinesThickness) { DashStyle = pBorderLinesStyle })
         {
             e.Graphics.DrawLines(pen, borderLinesPoints);
             gpBorderLines.AddLines(borderLinesPoints);
             gpBorderLines.CloseFigure();
             pen.DashStyle = DashStyle.Solid;
             gpBorderLines.Widen(pen);
         }
     }
     // Margin lines
     if (pMarginLinesShow && (pMarginLinesSide > LineNumberDockSide.None))
     {
         left = new Point((int)Math.Round(-pMarginLinesThickness), (int)Math.Round(-pMarginLinesThickness));
         right = new Point((int)Math.Round(Width + pMarginLinesThickness),
                             (int)Math.Round(Height + pMarginLinesThickness));
         using (Pen pen = new Pen(pMarginLinesColor, pMarginLinesThickness) { DashStyle = pMarginLinesStyle })
         {
             if ((pMarginLinesSide == LineNumberDockSide.Left) | (pMarginLinesSide == LineNumberDockSide.Height))
             {
                 e.Graphics.DrawLine(pen, new Point((int)Math.Round(Math.Floor(pMarginLinesThickness / 2.0)), 0),
                                     new Point((int)Math.Round(Math.Floor(pMarginLinesThickness / 2.0)), Height - 1));
                 left = new Point((int)Math.Round(Math.Ceiling(pMarginLinesThickness / 2.0)),
                                    (int)Math.Round(-pMarginLinesThickness));
             }
             if ((pMarginLinesSide == LineNumberDockSide.Right) | (pMarginLinesSide == LineNumberDockSide.Height))
             {
                 e.Graphics.DrawLine(pen, new Point((int)Math.Round(Width - Math.Ceiling(pMarginLinesThickness / 2.0)), 0),
                                     new Point((int)Math.Round(Width - Math.Ceiling(pMarginLinesThickness / 2.0)), Height - 1));
                 right = new Point((int)Math.Round(Width - Math.Ceiling(pMarginLinesThickness / 2.0)),
                                     (int)Math.Round(Height + pMarginLinesThickness));
             }
             // GraphicsPath for the MarginLines(s): MarginLines(s) are drawn as a rectangle connecting the left
             // and right points, which are either inside or outside of sight, depending on whether the MarginLines
             // at that side is visible. "left": TopLeft and "right": BottomRight
             gpMarginLines.AddRectangle(new Rectangle(left, new Size(right.X - left.X, right.Y - left.Y)));
             pen.DashStyle = DashStyle.Solid;
             gpMarginLines.Widen(pen);
         }
     }
     Region region = new Region(ClientRectangle);
     // SeeThroughMode: combine all the GraphicsPaths and set them as the region for the control.
     if (pSeeThroughMode)
     {
         region.MakeEmpty();
         region.Union(gpBorderLines);
         region.Union(gpMarginLines);
         region.Union(gpGridLines);
         region.Union(gpLineNumbers);
     }
     if (region.GetBounds(e.Graphics).IsEmpty)
     {
         // Note: If the control is in a condition that would show it as empty, then a border-region is still
         // drawn regardless of it's borders on/off state. This is added to make sure that the bounds of the
         // control are never lost (it would remain empty if this was not done).
         gpBorderLines.AddLines(borderLinesPoints);
         gpBorderLines.CloseFigure();
         using (Pen pen = new Pen(pBorderLinesColor, 1f) { DashStyle = DashStyle.Solid })
         {
             gpBorderLines.Widen(pen);
             region = new Region(gpBorderLines);
         }
     }
     Region = region;
 }
        /// <summary>
        /// Creates the line path hit testing (HitTest) and rendering (Draw, DrawOutline).
        /// </summary>
        public void Cache(Render.IDrawVisitor drawMethods)
        {
            if (m_Param.Path.PointCount == 0)
            {
                m_thickPath = new GraphicsPath();
                m_visibleThickPath = new GraphicsPath();
                SecondCache(drawMethods);
                return;
            }

             m_pointsInPath = ((Tools.Model.VectorPath)m_Param.Path).InternalPath.PathPoints;

            // I found a bug here where if I cloned the existing graphics path, it would
            // get into the GC even though it was referenced here. So, as a fix, create the
            // GraphicsPath as new graphics path in this object.

            m_thickPath = new GraphicsPath();
            if (m_Param.Path.PointCount > 0)
            {
                m_thickPath.AddPath(((Model.VectorPath)m_Param.Path).InternalPath, false);
                Pen widenPen = new Pen(Color.Black, (float)m_Param.PathThickness+Render.DrawHelper.EDGE_WIDTH);
                widenPen.StartCap = LineCap.Flat;
                widenPen.EndCap = LineCap.Flat;
                widenPen.LineJoin = LineJoin.MiterClipped;
                m_thickPath.Widen(widenPen);
            }

            m_visibleThickPath = new GraphicsPath();
            if (m_Param.Path.PointCount > 0)
            {
                m_visibleThickPath.AddPath(((Model.VectorPath)m_Param.Path).InternalPath, false);
                Pen widenPen = new Pen(Color.Black, (float)m_Param.PathThickness);
                widenPen.StartCap = LineCap.Flat;
                widenPen.EndCap = LineCap.Flat;
                widenPen.LineJoin = LineJoin.MiterClipped;
                m_visibleThickPath.Widen(widenPen);
            }

            SecondCache(drawMethods);
        }
        public void GetBounds(Graphics g)
        {
            // Create path number 1 and a Pen for drawing.
            GraphicsPath myPath = new GraphicsPath();
            Pen pathPen = new Pen(Color.Black, 1);

            // Add an Ellipse to the path and Draw it (circle in start

            // position).
            myPath.AddEllipse(20, 20, 100, 100);
            g.DrawPath(pathPen, myPath);

            // Get the path bounds for Path number 1 and draw them.
            RectangleF boundRect = myPath.GetBounds();
            g.DrawRectangle(new Pen(Color.Red, 1),
                                     boundRect.X,
                                     boundRect.Y,
                                     boundRect.Height,
                                     boundRect.Width);

            // Create a second graphics path and a wider Pen.
            GraphicsPath myPath2 = new GraphicsPath();
            Pen pathPen2 = new Pen(Color.Black, 10);

            // Create a new ellipse with a width of 10.
            myPath2.AddEllipse(150, 20, 100, 100);
            myPath2.Widen(pathPen2);
            g.FillPath(Brushes.Black, myPath2);

            // Get the second path bounds.
            RectangleF boundRect2 = myPath2.GetBounds();

            // Draw the bounding rectangle.
            g.DrawRectangle(new Pen(Color.Red, 1),
                                     boundRect2.X,
                                     boundRect2.Y,
                                     boundRect2.Height,
                                     boundRect2.Width);
        }
Beispiel #18
0
		public void Widen_NoPoint ()
		{
			using (GraphicsPath gp = new GraphicsPath ()) {
				Assert.AreEqual (0, gp.PointCount, "PointCount-1");
				Pen pen = new Pen (Color.Blue);
				gp.Widen (pen);
				Assert.AreEqual (0, gp.PointCount, "PointCount-2");
			}
		}
Beispiel #19
0
		/// <summary>
		/// Test wether the mouse hits a plot item.
		/// </summary>
		/// <param name="layer">The layer in which this plot item is drawn into.</param>
		/// <param name="hitpoint">The point where the mouse is pressed.</param>
		/// <returns>Null if no hit, or a <see cref="IHitTestObject" /> if there was a hit.</returns>
		public override IHitTestObject HitTest(IPlotArea layer, PointD2D hitpoint)
		{
			Processed2DPlotData pdata = _cachedPlotDataUsedForPainting;
			if (null == pdata)
				return null;

			PlotRangeList rangeList = pdata.RangeList;
			PointF[] ptArray = pdata.PlotPointsInAbsoluteLayerCoordinates;

			if (ptArray.Length < 2)
				return null;

			if (ptArray.Length < 2048)
			{
				GraphicsPath gp = new GraphicsPath();
				gp.AddLines(ptArray);
				if (gp.IsOutlineVisible((PointF)hitpoint, new Pen(Color.Black, 5)))
				{
					gp.Widen(new Pen(Color.Black, 5));
					return new HitTestObject(gp, this);
				}
			}
			else // we have too much points for the graphics path, so make a hit test first
			{
				int hitindex = -1;
				for (int i = 1; i < ptArray.Length; i++)
				{
					if (Math2D.IsPointIntoDistance((PointF)hitpoint, 5, ptArray[i - 1], ptArray[i]))
					{
						hitindex = i;
						break;
					}
				}
				if (hitindex < 0)
					return null;
				GraphicsPath gp = new GraphicsPath();
				int start = Math.Max(0, hitindex - 1);
				gp.AddLine(ptArray[start], ptArray[start + 1]);
				gp.AddLine(ptArray[start + 1], ptArray[start + 2]);
				gp.Widen(new Pen(Color.Black, 5));
				return new HitTestObject(gp, this);
			}

			return null;
		}
Beispiel #20
0
		public void Widen_Pen_Matrix_Empty ()
		{
			Pen pen = new Pen (Color.Blue);
			GraphicsPath path = new GraphicsPath ();
			path.AddPolygon (new Point[3] { new Point (5, 5), new Point (15, 5), new Point (10, 15) });
			path.Widen (pen, new Matrix ());
			Assert.AreEqual (9, path.PointCount, "Count");
			CheckWiden3 (path);
		}
Beispiel #21
0
        /// <summary>
        /// Widen path by positive amount in w
        /// </summary>
        /// <param name="gp"></param>
        /// <param name="w"></param>
        public static void WidenPath(GraphicsPath gp, float w)
        {
            if (gp == null)
                return;

            if (w < 0.0f)
                return;

            if (gp.GetBounds().IsEmpty)
                return;

            // create widening pen

            Pen widenPen = new Pen(Color.White, w);

            // by default pens are mitered, which will produce wierd results when widening a path

            widenPen.LineJoin = LineJoin.Bevel;

            // widen

            gp.Widen(widenPen);

            // cleanup pen

            widenPen.Dispose();
        }
Beispiel #22
0
		public void Widen_Pen_SmallWidth ()
		{
			Matrix m = new Matrix ();
			Rectangle rect = new Rectangle (1, 1, 2, 2);

			// pen's smaller than 1.0 (width) are "promoted" to 1
			Pen p = new Pen (Color.Aqua, 0);
			GraphicsPath gp = new GraphicsPath ();
			gp.AddRectangle (rect);
			gp.Widen (p);
			CheckWidenedBounds ("Width == 0, Null matrix", gp, null);
			CheckWidenedBounds ("Width == 0, Empty matrix", gp, m);

			p.Width = 0.5f;
			gp = new GraphicsPath ();
			gp.AddRectangle (rect);
			gp.Widen (p);
			CheckWidenedBounds ("Width == 0.5, Null matrix", gp, null);
			CheckWidenedBounds ("Width == 0.5, Empty matrix", gp, m);

			p.Width = 1.0f;
			gp = new GraphicsPath ();
			gp.AddRectangle (rect);
			gp.Widen (p);
			CheckWidenedBounds ("Width == 1.0, Null matrix", gp, null);
			CheckWidenedBounds ("Width == 1.0, Empty matrix", gp, m);

			p.Width = 1.1f;
			gp = new GraphicsPath ();
			gp.AddRectangle (rect);
			gp.Widen (p);
			RectangleF bounds = gp.GetBounds (m);
			Assert.AreEqual (0.45f, bounds.X, 0.00001f, "1.1.Bounds.X");
			Assert.AreEqual (0.45f, bounds.Y, 0.00001f, "1.1.Bounds.Y");
			Assert.AreEqual (3.10f, bounds.Width, 0.00001f, "1.1.Bounds.Width");
			Assert.AreEqual (3.10f, bounds.Height, 0.00001f, "1.1.Bounds.Height");
		}
Beispiel #23
0
        private void DrawMeasuringResults(Graphics g) {

            if (this.LoadedMapImagePack != null) {

                // Move to class so they are not declared every paint.
                /* FontFamily family = new FontFamily("Arial");
                int fontStyle = (int)FontStyle.Regular;
                int emSize = 12;
                StringFormat format = StringFormat.GenericDefault;
                */
                //double dblMetrePixels = this.ZoomFactor;

                if (this.LoadedMapImagePack.MapScale.X != 0.0F && this.LoadedMapImagePack.MapScale.Y != 0.0F && this.ZoomFactor != 0.0F && (this.m_pntStart.X != this.m_pntEnd.X || this.m_pntStart.Y != this.m_pntEnd.Y)) {
                    double dx = (this.m_pntStart.X - this.m_pntEnd.X) / (this.LoadedMapImagePack.MapScale.X * this.ZoomFactor);
                    double dy = (this.m_pntStart.Y - this.m_pntEnd.Y) / (this.LoadedMapImagePack.MapScale.Y * this.ZoomFactor);
                    double dblMetresDistance = Math.Sqrt(dx * dx + dy * dy);
                    //double dblMetresDistance = dblPixelDistance / dblMetrePixels;

                    GraphicsPath gpMeasuringResultsLine = new GraphicsPath();
                    gpMeasuringResultsLine.AddLine(this.m_pntStart, this.m_pntEnd);
                    gpMeasuringResultsLine.Widen(this.m_pOneWidth);
                    this.DrawBwShape(g, gpMeasuringResultsLine, 1.0F);
                    gpMeasuringResultsLine.Dispose();

                    GraphicsPath gpMeasuringResults = new GraphicsPath();
                    gpMeasuringResults.AddString(String.Format("{0:0.0} m\n{1:0.0} yd", dblMetresDistance, dblMetresDistance * 1.0936133D), this.family, this.fontStyle, this.emSize, new PointF(this.m_pntEnd.X, this.m_pntEnd.Y - 25), this.format);
                    this.DrawBwShape(g, gpMeasuringResults, 1.0F);
                    gpMeasuringResults.Dispose();
                }
                //family.Dispose();
            }
        }
Beispiel #24
0
			public override IGripManipulationHandle[] GetGrips(double pageScale, int gripLevel)
			{
				if (gripLevel <= 1)
				{
					LineShape ls = (LineShape)_hitobject;
					PointF[] pts = new PointF[] { new PointF(0, 0), new PointF((float)ls.Width, (float)ls.Height) };
					for (int i = 0; i < pts.Length; i++)
					{
						var pt = ls._transformation.TransformPoint(pts[i]);
						pt = this.Transformation.TransformPoint(pt);
						pts[i] = pt;
					}

					IGripManipulationHandle[] grips = new IGripManipulationHandle[gripLevel == 0 ? 1 : 3];

					// Translation grips
					GraphicsPath path = new GraphicsPath();
					path.AddLine(pts[0], pts[1]);
					path.Widen(new Pen(Color.Black, (float)(6 / pageScale)));
					grips[0] = new MovementGripHandle(this, path, null);

					// PathNode grips
					if (gripLevel == 1)
					{
						grips[2] = grips[0]; // put the movement grip to the background, the two NodeGrips need more priority
						float gripRadius = (float)(3 / pageScale);
						grips[0] = new PathNodeGripHandle(this, new PointF(0, 0), pts[0], gripRadius);
						grips[1] = new PathNodeGripHandle(this, new PointF(1, 1), pts[1], gripRadius);
					}
					return grips;
				}
				else
				{
					return base.GetGrips(pageScale, gripLevel);
				}
			}
Beispiel #25
0
        private void DrawScale(Graphics g) {

            if (this.LoadedMapImagePack != null) {

                // Move to class so they are not declared every paint.
                /* FontFamily family = new FontFamily("Arial");
                int fontStyle = (int)FontStyle.Regular;
                int emSize = 12;
                StringFormat format = StringFormat.GenericDefault;
                */
                GraphicsPath gpScale = new GraphicsPath();
                GraphicsPath gpScaleUnits = new GraphicsPath();

                gpScale.AddLine(new Point(10, (int)g.ClipBounds.Height - 50), new Point(10, (int)g.ClipBounds.Height - 30));
                gpScale.AddLine(new Point(10, (int)g.ClipBounds.Height - 40), new Point(200, (int)g.ClipBounds.Height - 40));
                gpScale.Widen(this.m_pOneWidth);

                gpScaleUnits.AddString("m", this.family, this.fontStyle, this.emSize, new Point(4, (int)g.ClipBounds.Height - 65), this.format);
                gpScaleUnits.AddString("yd", this.family, this.fontStyle, this.emSize, new Point(1, (int)g.ClipBounds.Height - 30), this.format);

                // Only interested in horizontal
                double dblMetrePixels = this.LoadedMapImagePack.MapScale.X * this.ZoomFactor;

                for (double i = 0.0D; i < 16.0D; i++) {

                    double dblMetres = Math.Pow(2, i);

                    // Metres
                    
                    int iOffset = (int)Math.Round(dblMetres * dblMetrePixels);

                    if (iOffset >= 15 && 10 + iOffset <= 200) {

                        GraphicsPath gpScaleMarkerLine = new GraphicsPath();
                        GraphicsPath gpScaleMarker = new GraphicsPath();

                        gpScaleMarker.AddString(String.Format("{0:0}", dblMetres), this.family, this.fontStyle, this.emSize, new Point(4 + iOffset, (int)g.ClipBounds.Height - 60), this.format);
                        gpScaleMarkerLine.AddLine(new Point(10 + iOffset, (int)g.ClipBounds.Height - 45), new Point(10 + iOffset, (int)g.ClipBounds.Height - 40));
                        gpScaleMarkerLine.Widen(this.m_pOneWidth);

                        this.DrawBwShape(g, gpScaleMarkerLine, 1.0F);
                        this.DrawBwShape(g, gpScaleMarker, 1.0F);

                        gpScaleMarkerLine.Dispose();
                        gpScaleMarker.Dispose();
                    }

                    // Yards

                    iOffset = (int)Math.Round(dblMetres * (dblMetrePixels / 1.0936133D));

                    if (iOffset >= 15 && 10 + iOffset <= 200) {

                        GraphicsPath gpScaleMarkerLine = new GraphicsPath();
                        GraphicsPath gpScaleMarker = new GraphicsPath();

                        gpScaleMarker.AddString(String.Format("{0:0}", dblMetres), this.family, this.fontStyle, this.emSize, new Point(4 + iOffset, (int)g.ClipBounds.Height - 32), this.format);
                        gpScaleMarkerLine.AddLine(new Point(10 + iOffset, (int)g.ClipBounds.Height - 35), new Point(10 + iOffset, (int)g.ClipBounds.Height - 40));
                        gpScaleMarkerLine.Widen(this.m_pOneWidth);

                        this.DrawBwShape(g, gpScaleMarkerLine, 1.0F);
                        this.DrawBwShape(g, gpScaleMarker, 1.0F);

                        gpScaleMarkerLine.Dispose();
                        gpScaleMarker.Dispose();
                    }
                }

                //gpScale.AddLine(new Point(10, (int)g.ClipBounds.Height - 20), new Point(10, (int)g.ClipBounds.Height - 10));
                //gpScale.AddLine(new Point(10, (int)g.ClipBounds.Height - 10), new Point(60, (int)g.ClipBounds.Height - 10));
                //gpScale.AddLine(new Point(10, (int)g.ClipBounds.Height - 20), new Point(60, (int)g.ClipBounds.Height - 20));

                this.DrawBwShape(g, gpScale, 1.0F);
                this.DrawBwShape(g, gpScaleUnits, 1.0F);

                gpScale.Dispose();
                gpScaleUnits.Dispose();

                //g.DrawLine(Pens.White, new Point(10, (int)g.ClipBounds.Height - 10), new Point(60, (int)g.ClipBounds.Height - 10));
            }
        }
    /// <summary>
    /// Gives the path where the hit test is successfull.
    /// </summary>
    /// <param name="layer"></param>
    /// <param name="withTicks">If true, the selection path is not only drawn around the axis, but around the axis and the ticks.</param>
    /// <returns>The graphics path of the selection rectangle.</returns>
    protected GraphicsPath GetPath(XYPlotLayer layer, bool withTicks, float inflateby)
    {

      Logical3D r0 = _cachedAxisStyleInfo.Identifier.Begin;
      Logical3D r1 = _cachedAxisStyleInfo.Identifier.End;
      GraphicsPath gp = new GraphicsPath();
      layer.CoordinateSystem.GetIsoline(gp, r0, r1);
     
      if(withTicks)
      {
        if(this._showFirstDownMajorTicks || this._showFirstUpMajorTicks)
          inflateby = Math.Max(inflateby,this._majorTickLength);
        if(this._showFirstDownMinorTicks || this._showFirstUpMinorTicks)
          inflateby = Math.Max(inflateby,this._minorTickLength);
      }

      Pen widenPen = new Pen(Color.Black, 2*inflateby);

      gp.Widen(widenPen);

      return gp;
    }
        bool PointInLine(Point[] line, Point pt)
        {
            Pen p = new Pen(Color.Black, 4);
            GraphicsPath gp = new GraphicsPath();
            gp.AddLine(line[0], line[1]);
            gp.Widen(p);
            p.Dispose();

            return gp.IsVisible(pt);
        }
Beispiel #28
0
		[Category ("NotWorking")] // can't/wont duplicate the lack of precision
		public void GetBounds_WithPen ()
		{
			Rectangle rect = new Rectangle (1, 1, 2, 2);
			Pen p = new Pen (Color.Aqua, 0);
			GraphicsPath gp = new GraphicsPath ();
			gp.AddRectangle (rect);

			RectangleF bounds = gp.GetBounds (null, p);
			// those bounds doesn't make any sense (even visually)
			// probably null gets mis-interpreted ???
			Assert.AreEqual (-6.09999943f, bounds.X, "NullMatrix.Bounds.X");
			Assert.AreEqual (-6.09999943f, bounds.Y, "NullMatrix.Bounds.Y");
			Assert.AreEqual (16.1999989f, bounds.Width, "NullMatrix.Bounds.Width");
			Assert.AreEqual (16.1999989f, bounds.Height, "NullMatrix.Bounds.Height");

			Matrix m = new Matrix ();
			bounds = gp.GetBounds (m, p);
			Assert.AreEqual (-0.419999957f, bounds.X, "EmptyMatrix.Bounds.X");
			Assert.AreEqual (-0.419999957f, bounds.Y, "EmptyMatrix.Bounds.Y");
			Assert.AreEqual (4.83999968f, bounds.Width, "EmptyMatrix.Bounds.Width");
			Assert.AreEqual (4.83999968f, bounds.Height, "EmptyMatrix.Bounds.Height");
			// visually we can see the bounds just a pixel bigger than the rectangle

			gp = new GraphicsPath ();
			gp.AddRectangle (rect);
			gp.Widen (p);
			bounds = gp.GetBounds (null);
			Assert.AreEqual (0.499999523f, bounds.X, "WidenNullMatrix.Bounds.X");
			Assert.AreEqual (0.499999523f, bounds.Y, "WidenNullMatrix.Bounds.Y");
			Assert.AreEqual (3.000001f, bounds.Width, "WidenNullMatrix.Bounds.Width");
			Assert.AreEqual (3.000001f, bounds.Height, "WidenNullMatrix.Bounds.Height");

			bounds = gp.GetBounds (m);
			Assert.AreEqual (0.499999523f, bounds.X, "WidenEmptyMatrix.Bounds.X");
			Assert.AreEqual (0.499999523f, bounds.Y, "WidenEmptyMatrix.Bounds.Y");
			Assert.AreEqual (3.000001f, bounds.Width, "WidenEmptyMatrix.Bounds.Width");
			Assert.AreEqual (3.000001f, bounds.Height, "WidenEmptyMatrix.Bounds.Height");
		}
Beispiel #29
0
		public void Widen_Pen ()
		{
			Pen pen = new Pen (Color.Blue);
			GraphicsPath path = new GraphicsPath ();
			path.AddRectangle (new Rectangle (1, 1, 2, 2));
			Assert.AreEqual (4, path.PointCount, "Count-1");
			path.Widen (pen);
			Assert.AreEqual (12, path.PointCount, "Count-2");

			PointF[] pts = path.PathPoints;
			Assert.AreEqual (0.5, pts[0].X, 0.25, "0.X");
			Assert.AreEqual (0.5, pts[0].Y, 0.25, "0.Y");
			Assert.AreEqual (3.5, pts[1].X, 0.25, "1.X");
			Assert.AreEqual (0.5, pts[1].Y, 0.25, "1.Y");
			Assert.AreEqual (3.5, pts[2].X, 0.25, "2.X");
			Assert.AreEqual (3.5, pts[2].Y, 0.25, "2.Y");
			Assert.AreEqual (0.5, pts[3].X, 0.25, "3.X");
			Assert.AreEqual (3.5, pts[3].Y, 0.25, "3.Y");
			Assert.AreEqual (1.5, pts[4].X, 0.25, "4.X");
			Assert.AreEqual (3.0, pts[4].Y, 0.25, "4.Y");
			Assert.AreEqual (1.0, pts[5].X, 0.25, "5.X");
			Assert.AreEqual (2.5, pts[5].Y, 0.25, "5.Y");
			Assert.AreEqual (3.0, pts[6].X, 0.25, "6.X");
			Assert.AreEqual (2.5, pts[6].Y, 0.25, "6.Y");
			Assert.AreEqual (2.5, pts[7].X, 0.25, "7.X");
			Assert.AreEqual (3.0, pts[7].Y, 0.25, "7.Y");
			Assert.AreEqual (2.5, pts[8].X, 0.25, "8.X");
			Assert.AreEqual (1.0, pts[8].Y, 0.25, "8.Y");
			Assert.AreEqual (3.0, pts[9].X, 0.25, "9.X");
			Assert.AreEqual (1.5, pts[9].Y, 0.25, "9.Y");
			Assert.AreEqual (1.0, pts[10].X, 0.25, "10.X");
			Assert.AreEqual (1.5, pts[10].Y, 0.25, "10.Y");
			Assert.AreEqual (1.5, pts[11].X, 0.25, "11.X");
			Assert.AreEqual (1.0, pts[11].Y, 0.25, "11.Y");

			byte[] types = path.PathTypes;
			Assert.AreEqual (0, types[0], "0");
			Assert.AreEqual (1, types[1], "1");
			Assert.AreEqual (1, types[2], "2");
			Assert.AreEqual (129, types[3], "3");
			Assert.AreEqual (0, types[4], "4");
			Assert.AreEqual (1, types[5], "5");
			Assert.AreEqual (1, types[6], "6");
			Assert.AreEqual (1, types[7], "7");
			Assert.AreEqual (1, types[8], "8");
			Assert.AreEqual (1, types[9], "9");
			Assert.AreEqual (1, types[10], "10");
			Assert.AreEqual (129, types[11], "11");
		}
        /// <summary>
        /// Create graphic objects used from hit test.
        /// </summary>
        protected virtual void CreateObjects()
        {
            if ( AreaPath != null )
                return;

            // Create path which contains wide line
            // for easy mouse selection
            AreaPath = new GraphicsPath();
            AreaPen = new Pen(Color.Black, 7);
            AreaPath.AddLine(startPoint.X, startPoint.Y, endPoint.X, endPoint.Y);
            AreaPath.Widen(AreaPen);

            // Create region from the path
            AreaRegion = new Region(AreaPath);
        }
Beispiel #31
0
        public void Draw(Graphics g, PointF pntDrawOffset, Point pntMouseLocation, MouseButtons mbButtons, Dictionary<Kill, KillDisplayDetails> dicKills, List<BattlemapRoundChange> lstRounds, KillDisplayColours colours, Dictionary<int, Color> teamColours)
        {
            GraphicsPath gpTimelineOutline = new GraphicsPath();

            gpTimelineOutline.AddLines(new Point[] { new Point(5, 0), new Point(0, 5), new Point(0, 15), new Point((int)g.ClipBounds.Width - 280, 15), new Point((int)g.ClipBounds.Width - 280, 5), new Point((int)g.ClipBounds.Width - 275, 0) });
            //gpTimelineOutline.AddLine(new Point(this.m_mtsSeek.SeekerPosition, 15), new Point((int)g.ClipBounds.Width - 280, 15));
            //gpTimelineOutline.AddLines(new Point[] { new Point(235, (int)g.ClipBounds.Height - 55), new Point(230, (int)g.ClipBounds.Height - 50), new Point(230, (int)g.ClipBounds.Height - 40), new Point((int)g.ClipBounds.Width - 50, (int)g.ClipBounds.Height - 40), new Point((int)g.ClipBounds.Width - 50, (int)g.ClipBounds.Height - 50), new Point((int)g.ClipBounds.Width - 45, (int)g.ClipBounds.Height - 55) });
            gpTimelineOutline.Widen(this.m_pOneWidth);

            this.ObjectPath = gpTimelineOutline;
            RectangleF recBounds = gpTimelineOutline.GetBounds();
            recBounds.Height += 50.0F;
            this.HotSpot = recBounds;

            //string strMouseOverKillList = String.Empty;
            float flMouseOffsetX = 0.0F;

            bool blRoundChanged = false;

            MapTextBlock timeList = new MapTextBlock();

            foreach (BattlemapRoundChange RoundChange in new List<BattlemapRoundChange>(lstRounds)) {
                float flOffsetXs = (this.HotSpot.Width - 5.0F) - ((float)((DateTime.Now.Ticks - RoundChange.ChangeTime.Ticks) / TimeSpan.TicksPerSecond) / 3600.0F) * (this.HotSpot.Width - 5.0F);
                RectangleF recChangePosition = new RectangleF(flOffsetXs + this.m_pntDrawOffset.X - 2.0F, this.m_pntDrawOffset.Y, 4.0F, 20.0F);

                if (flOffsetXs >= 0.0F) {
                    GraphicsPath gpChangeTime = new GraphicsPath();
                    gpChangeTime.AddLine(new PointF(flOffsetXs, 5), new PointF(flOffsetXs, 12));
                    gpChangeTime.Widen(this.m_pOneWidth);

                    this.DrawBwShape(g, gpChangeTime, this.TimelineOpacity, 4.0F, Color.Black, Color.RoyalBlue);
                    gpChangeTime.Dispose();

                    if (recChangePosition.Contains(new PointF(pntMouseLocation.X, pntMouseLocation.Y)) == true) {
                        //strMouseOverKillList += String.Format("Round change {0}\r\n", RoundChange.Map.PublicLevelName);

                        timeList.Strings.Add(new MapTextBlockString(String.Format("Round change {0}", RoundChange.Map.PublicLevelName), Color.Pink, true));

                        blRoundChanged = true;
                        flMouseOffsetX = flOffsetXs;
                        //flMouseOffsetX = flOffsetXs;
                    }
                }
            }

            foreach (KeyValuePair<Kill, KillDisplayDetails> kvpKill in new Dictionary<Kill, KillDisplayDetails>(dicKills)) {

                float flOffsetXs = (this.HotSpot.Width - 5.0F) - ((float)((DateTime.Now.Ticks - kvpKill.Key.TimeOfDeath.Ticks) / TimeSpan.TicksPerSecond) / 3600.0F) * (this.HotSpot.Width - 5.0F);
                RectangleF recKillPosition = new RectangleF(flOffsetXs + this.m_pntDrawOffset.X - 2.0F, this.m_pntDrawOffset.Y, 4.0F, 20.0F);

                if (recKillPosition.Contains(new PointF(pntMouseLocation.X + 5.0F, pntMouseLocation.Y)) == true) {
                    GraphicsPath gpKillTime = new GraphicsPath();
                    gpKillTime.AddLine(new PointF(flOffsetXs, 10), new PointF(flOffsetXs, 12));
                    gpKillTime.Widen(this.m_pOneWidth);

                    this.DrawBwShape(g, gpKillTime, this.TimelineOpacity, 4.0F, Color.Black, Color.RoyalBlue);
                    gpKillTime.Dispose();

                    Color killerColour = Color.White;
                    Color victimColour = Color.White;

                    if (colours == KillDisplayColours.EnemyColours) {
                        killerColour = ControlPaint.Light(Color.SeaGreen);
                        victimColour = ControlPaint.LightLight(Color.Black);
                    }
                    else if (colours == KillDisplayColours.TeamColours) {
                        if (teamColours.ContainsKey(kvpKill.Key.Killer.TeamID) == true && teamColours.ContainsKey(kvpKill.Key.Victim.TeamID) == true) {
                            killerColour = ControlPaint.Light(teamColours[kvpKill.Key.Killer.TeamID]);
                            victimColour = ControlPaint.Light(teamColours[kvpKill.Key.Victim.TeamID]);
                        }
                    }

                    if (kvpKill.Key.Killer.ClanTag.Length > 0) {
                        timeList.Strings.Add(new MapTextBlockString(String.Format("[{0}] ", kvpKill.Key.Killer.ClanTag), killerColour, false));
                    }

                    timeList.Strings.Add(new MapTextBlockString(kvpKill.Key.Killer.SoldierName, killerColour, false));

                    timeList.Strings.Add(new MapTextBlockString(String.Format("[{0}] ", kvpKill.Key.DamageType), Color.WhiteSmoke, false));

                    if (kvpKill.Key.Victim.ClanTag.Length > 0) {
                        timeList.Strings.Add(new MapTextBlockString(String.Format("[{0}] ", kvpKill.Key.Victim.ClanTag), victimColour, false));
                    }
                    timeList.Strings.Add(new MapTextBlockString(kvpKill.Key.Victim.SoldierName, victimColour, true));

                    flMouseOffsetX = flOffsetXs;
                }
            }

            if (timeList.Strings.Count > 0) {

                RectangleF recText = timeList.GetBounds();

                PointF timeListOffset = new PointF(pntDrawOffset.X + flMouseOffsetX - recText.Width / 2.0F, pntDrawOffset.Y - recText.Height);

                if (timeListOffset.X + recText.Width > g.ClipBounds.Width) {
                    timeListOffset.X = g.ClipBounds.Width - recText.Width;
                }

                timeList.Draw(g, timeListOffset, pntMouseLocation, mbButtons);
            }

            base.Draw(g, pntDrawOffset, pntMouseLocation, mbButtons);

            this.m_mtsSeek.ButtonOpacity = this.TimelineOpacity;
            this.m_mtsSeek.SeekerBounds = recBounds;
            this.m_mtsSeek.Draw(g, new PointF(pntDrawOffset.X, pntDrawOffset.Y + 13.0F), pntMouseLocation, mbButtons);

            timeList.Dispose();
        }
Beispiel #32
-1
 //是否包含圖形的座標
 public override bool Contains(Point point)
 {
     GraphicsPath path = new GraphicsPath();
     path.FillMode = FillMode.Winding;
     path.AddLine(StartPosition.X, StartPosition.Y, StartPosition.X + Width, StartPosition.Y + Height);
     path.Widen(new Pen(Color.AliceBlue, PATH_WIDEN));
     return path.IsVisible(point.X, point.Y);
 }