IsOutlineVisible() public method

public IsOutlineVisible ( Point point, Pen pen ) : bool
point Point
pen Pen
return bool
        public override bool ClickableAt(int x, int y)
        {
            Rectangle rect = GuiRectangle.GetGuiRectangle(Left, Top, Width, Height);
            int lineThickness = GetFieldValueAsInt(FieldType.LINE_THICKNESS) + 10;
            Color fillColor = GetFieldValueAsColor(FieldType.FILL_COLOR);

            // If we clicked inside the rectangle and it's visible we are clickable at.
            if (!Color.Transparent.Equals(fillColor))
            {
                if (Contains(x, y))
                {
                    return true;
                }
            }

            // check the rest of the lines
            if (lineThickness > 0)
            {
                using (Pen pen = new Pen(Color.White, lineThickness))
                {
                    using (GraphicsPath path = new GraphicsPath())
                    {
                        path.AddEllipse(rect);
                        return path.IsOutlineVisible(x, y, pen);
                    }
                }
            }
            else
            {
                return false;
            }
        }
		public bool HitTest(Point p)
		{
			GraphicsPath gp = new GraphicsPath();
			Matrix mtx = new Matrix();
			Pen pen = new Pen(el.BorderColor, el.BorderWidth + 4);
			pen.StartCap = el.StartCap;
			pen.EndCap = el.EndCap;
			gp.AddLine(el.Point1, el.Point2);
			gp.Transform(mtx);
			//Rectangle retGp = Rectangle.Round(gp.GetBounds());
			return gp.IsOutlineVisible (p, pen);
		}
 public override bool ClickableAt(int x, int y)
 {
     int lineThickness = GetFieldValueAsInt(FieldType.LINE_THICKNESS) +5;
     if (lineThickness > 0) {
         using (Pen pen = new Pen(Color.White)) {
             pen.Width = lineThickness;
             GraphicsPath path = new GraphicsPath();
             path.AddLine(this.Left, this.Top, this.Left + this.Width, this.Top + this.Height);
             return path.IsOutlineVisible(x,y, pen);
         }
     } else {
         return false;
     }
 }
Beispiel #4
0
		/// <summary>
		/// Determine if the specified screen point lies inside the bounding box of this
		/// <see cref="LineObj"/>.
		/// </summary>
		/// <remarks>The bounding box is calculated assuming a distance
		/// of <see cref="GraphPane.Default.NearestTol"/> pixels around the arrow segment.
		/// </remarks>
		/// <param name="pt">The screen point, in pixels</param>
		/// <param name="pane">
		/// A reference to the <see cref="PaneBase"/> object that is the parent or
		/// owner of this object.
		/// </param>
		/// <param name="g">
		/// A graphic device object to be drawn into.  This is normally e.Graphics from the
		/// PaintEventArgs argument to the Paint() method.
		/// </param>
		/// <param name="scaleFactor">
		/// The scaling factor to be used for rendering objects.  This is calculated and
		/// passed down by the parent <see cref="GraphPane"/> object using the
		/// <see cref="PaneBase.CalcScaleFactor"/> method, and is used to proportionally adjust
		/// font sizes, etc. according to the actual size of the graph.
		/// </param>
		/// <returns>true if the point lies in the bounding box, false otherwise</returns>
		override public bool PointInBox( PointF pt, PaneBase pane, Graphics g, float scaleFactor )
		{
			if ( ! base.PointInBox(pt, pane, g, scaleFactor ) )
				return false;

			// transform the x,y location from the user-defined
			// coordinate frame to the screen pixel location
			PointF pix = _location.TransformTopLeft( pane );
			PointF pix2 = _location.TransformBottomRight( pane );

            float tolerance = (float)GraphPane.Default.NearestTol * 2.0F;
            // nicksh: "GraphicsPath.IsOutlineVisible" can be slow, so do a first check to see if 
            // the point is at all near this Line.
		    var boundingBox = new RectangleF(Math.Min(pix.X, pix2.X), Math.Min(pix.Y, pix2.Y), 
                                             Math.Abs(pix.X - pix2.X), Math.Abs(pix.Y - pix2.Y));
            boundingBox.Inflate(tolerance, tolerance);
            if (!boundingBox.Contains(pt))
            {
                return false;
            }

			using ( Pen pen = new Pen( Color.Black, tolerance))
			{
				using ( GraphicsPath path = new GraphicsPath() )
				{
					path.AddLine( pix, pix2 );
					return path.IsOutlineVisible( pt, pen );
				}
			}
		}
		//Gets the path intercept of a line drawn from inside a graphicspath outwards
		//Path should be flattened before passing to this procedure
		public static PointF GetPathIntercept(PointF startPoint,PointF endPoint,GraphicsPath path,Pen outlinePen,RectangleF internalRectangle)
		{
			float x = 0;
			float y = 0;
			float xStep;
			float yStep;

			bool useInternal;
			//useInternal = ! internalRectangle.IsEmpty;
			useInternal = false;

			//work out interval in steps
			xStep = ((startPoint.X <= endPoint.X) ? 1.0F : -1.0F);
			yStep = ((startPoint.Y <= endPoint.Y) ? 1.0F : -1.0F);

			float gradient = (endPoint.Y - startPoint.Y) / (endPoint.X - startPoint.X);
			float reverseGradient = 1 / gradient;

			//Loop making smaller and smaller step adjustments, longer processing time but more accuracy
			while (xStep != 0)
			{
				//Check for vertical line
				if (startPoint.X != endPoint.X)
				{
					//Step through each value of x, determining y and checking if outline visible
					for (x = startPoint.X; ((startPoint.X < endPoint.X) ? x <= endPoint.X : x >= endPoint.X); x += xStep)
					{
						//calculate Y
						//y = Convert.ToSingle((gradient * (x - startPoint.X)) + startPoint.Y);
						y = (gradient * (x - startPoint.X)) + startPoint.Y;

						//check if we have hit the outline 
						if (path.IsOutlineVisible(x, y, outlinePen)) return new PointF(x, y);
						if (useInternal && internalRectangle.Contains(x,y)) break;
					}
				}
				//Try stepping through each value of y, this is for a line with a high gradient
				//where a small change in x produces a large change in y
				//therefore try small changes in y and work out x

				//Step through each value of y, determining x and checking if outline visible
				if (startPoint.Y != endPoint.Y)
				{
					for (y = startPoint.Y; ((startPoint.Y < endPoint.Y) ? y <= endPoint.Y : y >= endPoint.Y); y += yStep)
					{
						//calculate X
						//x = Convert.ToSingle((reverseGradient * (y - startPoint.Y) + startPoint.X));
						x = (reverseGradient * (y - startPoint.Y) + startPoint.X);

						//check if we have hit the outline 
						if (path.IsOutlineVisible(x, y, outlinePen)) return new PointF(x, y);
						if (useInternal && internalRectangle.Contains(x,y)) break;
					}
				}

				//Make smaller steps if havent found intercept
				xStep += ((startPoint.X <= endPoint.X)? -0.25F : 0.25F);
				yStep += ((startPoint.Y <= endPoint.Y)? -0.25F : 0.25F);
			}

			return startPoint;
		}
Beispiel #6
0
        /// <summary>
        /// Determine if the specified screen point lies inside the bounding box of this
        /// <see cref="LineObj"/>.
        /// </summary>
        /// <remarks>The bounding box is calculated assuming a distance
        /// of <see cref="GraphPane.Default.NearestTol"/> pixels around the arrow segment.
        /// </remarks>
        /// <param name="pt">The screen point, in pixels</param>
        /// <param name="pane">
        /// A reference to the <see cref="PaneBase"/> object that is the parent or
        /// owner of this object.
        /// </param>
        /// <param name="g">
        /// A graphic device object to be drawn into.  This is normally e.Graphics from the
        /// PaintEventArgs argument to the Paint() method.
        /// </param>
        /// <param name="scaleFactor">
        /// The scaling factor to be used for rendering objects.  This is calculated and
        /// passed down by the parent <see cref="GraphPane"/> object using the
        /// <see cref="PaneBase.CalcScaleFactor"/> method, and is used to proportionally adjust
        /// font sizes, etc. according to the actual size of the graph.
        /// </param>
        /// <returns>true if the point lies in the bounding box, false otherwise</returns>
        public override bool PointInBox(PointF pt, PaneBase pane, Graphics g, float scaleFactor)
        {
            if (! base.PointInBox(pt, pane, g, scaleFactor))
                return false;

            // transform the x,y location from the user-defined
            // coordinate frame to the screen pixel location
            PointF pix = _location.TransformTopLeft(pane);
            PointF pix2 = _location.TransformBottomRight(pane);

            using (var pen = new Pen(Color.Black, (float) GraphPane.Default.NearestTol*2.0F))
            {
                using (var path = new GraphicsPath())
                {
                    path.AddLine(pix, pix2);
                    return path.IsOutlineVisible(pt, pen);
                }
            }
        }
Beispiel #7
0
		[Category ("NotWorking")] // looks buggy - reported to MS as FDBK50868
		public void IsOutlineVisible_Line_End ()
		{
			// horizontal line
			using (GraphicsPath gp = new GraphicsPath ()) {
				gp.AddLine (10, 1, 14, 1);
				Assert.IsFalse (gp.IsOutlineVisible (14, 1, Pens.Red, null), "Int1h");
				Assert.IsFalse (gp.IsOutlineVisible (13.5f, 1.0f, Pens.Red, null), "Float1h");
				Assert.IsTrue (gp.IsOutlineVisible (13.4f, 1.0f, Pens.Red, null), "Float2h");
				Assert.IsFalse (gp.IsOutlineVisible (new Point (14, 1), Pens.Red, null), "Point1h");
				Assert.IsFalse (gp.IsOutlineVisible (new PointF (13.5f, 1.0f), Pens.Red, null), "PointF1h");
				Assert.IsTrue (gp.IsOutlineVisible (new PointF (13.49f, 1.0f), Pens.Red, null), "PointF2h");
			}
			// vertical line
			using (GraphicsPath gp = new GraphicsPath ()) {
				gp.AddLine (1, 10, 1, 14);
				Assert.IsFalse (gp.IsOutlineVisible (1, 14, Pens.Red, null), "Int1v");
				Assert.IsFalse (gp.IsOutlineVisible (1.0f, 13.5f, Pens.Red, null), "Float1v");
				Assert.IsTrue (gp.IsOutlineVisible (1.0f, 13.4f, Pens.Red, null), "Float2v");
				Assert.IsFalse (gp.IsOutlineVisible (new Point (1, 14), Pens.Red, null), "Point1v");
				Assert.IsFalse (gp.IsOutlineVisible (new PointF (1.0f, 13.5f), Pens.Red, null), "PointF1v");
				Assert.IsTrue (gp.IsOutlineVisible (new PointF (1.0f, 13.49f), Pens.Red, null), "PointF2v");
			}
		}
