当前位置: 首页>>代码示例>>C#>>正文


C# GraphicsPath.IsVisible方法代码示例

本文整理汇总了C#中System.Drawing.Drawing2D.GraphicsPath.IsVisible方法的典型用法代码示例。如果您正苦于以下问题:C# GraphicsPath.IsVisible方法的具体用法?C# GraphicsPath.IsVisible怎么用?C# GraphicsPath.IsVisible使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Drawing.Drawing2D.GraphicsPath的用法示例。


在下文中一共展示了GraphicsPath.IsVisible方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ContainsInShape

 //檢查座標x,y是否在圖形內
 public override bool ContainsInShape(int x, int y)
 {
     GraphicsPath path = new GraphicsPath();
     path.FillMode = FillMode.Winding;
     path.AddRectangle(new Rectangle(_locationOfTopPoint, new Size(Wideth, Height)));
     return path.IsVisible(x, y);
 }
开发者ID:ko255128,项目名称:basicPainter,代码行数:8,代码来源:Rectangles.cs

示例2: Contains

 //是否圖形包含的座標
 public override bool Contains(Point point)
 {
     GraphicsPath path = new GraphicsPath();
     path.FillMode = FillMode.Winding;
     path.AddRectangle(new System.Drawing.Rectangle(TopLeft.X, TopLeft.Y, AbsoluteSize.X, AbsoluteSize.Y));
     return path.IsVisible(point.X, point.Y);
 }
开发者ID:lohas1107,项目名称:painter,代码行数:8,代码来源:Rectangle.cs

示例3: ContainsInShape

 //檢查是否與圖案有交集
 public override bool ContainsInShape(int x, int y)
 {
     GraphicsPath path = new GraphicsPath();
     path.FillMode = FillMode.Winding;
     path.AddEllipse(new Rectangle(_locationOfTopPoint.X + _moveingXOffset, _locationOfTopPoint.Y + _moveingYOffset, Wideth, Height));
     return path.IsVisible(x, y);
 }
开发者ID:ko255128,项目名称:basicPainter,代码行数:8,代码来源:Ellipse.cs

示例4: ContainsInShape

 //檢查座標是否圖形內
 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);
 }
开发者ID:ko255128,项目名称:basicPainter,代码行数:9,代码来源:Line.cs

示例5: Clic

        public override bool Clic(Point p, Matrix matrix)
        {
            GraphicsPath g = new GraphicsPath();

            g.AddEllipse(new Rectangle(this.Position.X , this.Position.Y , Rayon * 2, Rayon * 2));

            return g.IsVisible(p);
        }
开发者ID:nadar71,项目名称:Krea,代码行数:8,代码来源:Cercle.cs

示例6: ContainsPoint

        public new bool ContainsPoint(float X, float Y)
        {
            GraphicsPath Path = new GraphicsPath();
            Path.StartFigure();
            if (TypeShape == Nows.Ellip)
                Path.AddEllipse(Rectan);
            else
                Path.AddPie(Rectan.X, Rectan.Y, Rectan.Width, Rectan.Height, startAngle, sweepAngle);
            Path.CloseFigure();

            return Path.IsVisible(X, Y);
        }
开发者ID:EvgenyKarataev,项目名称:GraphicEditor,代码行数:12,代码来源:Pie.cs

示例7: HitTest

		public override bool HitTest(System.Drawing.Point p)
		{
			GraphicsPath gp = new GraphicsPath();
			Matrix mtx = new Matrix();

			gp.AddEllipse(new Rectangle(el.Location.X,
				el.Location.Y,
				el.Size.Width,
				el.Size.Height));
			gp.Transform(mtx);

			return gp.IsVisible(p);
		}
开发者ID:AlexandrSurkov,项目名称:PKStudio,代码行数:13,代码来源:ElipseController.cs

示例8: HitTest

		public virtual bool HitTest(Point p)
		{
			GraphicsPath gp = new GraphicsPath();
			Matrix mtx = new Matrix();

			Point elLocation = el.Location;
			Size elSize = el.Size;
			gp.AddRectangle(new Rectangle(elLocation.X,
				elLocation.Y,
				elSize.Width,
				elSize.Height));
			gp.Transform(mtx);

			return gp.IsVisible(p);
		}