Beispiel #8
0
		private void IsOutlineVisible_Line (Graphics graphics)
		{
			Pen p2 = new Pen (Color.Red, 3.0f);
			using (GraphicsPath gp = new GraphicsPath ()) {
				gp.AddLine (10, 1, 14, 1);
				Assert.IsTrue (gp.IsOutlineVisible (10, 1, Pens.Red, graphics), "Int1");
				Assert.IsTrue (gp.IsOutlineVisible (10, 2, p2, graphics), "Int2");
				Assert.IsFalse (gp.IsOutlineVisible (10, 2, Pens.Red, graphics), "Int3");

				Assert.IsTrue (gp.IsOutlineVisible (11.0f, 1.0f, Pens.Red, graphics), "Float1");
				Assert.IsTrue (gp.IsOutlineVisible (11.0f, 1.0f, p2, graphics), "Float2");
				Assert.IsFalse (gp.IsOutlineVisible (11.0f, 2.0f, Pens.Red, graphics), "Float3");

				Point pt = new Point (12, 2);
				Assert.IsFalse (gp.IsOutlineVisible (pt, Pens.Red, graphics), "Point1");
				Assert.IsTrue (gp.IsOutlineVisible (pt, p2, graphics), "Point2");
				pt.Y = 1;
				Assert.IsTrue (gp.IsOutlineVisible (pt, Pens.Red, graphics), "Point3");

				PointF pf = new PointF (13.0f, 2.0f);
				Assert.IsFalse (gp.IsOutlineVisible (pf, Pens.Red, graphics), "PointF1");
				Assert.IsTrue (gp.IsOutlineVisible (pf, p2, graphics), "PointF2");
				pf.Y = 1;
				Assert.IsTrue (gp.IsOutlineVisible (pf, Pens.Red, graphics), "PointF3");
			}
			p2.Dispose ();
		}
		/// <summary>
		/// Performs a hit test on the <see cref="Graphic"/> at a given point.
		/// </summary>
		/// <param name="point">The mouse position in destination coordinates.</param>
		/// <returns>
		/// <b>True</b> if <paramref name="point"/> "hits" the <see cref="Graphic"/>,
		/// <b>false</b> otherwise.
		/// </returns>
		public override bool HitTest(Point point)
		{
			base.CoordinateSystem = CoordinateSystem.Destination;
			try
			{
				using (var gp = new GraphicsPath())
				using (var pen = new Pen(Color.Black, HitTestDistance))
				{
					PointF[] pathPoints = GetCurvePoints(_points);
					if (_points.IsClosed)
						gp.AddClosedCurve(pathPoints);
					else
						gp.AddCurve(pathPoints);
					return gp.IsOutlineVisible(point, pen);
				}
			}
			finally
			{
				base.ResetCoordinateSystem();
			}
		}
Beispiel #10
0
        public void OnMouseMove(MouseEventArgs e)
        {
            if (this.graph == null )
            {
                this.Operate = PolyOperate.Draw;
                return;
            }
            if (((SvgElement) this.graph).ParentNode == null)
            {
                this.Operate = PolyOperate.Draw;
                return;
            }
            if ((Control.ModifierKeys & Keys.Control) == Keys.Control || (this.mouseAreaControl.CurrentOperation == ToolOperation.Custom11) || (this.mouseAreaControl.CurrentOperation == ToolOperation.Custom14) || (this.mouseAreaControl.CurrentOperation == ToolOperation.Custom15))
            {
                addBegin =false;
                addEnd =false;
            }
            if (isKeydown((int)ItopVector.Core.Win32.Enum.VirtualKeys.VK_B) || (this.mouseAreaControl.CurrentOperation == ToolOperation.Custom13))
            {
                addBegin =true;
                addEnd =false;
            }
            else if (isKeydown((int)ItopVector.Core.Win32.Enum.VirtualKeys.VK_E) || (this.mouseAreaControl.CurrentOperation == ToolOperation.Custom12))
            {
                addEnd =true;
                addBegin=false;
            }
            if(addEnd || addBegin)
            {
                this.Operate = PolyOperate.Draw;
                return;
            }
            if (e.Button == MouseButtons.None)
            {
                this.win32.hdc = this.win32.W32GetDC(this.mouseAreaControl.Handle);
                this.win32.W32SetROP2(7);
                this.win32.W32PolyDraw(this.reversePath);
                this.reversePath.Reset();
                this.win32.ReleaseDC();
                int num4;
                PointF[] tfArray1 = (PointF[]) this.points.Clone();
                int num1 = 0;
                this.insertindex = num4 = -1;
                this.moveindex = num4;
                GraphicsPath path1 = new GraphicsPath();
                Pen pen1 = new Pen(Color.Beige, 4f);
                PointF[] tfArray3 = tfArray1;
                for (int num5 = 0; num5 < tfArray3.Length; num5++)
                {
                    PointF tf1 = tfArray3[num5];
                    RectangleF ef1 = new RectangleF(tf1.X - 2f, tf1.Y - 2f, 4f, 4f);
                    if (ef1.Contains((PointF) new Point(e.X, e.Y)))
                    {
                        this.moveindex = num1;
                        if ((Control.ModifierKeys & Keys.Control) == Keys.Control || (this.mouseAreaControl.CurrentOperation == ToolOperation.Custom11) || (this.mouseAreaControl.CurrentOperation == ToolOperation.Custom14))
                        {
                            if (((Control.ModifierKeys & Keys.Alt) == Keys.Alt || (this.mouseAreaControl.CurrentOperation == ToolOperation.Custom11)) && this.graph is Polyline && num5 > 0 && num5 < tfArray3.Length-1 && (this.mouseAreaControl.CurrentOperation != ToolOperation.Custom14))
                            {
            //								PointF[] tfs=new PointF[num5];
            //								for(int i=0;i<num5;i++)
            //								{
            //									tfs[i] = tfArray1[i];
            //								}
            //								((Polyline) this.graph).Points = tfs;
                                this.Operate = PolyOperate.Break;
                                return;
                            }
                            else
                            {
                                this.Operate = PolyOperate.Del;
                                return;
                            }
                        }
                        this.Operate = PolyOperate.MovePoint;
                        return;

                    }
                    if ((num1 - 1) >= 0)
                    {
                        path1.Reset();
                        PointF tf2 = tfArray1[num1 - 1];
                        path1.AddLine(tf2, tf1);
                        if (path1.IsOutlineVisible(new PointF((float) e.X, (float) e.Y), pen1))
                        {
                            if (((Control.ModifierKeys & Keys.Control) == Keys.Control) || (this.mouseAreaControl.CurrentOperation == ToolOperation.Custom15))

                            {
                                this.Operate = PolyOperate.Add;
                            }
                            else
                            {
                                this.Operate = PolyOperate.MovePath;
                            }
                            this.insertindex = num1;
                            return;
                        }
                    }
                    if (((num1 == (tfArray1.Length - 1)) && (this.mouseAreaControl.CurrentOperation == ToolOperation.Polygon)) && (tfArray1.Length >= 3))
                    {
                        path1.Reset();
                        PointF tf3 = tfArray1[0];
                        path1.AddLine(tf3, tf1);
                        if (path1.IsOutlineVisible(new PointF((float) e.X, (float) e.Y), pen1))
                        {
                            if (((Control.ModifierKeys & Keys.Control) == Keys.Control) || (this.mouseAreaControl.CurrentOperation == ToolOperation.Custom11)
                                || (this.mouseAreaControl.CurrentOperation == ToolOperation.Custom12) || (this.mouseAreaControl.CurrentOperation == ToolOperation.Custom13) || (this.mouseAreaControl.CurrentOperation == ToolOperation.Custom14))
                            {
                                this.Operate = PolyOperate.MovePath;
                            }
                            else
                            {
                                this.Operate = PolyOperate.Add;
                            }
                            this.insertindex = num1;
                            return;
                        }
                    }
                    num1++;
                }
                if (((Control.ModifierKeys & Keys.Control) == Keys.Control) || (this.mouseAreaControl.CurrentOperation == ToolOperation.ShapeTransform) || (this.mouseAreaControl.CurrentOperation == ToolOperation.Custom11)
                    || (this.mouseAreaControl.CurrentOperation == ToolOperation.Custom12) || (this.mouseAreaControl.CurrentOperation == ToolOperation.Custom13) || (this.mouseAreaControl.CurrentOperation == ToolOperation.Custom14) || (this.mouseAreaControl.CurrentOperation == ToolOperation.Custom15))
                {
                    this.Operate = PolyOperate.MovePoint;
                }
                else
                {
                    this.Operate = PolyOperate.Draw;
                }

                if( this.operate==PolyOperate.Draw)
                {
                    PointF pf1 =new PointF(e.X,e.Y);

                    PointF pf2 = this.points[points.Length -1];

                    PointF pf3 = pf1;
                    if(this.graph is Polygon)
                    {
                        pf3=points[0];
                    }

                    PointF[] array1=new PointF[3]{pf2,pf1,pf3};

                    this.win32.hdc = this.win32.W32GetDC(this.mouseAreaControl.Handle);
                    this.win32.W32SetROP2(7);
                    this.reversePath.Reset();
                    this.reversePath.AddLines(array1);
                    this.win32.W32PolyDraw(this.reversePath);
                    this.win32.ReleaseDC();
                }
            }
            if ((e.Button != MouseButtons.Left) || !this.mousedown)
            {
                return;
            }
            this.win32.hdc = this.win32.W32GetDC(this.mouseAreaControl.Handle);
            this.win32.W32SetROP2(7);
            this.win32.W32PolyDraw(this.reversePath);
            this.reversePath.Reset();
            PointF tf4 = this.mouseAreaControl.PicturePanel.PointToView(new PointF((float) e.X, (float) e.Y));
            SizeF ef2 = this.mouseAreaControl.PicturePanel.GridSize;
            float single1 = ef2.Height;
            float single2 = ef2.Width;
            if (this.mouseAreaControl.PicturePanel.SnapToGrid)
            {
                int num2 = (int) ((tf4.X + (single2 / 2f)) / single2);
                int num3 = (int) ((tf4.Y + (single1 / 2f)) / single1);
                tf4 = (PointF) new Point((int) (num2 * single2), (int) (num3 * single1));
            }
            tf4 = this.mouseAreaControl.PicturePanel.PointToSystem(tf4);
            //tf4 = this.mouseAreaControl.PicturePanel.PointToView(tf4);//05-16 �޸�
            switch (this.operate)
            {
                case PolyOperate.MovePath:
                {
                    PointF[] tfArray2 = (PointF[]) this.points.Clone();
                    Matrix matrix1 = new Matrix();
                    PointF tf5 = this.mouseAreaControl.PicturePanel.PointToSystem(this.startpoint);
                    matrix1.Translate(tf4.X - tf5.X, tf4.Y - tf5.Y);
                    matrix1.TransformPoints(tfArray2);
                    if ((tfArray2.Length < 3) || !(this.graph is Polygon))
                    {
                        this.reversePath.AddLines(tfArray2);
                        break;
                    }
                    this.reversePath.AddPolygon(tfArray2);
                    break;
                }
                case PolyOperate.MovePoint:
                {
                    if ((this.moveindex >= 0) && (this.moveindex < this.points.Length))
                    {
                        if (!this.prePoint.IsEmpty)
                        {
                            this.reversePath.AddLine(this.prePoint, tf4);
                        }
                        if (!this.nextPoint.IsEmpty)
                        {
                            this.reversePath.AddLine(tf4, this.nextPoint);
                        }
                        this.reversePath.AddRectangle(new RectangleF(tf4.X - 2f, tf4.Y - 2f, 4f, 4f));
                    }
                    goto Label_04D2;
                }
                default:
                {
                    goto Label_04D2;
                }
            }
            Label_04D2:
            this.win32.W32PolyDraw(this.reversePath);
            this.win32.ReleaseDC();
        }
Beispiel #11
0
		public void IsOutlineVisible_Point_Pen_Graphics()
		{
			path = new GraphicsPath ();
			path.AddRectangle (new RectangleF (10f, 10f, 300f, 300f));
			
			path.StartFigure();
			path.AddRectangle (new RectangleF (150f, 10f, 50f, 400f));

			Pen pen = new Pen (Color.Red, 5);
			Graphics gr = Graphics.FromImage (new Bitmap (512, 512));
			gr.Clip = new Region (new Rectangle ( 5, 5, 500, 50));

			Assert.IsFalse (path.IsOutlineVisible (new Point (0, 0), pen, gr));

			Assert.IsFalse (path.IsOutlineVisible (new Point (40, 40), pen, gr));

			Assert.IsTrue (path.IsOutlineVisible (new Point (9, 9), pen, gr));

			Assert.IsFalse (path.IsOutlineVisible (new Point (400, 400), pen, gr));

			Assert.IsTrue (path.IsOutlineVisible (new Point (312, 312), pen, gr));

			Assert.IsFalse (path.IsOutlineVisible (new Point (313, 313), pen, gr));

			Assert.IsTrue (path.IsOutlineVisible (new Point (310, 10), pen, gr));
			Assert.IsTrue (path.IsOutlineVisible (new Point (310, 10), pen, null));

			Assert.IsTrue (path.IsOutlineVisible (new Point (310, 210), pen, gr));
			Assert.IsTrue (path.IsOutlineVisible (new Point (310, 210), pen, null));

			//t.AssertCompare ();
		}
Beispiel #12
0
		public void IsOutlineVisible_Point_Pen()
		{				
			path = new GraphicsPath ();
			path.AddRectangle (new RectangleF (10f, 10f, 300f, 300f));
			
			path.StartFigure();
			path.AddRectangle (new RectangleF (150f, 10f, 50f, 400f));

			Pen pen = new Pen (Color.Red, 5);

			Assert.IsFalse (path.IsOutlineVisible (new Point (0, 0), pen));

			Assert.IsFalse (path.IsOutlineVisible (new Point (40, 40), pen));

			Assert.IsTrue (path.IsOutlineVisible (new Point (9, 9), pen));

			Assert.IsFalse (path.IsOutlineVisible (new Point (400, 400), pen));

			Assert.IsTrue (path.IsOutlineVisible (new Point (312, 312), pen));

			Assert.IsFalse (path.IsOutlineVisible (new Point (313, 313), pen));

			//t.AssertCompare ();
		}
Beispiel #13
0
		public void IsOutlineVisible_PointF_Pen_Graphics()
		{
			path = new GraphicsPath ();
			path.AddRectangle (new RectangleF (10f, 10f, 300f, 300f));
			
			path.StartFigure();
			path.AddRectangle (new RectangleF (150f, 10f, 50f, 400f));

			Pen pen = new Pen (Color.Red, 5);
			Graphics gr = Graphics.FromImage (new Bitmap (512, 512));
			gr.Clip = new Region (new Rectangle ( 5, 5, 500, 50));

			Assert.IsFalse (path.IsOutlineVisible (new PointF (0f, 0f), pen, gr));

			Assert.IsFalse (path.IsOutlineVisible (new PointF (40f, 40f), pen, gr));

			Assert.IsTrue (path.IsOutlineVisible (new PointF (9f, 9f), pen, gr));

			Assert.IsFalse (path.IsOutlineVisible (new PointF (400f, 400f), pen, gr));

			Assert.IsTrue (path.IsOutlineVisible (new PointF (312f, 312f), pen, gr));

			Assert.IsFalse (path.IsOutlineVisible (new PointF (313f, 313f), pen, gr));

			//t.AssertCompare ();
		}
Beispiel #14
0
		public void IsOutlineVisible_PointF_Pen()
		{
			path = new GraphicsPath ();
			path.AddRectangle (new RectangleF (10f, 10f, 300f, 300f));
			
			path.StartFigure();
			path.AddRectangle (new RectangleF (150f, 10f, 50f, 400f));

			Pen pen = new Pen (Color.Red, 5);

			Assert.IsFalse (path.IsOutlineVisible (new PointF (0f, 0f), pen));

			Assert.IsFalse (path.IsOutlineVisible (new PointF (40f, 40f), pen));

			Assert.IsTrue (path.IsOutlineVisible (new PointF (9f, 9f), pen));

			Assert.IsFalse (path.IsOutlineVisible (new PointF (400f, 400f), pen));

			Assert.IsTrue (path.IsOutlineVisible (new PointF (312f, 312f), pen));

			Assert.IsFalse (path.IsOutlineVisible (new PointF (313f, 313f), pen));

			//t.AssertCompare ();
		}
Beispiel #15
0
 private MousePoint GetMousePoint(GraphicsPath path, PointF point, Matrix matrix, ToolOperation operation)
 {
     if (operation == ToolOperation.Flip)
     {
         this.currentMousePoint = MousePoint.Flip;
     }
     RectangleF ef1 = PathFunc.GetBounds(path);
     PointF[] tfArray1 = new PointF[9] { new PointF(ef1.X, ef1.Y), new PointF(ef1.X + (ef1.Width / 2f), ef1.Y), new PointF(ef1.Right, ef1.Y), new PointF(ef1.Right, ef1.Y + (ef1.Height / 2f)), new PointF(ef1.Right, ef1.Bottom), new PointF(ef1.X + (ef1.Width / 2f), ef1.Bottom), new PointF(ef1.X, ef1.Bottom), new PointF(ef1.X, ef1.Y + (ef1.Height / 2f)), new PointF(ef1.X + (ef1.Width / 2f), ef1.Y + (ef1.Height / 2f)) } ;
     this.ps = tfArray1;
     matrix.TransformPoints(this.ps);
     //			this.ps = this.ps;
     RectangleF ef2 = new RectangleF(this.ps[0].X - 2f, this.ps[0].Y - 2f, 5f, 5f);
     GraphicsPath path1 = new GraphicsPath();
     path1.AddRectangle(ef2);
     ef2 = new RectangleF(this.ps[2].X - 2f, this.ps[2].Y - 2f, 5f, 5f);
     GraphicsPath path2 = new GraphicsPath();
     path2.AddRectangle(ef2);
     ef2 = new RectangleF(this.ps[1].X - 2f, this.ps[1].Y - 2f, 5f, 5f);
     GraphicsPath path3 = new GraphicsPath();
     path3.AddRectangle(ef2);
     ef2 = new RectangleF(this.ps[7].X - 2f, this.ps[7].Y - 2f, 5f, 5f);
     GraphicsPath path4 = new GraphicsPath();
     path4.AddRectangle(ef2);
     ef2 = new RectangleF(this.ps[6].X - 2f, this.ps[6].Y - 2f, 5f, 5f);
     GraphicsPath path5 = new GraphicsPath();
     path5.AddRectangle(ef2);
     ef2 = new RectangleF(this.ps[3].X - 2f, this.ps[3].Y - 2f, 5f, 5f);
     GraphicsPath path6 = new GraphicsPath();
     path6.AddRectangle(ef2);
     ef2 = new RectangleF(this.ps[5].X - 3f, this.ps[5].Y - 2f, 5f, 5f);
     GraphicsPath path7 = new GraphicsPath();
     path7.AddRectangle(ef2);
     ef2 = new RectangleF(this.ps[4].X - 2f, this.ps[4].Y - 2f, 5f, 5f);
     GraphicsPath path8 = new GraphicsPath();
     path8.AddRectangle(ef2);
     GraphicsPath path9 = new GraphicsPath();
     path9.AddLine(this.ps[0], this.ps[6]);
     GraphicsPath path10 = new GraphicsPath();
     path10.AddLine(this.ps[2], this.ps[4]);
     GraphicsPath path11 = new GraphicsPath();
     path11.AddLine(this.ps[0], this.ps[2]);
     GraphicsPath path12 = new GraphicsPath();
     path12.AddLine(this.ps[6], this.ps[4]);
     GraphicsPath path13 = new GraphicsPath();
     path13.AddRectangle(new RectangleF(this.ps[0].X - 5f, this.ps[0].Y - 5f, 8f, 8f));
     GraphicsPath path14 = new GraphicsPath();
     path14.AddRectangle(new RectangleF(this.ps[2].X - 2f, this.ps[2].Y - 5f, 8f, 8f));
     GraphicsPath path15 = new GraphicsPath();
     path15.AddRectangle(new RectangleF(this.ps[4].X - 3f, this.ps[4].Y - 3f, 8f, 8f));
     GraphicsPath path16 = new GraphicsPath();
     path16.AddRectangle(new RectangleF(this.ps[6].X - 2f, this.ps[6].Y - 5f, 8f, 8f));
     PointF tf1 = this.mouseAreaControl.CenterPoint;
     GraphicsPath path17 = new GraphicsPath();
     if (!tf1.IsEmpty)
     {
         path17.AddEllipse((float) (tf1.X - 3f), (float) (tf1.Y - 3f), (float) 6f, (float) 6f);
     }
     RectangleF ef3 = new RectangleF(point.X - 1f, point.Y - 1f, 2f, 2f);
     GraphicsPath path18 = (GraphicsPath) path.Clone();
     path.Transform(matrix);
     Pen pen1 = new Pen(Color.Blue, 3f);
     pen1.Alignment = PenAlignment.Center;
     MousePoint point1 = MousePoint.None;
     if (OperationFunc.IsSelectOperation(operation))
     {
         ToolOperation operation1 = operation;
         if ((operation1==ToolOperation.Exceptant)||(operation1 == ToolOperation.Select) && (path.IsVisible(point) || path.IsOutlineVisible(point, pen1)))
         {
             return MousePoint.Translate;
         }
     }
     else if (OperationFunc.IsTransformOperation(operation))
     {
         //				if (path17.IsVisible(point) || path17.IsOutlineVisible(point, pen1))
         //				{
         //					point1 = MousePoint.CenterPoint;
         //				}
         //				else
         if (path1.IsVisible(point) || path1.IsOutlineVisible(point, pen1))
         {
             point1 = MousePoint.ScaleTopLeft;
         }
         else if (path3.IsVisible(point) || path3.IsOutlineVisible(point, pen1))
         {
             point1 = MousePoint.ScaleTopMiddle;
         }
         else if (path2.IsVisible(point) || path2.IsOutlineVisible(point, pen1))
         {
             point1 = MousePoint.ScaleTopRight;
         }
         else if (path4.IsVisible(point) || path4.IsOutlineVisible(point, pen1))
         {
             point1 = MousePoint.ScaleMiddleLeft;
         }
         else if (path6.IsVisible(point) || path6.IsOutlineVisible(point, pen1))
         {
             point1 = MousePoint.ScaleMiddleRight;
         }
         else if (path5.IsVisible(point) || path5.IsOutlineVisible(point, pen1))
         {
             point1 = MousePoint.ScaleBottomLeft;
         }
         else if (path7.IsVisible(point) || path7.IsOutlineVisible(point, pen1))
         {
             point1 = MousePoint.ScaleBottomMiddle;
         }
         else if (path8.IsVisible(point) || path8.IsOutlineVisible(point, pen1))
         {
             point1 = MousePoint.ScaleBottomRight;
         }
         else
         {
             if (path9.IsVisible(point) || path9.IsOutlineVisible(point, pen1))
             {
                 return MousePoint.SkewYLeft;
             }
             if (path10.IsVisible(point) || path10.IsOutlineVisible(point, pen1))
             {
                 point1 = MousePoint.SkewYRight;
             }
             else if (path11.IsVisible(point) || path11.IsOutlineVisible(point, pen1))
             {
                 point1 = MousePoint.SkewXTop;
             }
             else if (path12.IsVisible(point) || path12.IsOutlineVisible(point, pen1))
             {
                 point1 = MousePoint.SkewXBottom;
             }
             else if (path13.IsVisible(point) || path13.IsOutlineVisible(point, pen1))
             {
                 this.rotateindex = 6;
                 point1 = MousePoint.Rotate;
             }
             else if (path14.IsVisible(point) || path14.IsOutlineVisible(point, pen1))
             {
                 this.rotateindex = 2;
                 point1 = MousePoint.Rotate;
             }
             else if (path15.IsVisible(point) || path15.IsOutlineVisible(point, pen1))
             {
                 this.rotateindex = 0;
                 point1 = MousePoint.Rotate;
             }
             else if (path16.IsVisible(point) || path16.IsOutlineVisible(point, pen1))
             {
                 this.rotateindex = 4;
                 point1 = MousePoint.Rotate;
             }
             else if (path.IsVisible(point))// || path.IsOutlineVisible(point,pen1))
             {
                 point1 = MousePoint.Translate;
             }
         }
         if (point1 != MousePoint.CenterPoint)
         {
             if (operation == ToolOperation.Rotate)
             {
                 if ((point1 == MousePoint.Rotate) || (point1 == MousePoint.Translate))
                 {
                     point1 = point1;
                 }
                 else
                 {
                     point1 = MousePoint.None;
                 }
             }
             else if (operation == ToolOperation.Scale)
             {
                 if ((((point1 == MousePoint.ScaleBottomLeft) || (point1 == MousePoint.ScaleBottomMiddle)) || ((point1 == MousePoint.ScaleBottomMiddle) || (point1 == MousePoint.ScaleBottomRight))) || ((((point1 == MousePoint.ScaleMiddleLeft) || (point1 == MousePoint.ScaleMiddleRight)) || ((point1 == MousePoint.ScaleTopLeft) || (point1 == MousePoint.ScaleTopMiddle))) || ((point1 == MousePoint.ScaleTopRight) || (point1 == MousePoint.Translate))))
                 {
                     point1 = point1;
                 }
                 else
                 {
                     point1 = MousePoint.None;
                 }
             }
             else if (operation == ToolOperation.Skew)
             {
                 if (((point1 == MousePoint.SkewXBottom) || (point1 == MousePoint.SkewXTop)) || (((point1 == MousePoint.SkewYLeft) || (point1 == MousePoint.SkewYRight)) || (point1 == MousePoint.Translate)))
                 {
                     point1 = point1;
                 }
                 else
                 {
                     point1 = MousePoint.None;
                 }
             }
         }
     }
     //            this.mouseAreaControl.Invalidate();
     return point1;
 }