开发者ID:AlexandrSurkov,项目名称:PKStudio,代码行数:15,代码来源:RectangleController.cs

示例9: IsVisible_Rectangle

		private void IsVisible_Rectangle (Graphics graphics)
		{
			using (GraphicsPath gp = new GraphicsPath ()) {
				gp.AddRectangle (new Rectangle (10, 10, 20, 20));
				Assert.IsFalse (gp.IsVisible (9, 9, graphics), "Int0");
				Assert.IsTrue (gp.IsVisible (10, 10, graphics), "Int1");
				Assert.IsTrue (gp.IsVisible (20, 20, graphics), "Int2");
				Assert.IsTrue (gp.IsVisible (29, 29, graphics), "Int3");
				Assert.IsFalse (gp.IsVisible (30, 29, graphics), "Int4");
				Assert.IsFalse (gp.IsVisible (29, 30, graphics), "Int5");
				Assert.IsFalse (gp.IsVisible (30, 30, graphics), "Int6");

				Assert.IsFalse (gp.IsVisible (9.4f, 9.4f, graphics), "Float0");
				Assert.IsTrue (gp.IsVisible (9.5f, 9.5f, graphics), "Float1");
				Assert.IsTrue (gp.IsVisible (10f, 10f, graphics), "Float2");
				Assert.IsTrue (gp.IsVisible (20f, 20f, graphics), "Float3");
				// the next diff is too close, so this fails with libgdiplus/cairo
				//Assert.IsTrue (gp.IsVisible (29.4f, 29.4f, graphics), "Float4");
				Assert.IsFalse (gp.IsVisible (29.5f, 29.5f, graphics), "Float5");
				Assert.IsFalse (gp.IsVisible (29.5f, 29.4f, graphics), "Float6");
				Assert.IsFalse (gp.IsVisible (29.4f, 29.5f, graphics), "Float7");
			}
		}
开发者ID:Profit0004,项目名称:mono,代码行数:23,代码来源:GraphicsPathTest.cs

示例10: PointInLine

        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);
        }
开发者ID:Elboodo,项目名称:My-FyiReporting,代码行数:10,代码来源:DesignXmlDraw.cs

示例11: Render

        /// <summary>
        /// Renders the current frame
        /// </summary>
        /// <param name="g">Graphics</param>
        /// <param name="frame">Frame to render</param>
        /// <param name="mousePos">Current mouse position</param>
        /// <returns></returns>
        private PositionSpec Render(Graphics g, IEnumerable<Face3D> frame, Point mousePos)
        {
            g.SmoothingMode = SmoothingMode.AntiAlias;
              PositionSpec pos = PositionSpec.Default;

              foreach (Face3D face in frame)
              {
            PointF[] parr = face.Vertices.Select(p => new PointF((float)p.X, (float)p.Y)).ToArray();
            Brush b = new SolidBrush(face.Color);
            double factor = ((Math.Sin((double)Environment.TickCount / (double)200) + 1) / 4) + 0.75;
            PositionSpec facePos = new PositionSpec() { FacePosition = face.Position, CubePosition = face.MasterPosition };

            if (this.MouseHandling)
            {
              if (_selections[facePos].HasFlag(Selection.Second))
            b = new HatchBrush(HatchStyle.Percent75, Color.Black, face.Color);
              else if (_selections[facePos].HasFlag(Selection.NotPossible))
            b = new SolidBrush(Color.FromArgb(face.Color.A, (int)(face.Color.R * 0.3), (int)(face.Color.G * 0.3), (int)(face.Color.B * 0.3)));
              else if (_selections[facePos].HasFlag(Selection.First))
            b = new HatchBrush(HatchStyle.Percent30, Color.Black, face.Color);
              else if (_selections[facePos].HasFlag(Selection.Possible))
            b = new SolidBrush(Color.FromArgb(face.Color.A, (int)(Math.Min(face.Color.R * factor, 255)), (int)(Math.Min(face.Color.G * factor, 255)), (int)(Math.Min(face.Color.B * factor, 255))));
              else b = new SolidBrush(face.Color);
            }
            else
              b = new SolidBrush(face.Color);

            g.FillPolygon(b, parr);
            g.DrawPolygon(new Pen(Color.Black, 1), parr);

            GraphicsPath gp = new GraphicsPath();
            gp.AddPolygon(parr);
            if (gp.IsVisible(mousePos))
              pos = facePos;
              }

              g.FillRectangle(new SolidBrush(this.BackColor), 0, this.Height - 25, this.Width - 1, 24);
              g.DrawRectangle(Pens.Black, 0, this.Height - 25, this.Width - 1, 24);
              g.DrawString(string.Format("[{0}] | {1}", _currentSelection.CubePosition, _currentSelection.FacePosition), this.Font, Brushes.Black, 5, this.Height - 20);

              g.FillRectangle(new SolidBrush(this.BackColor), 0, this.Height - 50, this.Width - 1, 25);
              g.DrawRectangle(Pens.Black, 0, this.Height - 50, this.Width - 1, 25);
              g.DrawString(this.State, this.Font, Brushes.Black, 5, this.Height - 45);

              g.DrawRectangle(Pens.Black, 0, 0, this.Width - 1, this.Height - 50);

              return pos;
        }