Beispiel #16
0
 private void SelectALine(Graphics gr, Point mouseClick)
 {
     using (var path = new GraphicsPath())
     {
         foreach (var p in myNetwork.Pipelines)
         {
             Point[] pts = new Point[p.InBetweenPoints.Count + 2];
             pts[0] = p.StartPoint;
             for (int i = 0; i < p.InBetweenPoints.Count; i++)
             {
                 pts[i + 1] = p.InBetweenPoints[i];
             }
             pts[p.InBetweenPoints.Count + 1] = p.EndPoint;
             path.AddLines(pts);
             if (path.IsOutlineVisible(mouseClick, new Pen(Color.Orange, 8), gr))
             {
                 selectedPipeline = p;
                 break;
             }
         }
     }
 }
Beispiel #17
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 #18
0
 public static PointF[] SplitBezierAtPoint(PointF start, PointF control1, PointF control2, PointF end, PointF point, out float t)
 {
     Pen pen1 = new Pen(Color.Blue, 2f);
     pen1.Alignment = PenAlignment.Center;
     GraphicsPath path1 = new GraphicsPath();
     path1.AddBezier(start, control1, control2, end);
     if (!path1.IsOutlineVisible(point, pen1))
     {
         t = -1f;
         return null;
     }
     PointF tf1 = PointF.Empty;
     PointF tf2 = PointF.Empty;
     PointF tf3 = PointF.Empty;
     PointF tf4 = PointF.Empty;
     PointF tf5 = PointF.Empty;
     t = 0.5f;
     PointF[] tfArray1 = BezierOperation.SplitBeizierAtT(start, control1, control2, end, t);
     PointF tf6 = tfArray1[2];
     for (float single1 = (float) Math.Sqrt(Math.Pow((double) (tf6.X - point.X), 2) + Math.Pow((double) (tf6.Y - point.Y), 2)); single1 > 3f; single1 = (float) Math.Sqrt(Math.Pow((double) (tf6.X - point.X), 2) + Math.Pow((double) (tf6.Y - point.Y), 2)))
     {
         path1 = new GraphicsPath();
         path1.AddBezier(start, tfArray1[0], tfArray1[1], tfArray1[2]);
         if (path1.IsOutlineVisible(point, pen1))
         {
             t /= 2f;
         }
         else
         {
             t += (t / 2f);
         }
         tfArray1 = BezierOperation.SplitBeizierAtT(start, control1, control2, end, t);
         tf6 = tfArray1[2];
     }
     t = t;
     return tfArray1;
 }
Beispiel #19
0
		public void IsOutlineVisible_Line_WithGraphics ()
		{
			using (Bitmap bitmap = new Bitmap (20, 20)) {
				using (Graphics g = Graphics.FromImage (bitmap)) {
					g.Transform = new Matrix (2, 0, 0, 2, 50, -50);
					g.PageUnit = GraphicsUnit.Millimeter;
					g.PageScale = 2.0f;
					using (GraphicsPath gp = new GraphicsPath ()) {
						gp.AddLine (10, 1, 14, 1);
						Assert.IsFalse (gp.IsOutlineVisible (10, 1, Pens.Red, g), "Int1");
					}
				}
				// graphics ISN'T ignored (Transform+PageUnit+PageScale)
			}
		}
Beispiel #20
0
        public void OnMouseMove(MouseEventArgs e)
        {
            if (this.currentGraph != null)
            {
                if (e.Button == MouseButtons.None)
                {
                    this.preInfo = null;
                    this.addInfo = null;
                    this.moveinfo = null;
                    Pen pen1 = new Pen(Color.Black, 4f);
                    pen1.Alignment = PenAlignment.Center;
                    if (Control.ModifierKeys == (Keys.Control | Keys.Shift))
                    {
                        this.CurrentOperate = BezierOperate.CenterPoint;
                        this.incenter = false;
                        RectangleF ef1 = new RectangleF(this.mouseAreaControl.CenterPoint.X - 4f, this.mouseAreaControl.CenterPoint.Y - 4f, 8f, 8f);
                        PointF tf1 = new PointF((float) e.X, (float) e.Y);
                        if (ef1.Contains(tf1))
                        {
                            this.incenter = true;
                        }
                        return;
                    }
                    PointF tf2 = new PointF((float) e.X, (float) e.Y);
                    GraphicsPath path1 = new GraphicsPath();
                    PointInfoCollection.PointInfoEnumerator enumerator1 = this.currentGraph.PointsInfo.GetEnumerator();
                    while (enumerator1.MoveNext())
                    {
                        PointInfo info1 = enumerator1.Current;
                        GraphicsPath path2 = new GraphicsPath();
                        path2.AddRectangle(new RectangleF(info1.MiddlePoint.X - 3f, info1.MiddlePoint.Y - 3f, 6f, 6f));
                        path2.Transform(this.revertMatrix);
                        if (path2.IsVisible(tf2) || path2.IsOutlineVisible(tf2, pen1))
                        {
                            this.preInfo = info1;
                            PointInfoCollection collection1 = new PointInfoCollection();
                            if (this.SubpathList.ContainsKey(info1.SubPath))
                            {
                                collection1 = (PointInfoCollection) this.SubpathList[info1.SubPath];
                            }
                            if ((((Control.ModifierKeys & Keys.Control) == Keys.Control) && ((Control.ModifierKeys & Keys.Alt) != Keys.Alt)) || (this.mouseAreaControl.CurrentOperation == ToolOperation.ShapeTransform)
                                   || (this.mouseAreaControl.CurrentOperation == ToolOperation.Custom14) || (this.mouseAreaControl.CurrentOperation == ToolOperation.Custom15))
                            {
                                this.CurrentOperate = BezierOperate.MoveAnchor;
                                return;
                            }
                            if ((info1.IsStart && (info1.PreInfo == null)) && (info1.NextInfo != null))
                            {
                                this.CurrentOperate = BezierOperate.CloseFigure;
                                return;
                            }
                            if ((collection1.IndexOf(info1) == (collection1.Count - 1)) && !info1.IsEnd)
                            {
                                this.CurrentOperate = BezierOperate.ChangeEndAnchor;
                                this.preInfo = info1;
                                return;
                            }
                            if (((Control.ModifierKeys & Keys.Alt) == Keys.Alt) || (this.mouseAreaControl.CurrentOperation == ToolOperation.ConvertAnchor))
                            {
                                this.CurrentOperate = BezierOperate.ConvertAnchor;
                                return;
                            }
                            this.CurrentOperate = BezierOperate.DelAnchor;
                            return;
                        }
                        if (info1.NextInfo != null)
                        {
                            path1.Reset();
                            if (info1.NextInfo.FirstControl.IsEmpty)
                            {
                                path1.AddLine(info1.MiddlePoint, info1.NextInfo.MiddlePoint);
                            }
                            else
                            {
                                path1.AddBezier(info1.MiddlePoint, info1.NextInfo.FirstControl, info1.NextInfo.SecondControl, info1.NextInfo.MiddlePoint);
                            }
                            path1.Transform(this.revertMatrix);
                            if (path1.IsOutlineVisible(tf2, pen1))
                            {
                                if (((Control.ModifierKeys & Keys.Control) == Keys.Control) || (this.mouseAreaControl.CurrentOperation == ToolOperation.ShapeTransform) || (this.mouseAreaControl.CurrentOperation == ToolOperation.Custom11)
                                    || (this.mouseAreaControl.CurrentOperation == ToolOperation.Custom12) || (this.mouseAreaControl.CurrentOperation == ToolOperation.Custom13) || (this.mouseAreaControl.CurrentOperation == ToolOperation.Custom14) || (this.mouseAreaControl.CurrentOperation == ToolOperation.Custom15))
                                {
                                    this.CurrentOperate = BezierOperate.MovePath;
                                    return;
                                }
                                if (((Control.ModifierKeys & Keys.Alt) != Keys.Alt) && (this.mouseAreaControl.CurrentOperation != ToolOperation.ConvertAnchor))
                                {
                                    this.addInfo = info1;
                                    this.CurrentOperate = BezierOperate.AddAnchor;
                                }
                                return;
                            }
                        }
                    }
                    if ((this.currentInfo != null) && (((this.mouseAreaControl.CurrentOperation == ToolOperation.ShapeTransform) || (this.mouseAreaControl.CurrentOperation == ToolOperation.Custom11) || ((Control.ModifierKeys & Keys.Control) == Keys.Control)) || ((Control.ModifierKeys & Keys.Alt) == Keys.Alt))
                        || (this.mouseAreaControl.CurrentOperation == ToolOperation.Custom12) || (this.mouseAreaControl.CurrentOperation == ToolOperation.Custom13) || (this.mouseAreaControl.CurrentOperation == ToolOperation.Custom14) || (this.mouseAreaControl.CurrentOperation == ToolOperation.Custom15))
                    {
                        int num1 = this.currentGraph.PointsInfo.IndexOf(this.currentInfo);
                        if (!this.currentInfo.FirstControl.IsEmpty)
                        {
                            GraphicsPath path3 = new GraphicsPath();
                            path3.AddRectangle(new RectangleF(this.currentInfo.FirstControl.X - 3f, this.currentInfo.FirstControl.Y - 2f, 4f, 4f));
                            path3.Transform(this.revertMatrix);
                            if (path3.IsVisible(tf2) || path3.IsOutlineVisible(tf2, pen1))
                            {
                                this.moveinfo = this.currentInfo.PreInfo;
                                this.movePoint = this.currentInfo.FirstControl;
                                this.CurrentOperate = BezierOperate.MoveControl;
                                return;
                            }
                        }
                        GraphicsPath path4 = new GraphicsPath();
                        GraphicsPath path5 = new GraphicsPath();
                        path4.AddRectangle(new RectangleF(this.currentInfo.SecondControl.X - 2f, this.currentInfo.SecondControl.Y - 2f, 4f, 4f));
                        path5.AddRectangle(new RectangleF(this.currentInfo.NextControl.X - 2f, this.currentInfo.NextControl.Y - 2f, 4f, 4f));
                        path4.Transform(this.revertMatrix);
                        path5.Transform(this.revertMatrix);
                        if ((!this.currentInfo.SecondControl.IsEmpty && (path4.IsVisible(tf2) || path4.IsOutlineVisible(tf2, pen1))) || (!this.currentInfo.NextControl.IsEmpty && (path5.IsVisible(tf2) || path5.IsOutlineVisible(tf2, pen1))))
                        {
                            this.moveinfo = this.currentInfo;
                            this.movePoint = (!this.currentInfo.SecondControl.IsEmpty && (path4.IsVisible(tf2) || path4.IsOutlineVisible(tf2, pen1))) ? this.currentInfo.SecondControl : this.currentInfo.NextControl;
                            this.CurrentOperate = BezierOperate.MoveControl;
                            return;
                        }
                        if (this.currentInfo.NextInfo != null)
                        {
                            path4.Reset();
                            path4.AddRectangle(new RectangleF(this.currentInfo.NextInfo.SecondControl.X - 2f, this.currentInfo.NextInfo.SecondControl.Y - 2f, 4f, 4f));
                            path4.Transform(this.revertMatrix);
                            if (!this.currentInfo.NextInfo.SecondControl.IsEmpty && (path4.IsVisible(tf2) || path4.IsOutlineVisible(tf2, pen1)))
                            {
                                this.moveinfo = this.currentInfo.NextInfo;
                                this.movePoint = this.currentInfo.NextInfo.SecondControl;
                                this.CurrentOperate = BezierOperate.MoveControl;
                                return;
                            }
                        }
                    }
                    if (((Control.ModifierKeys & Keys.Alt) == Keys.Alt) || (this.mouseAreaControl.CurrentOperation == ToolOperation.ConvertAnchor))
                    {
                        this.CurrentOperate = BezierOperate.ConvertAnchor;
                    }
                    else
                    {
                        if (((Control.ModifierKeys & Keys.Control) == Keys.Control) || (this.mouseAreaControl.CurrentOperation == ToolOperation.ShapeTransform) || (this.mouseAreaControl.CurrentOperation == ToolOperation.Custom11)
                            || (this.mouseAreaControl.CurrentOperation == ToolOperation.Custom12) || (this.mouseAreaControl.CurrentOperation == ToolOperation.Custom13) || (this.mouseAreaControl.CurrentOperation == ToolOperation.Custom14) || (this.mouseAreaControl.CurrentOperation == ToolOperation.Custom15))
                        {
                            this.CurrentOperate = BezierOperate.MoveAnchor;
                            return;
                        }
                        this.CurrentOperate = BezierOperate.Draw;
                    }
                    return;
                }
                if (e.Button == MouseButtons.Left)
                {
                    this.mouseAreaControl.Cursor = SpecialCursors.DragCursor;
                    SizeF ef2 = this.mouseAreaControl.PicturePanel.GridSize;
                    PointF tf3 = this.mouseAreaControl.PicturePanel.PointToView(new PointF((float) e.X, (float) e.Y));
                    float single1 = ef2.Height;
                    float single2 = ef2.Width;
                    if (this.mouseAreaControl.PicturePanel.SnapToGrid)
                    {
                        int num2 = (int) ((tf3.X + (single2 / 2f)) / single2);
                        int num3 = (int) ((tf3.Y + (single1 / 2f)) / single1);
                        tf3 = new PointF((float) ((int) (num2 * single2)), (float) ((int) (num3 * single1)));
                    }
                    tf3 = this.mouseAreaControl.PicturePanel.PointToSystem(tf3);
                    tf3 = this.PointToView(tf3);
                    Matrix matrix1 = new Matrix();
                    matrix1.Translate(tf3.X - this.startPoint.X, tf3.Y - this.startPoint.Y);
                    this.win32.hdc = this.win32.W32GetDC(this.mouseAreaControl.Handle);
                    this.win32.W32SetROP2(6);
                    this.win32.W32PolyDraw(this.reversePath);
                    this.reversePath.Reset();
                    switch (this.currentOperate)
                    {
                        case BezierOperate.Draw:
                        {
                            PointF tf4 = this.PointToView(new PointF((float) e.X, (float) e.Y));
                            PointF tf5 = new PointF((2f * this.startPoint.X) - tf4.X, (2f * this.startPoint.Y) - tf4.Y);
                            if (this.currentInfo != null)
                            {
                                this.reversePath.AddBezier(this.currentInfo.MiddlePoint, this.currentinfo.NextControl, tf5, this.startPoint);
                                this.reversePath.Transform(this.revertMatrix);
                            }
                            PointF[] tfArray10 = new PointF[3] { this.startPoint, tf4, tf5 } ;
                            PointF[] tfArray1 = tfArray10;
                            this.revertMatrix.TransformPoints(tfArray1);
                            RectangleF[] efArray1 = new RectangleF[3] { new RectangleF(tfArray1[1].X - 2f, tfArray1[1].Y - 2f, 4f, 4f), new RectangleF(tfArray1[2].X - 2f, tfArray1[2].Y - 2f, 4f, 4f), new RectangleF(tfArray1[0].X - 2f, tfArray1[0].Y - 2f, 4f, 4f) } ;
                            this.reversePath.AddRectangles(efArray1);
                            this.reversePath.AddLine(tfArray1[1], tfArray1[2]);
                            this.win32.W32PolyDraw(this.reversePath);
                            this.win32.ReleaseDC();
                            return;
                        }
                        case BezierOperate.AddAnchor:
                        case BezierOperate.DelAnchor:
                        case BezierOperate.ChangeAnchor:
                        case BezierOperate.CloseFigure:
                        {
                            return;
                        }
                        case BezierOperate.MoveAnchor:
                        {
                            PointInfoCollection.PointInfoEnumerator enumerator2 = this.activePoints.GetEnumerator();
                            while (enumerator2.MoveNext())
                            {
                                PointInfo info2 = enumerator2.Current;
                                PointInfo info3 = info2.PreInfo;
                                PointInfo info4 = info2.NextInfo;
                                PointF tf6 = info2.MiddlePoint;
                                PointF tf7 = info2.NextControl;
                                tf7 = tf7.IsEmpty ? info2.MiddlePoint : tf7;
                                PointF[] tfArray11 = new PointF[3] { (info2.SecondControl.IsEmpty && (info3 != null)) ? info3.MiddlePoint : info2.SecondControl, info2.MiddlePoint, tf7 } ;
                                PointF[] tfArray2 = tfArray11;
                                matrix1.TransformPoints(tfArray2);
                                this.reversePath.StartFigure();
                                if (info3 != null)
                                {
                                    PointF tf8 = info3.MiddlePoint;
                                    PointF tf9 = info2.FirstControl;
                                    if ((info2.IsStart && info3.IsEnd) && ((info3.MiddlePoint == info2.MiddlePoint) && (info3.PreInfo != null)))
                                    {
                                        tf8 = info3.PreInfo.MiddlePoint;
                                        tf9 = info3.FirstControl;
                                    }
                                    tf9 = tf9.IsEmpty ? tf8 : tf9;
                                    if (this.activePoints.Contains(info3))
                                    {
                                        PointF[] tfArray12 = new PointF[2] { tf8, tf9 } ;
                                        PointF[] tfArray3 = tfArray12;
                                        matrix1.TransformPoints(tfArray3);
                                        tf8 = tfArray3[0];
                                        tf9 = tfArray3[1];
                                    }
                                    if (tf8 != tfArray2[1])
                                    {
                                        if (info3.FirstControl.IsEmpty && info2.FirstControl.IsEmpty)
                                        {
                                            this.reversePath.AddLine(tf8, tfArray2[1]);
                                        }
                                        else
                                        {
                                            this.reversePath.AddBezier(tf8, tf9, tfArray2[0], tfArray2[1]);
                                        }
                                    }
                                }
                                this.reversePath.StartFigure();
                                if ((info4 != null) && !this.activePoints.Contains(info4))
                                {
                                    PointF tf10 = info4.SecondControl;
                                    tf10 = tf10.IsEmpty ? info4.MiddlePoint : tf10;
                                    if (info2.FirstControl.IsEmpty && info4.FirstControl.IsEmpty)
                                    {
                                        this.reversePath.AddLine(tfArray2[2], info4.MiddlePoint);
                                    }
                                    else
                                    {
                                        this.reversePath.AddBezier(tfArray2[1], tfArray2[2], tf10, info4.MiddlePoint);
                                    }
                                }
                            }
                            this.reversePath.Transform(this.revertMatrix);
                            if (this.currentInfo != null)
                            {
                                if (this.activePoints.Count == 1)
                                {
                                    PointF[] tfArray13 = new PointF[3] { this.currentInfo.SecondControl, this.currentInfo.MiddlePoint, this.currentInfo.NextControl } ;
                                    PointF[] tfArray4 = tfArray13;
                                    matrix1.TransformPoints(tfArray4);
                                    this.revertMatrix.TransformPoints(tfArray4);
                                    RectangleF[] efArray2 = new RectangleF[1] { new RectangleF(tfArray4[1].X - 2f, tfArray4[1].Y - 2f, 4f, 4f) } ;
                                    this.reversePath.AddRectangles(efArray2);
                                    if (!this.currentInfo.SecondControl.IsEmpty)
                                    {
                                        this.reversePath.AddRectangle(new RectangleF(tfArray4[0].X - 2f, tfArray4[0].Y - 2f, 4f, 4f));
                                        this.reversePath.AddLine(tfArray4[0], tfArray4[1]);
                                    }
                                    if (!this.currentInfo.NextControl.IsEmpty)
                                    {
                                        this.reversePath.AddRectangle(new RectangleF(tfArray4[2].X - 2f, tfArray4[2].Y - 2f, 4f, 4f));
                                        this.reversePath.AddLine(tfArray4[1], tfArray4[2]);
                                    }
                                }
                            }
                            else
                            {
                                int num4 = (int) Math.Min(this.startPoint.X, tf3.X);
                                int num5 = (int) Math.Min(this.startPoint.Y, tf3.Y);
                                int num6 = (int) Math.Max(this.startPoint.X, tf3.X);
                                int num7 = (int) Math.Max(this.startPoint.Y, tf3.Y);
                                this.reversePath.AddRectangle(new RectangleF((float) num4, (float) num5, (float) (num6 - num4), (float) (num7 - num5)));
                                this.reversePath.Transform(this.revertMatrix);
                            }
                            this.win32.W32PolyDraw(this.reversePath);
                            this.win32.ReleaseDC();
                            return;
                        }
                        case BezierOperate.ConvertAnchor:
                        {
                            if (this.currentInfo != null)
                            {
                                PointF[] tfArray18 = new PointF[2] { tf3, this.currentInfo.MiddlePoint } ;
                                PointF[] tfArray6 = tfArray18;
                                this.revertMatrix.TransformPoints(tfArray6);
                                PointF tf13 = tfArray6[0];
                                PointF tf14 = tfArray6[1];
                                if (this.currentInfo.NextInfo != null)
                                {
                                    this.reversePath.AddBezier(this.currentInfo.MiddlePoint, tf3, this.currentInfo.NextInfo.SecondControl.IsEmpty ? this.currentInfo.NextInfo.MiddlePoint : this.currentInfo.NextInfo.SecondControl, this.currentInfo.NextInfo.MiddlePoint);
                                }
                                if (this.currentInfo.PreInfo != null)
                                {
                                    this.reversePath.StartFigure();
                                    tf3 = new PointF((2f * this.currentInfo.MiddlePoint.X) - tf3.X, (2f * this.currentInfo.MiddlePoint.Y) - tf3.Y);
                                    PointInfo info5 = this.currentinfo.PreInfo;
                                    PointInfo info6 = this.currentinfo;
                                    if ((this.currentinfo.IsStart && info5.IsEnd) && (info5.MiddlePoint == this.currentinfo.MiddlePoint))
                                    {
                                        info6 = info5;
                                        info5 = info5.PreInfo;
                                    }
                                    if (info5 != null)
                                    {
                                        PointF tf15 = info6.FirstControl.IsEmpty ? info5.MiddlePoint : info6.FirstControl;
                                        this.reversePath.AddBezier(info5.MiddlePoint, tf15, tf3, info6.MiddlePoint);
                                    }
                                }
                                this.reversePath.Transform(this.revertMatrix);
                                this.reversePath.StartFigure();
                                RectangleF[] efArray5 = new RectangleF[1] { new RectangleF(tf14.X - 2f, tf14.Y - 2f, 4f, 4f) } ;
                                this.reversePath.AddRectangles(efArray5);
                                if (((Math.Abs((float) (tf13.X - tf3.X)) >= 1f) || (Math.Abs((float) (tf13.Y - tf3.Y)) >= 1f)) && (this.currentInfo.NextInfo != null))
                                {
                                    PointF tf16 = new PointF((2f * tf14.X) - tf13.X, (2f * tf14.Y) - tf13.Y);
                                    RectangleF[] efArray6 = new RectangleF[2] { new RectangleF(tf13.X - 2f, tf13.Y - 2f, 4f, 4f), new RectangleF(tf16.X - 2f, tf16.Y - 2f, 4f, 4f) } ;
                                    this.reversePath.AddRectangles(efArray6);
                                    this.reversePath.AddLine(tf16, tf14);
                                }
                                this.reversePath.AddLine(tf14, tf13);
                            }
                            this.win32.W32PolyDraw(this.reversePath);
                            this.win32.ReleaseDC();
                            return;
                        }
                        case BezierOperate.ChangeEndAnchor:
                        {
                            if (this.preInfo == null)
                            {
                                return;
                            }
                            PointF tf17 = new PointF((2f * this.preInfo.MiddlePoint.X) - tf3.X, (2f * this.preInfo.MiddlePoint.Y) - tf3.Y);
                            if ((((Control.ModifierKeys & Keys.Alt) != Keys.Alt) && !this.preInfo.FirstControl.IsEmpty) && (this.preInfo.MiddlePoint != this.preInfo.SecondControl))
                            {
                                this.reversePath.AddBezier(this.preInfo.PreInfo.MiddlePoint, this.preInfo.FirstControl, tf3, this.preInfo.MiddlePoint);
                                this.reversePath.Transform(this.revertMatrix);
                                PointF[] tfArray21 = new PointF[3] { tf3, this.preInfo.MiddlePoint, tf17 } ;
                                PointF[] tfArray9 = tfArray21;
                                this.revertMatrix.TransformPoints(tfArray9);
                                RectangleF[] efArray7 = new RectangleF[3] { new RectangleF(tfArray9[0].X - 2f, tfArray9[0].Y - 2f, 4f, 4f), new RectangleF(tfArray9[1].X - 2f, tfArray9[1].Y - 2f, 4f, 4f), new RectangleF(tfArray9[2].X - 2f, tfArray9[2].Y - 2f, 4f, 4f) } ;
                                this.reversePath.AddRectangles(efArray7);
                                this.reversePath.AddLine(tfArray9[0], tfArray9[2]);
                                goto Label_2164;
                            }
                            PointF[] tfArray20 = new PointF[2] { this.preInfo.MiddlePoint, tf3 } ;
                            PointF[] tfArray8 = tfArray20;
                            this.revertMatrix.TransformPoints(tfArray8);
                            this.reversePath.AddLine(tfArray8[0], tfArray8[1]);
                            goto Label_2164;
                        }
                        case BezierOperate.MoveControl:
                        {
                            if (this.moveinfo != null)
                            {
                                PointF[] tfArray14 = new PointF[2] { this.moveinfo.MiddlePoint, tf3 } ;
                                PointF[] tfArray5 = tfArray14;
                                this.revertMatrix.TransformPoints(tfArray5);
                                PointF tf11 = tfArray5[0];
                                PointF tf12 = tfArray5[1];
                                if (this.movePoint == this.moveinfo.SecondControl)
                                {
                                    if (this.moveinfo.PreInfo != null)
                                    {
                                        if (this.moveinfo.IsStart && this.moveinfo.PreInfo.IsEnd)
                                        {
                                            if (this.moveinfo.PreInfo.PreInfo != null)
                                            {
                                                this.reversePath.AddBezier(this.moveinfo.PreInfo.PreInfo.MiddlePoint, this.moveinfo.PreInfo.FirstControl, tf3, this.moveinfo.PreInfo.MiddlePoint);

                                            }
                                        }
                                        else
                                        {
                                            if (this.moveinfo.Command=="A")
                                            {
                                                float ry=matrix1.OffsetY+this.moveinfo.Ry;
                                                ry=ry>5?ry:this.moveinfo.Ry;

                                                ExtendedGraphicsPath expath1 = new ExtendedGraphicsPath(this.reversePath);

                                                expath1.AddArc(this.moveinfo.PreInfo.MiddlePoint,this.moveinfo.MiddlePoint,this.moveinfo.Rx,ry,this.moveinfo.LargeArcFlage==1,this.moveinfo.SweepFlage==1,this.moveinfo.Angle);
                                            }
                                            else
                                            {
                                                this.reversePath.AddBezier(this.moveinfo.PreInfo.MiddlePoint, this.moveinfo.FirstControl, tf3, this.moveinfo.MiddlePoint);
                                            }
                                        }
                                    }
                                    float single3 = tf12.X;
                                    float single4 = tf12.Y;
                                    bool flag1 = false;
                                    if (((this.moveinfo.NextInfo != null) && ((Control.ModifierKeys & Keys.Alt) != Keys.Alt)) && !this.moveinfo.Steep)
                                    {
                                        if (!this.moveinfo.NextInfo.FirstControl.IsEmpty)
                                        {
                                            float single5 = (float) Math.Sqrt(Math.Pow((double) (this.moveinfo.SecondControl.X - this.moveinfo.MiddlePoint.X), 2) + Math.Pow((double) (this.moveinfo.SecondControl.Y - this.moveinfo.MiddlePoint.Y), 2));
                                            float single6 = (float) Math.Sqrt(Math.Pow((double) (tf3.X - this.moveinfo.MiddlePoint.X), 2) + Math.Pow((double) (tf3.Y - this.moveinfo.MiddlePoint.Y), 2));
                                            if (single5 == 0f)
                                            {
                                                single5 += 0.0001f;
                                            }
                                            float single7 = single6 / single5;
                                            single3 = this.moveinfo.MiddlePoint.X + (single7 * (this.moveinfo.MiddlePoint.X - tf3.X));
                                            single4 = this.moveinfo.MiddlePoint.Y + (single7 * (this.moveinfo.MiddlePoint.Y - tf3.Y));
                                            this.reversePath.AddBezier(this.moveinfo.MiddlePoint, new PointF(single3, single4), this.moveinfo.NextInfo.SecondControl, this.moveinfo.NextInfo.MiddlePoint);
                                            PointF[] tfArray15 = new PointF[1] { new PointF(single3, single4) } ;
                                            tfArray5 = tfArray15;
                                            this.revertMatrix.TransformPoints(tfArray5);
                                            single3 = tfArray5[0].X;
                                            single4 = tfArray5[0].Y;
                                        }
                                        flag1 = this.activePoints.Contains(this.moveinfo.NextInfo);
                                    }
                                    this.reversePath.Transform(this.revertMatrix);
                                    this.reversePath.StartFigure();
                                    RectangleF[] efArray3 = new RectangleF[2] { new RectangleF(tf11.X - 2f, tf11.Y - 2f, 4f, 4f), new RectangleF(tf12.X - 2f, tf12.Y - 2f, 4f, 4f) } ;
                                    this.reversePath.AddRectangles(efArray3);
                                    if ((Math.Abs((float) (single3 - tf12.X)) >= 1f) || (Math.Abs((float) (single4 - tf12.Y)) >= 1f))
                                    {
                                        this.reversePath.AddRectangle(new RectangleF(single3 - 2f, single4 - 2f, 4f, 4f));
                                        this.reversePath.AddLine(new PointF(single3, single4), tf11);
                                    }
                                    this.reversePath.AddLine(tf11, tf12);
                                }
                                else if (this.movePoint == this.moveinfo.NextControl)
                                {
                                    if (this.moveinfo.Command=="A")
                                    {
                                        float rx=matrix1.OffsetX+this.moveinfo.Rx;
                                        rx=rx>5?rx:this.moveinfo.Rx;

                                        ExtendedGraphicsPath expath1 = new ExtendedGraphicsPath(this.reversePath);

                                        expath1.AddArc(this.moveinfo.PreInfo.MiddlePoint,this.moveinfo.MiddlePoint,rx,this.moveinfo.Ry,this.moveinfo.LargeArcFlage==1,this.moveinfo.SweepFlage==1,this.moveinfo.Angle);
                                    }
                                    else
                                    {
                                        if (this.moveinfo.NextInfo != null)
                                        {
                                            this.reversePath.AddBezier(this.moveinfo.MiddlePoint, tf3, this.moveinfo.NextInfo.SecondControl, this.moveinfo.NextInfo.MiddlePoint);
                                        }
                                    }
                                    float single8 = tf12.X;
                                    float single9 = tf12.Y;
                                    bool flag2 = true;
                                    if (((this.moveinfo.PreInfo != null) && ((Control.ModifierKeys & Keys.Alt) != Keys.Alt)) && !this.moveinfo.Steep)
                                    {
                                        if ((this.moveinfo.IsStart && this.moveinfo.PreInfo.IsEnd) && (this.moveinfo.PreInfo.PreInfo != null))
                                        {
                                            float single10 = (float) Math.Sqrt(Math.Pow((double) (this.moveinfo.NextControl.X - this.moveinfo.MiddlePoint.X), 2) + Math.Pow((double) (this.moveinfo.NextControl.Y - this.moveinfo.MiddlePoint.Y), 2));
                                            float single11 = (float) Math.Sqrt(Math.Pow((double) (tf3.X - this.moveinfo.MiddlePoint.X), 2) + Math.Pow((double) (tf3.Y - this.moveinfo.MiddlePoint.Y), 2));
                                            if (single10 == 0f)
                                            {
                                                single10 += 0.0001f;
                                            }
                                            float single12 = single11 / single10;
                                            single8 = this.moveinfo.MiddlePoint.X + (single12 * (this.moveinfo.MiddlePoint.X - tf3.X));
                                            single9 = this.moveinfo.MiddlePoint.Y + (single12 * (this.moveinfo.MiddlePoint.Y - tf3.Y));
                                            this.reversePath.StartFigure();
                                            this.reversePath.AddBezier(this.moveinfo.PreInfo.PreInfo.MiddlePoint, this.moveinfo.PreInfo.FirstControl, new PointF(single8, single9), this.moveinfo.MiddlePoint);
                                            PointF[] tfArray16 = new PointF[1] { new PointF(single8, single9) } ;
                                            tfArray5 = tfArray16;
                                            this.revertMatrix.TransformPoints(tfArray5);
                                            single8 = tfArray5[0].X;
                                            single9 = tfArray5[0].Y;
                                        }
                                        else if (!this.moveinfo.SecondControl.IsEmpty)
                                        {
                                            float single13 = (float) Math.Sqrt(Math.Pow((double) (this.moveinfo.NextControl.X - this.moveinfo.MiddlePoint.X), 2) + Math.Pow((double) (this.moveinfo.NextControl.Y - this.moveinfo.MiddlePoint.Y), 2));
                                            float single14 = (float) Math.Sqrt(Math.Pow((double) (tf3.X - this.moveinfo.MiddlePoint.X), 2) + Math.Pow((double) (tf3.Y - this.moveinfo.MiddlePoint.Y), 2));
                                            if (single13 == 0f)
                                            {
                                                single13 += 0.0001f;
                                            }
                                            float single15 = single14 / single13;
                                            single8 = this.moveinfo.MiddlePoint.X + (single15 * (this.moveinfo.MiddlePoint.X - tf3.X));
                                            single9 = this.moveinfo.MiddlePoint.Y + (single15 * (this.moveinfo.MiddlePoint.Y - tf3.Y));
                                            this.reversePath.StartFigure();
                                            this.reversePath.AddBezier(this.moveinfo.PreInfo.MiddlePoint, this.moveinfo.FirstControl, new PointF(single8, single9), this.moveinfo.MiddlePoint);
                                            PointF[] tfArray17 = new PointF[1] { new PointF(single8, single9) } ;
                                            tfArray5 = tfArray17;
                                            this.revertMatrix.TransformPoints(tfArray5);
                                            single8 = tfArray5[0].X;
                                            single9 = tfArray5[0].Y;
                                        }
                                        flag2 = this.activePoints.Contains(this.moveinfo.PreInfo);
                                    }
                                    this.reversePath.Transform(this.revertMatrix);
                                    this.reversePath.StartFigure();
                                    RectangleF[] efArray4 = new RectangleF[2] { new RectangleF(tf11.X - 2f, tf11.Y - 2f, 4f, 4f), new RectangleF(tf12.X - 2f, tf12.Y - 2f, 4f, 4f) } ;
                                    this.reversePath.AddRectangles(efArray4);
                                    if ((Math.Abs((float) (single8 - tf12.X)) >= 1f) || (Math.Abs((float) (single9 - tf12.Y)) >= 1f))
                                    {
                                        this.reversePath.AddRectangle(new RectangleF(single8 - 2f, single9 - 2f, 4f, 4f));
                                        this.reversePath.AddLine(new PointF(single8, single9), tf11);
                                    }
                                    this.reversePath.AddLine(tf11, tf12);
                                }
                                this.win32.W32PolyDraw(this.reversePath);
                                this.win32.ReleaseDC();
                            }
                            return;
                        }
                        case BezierOperate.MovePath:
                        {
                            this.reversePath = (GraphicsPath) this.currentGraph.GPath.Clone();
                            this.reversePath.Transform(matrix1);
                            this.reversePath.Transform(this.revertMatrix);
                            this.win32.W32PolyDraw(this.reversePath);
                            this.win32.ReleaseDC();
                            return;
                        }
                        case BezierOperate.CenterPoint:
                        {
                            PointF[] tfArray19 = new PointF[1] { tf3 } ;
                            PointF[] tfArray7 = tfArray19;
                            this.revertMatrix.TransformPoints(tfArray7);
                            this.reversePath.AddEllipse((float) (tfArray7[0].X - 4f), (float) (tfArray7[0].Y - 4f), (float) 8f, (float) 8f);
                            this.win32.W32PolyDraw(this.reversePath);
                            this.win32.ReleaseDC();
                            return;
                        }
                    }
                }
            }
            return;
            Label_2164:
            this.win32.W32PolyDraw(this.reversePath);
            this.win32.ReleaseDC();
        }