开发者ID:ArcaneSaint,项目名称:PXL_Programming_Expert_RubiksCubeSolver,代码行数:55,代码来源:CubeModel.cs

示例12: Render2D


//.........这里部分代码省略.........
            faces.AddRange(c.Faces.Where(f => c.Position.Flags.HasFlag(CubeFlagService.FromFacePosition(f.Position))).Select(f => new Face3D(null, f.Color, f.Position, c.Position.Flags)));
              frame = faces;

              foreach (Face3D face in frame)
              {
            #region CalculatePoints

            int x = 0, y = 0;
            int xOffs = borderX, yOffs = borderY;

            if (face.Position.HasFlag(FacePosition.Front))
            {
              xOffs += 3 * square; yOffs += 3 * square;
              CubePosition cubePos = new CubePosition(face.MasterPosition);
              x = xOffs + (CubeFlagService.ToInt(cubePos.X) + 1) * square;
              y = yOffs + (CubeFlagService.ToInt(cubePos.Y) * (-1) + 1) * square;
            }

            if (face.Position.HasFlag(FacePosition.Top))
            {
              xOffs += 3 * square;
              CubePosition cubePos = new CubePosition(face.MasterPosition);
              x = xOffs + (CubeFlagService.ToInt(cubePos.X) + 1) * square;
              y = yOffs + (CubeFlagService.ToInt(cubePos.Z) + 1) * square;
            }

            if (face.Position.HasFlag(FacePosition.Bottom))
            {
              xOffs += 3 * square; yOffs += 6 * square;
              CubePosition cubePos = new CubePosition(face.MasterPosition);
              x = xOffs + (CubeFlagService.ToInt(cubePos.X) + 1) * square;
              y = yOffs + (CubeFlagService.ToInt(cubePos.Z) * (-1) + 1) * square;
            }

            if (face.Position.HasFlag(FacePosition.Left))
            {
              yOffs += 3 * square;
              CubePosition cubePos = new CubePosition(face.MasterPosition);
              x = xOffs + (CubeFlagService.ToInt(cubePos.Z) + 1) * square;
              y = yOffs + (CubeFlagService.ToInt(cubePos.Y) * (-1) + 1) * square;
            }

            if (face.Position.HasFlag(FacePosition.Right))
            {
              xOffs += 6 * square; yOffs += 3 * square;
              CubePosition cubePos = new CubePosition(face.MasterPosition);
              x = xOffs + (CubeFlagService.ToInt(cubePos.Z) * (-1) + 1) * square;
              y = yOffs + (CubeFlagService.ToInt(cubePos.Y) * (-1) + 1) * square;
            }

            if (face.Position.HasFlag(FacePosition.Back))
            {
              xOffs += 9 * square; yOffs += 3 * square;
              CubePosition cubePos = new CubePosition(face.MasterPosition);
              x = xOffs + (CubeFlagService.ToInt(cubePos.X) * (-1) + 1) * square;
              y = yOffs + (CubeFlagService.ToInt(cubePos.Y) * (-1) + 1) * square;
            }
            #endregion

            Point[] parr = new Point[] { new Point(x, y), new Point(x, y + square), new Point(x + square, y + square), new Point(x + square, y)  };

            Brush b = new SolidBrush(face.Color);
            double factor = ((Math.Sin((double)Environment.TickCount / (double)200) + 1) / 4) + 0.75;
            PositionSpec facePos = new PositionSpec() { FacePosition = face.Position, CubePosition = face.MasterPosition };

            if (this.MouseHandling)
            {
              if (_selections[facePos].HasFlag(Selection.Second))
            b = new HatchBrush(HatchStyle.Percent75, Color.Black, face.Color);
              else if (_selections[facePos].HasFlag(Selection.NotPossible))
            b = new SolidBrush(Color.FromArgb(face.Color.A, (int)(face.Color.R * 0.3), (int)(face.Color.G * 0.3), (int)(face.Color.B * 0.3)));
              else if (_selections[facePos].HasFlag(Selection.First))
            b = new HatchBrush(HatchStyle.Percent30, Color.Black, face.Color);
              else if (_selections[facePos].HasFlag(Selection.Possible))
            b = new SolidBrush(Color.FromArgb(face.Color.A, (int)(Math.Min(face.Color.R * factor, 255)), (int)(Math.Min(face.Color.G * factor, 255)), (int)(Math.Min(face.Color.B * factor, 255))));
              else b = new SolidBrush(face.Color);
            }
            else
              b = new SolidBrush(face.Color);

            g.FillPolygon(b, parr);
            g.DrawPolygon(new Pen(Color.Black, 1), parr);

            GraphicsPath gp = new GraphicsPath();
            gp.AddPolygon(parr);
            if (gp.IsVisible(mousePos))
              pos = facePos;
              }

              g.DrawRectangle(Pens.Black, 0, this.Height - 25, this.Width - 1, 24);
              //g.DrawLine(Pens.Black, 0, this.Height - 25, this.Width, this.Height - 25);
              g.DrawString(string.Format("[{0}] | {1}", _currentSelection.CubePosition, _currentSelection.FacePosition), this.Font, Brushes.Black, 5, this.Height - 20);

              g.DrawRectangle(Pens.Black, 0, this.Height - 50, this.Width - 1, 25);
              g.DrawString(this.State, this.Font, Brushes.Black, 5, this.Height - 45);

              g.DrawRectangle(Pens.Black, 0, 0, this.Width - 1, this.Height - 50);

              return pos;
        }