Beispiel #21
0
		private void IsOutlineVisible_Rectangle (Graphics graphics)
		{
			Pen p2 = new Pen (Color.Red, 3.0f);
			using (GraphicsPath gp = new GraphicsPath ()) {
				gp.AddRectangle (new Rectangle (10, 10, 20, 20));
				Assert.IsTrue (gp.IsOutlineVisible (10, 10, Pens.Red, graphics), "Int1");
				Assert.IsTrue (gp.IsOutlineVisible (10, 11, p2, graphics), "Int2");
				Assert.IsFalse (gp.IsOutlineVisible (11, 11, Pens.Red, graphics), "Int3");

				Assert.IsTrue (gp.IsOutlineVisible (11.0f, 10.0f, Pens.Red, graphics), "Float1");
				Assert.IsTrue (gp.IsOutlineVisible (11.0f, 11.0f, p2, graphics), "Float2");
				Assert.IsFalse (gp.IsOutlineVisible (11.0f, 11.0f, Pens.Red, graphics), "Float3");

				Point pt = new Point (15, 10);
				Assert.IsTrue (gp.IsOutlineVisible (pt, Pens.Red, graphics), "Point1");
				Assert.IsTrue (gp.IsOutlineVisible (pt, p2, graphics), "Point2");
				pt.Y = 15;
				Assert.IsFalse (gp.IsOutlineVisible (pt, Pens.Red, graphics), "Point3");

				PointF pf = new PointF (29.0f, 29.0f);
				Assert.IsFalse (gp.IsOutlineVisible (pf, Pens.Red, graphics), "PointF1");
				Assert.IsTrue (gp.IsOutlineVisible (pf, p2, graphics), "PointF2");
				pf.Y = 31.0f;
				Assert.IsTrue (gp.IsOutlineVisible (pf, p2, graphics), "PointF3");
			}
			p2.Dispose ();
		}