开发者ID:ArcaneSaint,项目名称:PXL_Programming_Expert_RubiksCubeSolver,代码行数:101,代码来源:CubeModel.cs

示例13: tlVectorControl1_LeftClick


//.........这里部分代码省略.........
                    frmMainProperty fmain = new frmMainProperty();
                    glebeProperty gp = new glebeProperty();
                    gp.EleID = ((XmlElement)e.SvgElement).GetAttribute("id");
                    gp.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                    //fmain.InitData(gp); ///////////////////////////////////

                    XmlNodeList nlist = tlVectorControl1.SVGDocument.GetElementsByTagName("use");

                    PointF[] tfArray1 = TLMath.getPolygonPoints((XmlElement)e.SvgElement);
                    string str220 = "";
                    string str110 = "";
                    string str66 = "";
                    GraphicsPath selectAreaPath = new GraphicsPath();
                    selectAreaPath.AddLines(tfArray1);
                    selectAreaPath.CloseFigure();
                    //Matrix x=new Matrix(
                    //Region region1 = new Region(selectAreaPath);
                    for (int i = 0; i < nlist.Count; i++) {
                        float OffX = 0f;
                        float OffY = 0f;
                        Use use = (Use)nlist[i];
                        if (use.GetAttribute("xlink:href").Contains("Substation")) {
                            string strMatrix = use.GetAttribute("transform");
                            if (strMatrix != "") {
                                strMatrix = strMatrix.Replace("matrix(", "");
                                strMatrix = strMatrix.Replace(")", "");
                                string[] mat = strMatrix.Split(',');
                                if (mat.Length > 5) {
                                    OffX = Convert.ToSingle(mat[4]);
                                    OffY = Convert.ToSingle(mat[5]);
                                }
                            }
                            PointF TempPoint = TLMath.getUseOffset(use.GetAttribute("xlink:href"));
                            if (selectAreaPath.IsVisible(use.X + TempPoint.X + OffX, use.Y + TempPoint.Y + OffY)) {
                                if (use.GetAttribute("xlink:href").Contains("220")) {
                                    str220 = str220 + "'" + use.GetAttribute("id") + "',";
                                }
                                if (use.GetAttribute("xlink:href").Contains("110")) {
                                    str110 = str110 + "'" + use.GetAttribute("id") + "',";
                                }
                                if (use.GetAttribute("xlink:href").Contains("66")) {
                                    str66 = str66 + "'" + use.GetAttribute("id") + "',";
                                }
                            }
                        }
                    }
                    if (str220.Length > 1) {
                        str220 = str220.Substring(0, str220.Length - 1);
                    }
                    if (str110.Length > 1) {
                        str110 = str110.Substring(0, str110.Length - 1);
                    }
                    if (str66.Length > 1) {
                        str66 = str66.Substring(0, str66.Length - 1);
                    }
                    fmain.InitData(gp, str220, str110, str66);

                    XmlElement t1 = tlVectorControl1.SVGDocument.CreateElement("text") as Text;
                    Point point2 = tlVectorControl1.PointToView(new Point(e.Mouse.X, e.Mouse.Y));
                    t1.SetAttribute("x", Convert.ToString(point2.X - 20));
                    t1.SetAttribute("y", Convert.ToString(point2.Y - 10));
                    // t1.SetAttribute("layer", getlayer("供电区域层", tlVectorControl1.SVGDocument.getLayerList()).ID);
                    t1.SetAttribute("layer", SvgDocument.currentLayer);
                    t1.SetAttribute("style", "fill:#FFFFFF;fill-opacity:1;stroke:#000000;stroke-opacity:1;");
                    t1.SetAttribute("font-famliy", "宋体");
                    t1.SetAttribute("font-size", "14");
开发者ID:EdgarEDT,项目名称:myitoppsp,代码行数:67,代码来源:frmMain_wh.cs

示例14: foreach

        /*public void ResetPoly()
        {
            SvgElementCollection col= tlVectorControl1.SVGDocument.SelectCollection;
            if(col.Count<1){
                return;
            }
            SvgElementCollection.ISvgElementEnumerator enumerator1 = tlVectorControl1.DrawArea.ElementList.GetEnumerator();
            foreach(SvgElement ele in col){
                if (ele.GetType().ToString() == "ItopVector.Core.Figure.Polygon")
                {
                    glebeProperty p=new glebeProperty();
                    p.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                    p.EleID = ((IGraph)ele).ID;
                    p = Services.BaseService.GetObject("SelectglebePropertyByEleID", p);
                    if(p!=null){
                        PointF[] tfArray1 = TLMath.getPolygonPoints(ele);
                        GraphicsPath selectAreaPath = new GraphicsPath();
                        selectAreaPath.AddLines(tfArray1);
                        selectAreaPath.CloseFigure();
                        Region region1 = new Region(selectAreaPath);
                        while (enumerator1.MoveNext())
                        {
                            IGraph graph1 = (IGraph)enumerator1.Current;
                            GraphicsPath path1 = (GraphicsPath)graph1.GPath.Clone();
                            path1.Transform(graph1.GraphTransform.Matrix);
                            Region region2 = new Region(path1);
                            region2.Intersect(region1);
                            if (!region2.GetBounds(Graphics.FromHwnd(IntPtr.Zero)).IsEmpty)
                            {
                                glebeProperty p1 = new glebeProperty();
                                p1.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                                p1.EleID = graph1.ID;
                                p1 = Services.BaseService.GetObject("SelectglebePropertyByEleID", p1);
                                if(p1!=null){
                                    p1.ParentEleID = p.UID;
                                    Services.BaseService.Update("UpdateglebePropertyAreaAll", p1);
                                }
                            }
                        }
                    }
                }
            }
            MessageBox.Show("更新完成。","提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
        }*/
        private void contextMenuStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {
            try {
                if (e.ClickedItem.Text == "属性") {
                    XmlElement xml1 = (XmlElement)tlVectorControl1.SVGDocument.CurrentElement;
                    //PointF[] pf = TLMath.getPolygonPoints(xml1);

                    //((Polygon)xml1).Transform.Matrix.TransformPoints(pf);
                    // 规划
                    if (getlayer(SvgDocument.currentLayer, "电网规划层", tlVectorControl1.SVGDocument.getLayerList())) {

                        if (xml1 == null || tlVectorControl1.SVGDocument.CurrentElement.ID == "svg") {
                            MessageBox.Show("请先选择规划区域。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            return;
                        }
                        if (tlVectorControl1.SVGDocument.CurrentElement.GetType().ToString() == "ItopVector.Core.Figure.RectangleElement") {
                            //frmImgManager frm = new frmImgManager();
                            //frm.Show();
                        }
                        if (tlVectorControl1.SVGDocument.CurrentElement.GetType().ToString() == "ItopVector.Core.Figure.Polygon") {
                            XmlNodeList n1 = tlVectorControl1.SVGDocument.GetElementsByTagName("use");
                            PointF[] tfArray1 = TLMath.getPolygonPoints(xml1);
                            string str220 = "";
                            string str110 = "";
                            string str66 = "";

                            GraphicsPath selectAreaPath = new GraphicsPath();
                            selectAreaPath.AddLines(tfArray1);
                            selectAreaPath.CloseFigure();
                            //Matrix x=new Matrix(
                            //Region region1 = new Region(selectAreaPath);
                            for (int i = 0; i < n1.Count; i++) {
                                float OffX = 0f;
                                float OffY = 0f;
                                bool ck = false;
                                Use use = (Use)n1[i];
                                if (use.GetAttribute("xlink:href").Contains("Substation")) {
                                    string strMatrix = use.GetAttribute("transform");
                                    if (strMatrix != "") {
                                        strMatrix = strMatrix.Replace("matrix(", "");
                                        strMatrix = strMatrix.Replace(")", "");
                                        string[] mat = strMatrix.Split(',');
                                        if (mat.Length > 5) {
                                            OffX = Convert.ToSingle(mat[4]);
                                            OffY = Convert.ToSingle(mat[5]);
                                        }
                                    }
                                    if (frmlar.getSelectedLayer().Contains(use.GetAttribute("layer"))) {
                                        ck = true;
                                    }
                                    PointF TempPoint = TLMath.getUseOffset(use.GetAttribute("xlink:href"));
                                    if (selectAreaPath.IsVisible(use.X + TempPoint.X + OffX, use.Y + TempPoint.Y + OffY) && ck) {
                                        if (use.GetAttribute("xlink:href").Contains("220")) {
                                            str220 = str220 + "'" + use.GetAttribute("id") + "',";
                                        }
                                        if (use.GetAttribute("xlink:href").Contains("110")) {
//.........这里部分代码省略.........
开发者ID:EdgarEDT,项目名称:myitoppsp,代码行数:101,代码来源:frmMain_wh.cs

示例15: FillPolygon

        private void FillPolygon(List<PointF> points)
        {
            // We want to know to which side of the maps the first points need to be drawn to
            // This can also be done with pure math, but I don't want to... (http://www.blackpawn.com/texts/pointinpoly/)
            //
            // These graphic paths defines the draw direction
            // -----------
            // | \  n  / |
            // |  \   /  |
            // |   \ /   |
            // | w  /  e |
            // |   / \   |
            // |  /   \  |
            // | /  s  \ |
            // -----------
            GraphicsPath northTriangle = new GraphicsPath();
            northTriangle.AddLines(new PointF[] { new PointF(0, 0), new PointF(65536, 0), new PointF(32768, 32768) }); // the north triangle; Note: we use 65536 else 65535 will not be visible
            GraphicsPath eastTriangle = new GraphicsPath();
            eastTriangle.AddLines(new PointF[] { new PointF(65536, 0), new PointF(65536, 65536), new PointF(32768, 32768) }); // the east triangle
            GraphicsPath southTriangle = new GraphicsPath();
            southTriangle.AddLines(new PointF[] { new PointF(65536, 65536), new PointF(0, 65536), new PointF(32768, 32768) }); // the south triangle
            GraphicsPath westTriangle = new GraphicsPath();
            westTriangle.AddLines(new PointF[] { new PointF(0, 65536), new PointF(0, 0), new PointF(32768, 32768) }); // the west triangle

            PointF first = new PointF((float)points.First().X, (float)points.First().Y); // there are some shapes wich use 65536 as max X or Y
            PointF last = new PointF((float)points.Last().X, (float)points.Last().Y); // there are some shapes wich use 65536 as max X or Y

            // If its a complete polygon where the last equals the first point, don't do anything
            if (first.X == last.X && first.Y == last.Y) return;

            // Avoid flood fills
            // This happens if the start AND end of the shape are on the same side (see dartmoor, llyn bafog).
            bool avoidFloodFill = false;
            if (first.Y == 0 && last.Y == 0 && first.X > last.X) avoidFloodFill = true; // north
            else if (first.X == 65535 && last.X == 65535 && first.Y > last.Y) avoidFloodFill = true; // east
            else if (first.Y == 65535 && last.Y == 65535 && first.X < last.X) avoidFloodFill = true; // south
            else if (first.X == 0 && last.X == 0 && first.Y < last.Y) avoidFloodFill = true; // west

            // Fill the shape in a clockwise order, maximum 6 required steps
            // But first check if the distance last-point <--> first-point is lower
            double firstLastDistance = Tools.GetPointDistance(first, last);

            // Go the next map border at n, e, s, w
            PointF pointToPrepend = PointF.Empty;
            if (northTriangle.IsVisible(first)) pointToPrepend = new PointF(first.X, 0); // to north border
            else if (eastTriangle.IsVisible(first)) pointToPrepend = new PointF(65535, first.Y); // to east border
            else if (southTriangle.IsVisible(first)) pointToPrepend = new PointF(first.X, 65535); // to south border
            else if (westTriangle.IsVisible(first)) pointToPrepend = new PointF(0, first.Y); // to west border

            double newFirstDistance = Tools.GetPointDistance(pointToPrepend, first);
            if (pointToPrepend != null && firstLastDistance < newFirstDistance) return;

            // Do the same for last point
            PointF pointToAppend = PointF.Empty;
            if (northTriangle.IsVisible(last)) pointToAppend = new PointF(last.X, 0); // to north border
            else if (eastTriangle.IsVisible(last)) pointToAppend = new PointF(65535, last.Y); // to east border
            else if (southTriangle.IsVisible(last)) pointToAppend = new PointF(last.X, 65535); // to south border
            else if (westTriangle.IsVisible(last)) pointToAppend = new PointF(0, last.Y); // to west border

            double newLastDistance = Tools.GetPointDistance(last, pointToAppend);
            if (pointToAppend != null && firstLastDistance < newLastDistance) return;

            // Okay, we need to fill
            if (pointToPrepend != null) points.Insert(0, pointToPrepend);
            if (pointToAppend != null) points.Add(pointToAppend);

            // No we have first and last at least with one of 0/65535 on x and y

            // Go around
            while (true)
            {
                first = new PointF((float)points.First().X, (float)points.First().Y); // there are some shapes wich use 65536 as max X or Y
                last = new PointF((float)points.Last().X, (float)points.Last().Y); // there are some shapes wich use 65536 as max X or Y

                // Chek if we are finished
                if ((first.X == last.X && first.Y == last.Y) && !avoidFloodFill) break;

                if (first.Y == 0 && first.X != 65535 && (last.Y != 0 || first.X > last.X)) points.Insert(0, new PointF(65535, 0)); // to north-east corner
                else if (first.X == 65535 && first.Y != 65535 && (last.X != 65535 || first.Y > last.Y)) points.Insert(0, new PointF(65535, 65535)); // to south-east corner
                else if (first.Y == 65535 && first.X != 0 && (last.Y != 65535 || first.X < last.X)) points.Insert(0, new PointF(0, 65535)); // to south-west corner
                else if (first.X == 0 && first.Y != 0 && (last.X != 0 || first.Y < last.Y)) points.Insert(0, new PointF(0, 0)); // to north-west corner
                else break;
            }
        }
开发者ID:Merec,项目名称:DAoC-MapCreator,代码行数:84,代码来源:MapBounds.cs


注:本文中的System.Drawing.Drawing2D.GraphicsPath.IsVisible方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。