Beispiel #22
0
 private bool RemoveLine(Point p1, Point p2, Point p, int width)
 {
     bool isOnLine = false;
     using (GraphicsPath path = new GraphicsPath())
     {
         using (Pen pen = new Pen(Brushes.Black, width))
         {
             path.AddLine(p1, p2);
             isOnLine = path.IsOutlineVisible(p, pen);
         }
     }
     return isOnLine;
 }
 public override bool ClickableAt(int x, int y)
 {
     int lineThickness = GetFieldValueAsInt(FieldType.LINE_THICKNESS) + 10;
     if (lineThickness > 0) {
         using (Pen pen = new Pen(Color.White)) {
             pen.Width = lineThickness;
             SetArrowHeads((ArrowHeadCombination)GetFieldValue(FieldType.ARROWHEADS), pen);
             using (GraphicsPath path = new GraphicsPath()) {
                 path.AddLine(this.Left, this.Top, this.Left + this.Width, this.Top + this.Height);
                 return path.IsOutlineVisible(x, y, pen);
             }
         }
     } else {
         return false;
     }
 }
Beispiel #24
0
        /// <summary>
        /// Add the Disputed International Boundaries Layers into Layer Collection. (Only those layers will be added which have common or intersected boundaries with existing layers.)
        /// </summary>
        /// <param name="dIBFolderPath"></param>
        public void AddDisputedInternationalBoundaries(string dIBFolderPath)
        {
            Shape _Shape;
            GraphicsPath gp = new GraphicsPath();
            IDictionaryEnumerator dicEnumerator;
            Pen CheckPen = new Pen(Brushes.Black);
            Dictionary<string, ShapeInfo> DIBLayersToAdd = new Dictionary<string, ShapeInfo>();

            try
            {
                //- Extract DIB Shape Files form Resources into Specified Folder.
                this.ExtractDIBShapes(dIBFolderPath);

                //- Add DIB layers.
                if (string.IsNullOrEmpty(dIBFolderPath) == false && Directory.Exists(dIBFolderPath))
                {
                    foreach (string dibFilePath in Directory.GetFiles(dIBFolderPath, "*.shp"))
                    {
                        //- Load this layer & get its extent.
                        ShapeInfo DIbLayerInfo = ShapeFileReader.GetShapeInfo(dIBFolderPath, Path.GetFileNameWithoutExtension(dibFilePath));

                        if (DIbLayerInfo != null)
                        {
                            //- Check if this layer Coordinates coincides with any of the polygons of existing base Layers.
                            foreach (Layer Lyr in this.m_Layers)
                            {
                                if (Lyr.Extent.Contains(DIbLayerInfo.Extent) || Lyr.Extent.IntersectsWith(DIbLayerInfo.Extent))
                                {
                                    dicEnumerator = Lyr.GetRecords(Lyr.LayerPath + "\\" + Lyr.ID).GetEnumerator();

                                    while (dicEnumerator.MoveNext())
                                    {
                                        //Traverse Shapes
                                        _Shape = (Shape)dicEnumerator.Value;
                                        gp.Reset();
                                        for (int i = 0; i <= _Shape.Parts.Count - 1; i++)
                                        {
                                            gp.AddPolygon((PointF[])_Shape.Parts[i]);
                                        }

                                        //gp.CloseAllFigures();

                                        //- Check if any point of DIB Layer's Shape coincides with graphics Path of existing Polygons or not.
                                        foreach (Shape dibShape in DIbLayerInfo.Records.Values)
                                        {
                                            foreach (PointF[] DIBPoints in dibShape.Parts)
                                            {
                                                if (gp.IsOutlineVisible(DIBPoints[0], CheckPen) || gp.IsOutlineVisible(DIBPoints[DIBPoints.Length - 1], CheckPen)
                                                    || gp.IsOutlineVisible(DIBPoints[(int)(DIBPoints.Length / 2)], CheckPen))
                                                {
                                                    //- Add Into Collection
                                                    DIBLayersToAdd.Add(dibFilePath, DIbLayerInfo);
                                                    break;
                                                }

                                                if (DIBLayersToAdd.ContainsKey(dibFilePath))
                                                {
                                                    break;
                                                }
                                            }
                                            if (DIBLayersToAdd.ContainsKey(dibFilePath))
                                            {
                                                break;
                                            }
                                        }

                                        if (DIBLayersToAdd.ContainsKey(dibFilePath))
                                        {
                                            break;
                                        }

                                    }

                                    if (DIBLayersToAdd.ContainsKey(dibFilePath))
                                    {
                                        break;
                                    }
                                }
                            }
                        }

                    }

                    //- Now Add DIBLayers which were found to be intersected with current polygons layers.
                    //- First Add polygon Layers
                    foreach (KeyValuePair<string, ShapeInfo> dibLayerEntry in DIBLayersToAdd)
                    {
                        switch (dibLayerEntry.Value.ShapeType)
                        {
                            case ShapeType.PolygonFeature:
                            case ShapeType.Polygon:
                            case ShapeType.PolygonCustom:
                            case ShapeType.PolygonBuffer:
                                Layer lyr = this.m_Layers.AddShapeFile(dIBFolderPath, Path.GetFileNameWithoutExtension(dibLayerEntry.Key));
                                lyr.IsDIB = true;

                                break;
                        }
                    }

                    //- Now Add polyline, Point Layers
                    foreach (KeyValuePair<string, ShapeInfo> dibLayerEntry in DIBLayersToAdd)
                    {
                        switch (dibLayerEntry.Value.ShapeType)
                        {
                            case ShapeType.PointFeature:
                            case ShapeType.Point:
                            case ShapeType.PointCustom:
                            case ShapeType.PolyLineCustom:
                            case ShapeType.PolyLineFeature:
                            case ShapeType.PolyLine:
                                Layer lyr = this.m_Layers.AddShapeFile(dIBFolderPath, Path.GetFileNameWithoutExtension(dibLayerEntry.Key));
                                lyr.IsDIB = true;
                                break;
                        }
                    }

                    //- Apply DIB Layers Settings
                    this.ApplyDIBSettings(Path.Combine(dIBFolderPath, DIBSettings.DIBSettingFileName));
                }
            }
            catch
            {

            }
            finally
            {
                CheckPen.Dispose();
                gp.Dispose();
            }
        }
Beispiel #25
0
        public static bool EllipseClickableAt(Rectangle rect, int lineThickness, Color fillColor, int x, int y)
        {
            // If we clicked inside the rectangle and it's visible we are clickable at.
            if (!Color.Transparent.Equals(fillColor))
            {
                if (rect.Contains(x, y))
                {
                    return true;
                }
            }

            // check the rest of the lines
            if (lineThickness > 0)
            {
                using (Pen pen = new Pen(Color.White, lineThickness))
                {
                    using (GraphicsPath path = new GraphicsPath())
                    {
                        path.AddEllipse(rect);
                        return path.IsOutlineVisible(x, y, pen);
                    }
                }
            }
            return false;
        }
        public void IsOutlineVisible1(Graphics g)
        {
            GraphicsPath myPath = new GraphicsPath();
            Rectangle rect = new Rectangle(20, 20, 100, 100);
            myPath.AddRectangle(rect);
            Pen testPen = new Pen(Color.AliceBlue, 20);
            var widePath = (GraphicsPath)myPath.Clone();
            widePath.Widen(testPen);
            g.FillPath(Brushes.Wheat, widePath);
            g.DrawPath(Pens.Black, myPath);

            var point = new PointF(100, 50);

            bool visible = myPath.IsOutlineVisible(point, testPen, g);
            g.FillRectangle(Brushes.Red, new RectangleF(point.X, point.Y, 2, 2));
            // Show the result.
            g.DrawString("Visible = " + visible, new Font("Arial", 12), Brushes.Red, point.X + 10, point.Y);

            point.X = 115;
            point.Y = 80;

            visible = myPath.IsOutlineVisible(point, testPen, g);
            g.FillRectangle(Brushes.Green, new RectangleF(point.X, point.Y, 2, 2));
            // Show the result.
            g.DrawString("Visible = " + visible, new Font("Arial", 12), Brushes.Green, point.X + 10, point.Y);
        }
Beispiel #27
0
		internal static bool HitTest(
			PointF point, 
			RectangleF boundingBox, 
			float startAngle,
			float sweepAngle,
			SpatialTransform transform)
		{
			GraphicsPath path = new GraphicsPath();
			path.AddArc(RectangleUtilities.ConvertToPositiveRectangle(boundingBox), startAngle, sweepAngle);

			Pen pen = new Pen(Brushes.White, HitTestDistance / transform.CumulativeScale);
			bool result = path.IsOutlineVisible(point, pen);

			path.Dispose();
			pen.Dispose();

			return result;
		}
Beispiel #28
0
        /// <summary>
        /// Determine if the specified screen point lies inside the bounding box of this
        /// <see cref="ArrowItem"/>.
        /// </summary>
        /// <remarks>The bounding box is calculated assuming a distance
        /// of <see cref="GraphPane.Default.NearestTol"/> pixels around the arrow segment.
        /// </remarks>
        /// <param name="pt">The screen point, in pixels</param>
        /// <param name="pane">
        /// A reference to the <see cref="GraphPane"/> object that is the parent or
        /// owner of this object.
        /// </param>
        /// <param name="g">
        /// A graphic device object to be drawn into.  This is normally e.Graphics from the
        /// PaintEventArgs argument to the Paint() method.
        /// </param>
        /// <param name="scaleFactor">
        /// The scaling factor to be used for rendering objects.  This is calculated and
        /// passed down by the parent <see cref="GraphPane"/> object using the
        /// <see cref="GraphPane.CalcScaleFactor"/> method, and is used to proportionally adjust
        /// font sizes, etc. according to the actual size of the graph.
        /// </param>
        /// <returns>true if the point lies in the bounding box, false otherwise</returns>
        public override bool PointInBox( PointF pt, GraphPane pane, Graphics g, double scaleFactor )
        {
            // transform the x,y location from the user-defined
            // coordinate frame to the screen pixel location
            PointF pix = this.location.TransformTopLeft( pane );
            PointF pix2 = this.location.TransformBottomRight( pane );

            Pen pen = new Pen( Color.Black, (float) GraphPane.Default.NearestTol * 2.0F );
            GraphicsPath path = new GraphicsPath();
            path.AddLine( pix, pix2 );
            return path.IsOutlineVisible( pt, pen );
        }