IsVisible() public method

public IsVisible ( Point point ) : bool
point Point
return bool
Esempio n. 1
0
 //檢查座標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);
 }
Esempio n. 2
0
 //是否圖形包含的座標
 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);
 }
Esempio n. 3
0
 //檢查是否與圖案有交集
 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);
 }
Esempio n. 4
0
 //檢查座標是否圖形內
 public override bool ContainsInShape(int x, int y)
 {
     GraphicsPath path = new GraphicsPath();
     path.FillMode = FillMode.Winding;
     path.AddLine(_locationOfPaintFirstPoint.X + _moveingXOffset, _locationOfPaintFirstPoint.Y + _moveingYOffset,_locationOfPaintEndPoint.X + _moveingXOffset, _locationOfPaintEndPoint.Y + _moveingYOffset);
     path.Widen(_pen);
     return path.IsVisible(x, y);
 }
Esempio n. 5
0
        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);
        }
Esempio n. 6
0
        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);
        }
		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);
		}
		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);
		}
        /// <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;
        }
        public PositionSpec Render2D(Graphics g, IEnumerable<Face3D> frame, Point mousePos)
        {
            g.SmoothingMode = SmoothingMode.AntiAlias;
              PositionSpec pos = PositionSpec.Default;

              int square = 0, borderX = 5, borderY = 5;
              if (((double)(this.Screen.Width - 10) / (double)(this.Screen.Height - 10)) > (4.0 / 3.0))
              {
            square = (int)(this.Screen.Height / 9.0);
            borderX = (this.Screen.Width - 12 * square) / 2;
              }
              else
              {
            square = (int)(this.Screen.Width / 12.0);
            borderY = (this.Screen.Height - 9 * square) / 2;
              }

              List<Face3D> faces = new List<Face3D>();
              foreach (Cube c in this.Rubik.Cubes)
            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;
        }
Esempio n. 11
0
        void tlVectorControl1_LeftClick(object sender, ItopVector.DrawArea.SvgElementSelectedEventArgs e)
        {
            //SvgElement ele2 = tlVectorControl1.CreateBySymbolID("kbs-8", (tlVectorControl1.DrawArea.PointToView(e.Mouse.Location)));
            //ele2 = tlVectorControl1.AddShape(ele2, Point.Empty);
            if (tlVectorControl1.SVGDocument.CurrentElement != null &&
                tlVectorControl1.SVGDocument.CurrentElement.GetAttribute("xlink:href").Contains("XL_GT_1")) {
                sel_start_point = tlVectorControl1.SVGDocument.CurrentElement.ID;
            }

            if (sel_sym == "bt_start") {
                SvgElement ele = tlVectorControl1.CreateBySymbolID("XL_GT_1", (tlVectorControl1.DrawArea.PointToView(e.Mouse.Location)));
                ele = tlVectorControl1.AddShape(ele, Point.Empty);
                ele.SetAttribute("order", "0");
                ele.SetAttribute("start_point", ele.ID);
            }
            if (sel_sym == "bt_end") {
                SvgElement ele = tlVectorControl1.CreateBySymbolID("XL_GT_2", (tlVectorControl1.DrawArea.PointToView(e.Mouse.Location)));
                ele.SetAttribute("start_point", sel_start_point);
                ele.SetAttribute("order", "999");
                tlVectorControl1.AddShape(ele, Point.Empty);
            }
            if (sel_sym == "bt_must") {
                SvgElement ele = tlVectorControl1.CreateBySymbolID("XL_GT_3", (tlVectorControl1.DrawArea.PointToView(e.Mouse.Location)));
                ele.SetAttribute("start_point", sel_start_point);
                tlVectorControl1.AddShape(ele, Point.Empty);
                frmInputNum num = new frmInputNum();
                num.ShowDialog();
                ele.SetAttribute("order", num.InputStrSEL);
            }
            if (sel_sym == "bt_point") {
                SvgElement ele = tlVectorControl1.CreateBySymbolID("XL_GT_4", (tlVectorControl1.DrawArea.PointToView(e.Mouse.Location)));
                ele.SetAttribute("start_point", sel_start_point);
                tlVectorControl1.AddShape(ele, Point.Empty);
                frmInputNum num = new frmInputNum();
                num.ShowDialog();
                ele.SetAttribute("order", num.InputStrSEL);
            }
            //if (sel_sym != "" && sel_start_point!="")
            //{
            //    XmlNodeList il= tlVectorControl1.SVGDocument.SelectNodes("svg/use [@start_point='" + sel_start_point + "']");
            //    if (il.Count < 3)
            //    {
            //        return;
            //    }
            //    for (int i = 0; i < il.Count;i++ )
            //    {
            //        Use u = (Use)il[i];
            //        PointF f = u.CenterPoint;

            //    }
            //    //PointF[] pnt = ((Polyline)(tlVectorControl1.SVGDocument.CurrentElement)).Points;
            //    //if (pnt.Length < 3) return;
            //    for (int i = 0; i < il.Count; i++)
            //    {
            //        double ang = TLMath.getLineAngle(((Use)il[i]).CenterPoint, ((Use)il[i + 1]).CenterPoint, ((Use)il[i + 2]).CenterPoint);
            //        if (ang * 57.3 > 60)
            //        {
            //            MessageBox.Show("线路转角不能大于60度。\r\n "+"第" + (i + 1) + "转角:" + Convert.ToDouble(ang * 57.3).ToString("##.##") + "度。\r\n", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            //           // tlVectorControl1.Delete();
            //            return;
            //        }

            //        if (i == il.Count - 3)
            //        {
            //            break;
            //        }
            //    }
            //}
            if (csOperation == CustomOperation.OP_MeasureDistance) {
                Polyline pl = tlVectorControl1.SVGDocument.CurrentElement as Polyline;
                if (pl.Points.Length > 1) {
                    double d = 0;
                    for (int i = 1; i < pl.Points.Length; i++) {
                        d += this.mapview.CountLength(pl.Points[i - 1], pl.Points[i]);
                    }
                    label1.Text = d + "公里";

                    Point pt = new Point(e.Mouse.X, e.Mouse.Y);
                    pt = PointToClient(tlVectorControl1.PointToScreen(pt));
                    //tlVectorControl1.SetToolTip(label1.Text);
                    label1.Left = pt.X;
                    label1.Top = pt.Y;

                    label1.Visible = true;
                }
                return;
            }
            //System.IO.FileInfo ff = new System.IO.FileInfo("c:\\1111.txt");
            //System.IO.StreamWriter wt= ff.CreateText();
            //wt.Write(tlVectorControl1.SVGDocument.OuterXml);
            //wt.Close();
            //SortedList l = new SortedList();
            //l.Add("1", "aaa");
            //l.Add("5", "bbb");
            //l.Add("2", "ccc");

            //if (tlVectorControl1.ScaleRatio < 0.1f) {
            //    tlVectorControl1.ScaleRatio = 0.1f;
            //    scaleBox.ComboBoxEx.Text = "";
            //    scaleBox.SelectedText = "10%";
            //}
            tip.Hide();
            fInfo.Hide();

            if (tlVectorControl1.Operation == ToolOperation.Text) {
                frmTextInput ft = new frmTextInput();
                if (ft.ShowDialog() == DialogResult.OK) {
                    string txt = ft.Content;
                    XmlElement n1 = tlVectorControl1.SVGDocument.CreateElement("text") as Text;
                    Point point1 = tlVectorControl1.PointToView(new Point(e.Mouse.X, e.Mouse.Y));
                    n1.SetAttribute("x", point1.X.ToString());
                    n1.SetAttribute("y", point1.Y.ToString());
                    n1.InnerText = txt;
                    n1.SetAttribute("layer", SvgDocument.currentLayer);
                    tlVectorControl1.SVGDocument.RootElement.AppendChild(n1);
                    tlVectorControl1.Operation = ToolOperation.Select;
                }
            }
            if (MapType == "规划统计") {
                try {
                    if (e.SvgElement.ID == "svg") {
                        MapType = "接线图";
                        return;
                    }
                    if (((Polygon)e.SvgElement) == null) return;
                    XmlElement n1 = tlVectorControl1.SVGDocument.CreateElement("circle") as Circle;
                    Point point1 = tlVectorControl1.PointToView(new Point(e.Mouse.X, e.Mouse.Y));
                    n1.SetAttribute("cx", point1.X.ToString());
                    n1.SetAttribute("cy", point1.Y.ToString());
                    n1.SetAttribute("r", "42.5");
                    n1.SetAttribute("r", "42.5");
                    //n1.SetAttribute("layer", getlayer("供电区域层", tlVectorControl1.SVGDocument.getLayerList()).ID);
                    n1.SetAttribute("layer", SvgDocument.currentLayer);
                    n1.SetAttribute("style", "fill:#FFFFC0;fill-opacity:0.5;stroke:#000000;stroke-opacity:1;");
                    tlVectorControl1.SVGDocument.RootElement.AppendChild(n1);

                    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");
                    t1.InnerText = fmain.glebeProp.Area + "\r\n" + fmain.glebeProp.Burthen; //+"\r\n" + fmain.glebeProp.Number;
                    tlVectorControl1.SVGDocument.RootElement.AppendChild(t1);
                    tlVectorControl1.Refresh();
                    fmain.Dispose();
                    MapType = "接线图";
                } catch (Exception e2) { MapType = "接线图"; }
            }
            if (tlVectorControl1.SVGDocument.SelectCollection.Count > 1) {
                return;
            }
            decimal ViewScale = 1;
            string str_Scale = tlVectorControl1.SVGDocument.getViewScale();
            if (str_Scale != "") {
                ViewScale = Convert.ToDecimal(str_Scale);
            }
            if (e.SvgElement.GetType().ToString() == "ItopVector.Core.Figure.Polygon") {
                string IsArea = ((XmlElement)e.SvgElement).GetAttribute("IsArea");
                if (IsArea != "") {

                    XmlElement n1 = (XmlElement)e.SvgElement;
                    string str_points = n1.GetAttribute("points");
                    string[] points = str_points.Split(",".ToCharArray());
                    PointF[] pnts = new PointF[points.Length];

                    for (int i = 0; i < points.Length; i++) {
                        string[] pointsXY = points[i].Split(" ".ToCharArray());
                        pnts[i].X = Convert.ToSingle(pointsXY[0]);
                        pnts[i].Y = Convert.ToSingle(pointsXY[1]);
                    }
                    decimal temp1 = TLMath.getPolygonArea(pnts, 1);

                    temp1 = TLMath.getNumber2(temp1, tlVectorControl1.ScaleRatio);
                    SelUseArea = temp1.ToString("#####.####");
                    //tip.Text = "区域面积:" + SelUseArea;
                    if (SelUseArea != "") {
                        if (Convert.ToDecimal(SelUseArea) >= 1) {
                            fInfo.Info = "区域面积:" + SelUseArea + "(KM²)";
                        } else {
                            fInfo.Info = "区域面积: 0" + SelUseArea + "(KM²)";
                        }
                    }
                    fInfo.Top = e.Mouse.Y;
                    fInfo.Left = e.Mouse.X;
                    fInfo.Width = (fInfo.Info.Length) * 12;
                    if (SelUseArea != "") {
                        fInfo.Show();

                    }
                    //tip.ShowToolTip();
                }

            }
            if (e.SvgElement.GetType().ToString() == "ItopVector.Core.Figure.Line") {
                string IsLead = ((XmlElement)e.SvgElement).GetAttribute("IsLead");
                if (IsLead != "") {
                    Line line = (Line)e.SvgElement;
                    decimal temp1 = TLMath.getLineLength(line, 1);
                    temp1 = TLMath.getNumber(temp1, tlVectorControl1.ScaleRatio);
                    string len = temp1.ToString("#####.####");
                    LineLen = len;
                    LineInfo lineInfo = new LineInfo();
                    lineInfo.EleID = e.SvgElement.ID;
                    lineInfo.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                    LineInfo _lineTemp = (LineInfo)Services.BaseService.GetObject("SelectLineInfoByEleID", lineInfo);

                    if ((len != "") && (_lineTemp != null)) {
                        if (Convert.ToDecimal(len) >= 1) {
                            fInfo.Info = "线路名称:" + _lineTemp.LineName + " 线路长度:" + len + "(KM)\r\n" + "导线型号:" + _lineTemp.LineType + " 电压等级:" + _lineTemp.Voltage + "kV 投产年限:" + _lineTemp.ObligateField3;
                        } else {
                            fInfo.Info = "线路名称:" + _lineTemp.LineName + " 线路长度: 0" + len + "(KM)\r\n" + "导线型号:" + _lineTemp.LineType + " 电压等级:" + _lineTemp.Voltage + "kV 投产年限:" + _lineTemp.ObligateField3;
                        }
                    } else if (len != "") {
                        if (Convert.ToDecimal(len) >= 1) {
                            fInfo.Info = "线路名称:" + " " + "线路长度:" + len + "(KM)\r\n" + "导线型号:" + " " + " 电压等级:" + " " + " 投产年限:" + " ";
                        } else {
                            fInfo.Info = "线路名称:" + " " + "线路长度: 0" + len + "(KM)\r\n" + "导线型号:" + " " + " 电压等级:" + " " + " 投产年限:" + " ";
                        }
                    }
                    fInfo.Top = e.Mouse.Y;
                    fInfo.Left = e.Mouse.X;
                    fInfo.Width = (fInfo.Info.Length) * 7;
                    fInfo.Height = 50;
                    if (len != "") {
                        fInfo.Show();

                    }

                }
            }
            if (e.SvgElement.GetType().ToString() == "ItopVector.Core.Figure.Polyline") {
                string IsLead = ((XmlElement)e.SvgElement).GetAttribute("IsLead");
                if (IsLead != "") {
                    Polyline polyline = (Polyline)e.SvgElement;
                    decimal temp1 = TLMath.getPolylineLength(polyline, 1);
                    temp1 = TLMath.getNumber(temp1, tlVectorControl1.ScaleRatio);
                    string len = temp1.ToString("#####.####");
                    LineLen = len;
                    LineInfo lineInfo = new LineInfo();
                    lineInfo.EleID = e.SvgElement.ID;
                    lineInfo.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                    LineInfo _lineTemp = (LineInfo)Services.BaseService.GetObject("SelectLineInfoByEleID", lineInfo);

                    if ((len != "") && (_lineTemp != null)) {
                        if (Convert.ToDecimal(len) >= 1) {
                            fInfo.Info = "线路名称:" + _lineTemp.LineName + " 线路长度:" + len + "(KM)\r\n" + "导线型号:" + _lineTemp.LineType + " 电压等级:" + _lineTemp.Voltage + "kV 投产年限:" + _lineTemp.ObligateField3;
                        } else {
                            fInfo.Info = "线路名称:" + _lineTemp.LineName + " 线路长度: 0" + len + "(KM)\r\n" + "导线型号:" + _lineTemp.LineType + " 电压等级:" + _lineTemp.Voltage + "kV 投产年限:" + _lineTemp.ObligateField3;
                        }
                    } else if (len != "") {
                        if (Convert.ToDecimal(len) >= 1) {
                            fInfo.Info = "线路名称:" + " " + "线路长度:" + len + "(KM)\r\n" + "导线型号:" + " " + " 电压等级:" + " " + " 投产年限:" + " ";
                        } else {
                            fInfo.Info = "线路名称:" + " " + "线路长度: 0" + len + "(KM)\r\n" + "导线型号:" + " " + " 电压等级:" + " " + " 投产年限:" + " ";
                        }
                    }
                    fInfo.Top = e.Mouse.Y;
                    fInfo.Left = e.Mouse.X;
                    fInfo.Width = (fInfo.Info.Length) * 7;
                    fInfo.Height = 50;
                    //fInfo.Right = fInfo.Left+fInfo.Info.Length*10;
                    if (len != "") {
                        fInfo.Show();
                    }
                }
            }
            if (e.SvgElement.GetType().ToString() == "ItopVector.Core.Figure.Use") {
                string aaa = ((Use)e.SvgElement).RefElement.ID;
                //if (!aaa.Contains("Substation"))
                //{
                //    return;
                //}

                string IsLead = ((XmlElement)e.SvgElement).GetAttribute("IsLead");

                if (aaa.Contains("Substation")) {
                    substation sub = new substation();
                    sub.EleID = e.SvgElement.ID;
                    sub.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                    substation _subTemp = (substation)Services.BaseService.GetObject("SelectsubstationByEleID", sub);
                    if (_subTemp != null) {
                        fInfo.Info = "变电站名称:" + _subTemp.EleName + " 容量:" + _subTemp.Number + "MVA\r\n" + " 电压等级:" + _subTemp.ObligateField1 + "kV 最大负荷:" + _subTemp.Burthen + "MW \r\n 负荷率:" + _subTemp.ObligateField2 + " 投产年限:" + _subTemp.ObligateField5;
                    } else {
                        fInfo.Info = "变电站名称:" + " " + " 容量:0" + "MVA" + "\r\n 电压等级: 最大负荷: \r\n 负荷率: 投产年限:";
                    }
                    fInfo.Top = e.Mouse.Y;
                    fInfo.Left = e.Mouse.X;
                    fInfo.Width = (fInfo.Info.Length) * 5;
                    fInfo.Height = 60;
                    fInfo.Show();
                }
                if (aaa.Contains("kbs") || aaa.Contains("fjx") || aaa.Contains("byq")) {
                    string s_name = "";
                    if (aaa.Contains("kbs")) {
                        s_name = "开闭所";
                    }
                    if (aaa.Contains("fjx")) {
                        s_name = "分接箱";
                    }
                    if (aaa.Contains("byq")) {
                        s_name = "变压器";
                    }
                    PSP_Gra_item sub = new PSP_Gra_item();
                    sub.EleID = e.SvgElement.ID;
                    sub.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                    sub.LayerID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                    PSP_Gra_item _subTemp = (PSP_Gra_item)Services.BaseService.GetObject("SelectPSP_Gra_itemByEleIDKey", sub);
                    if (_subTemp != null) {
                        fInfo.Info = s_name + "编号:" + _subTemp.EleKeyID + "\r\n 名称:" + _subTemp.EleName;
                    } else {
                        fInfo.Info = s_name + "编号:   \r\n 名称: ";
                    }
                    fInfo.Top = e.Mouse.Y;
                    fInfo.Left = e.Mouse.X;
                    fInfo.Width = (fInfo.Info.Length) * 8;
                    fInfo.Height = 60;
                    fInfo.Show();
                }
            }
            if (e.SvgElement.GetType().ToString() == "ItopVector.Core.Figure.ConnectLine") {
                ConnectLine cline = (ConnectLine)tlVectorControl1.SVGDocument.CurrentElement;
                if (cline.StartGraph != null) {
                    string code = ((XmlElement)cline.StartGraph).GetAttribute("devxldm");

                    if (code != "") {
                        xltProcessor.SelectLine(code);
                        tlVectorControl1.CurrentOperation = ToolOperation.Select;
                    }
                }
            }
            /*  if (tlVectorControl1.Operation == ToolOperation.LeadLine)
              {
                  string gt = sgt1.Text;
                  XmlElement u1 = tlVectorControl1.SVGDocument.CreateElement("use") as Use;
                  Point point1 = tlVectorControl1.PointToView(new Point(e.Mouse.X, e.Mouse.Y));
                  u1.SetAttribute("xlink:href", "#" + gt + "0");
                  u1.SetAttribute("x", point1.X.ToString());
                  u1.SetAttribute("y", point1.Y.ToString());
                  u1.SetAttribute("layer", SvgDocument.currentLayer);
                  u1.SetAttribute("style", "fill:#FFFFFF;fill-opacity:1;stroke:#000000;stroke-opacity:1;");
                  tlVectorControl1.SVGDocument.RootElement.AppendChild(u1);
              }*/
            //tlVectorControl1.SVGDocument.CurrentElement = null;
        }
Esempio n. 12
0
        /*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")) {
                                            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);
                            }
                            glebeProperty _gle = new glebeProperty();
                            _gle.EleID = tlVectorControl1.SVGDocument.CurrentElement.ID;
                            _gle.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;

                            IList<glebeProperty> UseProList = Services.BaseService.GetList<glebeProperty>("SelectglebePropertyByEleID", _gle);
                            if (UseProList.Count > 0) {
                                _gle = UseProList[0];
                                _gle.LayerID = SvgDocument.currentLayer;
                                frmMainProperty f = new frmMainProperty();

                                f.InitData(_gle, str220, str110, str66);

                                f.ShowDialog();
                                if (f.checkBox1.Checked == false) {
                                    tlVectorControl1.SVGDocument.RootElement.RemoveChild(tlVectorControl1.SVGDocument.CurrentElement);
                                }
                                //tlVectorControl1.Refresh();
                            }
                            //}
                        }

                    }
                    if (getlayer(SvgDocument.currentLayer, "城市规划层", tlVectorControl1.SVGDocument.getLayerList())) {

                        if (tlVectorControl1.SVGDocument.getRZBRatio() != "") {
                            rzb = tlVectorControl1.SVGDocument.getRZBRatio();
                        }

                        if (xml1 == null || tlVectorControl1.SVGDocument.CurrentElement.ID == "svg") {
                            MessageBox.Show("请先选择地块。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            return;
                        }
                        if (tlVectorControl1.SVGDocument.CurrentElement.GetType().ToString() == "ItopVector.Core.Figure.Polygon") {
                            string IsArea = ((XmlElement)tlVectorControl1.SVGDocument.CurrentElement).GetAttribute("IsArea");
                            if (IsArea != "") {
                                frmProperty f = new frmProperty();
                                if (SelUseArea == "") { SelUseArea = "0"; }
                                f.InitData(xml1.GetAttribute("id"), tlVectorControl1.SVGDocument.SvgdataUid, SelUseArea, rzb, SvgDocument.currentLayer);
                                //f.ShowDialog();
                                if (progtype != "城市规划层") {
                                    f.IsReadonly = true;
                                }
                                if (f.ShowDialog() == DialogResult.OK) {
                                    SVG_ENTITY ent = new SVG_ENTITY();
                                    if (f.IsCreate) {
                                        ent.SUID = Guid.NewGuid().ToString();
                                        ent.EleID = f.gPro.EleID;
                                        ent.layerID = f.gPro.LayerID;
                                        ent.MDATE = System.DateTime.Now;
                                        ent.NAME = f.gPro.UseID;
                                        ent.svgID = f.gPro.SvgUID;
                                        ent.TYPE = "polygon-dk";
                                        //ent.voltage = f.gPro.Voltage;
                                        Services.BaseService.Create<SVG_ENTITY>(ent);
                                    } else {
                                        ent.NAME = f.gPro.UseID;
                                        ent.layerID = f.gPro.LayerID;
                                        ent.MDATE = System.DateTime.Now;
                                        //ent.voltage = fl.Line.Voltage;
                                        Services.BaseService.Update<SVG_ENTITY>(ent);
                                    }
                                    if (f.gPro.ObligateField1 != "") {
                                        string color1 = ColorTranslator.ToHtml(Color.FromArgb(Convert.ToInt32(f.gPro.ObligateField1)));
                                        color1 = "fill:" + color1 + ";";
                                        ((XmlElement)tlVectorControl1.SVGDocument.CurrentElement).SetAttribute("style", color1);
                                        tlVectorControl1.UpdateProperty();
                                    }

                                }
                            }
                        }
                    }

                    if (tlVectorControl1.SVGDocument.CurrentElement.GetType().ToString() == "ItopVector.Core.Figure.Line" || tlVectorControl1.SVGDocument.CurrentElement.GetType().ToString() == "ItopVector.Core.Figure.Polyline") {
                        string lineWidth = "2";
                        string IsLead = ((XmlElement)tlVectorControl1.SVGDocument.CurrentElement).GetAttribute("IsLead");
                        //if (IsLead != "")       //原先导线的属性添加情况
                        //{
                        //    frmLineProperty fl = new frmLineProperty();
                        //    fl.LineNode = tlVectorControl1.SVGDocument.CurrentElement;
                        //    fl.InitData(tlVectorControl1.SVGDocument.CurrentElement.GetAttribute("id"), tlVectorControl1.SVGDocument.SvgdataUid, LineLen, SvgDocument.currentLayer);
                        //    if (fl.ShowDialog() == DialogResult.OK)
                        //    {
                        //        SVG_ENTITY ent = new SVG_ENTITY();
                        //        if (fl.IsCreate)
                        //        {
                        //            ent.SUID = Guid.NewGuid().ToString();
                        //            ent.EleID = fl.Line.EleID;
                        //            ent.layerID = fl.Line.LayerID;
                        //            ent.MDATE = System.DateTime.Now;
                        //            ent.NAME = fl.Line.LineName;
                        //            ent.svgID = fl.Line.SvgUID;
                        //            ent.TYPE = "line";
                        //            ent.voltage =Convert.ToInt32(fl.Line.Voltage);
                        //            Services.BaseService.Create<SVG_ENTITY>(ent);
                        //        }
                        //        else
                        //        {
                        //            ent.NAME = fl.Line.LineName;
                        //            ent.layerID = fl.Line.LayerID;
                        //            ent.MDATE = System.DateTime.Now;
                        //            ent.voltage =Convert.ToInt32( fl.Line.Voltage);
                        //            Services.BaseService.Update<SVG_ENTITY>(ent);
                        //        }

                        //        lineWidth = fl.LineWidth;
                        //        string styleValue = "";
                        //        if (fl.Line.ObligateField1 == "规划")
                        //        {
                        //            styleValue = "stroke-dasharray:" + ghType + ";stroke-width:" + lineWidth + ";";
                        //        }
                        //        else
                        //        {
                        //            styleValue = "stroke-width:" + lineWidth + ";";
                        //        }
                        //        //string aa= ColorTranslator.ToHtml(Color.Black);
                        //        styleValue = styleValue + "stroke:" + ColorTranslator.ToHtml(Color.FromArgb(Convert.ToInt32(fl.Line.ObligateField2)));
                        //        SvgElement se = tlVectorControl1.SVGDocument.CurrentElement;
                        //        se.RemoveAttribute("style");
                        //        se.SetAttribute("style", styleValue);
                        //        se.SetAttribute("info-name", fl.Line.LineName);

                        //    }
                        //}
                        if (IsLead != "")       //修改后的导线的属性添加情况
                        {
                            PSPDEV obj = new PSPDEV();
                            string deviceid = xml1.GetAttribute("Deviceid");
                            if (string.IsNullOrEmpty(deviceid)) {
                                obj = (PSPDEV)DeviceHelper.SelectDevice(DeviceType.XL, Itop.Client.MIS.ProgUID);
                                if (obj==null)
                                {
                                    tlVectorControl1.SVGDocument.CurrentElement = xml1 as SvgElement;
                                    tlVectorControl1.Delete();
                                }
                                if ( obj is PSPDEV) {
                                    deviceid = ((PSPDEV)obj).SUID;
                                    xml1.SetAttribute("Deviceid", deviceid);
                                }
                            }
                            if (!string.IsNullOrEmpty(deviceid)) {
                                obj = (PSPDEV)DeviceHelper.GetDevice<PSPDEV>(deviceid);
                                if (obj != null) {
                                    xml1.SetAttribute("info-name", ((PSPDEV)obj).Name);
                                    DeviceHelper.ShowDeviceDlg(DeviceType.XL, deviceid, false);
                                }

                                LineInfo li = new LineInfo();
                                li.UID = obj.SUID;
                                li = (LineInfo)Services.BaseService.GetObject("SelectLineInfoByKey", li);
                                if (li != null) {
                                    li.LayerID = SvgDocument.currentLayer;
                                    li.EleID = xml1.GetAttribute("id");
                                    li.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                                    LineType lt = new LineType();
                                    lt.TypeName = li.Voltage.ToString() + "kV";
                                    lt = (LineType)Services.BaseService.GetObject("SelectLineTypeByTypeName", lt);
                                    li.ObligateField3 = obj.OperationYear;
                                    if (lt != null)
                                    {
                                        li.ObligateField2 = lt.Color;
                                        lineWidth = lt.ObligateField1;
                                    }

                                    if (!string.IsNullOrEmpty(li.ObligateField3)) {
                                        if (Convert.ToInt32(obj.OperationYear) > DateTime.Now.Year) {
                                            li.ObligateField1 = "规划";
                                        } else
                                            li.ObligateField1 = "运行";
                                    }
                                    Services.BaseService.Update<LineInfo>(li);
                                } else {
                                    li = new LineInfo();
                                    li.UID = obj.SUID;
                                    li.LineName = obj.Name;
                                    li.Length = obj.LineLength.ToString();
                                    li.LineType = obj.LineType;
                                    li.Voltage = obj.ReferenceVolt.ToString();
                                    li.EleID = xml1.GetAttribute("id");
                                    li.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                                    LineType lt = new LineType();
                                    lt.TypeName = obj.ReferenceVolt.ToString() + "kV";
                                    lt = (LineType)Services.BaseService.GetObject("SelectLineTypeByTypeName", lt);
                                    li.ObligateField3 = obj.OperationYear;
                                    if (lt != null)
                                    {
                                        li.ObligateField2 = lt.Color;
                                        lineWidth = lt.ObligateField1;
                                    }

                                    if (!string.IsNullOrEmpty(li.ObligateField3)) {
                                        if (Convert.ToInt32(obj.OperationYear) > DateTime.Now.Year) {
                                            li.ObligateField1 = "规划";
                                        } else
                                            li.ObligateField1 = "运行";
                                    }

                                    Services.BaseService.Create<LineInfo>(li);
                                }

                                string styleValue = "";
                                if (li.ObligateField1 == "规划") {
                                    styleValue = "stroke-dasharray:" + ghType + ";stroke-width:" + lineWidth + ";";
                                } else {
                                    styleValue = "stroke-width:" + lineWidth + ";";
                                }
                                //string aa= ColorTranslator.ToHtml(Color.Black);
                                styleValue = styleValue + "stroke:" + ColorTranslator.ToHtml(Color.FromArgb(Convert.ToInt32(li.ObligateField2)));
                                SvgElement se = tlVectorControl1.SVGDocument.CurrentElement;
                                se.RemoveAttribute("style");
                                se.SetAttribute("style", styleValue);
                                se.SetAttribute("info-name", li.LineName);
                                //***** ********添加FistNode和LastNode
                                XmlNodeList useList = tlVectorControl1.SVGDocument.SelectNodes("svg/use");

                                foreach (XmlNode element in useList) {
                                    if (!string.IsNullOrEmpty((element as XmlElement).GetAttribute("Deviceid"))) {
                                        string con = "WHERE SvgUID='" + (element as XmlElement).GetAttribute("Deviceid") + "'AND ProjectID = '" + Itop.Client.MIS.ProgUID + "'" + "AND Type='01'";
                                        IList pspMX = Services.BaseService.GetList("SelectPSPDEVByCondition", con);
                                        if (pspMX != null) {
                                            foreach (PSPDEV pspmx in pspMX) {
                                                if (obj.IName == pspmx.Name) {
                                                    (xml1 as XmlElement).SetAttribute("FirstNode", (element as XmlElement).GetAttribute("id"));

                                                } else if (obj.JName == pspmx.Name) {
                                                    (xml1 as XmlElement).SetAttribute("LastNode", (element as XmlElement).GetAttribute("id"));
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                            //**

                        }
                    }
                    if (xml1.GetAttribute("xlink:href").Contains("Substation") || xml1.GetAttribute("xlink:href").Contains("Power")) {
                        string lab = xml1.GetAttribute("xlink:href");

                        float x = 0f;
                        float y = 0f;

                        x = ((Use)xml1).X;

                        y = ((Use)xml1).Y;

                        PointF p1 = new PointF(x, y);
                        PointF[] pnt = new PointF[1];
                        pnt[0] = p1;
                        Use temp = xml1.Clone() as Use;
                        temp.Transform.Matrix.TransformPoints(pnt);

                        LongLat templat = mapview.OffSetZero(-(int)(pnt[0].X * tlVectorControl1.ScaleRatio), -(int)(pnt[0].Y * tlVectorControl1.ScaleRatio));

                        string[] jd = templat.Longitude.ToString("####.####").Split('.');
                        int d1 = Convert.ToInt32(jd[0]);
                        string[] df1 = Convert.ToString(Convert.ToDecimal("0." + jd[1]) * 60).Split('.');
                        int f1 = Convert.ToInt32(df1[0]);
                        decimal m1 = Convert.ToDecimal("0." + df1[1]) * 60;

                        string[] wd = templat.Latitude.ToString("####.####").Split('.');
                        int d2 = Convert.ToInt32(wd[0]);
                        string[] df2 = Convert.ToString(Convert.ToDecimal("0." + wd[1]) * 60).Split('.');
                        int f2 = Convert.ToInt32(df2[0]);
                        decimal m2 = Convert.ToDecimal("0." + df2[1]) * 60;

                        string strjwd = "经纬度: " + d1.ToString() + "°" + f1.ToString() + "′" + m1.ToString("##.#") + "″," + d2.ToString() + "°" + f2.ToString() + "′" + m2.ToString("##.#") + "″";
                        object obj = null;
                        string deviceid = xml1.GetAttribute("Deviceid");
                        if (string.IsNullOrEmpty(deviceid)) {
                            //XmlElement n1 = tlVectorControl1.SVGDocument.CreateElement("text") as Text;
                            if (xml1.GetAttribute("xlink:href").Contains("Power")) {
                                obj = DeviceHelper.SelectDevice(DeviceType.DY, Itop.Client.MIS.ProgUID);
                                if (obj == null)
                                {
                                    tlVectorControl1.SVGDocument.CurrentElement = xml1 as SvgElement;
                                    tlVectorControl1.Delete();
                                }
                                if (obj is PSP_PowerSubstation_Info) {
                                    deviceid = ((PSP_PowerSubstation_Info)obj).UID;
                                    xml1.SetAttribute("Deviceid", deviceid);
                                }
                                substation sb = new substation();
                                sb.UID = ((PSP_PowerSubstation_Info)obj).UID;
                                sb = (substation)Services.BaseService.GetObject("SelectsubstationByKey", sb);
                                if (sb != null) {
                                    sb.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                                    sb.LayerID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                                    sb.EleID = xml1.GetAttribute("id");
                                    if (((PSP_PowerSubstation_Info)obj).Flag == "2") {
                                        sb.ObligateField3 = "规划";
                                    } else if (((PSP_PowerSubstation_Info)obj).Flag == "1") {
                                        sb.ObligateField3 = "现行";
                                    }
                                    Services.BaseService.Update<substation>(sb);
                                } else {
                                    sb = new substation();
                                    sb.UID = ((PSP_PowerSubstation_Info)obj).UID;
                                    sb.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                                    sb.EleID = xml1.GetAttribute("id");
                                    sb.LayerID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                                    if (((PSP_PowerSubstation_Info)obj).Flag == "2") {
                                        sb.ObligateField3 = "规划";
                                    } else if (((PSP_PowerSubstation_Info)obj).Flag == "1") {
                                        sb.ObligateField3 = "现行";
                                    }
                                    Services.BaseService.Create<substation>(sb);
                                }
                            } else {
                                obj = DeviceHelper.SelectDevice(DeviceType.BDZ, Itop.Client.MIS.ProgUID);
                                if (obj == null)
                                {
                                    tlVectorControl1.SVGDocument.CurrentElement = xml1 as SvgElement;
                                    tlVectorControl1.Delete();
                                }
                                if (obj is PSP_Substation_Info) {
                                    deviceid = ((PSP_Substation_Info)obj).UID;
                                    xml1.SetAttribute("Deviceid", deviceid);
                                    //RectangleF t = ((IGraph)xml1).GetBounds();
                                    //n1.SetAttribute("x", (t.X - 30).ToString());
                                    //n1.SetAttribute("y", (t.Y - 30).ToString());
                                    //n1.SetAttribute("font-size", "24");
                                    //n1.InnerText = ((PSP_Substation_Info)obj).Title;
                                    //n1.SetAttribute("layer", SvgDocument.currentLayer);
                                    //n1.SetAttribute("ParentID", temp.GetAttribute("id"));
                                    //tlVectorControl1.SVGDocument.RootElement.AppendChild(n1);
                                    //tlVectorControl1.Operation = ToolOperation.Select;
                                }
                                substation sb = new substation();
                                sb.UID = ((PSP_Substation_Info)obj).UID;
                                sb = (substation)Services.BaseService.GetObject("SelectsubstationByKey", sb);
                                if (sb != null) {

                                    sb.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                                    sb.LayerID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                                    sb.EleID = xml1.GetAttribute("id");
                                    if (((PSP_Substation_Info)obj).Flag == "2") {
                                        sb.ObligateField3 = "规划";
                                    } else if (((PSP_Substation_Info)obj).Flag == "1") {
                                        sb.ObligateField3 = "现行";
                                    }
                                    Services.BaseService.Update<substation>(sb);
                                } else {
                                    sb = new substation();
                                    sb.UID = ((PSP_Substation_Info)obj).UID;
                                    sb.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                                    sb.EleID = xml1.GetAttribute("id");
                                    sb.LayerID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                                    if (((PSP_Substation_Info)obj).Flag == "2") {
                                        sb.ObligateField3 = "规划";
                                    } else if (((PSP_Substation_Info)obj).Flag == "1") {
                                        sb.ObligateField3 = "现行";
                                    }
                                    Services.BaseService.Create<substation>(sb);
                                }
                            }
                        }
                        if (!string.IsNullOrEmpty(deviceid)) {
                            if (xml1.GetAttribute("xlink:href").Contains("Power")) {
                                obj = DeviceHelper.GetDevice<PSP_PowerSubstation_Info>(deviceid);
                                if (obj != null) {
                                    xml1.SetAttribute("info-name", ((PSP_PowerSubstation_Info)obj).Title);
                                    //XmlElement n1 = tlVectorControl1.SVGDocument.SelectSingleNode("/text[@ParentUID='" + xml1.GetAttribute("id") + "']");
                                    DeviceHelper.ShowDeviceDlg(DeviceType.DY, deviceid, false);
                                }
                                substation sb = new substation();
                                sb.UID = ((PSP_PowerSubstation_Info)obj).UID;
                                sb = (substation)Services.BaseService.GetObject("SelectsubstationByKey", sb);
                                if (sb != null) {
                                    sb.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                                    sb.LayerID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                                    sb.EleID = xml1.GetAttribute("id");
                                    if (((PSP_PowerSubstation_Info)obj).Flag == "2") {
                                        sb.ObligateField3 = "规划";
                                    } else if (((PSP_PowerSubstation_Info)obj).Flag == "1") {
                                        sb.ObligateField3 = "现行";
                                    }
                                    Services.BaseService.Update<substation>(sb);
                                } else {
                                    sb = new substation();
                                    sb.UID = ((PSP_PowerSubstation_Info)obj).UID;
                                    sb.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                                    sb.LayerID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                                    sb.EleID = xml1.GetAttribute("id");
                                    if (((PSP_PowerSubstation_Info)obj).Flag == "2") {
                                        sb.ObligateField3 = "规划";
                                    } else if (((PSP_PowerSubstation_Info)obj).Flag == "1") {
                                        sb.ObligateField3 = "现行";
                                    }
                                    Services.BaseService.Create<substation>(sb);
                                }
                            } else {
                                obj = DeviceHelper.GetDevice<PSP_Substation_Info>(deviceid);
                                if (obj != null) {
                                    xml1.SetAttribute("info-name", ((PSP_Substation_Info)obj).Title);
                                    //XmlElement n1 = tlVectorControl1.SVGDocument.SelectSingleNode("/text[@ParentUID='" + xml1.GetAttribute("id") + "']");
                                    DeviceHelper.ShowDeviceDlg(DeviceType.BDZ, deviceid, false);
                                }
                                substation sb = new substation();
                                sb.UID = ((PSP_Substation_Info)obj).UID;
                                sb = (substation)Services.BaseService.GetObject("SelectsubstationByKey", sb);
                                if (sb != null) {
                                    sb.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                                    sb.LayerID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                                    sb.EleID = xml1.GetAttribute("id");
                                    if (((PSP_Substation_Info)obj).Flag == "2") {
                                        sb.ObligateField3 = "规划";
                                    } else if (((PSP_Substation_Info)obj).Flag == "1") {
                                        sb.ObligateField3 = "现行";
                                    }
                                    Services.BaseService.Update<substation>(sb);
                                } else {
                                    sb = new substation();
                                    sb.UID = ((PSP_Substation_Info)obj).UID;
                                    sb.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                                    sb.EleID = xml1.GetAttribute("id");
                                    sb.LayerID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                                    if (((PSP_Substation_Info)obj).Flag == "2") {
                                        sb.ObligateField3 = "规划";
                                    } else if (((PSP_Substation_Info)obj).Flag == "1") {
                                        sb.ObligateField3 = "现行";
                                    }
                                    Services.BaseService.Create<substation>(sb);
                                }
                            }

                        }
                        //frmSubstationProperty frmSub = new frmSubstationProperty();
                        //frmSub.jwstr = strjwd;
                        //frmSub.InitData(xml1.GetAttribute("id"), tlVectorControl1.SVGDocument.SvgdataUid, SvgDocument.currentLayer, lab);
                        //if (frmSub.ShowDialog() == DialogResult.OK)
                        //{
                        //    xml1.SetAttribute("info-name", frmSub.Sub.EleName);
                        //    SVG_ENTITY ent = new SVG_ENTITY();
                        //    if (frmSub.IsCreate)
                        //    {
                        //        ent.SUID = Guid.NewGuid().ToString();
                        //        ent.EleID = frmSub.Sub.EleID;
                        //        ent.layerID = frmSub.Sub.LayerID;
                        //        ent.MDATE = System.DateTime.Now;
                        //        ent.NAME = frmSub.Sub.EleName;
                        //        ent.svgID = frmSub.Sub.SvgUID;
                        //        ent.TYPE = "substation";
                        //        ent.voltage = Convert.ToInt32(frmSub.Sub.ObligateField1);
                        //        Services.BaseService.Create<SVG_ENTITY>(ent);
                        //    }
                        //    else
                        //    {
                        //        ent.NAME = frmSub.Sub.EleName;
                        //        ent.layerID = frmSub.Sub.LayerID;
                        //        ent.MDATE = System.DateTime.Now;
                        //        //ent.voltage = fl.Line.Voltage;
                        //        Services.BaseService.Update<SVG_ENTITY>(ent);
                        //    }
                        //}
                    }
                    if (xml1.GetAttribute("xlink:href").Contains("XL_GT_3") || xml1.GetAttribute("xlink:href").Contains("XL_GT_4")) {
                        frmInputNum num = new frmInputNum();
                        num.InputStr = xml1.GetAttribute("order");
                        num.ShowDialog();
                        xml1.SetAttribute("order", num.InputStrSEL);
                    }
                    //if (xml1.GetAttribute("xlink:href").Contains("bdz") || xml1.GetAttribute("xlink:href").Contains("hwg") ||
                    //    xml1.GetAttribute("xlink:href").Contains("fjx") || xml1.GetAttribute("xlink:href").Contains("kbs") ||
                    //    xml1.GetAttribute("xlink:href").Contains("byq") || xml1.GetAttribute("xlink:href").Contains("kg"))
                    //{
                    //    frmInputDialog n1 = new frmInputDialog();
                    //    n1.InputStr = xml1.GetAttribute("info-name").ToString();
                    //    if (n1.ShowDialog() == DialogResult.OK)
                    //    {
                    //        xml1.SetAttribute("info-name",n1.InputStr);
                    //    }

                    //}
                    if (xml1.GetAttribute("xlink:href").Contains("kbs") || xml1.GetAttribute("xlink:href").Contains("hwg")) {
                        frmkbsProperty num = new frmkbsProperty();
                        num.InitData(((SvgElement)xml1).ID, tlVectorControl1.SVGDocument.SvgdataUid, tlVectorControl1.SVGDocument.CurrentLayer.ID);
                        num.ShowDialog();
                    }
                    if (xml1.GetAttribute("xlink:href").Contains("fjx")) {
                        frmfjxProperty num = new frmfjxProperty();
                        num.InitData(((SvgElement)xml1).ID, tlVectorControl1.SVGDocument.SvgdataUid, tlVectorControl1.SVGDocument.CurrentLayer.ID);
                        num.ShowDialog();
                    }
                    if (xml1.GetAttribute("xlink:href").Contains("byq")) {
                        frmbyqProperty num = new frmbyqProperty();
                        num.InitData(((SvgElement)xml1).ID, tlVectorControl1.SVGDocument.SvgdataUid, tlVectorControl1.SVGDocument.CurrentLayer.ID);
                        num.ShowDialog();
                    }
                    if (xml1.GetAttribute("xlink:href").Contains("SB_GT")) {
                        string lineWidth = "2";

                        string Code = xltProcessor.GetCurrentLineCode();
                        string _len = xltProcessor.GetWholeLineLength(Code).ToString("#####.####");

                        frmLineProperty fl = new frmLineProperty();
                        fl.LineNode = tlVectorControl1.SVGDocument.CurrentElement;
                        fl.InitData(Code, tlVectorControl1.SVGDocument.SvgdataUid, _len, SvgDocument.currentLayer);
                        if (fl.ShowDialog() == DialogResult.OK) {
                            //Value="stroke-dasharray:8 8;stroke-width:2;stroke:#00C000;"
                            lineWidth = fl.LineWidth;
                            string styleValue = "";
                            if (fl.Line.ObligateField1 == "规划") {
                                styleValue = "stroke-dasharray:4 4;stroke-width:" + lineWidth + ";";
                            } else {
                                styleValue = "stroke-width:" + lineWidth + ";";
                            }

                            styleValue = styleValue + "stroke:" + ColorTranslator.ToHtml(Color.FromArgb(Convert.ToInt32(fl.Line.ObligateField2)));
                            ((XmlElement)tlVectorControl1.SVGDocument.CurrentElement).RemoveAttribute("style");
                            ((XmlElement)tlVectorControl1.SVGDocument.CurrentElement).SetAttribute("style", styleValue);

                            xltProcessor.SetWholeLineAttribute(Code, "style", styleValue);
                        }
                    }

                }
                if (e.ClickedItem.Text == "移动") {
                    if (tlVectorControl1.SVGDocument.CurrentElement == null || tlVectorControl1.SVGDocument.CurrentElement.ID == "svg") {
                        return;
                    }
                    XmlElement xmln = (XmlElement)tlVectorControl1.SVGDocument.CurrentElement;
                    frmMove fm = new frmMove();
                    PointF pf11 = ((Use)xmln).CenterPoint;
                    LongLat temp = mapview.ParseToLongLat((int)pf11.X, (int)pf11.Y);
                    string[] jd = temp.Longitude.ToString("####.####").Split('.');
                    int d1 = Convert.ToInt32(jd[0]);
                    string[] df1 = Convert.ToString(Convert.ToDecimal("0." + jd[1]) * 60).Split('.');
                    int f1 = Convert.ToInt32(df1[0]);
                    decimal m1 = Convert.ToDecimal("0." + df1[1]) * 60;

                    string[] wd = temp.Latitude.ToString("####.####").Split('.');
                    int d2 = Convert.ToInt32(wd[0]);
                    string[] df2 = Convert.ToString(Convert.ToDecimal("0." + wd[1]) * 60).Split('.');
                    int f2 = Convert.ToInt32(df2[0]);
                    decimal m2 = Convert.ToDecimal("0." + df2[1]) * 60;
                    strj1 = d1.ToString();
                    strw1 = f1.ToString();
                    strd1 = m1.ToString();
                    strj2 = d2.ToString();
                    strw2 = f2.ToString();
                    strd2 = m2.ToString();
                    fm.Init(strj1, strw1, strd1, strj2, strw2, strd2);
                    if (fm.ShowDialog() == DialogResult.OK) {
                        string strValue = fm.StrValue;
                        string[] str = strValue.Split(',');
                        string[] JWD1 = str[0].Split(' ');
                        decimal J1 = Convert.ToDecimal(JWD1[0]);
                        decimal W1 = Convert.ToDecimal(JWD1[1]);
                        decimal D1 = Convert.ToDecimal(JWD1[2]);
                        string[] JWD2 = str[1].Split(' ');
                        decimal J2 = Convert.ToDecimal(JWD2[0]);
                        decimal W2 = Convert.ToDecimal(JWD2[1]);
                        decimal D2 = Convert.ToDecimal(JWD2[2]);

                        decimal JD = J1 + W1 / 60 + D1 / 3600;
                        decimal WD = J2 + W2 / 60 + D2 / 3600;

                        PointF pf1 = mapview.ParseToPoint(JD, WD);

                        PointF p1 = ((Use)xmln).CenterPoint;

                        SvgElement e1 = xmln as SvgElement;
                        Matrix matrix2 = ((IGraph)e1).GraphTransform.Matrix.Clone();
                        Matrix matrix3 = tlVectorControl1.DrawArea.CoordTransform.Clone();
                        matrix3.Invert();
                        matrix2.Multiply(matrix3, MatrixOrder.Append);
                        matrix2.Invert();
                        PointF[] pfArray1 = new PointF[] { new PointF(pf1.X / tlVectorControl1.ScaleRatio, pf1.Y / tlVectorControl1.ScaleRatio), p1 };
                        matrix2.TransformPoints(pfArray1);

                        float single1 = pfArray1[0].X - pfArray1[1].X;
                        float single2 = pfArray1[0].Y - pfArray1[1].Y;

                        Matrix matrix6 = ((IGraph)e1).Transform.Matrix.Clone();
                        if (e1.SvgAttributes.ContainsKey("transform")) {
                            Matrix matrix7 = ((Matrix)e1.SvgAttributes["transform"]).Clone();
                            matrix7.Invert();
                            matrix6.Multiply(matrix7, MatrixOrder.Append);
                        }
                        Matrix matrix5 = new Matrix();
                        matrix5.Translate(single1, single2);
                        Matrix matrix8 = ((IGraph)e1).Transform.Matrix.Clone();
                        matrix8.Multiply(matrix5);
                        matrix6.Invert();
                        matrix6.Multiply(matrix8, MatrixOrder.Append);
                        Transf tf = new Transf();
                        tf.setMatrix(matrix6);
                        (xmln as Use).Transform = tf;

                    }
                }
                if (e.ClickedItem.Text == "接线图") {
                    if (tlVectorControl1.SVGDocument.CurrentElement == null || tlVectorControl1.SVGDocument.CurrentElement.ID == "svg") {
                        return;
                    }
                    ParentUID = tlVectorControl1.SVGDocument.SvgdataUid;
                    Save();
                    ParentUID = tlVectorControl1.SVGDocument.SvgdataUid;
                    SVGFILE svg_temp = new SVGFILE();
                    //XmlElement xml1 = ((XmlElement)(e.Elements[0]));xml1.GetAttribute("id");
                    svg_temp.SUID = ((XmlElement)tlVectorControl1.SVGDocument.CurrentElement).GetAttribute("id");
                    svg_temp.FILENAME = getBdzName(svg_temp.SUID);// ((XmlElement)tlVectorControl1.SVGDocument.CurrentElement).GetAttribute("info-name");
                    string strWhere = string.Format("suid='{0}' or filename='{1}' ", svg_temp.SUID, svg_temp.FILENAME);
                    IList svglist = Services.BaseService.GetList("SelectSVGFILEByWhere", strWhere);
                    OpenJXT(svglist, svg_temp);
                    //frmlar.SymbolDoc = tlVectorControl1.SVGDocument;
                    //frmlar.Progtype = MapType;
                    //frmlar.InitData();
                    //JxtBar();
                }
                if (e.ClickedItem.Text == "打开") {
                    if (tlVectorControl1.SVGDocument.CurrentElement.ID == "svg") {
                        MessageBox.Show("请选择地块。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return;
                    }
                    UseRelating UseRel = new UseRelating();
                    UseRel.UseID = tlVectorControl1.SVGDocument.CurrentElement.ID;
                    IList<UseRelating> UseRelList = Services.BaseService.GetList<UseRelating>("SelectUseRelatingByUseID", UseRel);
                    if (UseRelList.Count < 1) {
                        MessageBox.Show("选择的地块还没有关联到其他地图,请先设置关联地图", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return;
                    }
                    UseRel = UseRelList[0];
                    SVGFILE svgFile = new SVGFILE();
                    svgFile.SUID = UseRel.LinkUID;
                    IList svgList = Services.BaseService.GetList("SelectSVGFILEByKey", svgFile);
                    if (svgList.Count < 1) {
                        MessageBox.Show("被关联的地图已经被删除,请重新设置关联地图", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return;
                    }
                    svgFile = (SVGFILE)svgList[0];
                    //SvgDocument doc = new SvgDocument();

                    if (!string.IsNullOrEmpty(svgFile.SVGDATA)) {
                        //doc.LoadXml(svgFile.SVGDATA);
                        ctlfile_OnOpenSvgDocument(sender, svgFile.SUID);
                    }

                }
                if (e.ClickedItem.Text == "区域打印") {
                    PrintHelper ph = new PrintHelper(tlVectorControl1, mapview);
                    frmPrinter dlg = new frmPrinter();
                    dlg.printHelper = ph;
                    dlg.ShowDialog();
                    return;
                    ArrayList idlist = new ArrayList();
                    ArrayList symlist = new ArrayList();

                    SvgDocument _doc = new SvgDocument();

                    Graph poly1 = tlVectorControl1.SVGDocument.CurrentElement as Graph;
                    if (poly1 == null || poly1.GetAttribute("id") == "svg") {
                        return;
                    }

                    GraphicsPath gr1 = new GraphicsPath();
                    //gr1.AddRectangle(TLMath.getRectangle(poly1));
                    gr1.AddPolygon(TLMath.getPolygonPoints(poly1));
                    //gr1.CloseFigure();
                    gr1 = (GraphicsPath)poly1.GPath.Clone();
                    gr1.Transform((poly1 as IGraph).Transform.Matrix);

                    RectangleF ef1 = gr1.GetBounds();
                    ef1 = PathFunc.GetBounds(gr1);
                    StringBuilder svgtxt = new StringBuilder("<?xml version=\"1.0\" encoding=\"utf-8\"?><svg id=\"svg\" width=\"" + ef1.Width + "\" height=\"" + ef1.Height + "\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" xmlns:itop=\"http://www.Itop.com/itop\">");

                    XmlNodeList nlist = tlVectorControl1.SVGDocument.GetElementsByTagName("defs");
                    if (nlist.Count > 0) {
                        XmlNode node = nlist[0];
                        svgtxt.AppendLine(node.OuterXml);
                    }
                    SvgElementCollection.ISvgElementEnumerator enumerator1 = tlVectorControl1.DrawArea.ElementList.GetEnumerator();// mouseAreaControl.PicturePanel.ElementList.GetEnumerator();
                    while (enumerator1.MoveNext()) {
                        IGraph graph1 = (IGraph)enumerator1.Current;

                        GraphicsPath path1 = (GraphicsPath)graph1.GPath.Clone();
                        //path1.Transform(graph1.GraphTransform.Matrix);
                        //path1.Transform(graph1.Transform.Matrix);
                        // RectangleF ef2 = path1.GetBounds();// PathFunc.GetBounds(path1);

                        //for (int n = 0; n < selCol.Count - 1; n++)
                        //{
                        //    //_doc.AppendChild((XmlNode)selCol[n]);
                        //    svgtxt = svgtxt + ((XmlElement)selCol[n]).OuterXml + "\r\n";
                        //}
                        if (!graph1.Visible || !graph1.DrawVisible || !graph1.Layer.Visible) continue;

                        GraphicsPath path2 = (GraphicsPath)graph1.GPath.Clone();
                        path2.Transform(graph1.Transform.Matrix);
                        RectangleF ef2 = PathFunc.GetBounds(path2);

                        if (ef1.Contains(ef2) || RectangleF.Intersect(ef1, ef2) != RectangleF.Empty) {

                            SvgElement ele = (SvgElement)graph1;
                            svgtxt.AppendLine(ele.OuterXml);
                            //tlVectorControl1.SVGDocument.AddSelectElement(graph1);
                            if (graph1 is Use) {
                                //PointF offset = TLMath.getUseOffset(((XmlElement)graph1).GetAttribute("xlink:href"));
                                //if (ef1.Contains(new PointF(((Use)graph1).X + offset.X, ((Use)graph1).Y + offset.Y))) {
                                //SvgElement ele = (SvgElement)graph1;
                                //svgtxt.AppendLine(ele.OuterXml);

                                string symid = ((XmlElement)graph1).GetAttribute("xlink:href");
                                if (!symlist.Contains(symid)) {
                                    symlist.Add(symid);
                                }
                                //}
                            }
                            if (graph1.GetType().FullName == "ItopVector.Core.Figure.Polyline") {
                                string IsLead = ((XmlElement)graph1).GetAttribute("IsLead");
                                if (IsLead != "") {
                                    if (ef1.Contains(ef2)) {
                                        idlist.Add(graph1.ID);
                                    }
                                }
                            }

                        }
                        //if (ef1.Contains(ef2)|| RectangleF.Intersect(ef1,ef2) !=RectangleF.Empty )
                        //{
                        //    SvgElement ele = (SvgElement)graph1;
                        //    svgtxt.AppendLine(ele.OuterXml);
                        //    //tlVectorControl1.SVGDocument.AddSelectElement(graph1);
                        //    if (graph1 is Use ) {
                        //        PointF offset = TLMath.getUseOffset(((XmlElement)graph1).GetAttribute("xlink:href"));
                        //        if (ef1.Contains(new PointF(((Use)graph1).X + offset.X, ((Use)graph1).Y + offset.Y))) {
                        //            //SvgElement ele = (SvgElement)graph1;
                        //            //svgtxt.AppendLine(ele.OuterXml);

                        //            string symid = ((XmlElement)graph1).GetAttribute("xlink:href");
                        //            if (!symlist.Contains(symid)) {
                        //                symlist.Add(symid);
                        //            }
                        //        }
                        //    }
                        //    if (graph1.GetType().FullName == "ItopVector.Core.Figure.Polyline") {
                        //        string IsLead = ((XmlElement)graph1).GetAttribute("IsLead");
                        //        if (IsLead != "") {
                        //            if (ef1.Contains(ef2)) {
                        //                idlist.Add(graph1.ID);
                        //            }
                        //        }
                        //    }
                        //}

                    }
                    symlist = ResetList(symlist);
                    svgtxt.AppendLine("</svg>");
                    _doc.LoadXml(svgtxt.ToString());
                    _doc.SvgdataUid = tlVectorControl1.SVGDocument.SvgdataUid;
                    frmPrintF pri = new frmPrintF();
                    pri.Init(tlVectorControl1.SVGDocument.CurrentElement.ID, tlVectorControl1.SVGDocument.SvgdataUid);
                    if (pri.ShowDialog() == DialogResult.OK) {
                        frmSubPrint s = new frmSubPrint();
                        s.Vector = tlVectorControl1;
                        s.InitImg(pri.strzt, pri.strgs, pri.pri, idlist, symlist);
                        s.Open(_doc, ef1);
                        s.Show();
                    }
                }
                if (e.ClickedItem.Text == "分类统计报表") {
                    if (tlVectorControl1.SVGDocument.CurrentElement == null || tlVectorControl1.SVGDocument.CurrentElement.ID == "svg") {
                        return;
                    }
                    IGraph poly1 = (IGraph)tlVectorControl1.SVGDocument.CurrentElement;
                    frmPloyPrint p = new frmPloyPrint();

                    p.InitDate(poly1.ID, tlVectorControl1.SVGDocument.SvgdataUid);
                    p.ShowDialog();
                }
                if (e.ClickedItem.Text == "保存图片") {
                    if (tlVectorControl1.SVGDocument.CurrentElement.GetType().ToString() == "ItopVector.Core.Figure.RectangleElement") {
                        //frmImgInfoInput finput = new frmImgInfoInput();
                        //if (finput.ShowDialog() == DialogResult.OK)
                        //{
                        PrintHelper ph = new PrintHelper(tlVectorControl1, mapview);
                        frmImgManager frm = new frmImgManager();
                        //frm.StrName = finput.StrName;
                        //frm.StrRemark = finput.StrRemark;
                        frm.Pic = ph.getImage();
                        frm.ShowDialog();
                        //}
                    }
                }
            } catch (Exception e1) {
                //MessageBox.Show(e1.Message);
            }
            if (e.ClickedItem.Text == "三维变电站") {
                try {
                    string strid = tlVectorControl1.SVGDocument.CurrentElement.ID;
                    substation s = new substation();
                    s.EleID = strid;
                    s.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                    s = (substation)Services.BaseService.GetObject("SelectsubstationByEleID", s);
                    ProcessStartInfo p = new ProcessStartInfo();
                    p.FileName = Application.StartupPath + "\\" + s.EleName + "\\bdz.exe";
                    p.WorkingDirectory = Application.StartupPath + "\\" + s.EleName;
                    Process.Start(p);
                } catch (Exception e1) { }
            }
            if (e.ClickedItem.Text == "更新关联变电站") {
                UpdateLine();
            }
            if (e.ClickedItem.Text == "删除") {
                Delete();
            }
        }
Esempio n. 13
0
        // See if the mouse is over a polygon's body.
        private bool MouseIsOverPolygon(Point mouse_pt, out List<Point> hit_polygon)
        {
            // Examine each polygon.
            // Examine them in reverse order to check the ones on top first.
            for (int i = Polygons.Count - 1; i >= 0; i--)
            {
                // Make a GraphicsPath representing the polygon.
                GraphicsPath path = new GraphicsPath();
                path.AddPolygon(Polygons[i].ToArray());

                // See if the point is inside the GraphicsPath.
                if (path.IsVisible(mouse_pt))
                {
                    hit_polygon = Polygons[i];
                    return true;
                }
            }

            hit_polygon = null;
            return false;
        }
Esempio n. 14
0
        public string[] GetArea(int x, int y, string LayerId)
        {
            string[] RetVal = new string[3];
            RetVal[0] = "";
            RetVal[1] = "";
            RetVal[2] = "";

            int i;
            int j;
            Layer _Layer;
            Shape _Shape;
            GraphicsPath gp = new GraphicsPath();
            IDictionaryEnumerator dicEnumerator;
            Matrix TransMatrix = new Matrix(m_TransMatrix[0], m_TransMatrix[1], m_TransMatrix[2], m_TransMatrix[3], m_TransMatrix[4], m_TransMatrix[5]);

            bool bLayerVisible;
            Theme _Theme = m_Themes.GetActiveTheme();
            if (LayerId == "")
            {
                for (j = this.Layers.Count - 1; j >= 0; j += -1)
                {
                    _Layer = this.Layers[j];

                    switch (_Layer.LayerType)
                    {
                        case ShapeType.PointCustom:
                        case ShapeType.PolyLineCustom:
                        case ShapeType.PolygonCustom:
                        case ShapeType.PolygonBuffer:
                            bLayerVisible = _Layer.Visible;
                            break;
                        default:
                            if ((_Theme == null))
                            {
                                bLayerVisible = _Layer.Visible;
                            }
                            else
                            {
                                bLayerVisible = (bool)_Theme.LayerVisibility[_Layer.ID];
                            }

                            break;
                    }

                    if (bLayerVisible == true)
                    {
                        dicEnumerator = _Layer.GetRecords(_Layer.LayerPath + "\\" + _Layer.ID).GetEnumerator();

                        switch (_Layer.LayerType)
                        {
                            case ShapeType.Polygon:
                            case ShapeType.PolygonFeature:
                            case ShapeType.PolygonCustom:
                            case ShapeType.PolygonBuffer:
                                while (dicEnumerator.MoveNext())
                                {
                                    //Traverse Shapes
                                    _Shape = (Shape)dicEnumerator.Value;
                                    gp.Reset();
                                    for (i = 0; i <= _Shape.Parts.Count - 1; i++)
                                    {
                                        gp.AddPolygon((PointF[])_Shape.Parts[i]);
                                    }
                                    gp.Transform(TransMatrix);
                                    if (gp.IsVisible(x, y))
                                    {
                                        RetVal[0] = _Layer.ID;
                                        RetVal[1] = _Shape.AreaId;
                                        if (_Layer.AreaNames.ContainsKey(_Shape.AreaId))
                                        {
                                            //Get language specific AreaName from Database if it exists
                                            RetVal[2] = _Layer.AreaNames[_Shape.AreaId].ToString();
                                        }
                                        else
                                        {
                                            //Get Shapefile Area Name
                                            RetVal[2] = _Shape.AreaName;
                                        }
                                        return (RetVal);
                                    }
                                }

                                break;
                            case ShapeType.PolyLine:
                            case ShapeType.PolyLineFeature:
                            case ShapeType.PolyLineCustom:
                                break;
                            //OPT
                            case ShapeType.Point:
                            case ShapeType.PointFeature:
                            case ShapeType.PointCustom:
                                PointF[] Pt = new PointF[1];
                                while (dicEnumerator.MoveNext())
                                {
                                    //Traverse Shapes
                                    _Shape = (Shape)dicEnumerator.Value;
                                    Pt[0] = (PointF)_Shape.Parts[0];
                                    TransMatrix.TransformPoints(Pt);
                                    gp.Reset();
                                    gp.AddEllipse(Pt[0].X - 3, Pt[0].Y - 3, 6, 6);
                                    if (gp.IsVisible(x, y))
                                    {
                                        RetVal[0] = _Layer.ID;
                                        RetVal[1] = _Shape.AreaId;
                                        if (_Layer.AreaNames.ContainsKey(_Shape.AreaId))
                                        {
                                            //Get language specific AreaName from Database if it exists
                                            RetVal[2] = (string)_Layer.AreaNames[_Shape.AreaId];
                                        }
                                        else
                                        {
                                            //Get Shapefile Area Name
                                            RetVal[2] = _Shape.AreaName;
                                        }
                                        return (RetVal);
                                    }
                                }

                                break;
                        }
                    }
                }
            }
            else
            {
                _Layer = this.Layers[LayerId];
                dicEnumerator = _Layer.GetRecords(_Layer.LayerPath + "\\" + _Layer.ID).GetEnumerator();
                switch (_Layer.LayerType)
                {
                    case ShapeType.Polygon:
                    case ShapeType.PolygonFeature:
                    case ShapeType.PolygonCustom:
                    case ShapeType.PolygonBuffer:
                        while (dicEnumerator.MoveNext())
                        {
                            //Traverse Shapes
                            _Shape = (Shape)dicEnumerator.Value;
                            gp.Reset();
                            for (i = 0; i <= _Shape.Parts.Count - 1; i++)
                            {
                                gp.AddPolygon((PointF[])_Shape.Parts[i]);
                            }
                            gp.Transform(TransMatrix);
                            if (gp.IsVisible(x, y))
                            {
                                RetVal[0] = _Layer.ID;
                                RetVal[1] = _Shape.AreaId;
                                RetVal[2] = _Shape.AreaName;
                                return (RetVal);
                            }
                        }

                        break;
                    case ShapeType.PolyLine:
                    case ShapeType.PolyLineFeature:
                    case ShapeType.PolyLineCustom:
                        break;
                    //OPT
                    case ShapeType.Point:
                    case ShapeType.PointFeature:
                    case ShapeType.PointCustom:
                        PointF[] Pt = new PointF[1];
                        while (dicEnumerator.MoveNext())
                        {
                            //Traverse Shapes
                            _Shape = (Shape)dicEnumerator.Value;
                            Pt[0] = (PointF)_Shape.Parts[0];
                            TransMatrix.TransformPoints(Pt);
                            gp.Reset();
                            gp.AddEllipse(Pt[0].X - 3, Pt[0].Y - 3, 6, 6);
                            if (gp.IsVisible(x, y))
                            {
                                RetVal[0] = _Layer.ID;
                                RetVal[1] = _Shape.AreaId;
                                RetVal[2] = _Shape.AreaName;
                                return (RetVal);
                            }
                        }

                        break;
                }
            }

            return RetVal;
        }
Esempio n. 15
0
		// bug #325502 has shown that ellipse didn't work with earlier code
		private void IsVisible_Ellipse (Graphics graphics)
		{
			using (GraphicsPath gp = new GraphicsPath ()) {
				gp.AddEllipse (new Rectangle (10, 10, 20, 20));
				Assert.IsFalse (gp.IsVisible (10, 10, graphics), "Int1");
				Assert.IsTrue (gp.IsVisible (20, 20, graphics), "Int2");
				Assert.IsFalse (gp.IsVisible (29, 29, graphics), "Int3");

				Assert.IsFalse (gp.IsVisible (10f, 10f, graphics), "Float2");
				Assert.IsTrue (gp.IsVisible (20f, 20f, graphics), "Float3");
				Assert.IsFalse (gp.IsVisible (29.4f, 29.4f, graphics), "Float4");
			}
		}
Esempio n. 16
0
    public IHitTestObject HitTest(PointF pageC, bool plotItemsOnly)
    {
      IHitTestObject hit;

      PointF layerC = GraphToLayerCoordinates(pageC);


      List<GraphicBase> specObjects = new List<GraphicBase>();
      foreach (AxisStyle style in _axisStyles)
        specObjects.Add(style.Title);
      foreach(GraphicBase gb in _legends)
        specObjects.Add(gb);

      if (!plotItemsOnly)
      {

        // do the hit test first for the special objects of the layer
        foreach (GraphicBase go in specObjects)
        {
          if (null != go)
          {
            hit = go.HitTest(layerC);
            if (null != hit)
            {
              if (null == hit.Remove && (hit.HittedObject is GraphicBase))
                hit.Remove = new DoubleClickHandler(EhTitlesOrLegend_Remove);
              return ForwardTransform(hit);
            }
          }
        }

        // first hit testing all four corners of the layer
        GraphicsPath layercorners = new GraphicsPath();
        float catchrange = 6;
        layercorners.AddEllipse(-catchrange, -catchrange, 2 * catchrange, 2 * catchrange);
        layercorners.AddEllipse(_cachedLayerSize.Width - catchrange, 0 - catchrange, 2 * catchrange, 2 * catchrange);
        layercorners.AddEllipse(0 - catchrange, _cachedLayerSize.Height - catchrange, 2 * catchrange, 2 * catchrange);
        layercorners.AddEllipse(_cachedLayerSize.Width - catchrange, _cachedLayerSize.Height - catchrange, 2 * catchrange, 2 * catchrange);
        layercorners.CloseAllFigures();
        if (layercorners.IsVisible(layerC))
        {
          hit = new HitTestObject(layercorners, this);
          hit.DoubleClick = LayerPositionEditorMethod;
          return ForwardTransform(hit);
        }



        // hit testing the axes - first a small area around the axis line
        // if hitting this, the editor for scaling the axis should be shown
        foreach (AxisStyle style in this._axisStyles)
        {
          if (style.ShowAxisLine && null != (hit = style.AxisLineStyle.HitTest(this, layerC, false)))
          {
            hit.DoubleClick = AxisScaleEditorMethod;
            return ForwardTransform(hit);
          }
        }


        // hit testing the axes - secondly now with the ticks
        // in this case the TitleAndFormat editor for the axis should be shown
        foreach (AxisStyle style in this._axisStyles)
        {
          if (style.ShowAxisLine && null != (hit = style.AxisLineStyle.HitTest(this, layerC, true)))
          {
            hit.DoubleClick = AxisStyleEditorMethod;
            return ForwardTransform(hit);
          }
        }


        // hit testing the major and minor labels
        foreach (AxisStyle style in this._axisStyles)
        {
          if (style.ShowMajorLabels && null != (hit = style.MajorLabelStyle.HitTest(this, layerC)))
          {
            hit.DoubleClick = AxisLabelMajorStyleEditorMethod;
            hit.Remove = EhAxisLabelMajorStyleRemove;
            return ForwardTransform(hit);
          }
          if (style.ShowMinorLabels && null != (hit = style.MinorLabelStyle.HitTest(this, layerC)))
          {
            hit.DoubleClick = AxisLabelMinorStyleEditorMethod;
            hit.Remove = EhAxisLabelMinorStyleRemove;
            return ForwardTransform(hit);
          }
        }



        // now hit testing the other objects in the layer
        foreach (GraphicBase go in _graphObjects)
        {
          hit = go.HitTest(layerC);
          if (null != hit)
          {
            if (null == hit.Remove && (hit.HittedObject is GraphicBase))
              hit.Remove = new DoubleClickHandler(EhGraphicsObject_Remove);
            return ForwardTransform(hit);
          }
        }
      }

      if (null != (hit = _plotItems.HitTest(this, layerC)))
      {
        if (hit.DoubleClick == null) hit.DoubleClick = PlotItemEditorMethod;
        return ForwardTransform(hit);
      }

      return null;
    }
Esempio n. 17
0
        private void contextMenuStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {
            if (tlVectorControl1.SVGDocument.RootElement == null) {
                return;
            }
            XmlElement xml1 = (XmlElement)tlVectorControl1.SVGDocument.CurrentElement;
            if (xml1 != null) {
                if (e.ClickedItem.Text == "属性") {

                    if (getlayer(SvgDocument.currentLayer, "电网规划层", tlVectorControl1.SVGDocument.getLayerList()/*"layer24288"*/)) {

                        if (xml1 == null || tlVectorControl1.SVGDocument.CurrentElement.ID == "svg") {
                            MessageBox.Show("请选择地块。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            return;
                        }
                        /*  if (xml1.GetType().ToString() == "ItopVector.Core.Figure.Polygon")
                          {
                              //string IsArea = ((XmlElement)tlVectorControl1.SVGDocument.CurrentElement).GetAttribute("IsArea");
                              //if (IsArea != "")
                              //{
                              glebeProperty _gle = new glebeProperty();
                              _gle.EleID = tlVectorControl1.SVGDocument.CurrentElement.ID;
                              _gle.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;

                              IList<glebeProperty> UseProList = Services.BaseService.GetList<glebeProperty>("SelectglebePropertyByEleID", _gle);
                              if (UseProList.Count > 0)
                              {
                                  _gle = UseProList[0];

                                  frmMainProperty f = new frmMainProperty();

                                  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"))
                                              {
                                                  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);
                                  }
                                  f.InitData(_gle, str220, str110, str66);  ////////////////////////////////////////////////////
                                  f.IsReadonly = true;
                                  f.ShowDialog();

                              }
                              //}
                          }*/

                    }
                    if (getlayer(SvgDocument.currentLayer, "城市规划层", tlVectorControl1.SVGDocument.getLayerList())/*"layer97052"*/) {
                        if (tlVectorControl1.SVGDocument.getRZBRatio() != "") {
                            rzb = tlVectorControl1.SVGDocument.getRZBRatio();
                        }
                        if (xml1.GetType().ToString() == "ItopVector.Core.Figure.Polygon") {
                            string IsArea = xml1.GetAttribute("IsArea");
                            if (IsArea != "") {
                                frmProperty f = new frmProperty();
                                f.InitData(xml1.GetAttribute("id"), tlVectorControl1.SVGDocument.SvgdataUid, SelUseArea, rzb, SvgDocument.currentLayer);
                                f.IsReadonly = true;
                                f.ShowDialog();
                            }
                        }
                    }
                    if (xml1 == null) return;
                    if (xml1.GetType().ToString() == "ItopVector.Core.Figure.Line" || xml1.GetType().ToString() == "ItopVector.Core.Figure.Polyline") {
                        string IsLead = xml1.GetAttribute("IsLead");
                        if (IsLead != "") {
                            frmLineProperty fl = new frmLineProperty();
                            fl.InitData(xml1.GetAttribute("id"), tlVectorControl1.SVGDocument.SvgdataUid, LineLen, SvgDocument.currentLayer);
                            fl.IsReadonly = true;
                            fl.ShowDialog();
                        }
                    }
                    if (xml1.GetAttribute("xlink:href").Contains("Substation")) {
                        string lab = xml1.GetAttribute("xlink:href");
                        frmSubstationProperty frmSub = new frmSubstationProperty();
                        frmSub.InitData(xml1.GetAttribute("id"), tlVectorControl1.SVGDocument.SvgdataUid, SvgDocument.currentLayer, lab);
                        frmSub.IsReadonly = true;
                        frmSub.ShowDialog();
                    }
                    if (tlVectorControl1.Operation == ToolOperation.InterEnclosure) {
                        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")) {
                                            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);
                            }
                            glebeProperty _gle = new glebeProperty();
                            _gle.EleID = tlVectorControl1.SVGDocument.CurrentElement.ID;
                            _gle.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;

                            IList<glebeProperty> UseProList = Services.BaseService.GetList<glebeProperty>("SelectglebePropertyByEleID", _gle);
                            if (UseProList.Count > 0) {
                                _gle = UseProList[0];
                                _gle.LayerID = SvgDocument.currentLayer;
                                frmMainProperty f = new frmMainProperty();
                                f.simpleButton4.Visible = false;
                                f.InitData(_gle, str220, str110, str66);
                                //f.InitData(_gle, str220, str110, str66);  ////////////////////////////////////////////////////
                                f.IsReadonly = true;
                                f.ShowDialog();
                                //if (f.checkBox1.Checked == false)
                                //{
                                tlVectorControl1.SVGDocument.RootElement.RemoveChild(tlVectorControl1.SVGDocument.CurrentElement);
                                //}
                                //tlVectorControl1.Refresh();
                            }
                            //}
                        }
                    }
                    tlVectorControl1.SVGDocument.CurrentElement = null;
                }

                if (e.ClickedItem.Text == "接线图") {
                    pid = tlVectorControl1.SVGDocument.SvgdataUid;
                    SVGFILE svg_temp = new SVGFILE();
                    svg_temp.SUID = xml1.GetAttribute("id");
                    IList svglist = Services.BaseService.GetList("SelectSVGFILEByKey", svg_temp);
                    if (svglist.Count > 0) {
                        svg_temp = (SVGFILE)svglist[0];
                        SvgDocument sdoc = new SvgDocument();
                        sdoc.LoadXml(svg_temp.SVGDATA);
                        tlVectorControl1.SVGDocument = sdoc;
                        tlVectorControl1.SVGDocument.SvgdataUid = svg_temp.SUID;
                        MapType = "所内接线图";
                    } else {
                        tlVectorControl1.NewFile();
                        tlVectorControl1.IsPasteGrid = false;
                        tlVectorControl1.IsShowGrid = false;
                        tlVectorControl1.IsShowRule = false;
                        tlVectorControl1.IsShowTip = false;
                        tlVectorControl1.SVGDocument.SvgdataUid = svg_temp.SUID;
                        MapType = "所内接线图";
                    }
                    if (tlVectorControl1.SVGDocument.getLayerList().Count == 0) {
                        Layer _lar = ItopVector.Core.Figure.Layer.CreateNew("接线图", tlVectorControl1.SVGDocument);
                        _lar.SetAttribute("layerType", "所内接线图");
                        _lar.Visible = true;
                        SvgDocument.currentLayer = ((Layer)tlVectorControl1.SVGDocument.getLayerList()[0]).ID;
                    }
                    CreateComboBox();

                    ButtonEnb(true);
                    LoadImage = false;
                    bk1.Visible = false;
                    selLar = "";
                    tlVectorControl1.Refresh();
                }
            }
        }
Esempio n. 18
0
		/// <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
			{
				PointF[] pathPoints = GetCurvePoints(_points);
				GraphicsPath gp = new GraphicsPath();
				if (_points.IsClosed)
					gp.AddClosedCurve(pathPoints);
				else
					gp.AddCurve(pathPoints);
				return gp.IsVisible(point);
			}
			finally
			{
				base.ResetCoordinateSystem();
			}
		}
Esempio n. 19
0
 /// <summary>
 /// gets if the fader or diamond at the given position would be hit by the given point
 /// </summary>
 private bool HitsSlider(Graphics gr, double pos, bool flip, bool diamond, Point pt, ref Point offset)
 {
     using (GraphicsPath path = new GraphicsPath()) {
         Rectangle fader = PosToRectangle(pos);
         offset = new Point(pt.X - (fader.X + fader.Width/2),
                            pt.Y - (fader.Y + fader.Height/2));
         path.AddPolygon(diamond
                             ? GetDiamondPolygon(fader, flip)
                             : GetFaderPolygon(fader, flip));
         return path.IsVisible(pt);
     }
 }
Esempio n. 20
0
        private void DrawChart(ref Graphics g, Theme _Theme, Matrix mTransMatrix, RectangleF CurExt, bool bSearch, float PtX, float PtY, ref string LayerId, ref string AreaId, ref GraphicsPath gPath)
        {
            #region "-- local Variables --"

            int i;

            Brush[] BrIS = new Brush[(_Theme.IndicatorColor.Length * _Theme.SubgroupFillStyle.Length)];

            StringFormat _StringFormat = new StringFormat();
            _StringFormat.Alignment = StringAlignment.Center;
            _StringFormat.LineAlignment = StringAlignment.Center;
            _StringFormat.FormatFlags = StringFormatFlags.NoClip;

            for (i = 0; i <= _Theme.SubgroupFillStyle.Length - 1; i++)
            {
                BrIS[i] = new SolidBrush(Color.FromArgb(int.Parse(_Theme.SubgroupFillStyle[i])));
            }

            int VisibleTimePeriods = 0;
            int SpCnt = 0;                      // ChartSeriesNames (Subgroup / Source) visible count.
            int TotalBarColumns = 0;            // Totol Bar columns to draw for ONE Area
            int BarCtr = 0;
            int TimeVisibleCtr = 0;              // TimePeriod Counter for visible TimePeriods.
            int LineCtr = 0;
            float ColumnGap = 0;                // Distance between Column Charts of two consecutive TimePeriods
            double UnitWidth;
            decimal MaxData = _Theme.Maximum;
            float MapTop = m_FullExtent.Top;
            Font TextFont = null;               // maximum limit for Text Size of chart data value.
            Brush ChartDataLabelBrush = null;
            Font ChartAxisLabelFont = null;
            Brush ChartAxisLabelBrush = null;

            float TextFontSize = 6.2F;           // Text size for Chart data value.
            decimal DataValue = 0;
            PointF Pt = new PointF();
            PointF[] Pts = new PointF[] { Pt };
            PointF[] PtData = new PointF[1];
            PointF[] LeaderPts = new PointF[2];
            Pen PnLeader = new Pen(_Theme.ChartLeaderColor, _Theme.ChartLeaderWidth);
            PointF Centroid = new PointF(0, 0);
            GraphicsPath gpShp = new GraphicsPath();
            AreaInfo _AreaInfo;
            string[] DataArr;
            Hashtable ChartData = null; // Collection of TimePeriod wise delimited DataValue for multiple Subgroup/Source
            string ChartMRD = string.Empty;
            bool DataFoundForTimePeriod = false;

            //-- Pie variables
            float StartAngle = 0;     // Start angle for first Pie section , starting from 0 degree in clockwise direction
            float PieAngle = 0;
            float PieDiameter = 0;
            float PieMinDiameter = 0;
            float PieMaxDiameter = 0;
            decimal DataValueSum = 0;   // sum
            RectangleF ChartExtent = new RectangleF();  // Applicable for Pie & Line Chart

            // Line variables
            PointF LineStartPoint = new PointF();
            PointF LineEndPoint = new PointF();
            PointF[] LinePoints = new PointF[2];
            object[] LineSubgroupPoints = null; // Line points for visible Subgroup for any TimePeriod
            float LineChartYAxisLenght = 0F;
            float LineThickness = (float)_Theme.ChartLineThickness;
            bool AxisDrawn = false;         // indicates whether X, Y Axis are drawn one time.
            PointF AxisPoint1 = new PointF();
            PointF AxisPoint2 = new PointF();
            PointF[] AxisPoints = new PointF[2];
            decimal LineMaxDataValue = 0;

            PnLeader.DashStyle = _Theme.ChartLeaderStyle;
            #endregion

            //-- visible series - Subgroups / Sources
            string[] ChartVisibleSeries;

            if (_Theme.ChartSeriestype == ChartSeriesType.Subgroup)
            {
                ChartVisibleSeries = _Theme.SubgroupVisible;
            }
            else
            {
                ChartVisibleSeries = _Theme.SourceVisible;
            }

            //- Count Visible Series (either Subgroup Or Sources)
            for (i = 0; i <= ChartVisibleSeries.Length - 1; i++)
            {
                if (ChartVisibleSeries[i] == "1")
                    SpCnt += 1;
            }

            //-- Set TextFont Size on the basis of Map's Current Extent
            if (CurExt.Width < 40 && CurExt.Width >= 25)
            {
                TextFontSize = 7;
            }
            else if (CurExt.Width < 25)
            {
                TextFontSize = 8;
            }
            //TextFont = new Font(_Theme.LabelFont.Name, TextFontSize);

            //-- Set Font used to render Data Value & Chart Axis Labels
            CustomLabelSetting labelSetting = _Theme.ChartDataLabelSettings;
            if (labelSetting == null)
            {
                labelSetting = new CustomLabelSetting();
            }
            TextFont = labelSetting.LabelFont;
            ChartDataLabelBrush = new SolidBrush(labelSetting.LabelColor);

            labelSetting = _Theme.ChartAxisLabelSettings;
            if (labelSetting == null)
            {
                labelSetting = new CustomLabelSetting();
            }
            ChartAxisLabelFont = labelSetting.LabelFont;
            ChartAxisLabelBrush = new SolidBrush(labelSetting.LabelColor);

            //*** Bugfix / Enhancement 02 May 2006 Controling chart width
            //*** Bugfix / Enhancement 15 Jun 2006 Controling chart width
            //*** Set the unit width to 1/20th of the Screen width.
            //*** If there are multiple subgroup that should be accomodated then they should be accomodated within unit width
            //*** Set Width of Bars based on FullExtentWidth(/) + Subgroup Count(\) + Chart Size(/)
            UnitWidth = ((m_FullExtent.Width) / (SpCnt * 20)) * Math.Pow(1.5, _Theme.ChartWidth - 10);
            //UnitWidth = ((m_FullExtent.Width) / (50)) + ((float)_Theme.ChartWidth /  20);
            //Exponential Rise (_Theme.ChartWidth / 10) '
            //UnitWidth = (1 / SpCnt) * (_Theme.ChartWidth / 10) '*** Set Width of Bars based on FullExtentWidth(/) + Subgroup Count(\) + Chart Size(/)
            ColumnGap = (float)((UnitWidth * 0.5) * (_Theme.ColumnsGap));

            Theme _ATheme = m_Themes.GetActiveTheme();
            bool bLayerVisibility;

            Shape _Shape;
            //Polygon : Polyline : Point
            if (SpCnt > 0)
            {
                // and calculate the PieDiameter (Max & Min) on the basis of Map FullExtent.
                // Maximum PieDiameter is kept at 1/5 th of FullExtent.
                if (_Theme.ChartType != ChartType.Column)
                {

                    if ((PieMaxDiameter < m_FullExtent.Height / 5F) || (PieMaxDiameter < m_FullExtent.Width / 5F))
                    {
                        //- max
                        if (m_FullExtent.Height > m_FullExtent.Width)
                        {
                            PieMaxDiameter = (m_FullExtent.Width) / 5F;
                        }
                        else
                        {
                            PieMaxDiameter = (m_FullExtent.Height) / 5F;
                        }
                        //- Validate Maximum Piediameter shoukd be > 3F
                        if (PieMaxDiameter < 3F)
                        {
                            PieMaxDiameter = 3F;
                        }
                        //- Mimimum PieDiameter is Kept 1/3rd of Maximim.
                        PieMinDiameter = PieMaxDiameter * 0.3F;
                    }

                    //-- Maximum Diameter must be less than Total Extent / 5
                    if ((PieMaxDiameter > CurExt.Width / 4))
                    {
                        PieMaxDiameter = CurExt.Width / 4;
                        //- Mimimum PieDiameter is Kept 1/3rd of Maximim.
                        PieMinDiameter = PieMaxDiameter * 0.3F;
                    }
                }

                //*** If all subgroup are unchecked then no need of rendering
                foreach (Layer Lyr in Layers)
                {
                    //--Reset Chart variables
                    StartAngle = 0;
                    PieAngle = 0;
                    DataValueSum = 0;
                    AxisDrawn = false;
                    VisibleTimePeriods = 0;

                    //Traverse Layers collection
                    if ((_ATheme == null))
                    {
                        bLayerVisibility = Lyr.Visible;
                    }
                    else
                    {
                        if (_ATheme.LayerVisibility[Lyr.ID] == null)
                        {
                            bLayerVisibility = false;
                        }
                        else
                        {
                            bLayerVisibility = (bool)_ATheme.LayerVisibility[Lyr.ID];
                        }
                    }
                    if (Lyr.LayerType == ShapeType.Polygon & bLayerVisibility == true & Lyr.Extent.IntersectsWith(CurExt))
                    {
                        // Render layer only if it lies within current map extent
                        Hashtable ht = Lyr.GetRecords(Lyr.LayerPath + "\\" + Lyr.ID);
                        IDictionaryEnumerator dicEnumerator = ht.GetEnumerator();
                        while (dicEnumerator.MoveNext())
                        {
                            //Traverse Shapes
                            _Shape = (Shape)dicEnumerator.Value;

                            //--Check AreaID exists in AreaIndexes. AND AreaID should NOT be excluded explicitly.
                            if (_Theme.AreaIndexes.ContainsKey(_Shape.AreaId) && _Theme.ExcludeAreaIDs.Contains(_Shape.AreaId) == false)
                            {
                                _AreaInfo = (AreaInfo)_Theme.AreaIndexes[_Shape.AreaId];

                                //-- get ChartData and ChartMRDData.
                                ChartData = _AreaInfo.ChartData;
                                ChartMRD = _AreaInfo.ChartMostRecentData;

                                //*** Get Shape Centroid
                                if (_Theme.ModifiedCharts.ContainsKey(Lyr.ID + "_" + _Shape.AreaId))
                                {
                                    //*** Get Modified Centroid for Nudged Chart
                                    Centroid = (PointF)_Theme.ModifiedCharts[Lyr.ID + "_" + _Shape.AreaId];

                                    //*** Draw Leader Line for Nudged Chart if atleast one subgroup bar is visible
                                    if (SpCnt > 0 & _Theme.ChartLeaderVisible == true)
                                    {
                                        LeaderPts[0] = Centroid;
                                        if (Lyr.LayerType == ShapeType.Polygon)
                                        {
                                            LeaderPts[1] = _Shape.Centroid;
                                        }
                                        else if (Lyr.LayerType == ShapeType.Point)
                                        {
                                            LeaderPts[1] = (PointF)_Shape.Parts[0];
                                        }
                                        mTransMatrix.TransformPoints(LeaderPts);
                                        g.DrawLine(PnLeader, LeaderPts[0], LeaderPts[1]);
                                    }
                                }
                                else
                                {
                                    //*** Get default Shape Centroid
                                    if (Lyr.LayerType == ShapeType.Polygon)
                                    {
                                        Centroid = _Shape.Centroid;
                                    }
                                    else if (Lyr.LayerType == ShapeType.Point)
                                    {
                                        Centroid = (PointF)_Shape.Parts[0];
                                    }
                                }

                                //--Reset Chart variables
                                AxisDrawn = false;
                                VisibleTimePeriods = 0;
                                DataValueSum = 0;
                                TimeVisibleCtr = 0;
                                StartAngle = 0;
                                PieAngle = 0;

                                #region "-- Set Pie / Line Chart Extent "

                                //-- Get X, Y position & Diameter of Pie Circle / Extent for Line Chart .
                                if (_Theme.ChartType == ChartType.Pie || _Theme.ChartType == ChartType.Line)
                                {
                                    //-- Pie drawn should be fitted in the Area.
                                    // so reduce the Area of Pie to 40% of Total Area Extent
                                    ChartExtent = _Shape.Extent;

                                    ChartExtent.Width = ChartExtent.Width * 0.5F;
                                    ChartExtent.Height = ChartExtent.Height * 0.5F;
                                    //-- Set the Pie Diameter according to layer's width and height
                                    if (_Theme.PieAutoSize)            //|| (!(_Theme.PieAutoSize) & _Theme.PieSize <= 0))
                                    {
                                        //-- If Shape Area is very small i.e. < Minumum Diameter set,
                                        // then
                                        if (ChartExtent.Width < PieMinDiameter || ChartExtent.Height < PieMinDiameter)
                                        {
                                            PieDiameter = PieMinDiameter;
                                        }
                                        else if (ChartExtent.Width > PieMaxDiameter && ChartExtent.Height > PieMaxDiameter)
                                        {
                                            //If PieDiameter is too high i.e. > Maximum Diameter set,
                                            PieDiameter = PieMaxDiameter;
                                        }
                                        else if (ChartExtent.Height < ChartExtent.Width)
                                        {
                                            if (ChartExtent.Height * 0.9 < PieMinDiameter)
                                            {
                                                PieDiameter = PieMinDiameter;
                                            }
                                            else
                                            {
                                                PieDiameter = ChartExtent.Height * 0.9F;
                                                //PieDiameter = PieRectExtent.Height * 0.5F + (1 - PieRectExtent.Height / PieRectExtent.Width);
                                            }
                                        }
                                        else
                                        {
                                            if (ChartExtent.Width * 0.9 < PieMinDiameter)
                                            {
                                                PieDiameter = PieMinDiameter;
                                            }
                                            else
                                            {
                                                PieDiameter = ChartExtent.Width * 0.9F;
                                                //PieDiameter = PieRectExtent.Height * 0.5F + (1 - PieRectExtent.Height / PieRectExtent.Width);
                                            }
                                            //PieDiameter = PieRectExtent.Width * 0.5F + (1 - PieRectExtent.Width / PieRectExtent.Height);
                                        }

                                        //-- Multiply by Auto size Factor value.
                                        PieDiameter *= _Theme.PieAutoSizeFactor;
                                    }
                                    else if (_Theme.PieSize > 0)
                                    {
                                        //-- Fixed size of each pie is started at minium from curExtent / 12
                                        PieMaxDiameter = CurExt.Height / 12;
                                        //-- Then add (PieSize / 10) to it.
                                        PieDiameter = (PieMaxDiameter) * (1 + (float)_Theme.PieSize / 10);
                                    }

                                    ChartExtent.Width = PieDiameter;
                                    ChartExtent.Height = PieDiameter;

                                    if (_Theme.ModifiedCharts.ContainsKey(Lyr.ID + "_" + _Shape.AreaId))
                                    {
                                        //-- IF Chart is nudged then keep Pie center on Centroid.
                                        ChartExtent.X = Centroid.X - PieDiameter * 0.5F;
                                        ChartExtent.Y = Centroid.Y - PieDiameter * 0.5F;
                                    }
                                    else
                                    {
                                        //else, Keep pie center little displaced from Centroid towards downwards
                                        ChartExtent.X = Centroid.X - PieDiameter * 0.6F;
                                        ChartExtent.Y = Centroid.Y - PieDiameter * 0.7F;
                                    }

                                    if (_Theme.ChartType == ChartType.Line)
                                    {
                                        ChartExtent.Y = Centroid.Y - ChartExtent.Height * 0.1F;
                                        ChartExtent.Height = PieDiameter;
                                        ChartExtent.Width = ChartExtent.Height * 1.4F;
                                    }
                                }

                                #endregion

                                //- Get Visible TimePeriods (used in calculating X-Axis length)
                                foreach (string KeyTimePeriod in ChartData.Keys)
                                {
                                    if ((bool)_Theme.ChartTimePeriods[KeyTimePeriod] == true)
                                    {
                                        //- Count TimePeriods only if DataValue exists for visible Subgroups
                                        string[] TempDataArr = ChartData[KeyTimePeriod].ToString().Split(',');
                                        for (i = 0; i < TempDataArr.Length; i++)
                                        {
                                            if (string.IsNullOrEmpty(TempDataArr[i]) == false)
                                            {
                                                if (ChartVisibleSeries[i] == "1")
                                                {
                                                    VisibleTimePeriods++;
                                                    break;
                                                }
                                            }
                                        }

                                    }
                                }
                                if (VisibleTimePeriods == 0 || _Theme.DisplayChartMRD)
                                {
                                    VisibleTimePeriods = 1;
                                }

                                //--Total bar column to draw for single Area. (Total Subroups * Total TimePeriod)
                                TotalBarColumns = VisibleTimePeriods * SpCnt;
                                BarCtr = 0;
                                LineSubgroupPoints = new object[ChartVisibleSeries.Length]; // holds line Points drawn

                                //-- Loop TimePeriods  for Column OR Line chart. Column/ Line will be plotted for each TimePeriod
                                foreach (string TimePeriodKey in _Theme.ChartTimePeriods.Keys)
                                {
                                    if (string.IsNullOrEmpty(TimePeriodKey.ToString()) == false)
                                    {
                                        //-- Check TimePeriod visibiliy and visibleTime < 2 for LineChart
                                        if (!(_Theme.ChartType == ChartType.Line && VisibleTimePeriods < 2))
                                        {
                                            //-- Check if TimePeriod visibilty is ON, And ChartData must have data against timePeriod
                                            if ((_Theme.ChartTimePeriods[TimePeriodKey.ToString()] == true && ChartData.ContainsKey(TimePeriodKey)) || _Theme.DisplayChartMRD)
                                            {
                                                if (TimeVisibleCtr < VisibleTimePeriods)
                                                {
                                                    TimeVisibleCtr++;
                                                }
                                                LineCtr = 0;
                                                DataValueSum = 0;
                                                DataFoundForTimePeriod = false;

                                                //-- If MRD for Chart is ON, Get mostRecent DataValues
                                                if (_Theme.DisplayChartMRD)
                                                {
                                                    DataArr = ChartMRD.Split(',');
                                                }
                                                else    //IF MRD is Off, get TimePeriodwise DataValues.
                                                {
                                                    DataArr = ChartData[TimePeriodKey].ToString().Split(',');
                                                }

                                                //-- Get sum of all dataValues, will be used in PieChart, LineChart
                                                // sum for only visible subgroups
                                                for (i = 0; i < DataArr.Length; i++)
                                                {
                                                    if (string.IsNullOrEmpty(DataArr[i]) == false)
                                                    {

                                                        decimal decVal = Convert.ToDecimal(DataArr[i], CultureInfo.InvariantCulture.NumberFormat);
                                                        if (decVal > 0 && ChartVisibleSeries[i] == "1")
                                                        {
                                                            DataFoundForTimePeriod = true;  //-- Indicates that some Data is found for visible Subgroup

                                                            //-- Round DataValues
                                                            decVal = Math.Round(decVal, _Theme.RoundDecimals);
                                                            DataArr[i] = decVal.ToString().Replace(",", ".");

                                                            DataValueSum += decVal;
                                                        }
                                                    }
                                                }

                                                // -- Get maximum DataValue for LineChart
                                                if (_Theme.ChartType == ChartType.Line)
                                                {
                                                    if (_Theme.DisplayChartMRD)
                                                    {
                                                        LineMaxDataValue = this.GetMaximumChartDataValue(DataArr);
                                                    }
                                                    else
                                                    {
                                                        LineMaxDataValue = this.GetMaximumChartDataValue(ChartData);
                                                    }
                                                    LineMaxDataValue *= 1.3M;
                                                }

                                                int j = 0;
                                                //*** Counter for Visible Series (subgroup / Sources)
                                                for (i = 0; i <= _Theme.SubgroupFillStyle.Length - 1; i++)
                                                {
                                                    if (ChartVisibleSeries[i] == "1" && DataFoundForTimePeriod)
                                                    {
                                                        BarCtr++;   //This is Nth Bar Column drawing (after increment)
                                                        try
                                                        {
                                                            if (DataArr[i] == "")
                                                            {
                                                                DataValue = 0;
                                                            }
                                                            else
                                                            {
                                                                DataValue = Convert.ToDecimal(Conversion.Val(DataArr[i]), CultureInfo.InvariantCulture.NumberFormat);
                                                                //DataValue = (decimal)Microsoft.VisualBasic.Conversion.Val(DataArr[i]);
                                                                //Cdbl
                                                            }

                                                            //-- If DataValue is NOT Zero, NOT Pie chart
                                                            if (DataArr[i] != "" && DataValueSum != 0)
                                                            {
                                                                #region "-- Column --"

                                                                if (_Theme.ChartType == ChartType.Column)
                                                                {
                                                                    Pt = Centroid;
                                                                    if (_Theme.ModifiedCharts.ContainsKey(Lyr.ID + "_" + _Shape.AreaId))
                                                                    {
                                                                        Pt.X = Pt.X + ((BarCtr - 1) * (float)UnitWidth) + (ColumnGap * (TimeVisibleCtr - 1));
                                                                    }
                                                                    else
                                                                    {
                                                                        //-Chart Mid point should coincide with the Centroid of Shape
                                                                        //- get Totol width of Column Chart , and get mid point of chart
                                                                        float ChartWidth = (float)(UnitWidth * TotalBarColumns) + ((VisibleTimePeriods - 1) * ColumnGap);

                                                                        Pt.X = Pt.X - ChartWidth / 2F + ((BarCtr - 1) * (float)UnitWidth) + (ColumnGap * (TimeVisibleCtr - 1));
                                                                        //Pt.Y = Pt.Y + (_Shape.Extent.Height) / 20;
                                                                        Pt.Y = Pt.Y - (CurExt.Height) / 40;
                                                                    }

                                                                    Pts = new PointF[4];
                                                                    Pts[0] = Pt;
                                                                    //1st

                                                                    Pt.X = Pt.X + (float)UnitWidth;
                                                                    Pts[1] = Pt;
                                                                    //2nd

                                                                    //*** Bugfix / Enhancement 15 Jun 2006 Controling Chart Height
                                                                    //*** Set Height of Bars based on FullExtentWidth(/) + DataValue(\) + Chart Size(/)
                                                                    Pt.Y = Pt.Y + (float)((m_FullExtent.Height / 2) * (float)(DataValue / MaxData) * Math.Pow(1.5, _Theme.ChartSize - 10));
                                                                    // exponential rise (_Theme.ChartSize / 10))

                                                                    //--AXIS X & Y
                                                                    //-- First Draw the X for Column Chart.
                                                                    //-- Axis should be drawn only first time.
                                                                    // Axis for Column to be drawn only for multiple TimePeriods.
                                                                    gpShp.Reset();
                                                                    if (AxisDrawn == false && _Theme.DisplayChartMRD == false)
                                                                    {
                                                                        //--Get Origin of Axis to be drawn, starting near first Column bar.
                                                                        //- Get coordinates of First Column bar
                                                                        AxisPoint1 = Centroid;
                                                                        if (_Theme.ModifiedCharts.ContainsKey(Lyr.ID + "_" + _Shape.AreaId))
                                                                        {
                                                                        }
                                                                        else
                                                                        {
                                                                            //-Chart Mid point should coincide with the Centroid of Shape
                                                                            //- get Totol width of Column Chart , and get mid point of chart
                                                                            float ChartWidth = (float)(UnitWidth * TotalBarColumns) + ((VisibleTimePeriods - 1) * ColumnGap);

                                                                            AxisPoint1.X = AxisPoint1.X - ChartWidth / 2F;
                                                                            AxisPoint1.Y = Pts[0].Y;
                                                                        }

                                                                        //-- Adding Axis buffer
                                                                        AxisPoint1.X = AxisPoint1.X - ((float)UnitWidth / 6F);
                                                                        AxisPoint1.Y = AxisPoint1.Y;

                                                                        AxisPoint2.X = AxisPoint1.X + ((float)UnitWidth * TotalBarColumns) + (ColumnGap * (VisibleTimePeriods - 1)) + ((float)UnitWidth / 3F);

                                                                        AxisPoint2.Y = AxisPoint1.Y;

                                                                        // X Axis
                                                                        if (_Theme.ShowChartAxis)
                                                                        {
                                                                            //gpShp.AddLine(AxisPoint1, AxisPoint2);
                                                                            AxisPoints[0] = AxisPoint1;
                                                                            AxisPoints[1] = AxisPoint2;
                                                                            mTransMatrix.TransformPoints(AxisPoints);
                                                                            g.DrawLine(new Pen(new SolidBrush(_Theme.ChartAxisColor), 1), AxisPoints[0], AxisPoints[1]);
                                                                        }
                                                                        AxisDrawn = true;
                                                                        AxisPoint1.X += (float)UnitWidth / 6F;
                                                                        AxisPoint2.X -= 0.1F;
                                                                    }

                                                                    if (Pt.Y > MapTop)
                                                                    {
                                                                        // ReDimStatement not supported in C#, so Pts array is copied into new array PtsTemp
                                                                        PointF[] PtsTemp = new PointF[7];      //PtsTemp[] is resized as desired
                                                                        Array.Copy(Pts, PtsTemp, Math.Min(Pts.Length, PtsTemp.Length));
                                                                        Pts = PtsTemp;      // PtsTemp elements are copied back into Pts[]

                                                                        Pt.Y = MapTop - 2 * (float)UnitWidth;
                                                                        Pts[2] = Pt;
                                                                        //3rd
                                                                        Pt.X = Pt.X - (float)UnitWidth / 4;
                                                                        Pts[3] = Pt;
                                                                        //4rd
                                                                        Pt.Y = Pt.Y - (float)UnitWidth / 4;
                                                                        Pt.X = Pt.X - (float)UnitWidth / 4;
                                                                        Pts[4] = Pt;
                                                                        //5th
                                                                        Pt.Y = MapTop - 2 * (float)UnitWidth;
                                                                        Pts[5] = Pt;
                                                                        //6th
                                                                        Pt.X = Pt.X - (float)UnitWidth / 2;
                                                                        Pts[6] = Pt;
                                                                        //7th
                                                                        //gpShp.Reset();
                                                                        gpShp.AddPolygon(Pts);

                                                                        //*** Set Bar Break
                                                                        Array.Clear(Pts, 0, 7);
                                                                        Pt.Y = Pt.Y + (float)UnitWidth / 4;
                                                                        Pts[0] = Pt;
                                                                        Pt.X = Pt.X + (float)UnitWidth / 2;
                                                                        Pts[1] = Pt;
                                                                        Pt.Y = Pt.Y + (float)UnitWidth / 4;
                                                                        Pt.X = Pt.X + (float)UnitWidth / 4;
                                                                        Pts[2] = Pt;
                                                                        Pt.Y = Pt.Y - (float)UnitWidth / 4;
                                                                        Pts[3] = Pt;
                                                                        Pt.X = Pt.X + (float)UnitWidth / 4;
                                                                        Pts[4] = Pt;
                                                                        Pt.Y = MapTop - (float)UnitWidth;
                                                                        Pts[5] = Pt;
                                                                        Pt.X = Pt.X - (float)UnitWidth;
                                                                        Pts[6] = Pt;
                                                                        //gpShp.AddPolygon(Pts);
                                                                    }
                                                                    else
                                                                    {
                                                                        Pts[2] = Pt;
                                                                        //3rd
                                                                        Pt.X = Pt.X - (float)UnitWidth;
                                                                        Pts[3] = Pt;
                                                                        //4th
                                                                        //gpShp.Reset();
                                                                        //gpShp.AddPolygon(Pts);
                                                                    }

                                                                    //-- Add Bar polygon
                                                                    gpShp.AddPolygon(Pts);
                                                                }

                                                                #endregion

                                                                #region "-- LINE --"

                                                                if (_Theme.ChartType == ChartType.Line)
                                                                {
                                                                    LineCtr++;

                                                                    //-- First Draw the X, Y axis for Line Chart.
                                                                    //-- Axis should be drawn only first time.
                                                                    gpShp.Reset();
                                                                    if (AxisDrawn == false && VisibleTimePeriods > 1)
                                                                    {

                                                                        // X Axis
                                                                        AxisPoint1 = new PointF(ChartExtent.Left, ChartExtent.Top);
                                                                        AxisPoint2 = new PointF(ChartExtent.Left + ChartExtent.Width, ChartExtent.Top);

                                                                        if (_Theme.ShowChartAxis)
                                                                        {
                                                                            //gpShp.AddLine(AxisPoint1, AxisPoint2);
                                                                            AxisPoints[0] = AxisPoint1;
                                                                            AxisPoints[1] = AxisPoint2;
                                                                            mTransMatrix.TransformPoints(AxisPoints);
                                                                            g.DrawLine(new Pen(new SolidBrush(_Theme.ChartAxisColor), 1), AxisPoints[0], AxisPoints[1]);
                                                                        }

                                                                        // Y Axis
                                                                        AxisPoint2 = new PointF(ChartExtent.Left, ChartExtent.Top + ChartExtent.Height);
                                                                        if (_Theme.ShowChartAxis)
                                                                        {
                                                                            //gpShp.AddLine(AxisPoint1, AxisPoint2);
                                                                            AxisPoints[0] = AxisPoint1;
                                                                            AxisPoints[1] = AxisPoint2;
                                                                            mTransMatrix.TransformPoints(AxisPoints);
                                                                            g.DrawLine(new Pen(new SolidBrush(_Theme.ChartAxisColor), 1), AxisPoints[0], AxisPoints[1]);
                                                                        }

                                                                        // Get Y Axis height
                                                                        LineChartYAxisLenght = ChartExtent.Height;

                                                                        // - Get horizontal distance between two consecutive points
                                                                        UnitWidth = ChartExtent.Width / (VisibleTimePeriods + 1);

                                                                        // -- Set Start Point same as
                                                                        LineStartPoint = new PointF(ChartExtent.Left + (float)(UnitWidth * TimeVisibleCtr), ChartExtent.Top + (float)(DataValue / LineMaxDataValue) * LineChartYAxisLenght);

                                                                        AxisDrawn = true;
                                                                    }

                                                                    //-- Draw Points for given DataValue
                                                                    LineEndPoint = new PointF(ChartExtent.Left + (float)(UnitWidth * TimeVisibleCtr), ChartExtent.Top + (float)(DataValue / LineMaxDataValue) * LineChartYAxisLenght);

                                                                    if (LineSubgroupPoints[i] != null)
                                                                    {
                                                                        //-- Join  Line from previous Point to New Point
                                                                        //-  In first loop, line will start from origin
                                                                        LineStartPoint = (PointF)LineSubgroupPoints[i];
                                                                        //PointF[] Line = { LineStartPoint, LineEndPoint, new PointF(LineEndPoint.X, LineEndPoint.Y - 0.02F), new PointF(LineStartPoint.X, LineStartPoint.Y - 0.02F) };
                                                                        //gpShp.AddPolygon(Line);
                                                                        LinePoints = new PointF[] { LineStartPoint, LineEndPoint };
                                                                        mTransMatrix.TransformPoints(LinePoints);
                                                                        g.DrawLine(new Pen(BrIS[i], LineThickness), LinePoints[0], LinePoints[1]);
                                                                    }
                                                                    //-- Draw a dot circle on Point
                                                                    float PointDiameter = CurExt.Height / 400;
                                                                    gpShp.AddEllipse(LineEndPoint.X - PointDiameter, LineEndPoint.Y - PointDiameter, PointDiameter * 2, PointDiameter * 2);

                                                                    //- Set End point as Starting point for next Point to draw.
                                                                    LineSubgroupPoints[i] = LineEndPoint;
                                                                }
                                                                #endregion

                                                                #region "-- PIE --"

                                                                else if (_Theme.ChartType == ChartType.Pie)
                                                                {
                                                                    if (!(string.IsNullOrEmpty(DataArr[i])) && DataValue > -1 && DataValueSum > 0)
                                                                    {
                                                                        //--Increment Start Angle for next Pie in loop
                                                                        StartAngle += PieAngle;

                                                                        if (j == SpCnt - 1)
                                                                        {
                                                                            PieAngle = 360 - StartAngle;
                                                                        }
                                                                        else
                                                                        {
                                                                            PieAngle = (int)(DataValue / DataValueSum * 360);    // (decimal.Parse(DataArr[i])
                                                                        }
                                                                        gpShp.Reset();
                                                                        //gpShp.AddPie((int)(PieRectExtent.X + PieRectExtent.Width * 0.5), (int)(PieRectExtent.Y + PieRectExtent.Height * 0.4), (int)(PieRectExtent.Height * 0.5), (int)(PieRectExtent.Height * 0.5), StartAngle, PieAngle);
                                                                        //gpShp.AddPie((int)(PieRectExtent.X), (int)PieRectExtent.Y, (int)PieRectExtent.Width , (int)PieRectExtent.Height, StartAngle, PieAngle);
                                                                        if (StartAngle == 0 && PieAngle == 360)
                                                                        {
                                                                            gpShp.AddEllipse(ChartExtent);
                                                                        }
                                                                        else
                                                                        {
                                                                            gpShp.AddPie(ChartExtent.X, ChartExtent.Y, ChartExtent.Width, ChartExtent.Height, StartAngle, PieAngle);
                                                                        }

                                                                    }
                                                                }

                                                                #endregion

                                                                #region "-- Draw Chart Shape --"

                                                                //*** Draw Column or Pie, or Line Chart
                                                                gpShp.Transform(mTransMatrix);

                                                                if (bSearch)
                                                                {
                                                                    if (gpShp.IsVisible(PtX, PtY))
                                                                    {
                                                                        AreaId = _Shape.AreaId;
                                                                        LayerId = Lyr.ID;
                                                                    }
                                                                    if (_Theme.ChartType == ChartType.Column)
                                                                    {
                                                                        gPath.AddPolygon(Pts);
                                                                    }
                                                                    else if (_Theme.ChartType == ChartType.Line)
                                                                    {
                                                                        gPath.AddRectangle(ChartExtent);
                                                                    }
                                                                    else if (_Theme.ChartType == ChartType.Pie)
                                                                    {
                                                                        gPath.AddPie(ChartExtent.X, ChartExtent.Y, ChartExtent.Width, ChartExtent.Height, StartAngle, PieAngle);
                                                                    }
                                                                }
                                                                else
                                                                {
                                                                    g.SmoothingMode = SmoothingMode.AntiAlias;
                                                                    g.PixelOffsetMode = PixelOffsetMode.HighQuality;
                                                                    //PathGradientBrush LBrush = new PathGradientBrush(gpShp);
                                                                    //LBrush.SurroundColors = new Color[] { Color.Red, Color.Green, Color.Blue };
                                                                    // LBrush.CenterColor = Color.Gray;

                                                                    g.FillPath(BrIS[i], gpShp);  //LBrush

                                                                    //LBrush.Dispose();
                                                                    if (_Theme.ChartType == ChartType.Pie)
                                                                    {
                                                                        //-- In case of Pie, draw shape border with gray
                                                                        g.DrawPath(Pens.DarkGray, gpShp);
                                                                    }
                                                                    else
                                                                    {
                                                                        g.DrawPath(Pens.Black, gpShp);
                                                                    }

                                                                    //*** Draw Data Value
                                                                    // Draw data Value if DataValueSum is >0 OR ( visible TimePeriods >= 2 in Line Chart)
                                                                    if (!(string.IsNullOrEmpty(DataArr[i])) && (_Theme.DisplayChartData == true && DataValueSum != 0) && (!(_Theme.ChartType == ChartType.Line && VisibleTimePeriods < 2)))
                                                                    {
                                                                        //--DataValue Label's X, Y position
                                                                        switch (_Theme.ChartType)
                                                                        {
                                                                            case ChartType.Column:
                                                                                Pt.X = Pt.X + (float)UnitWidth / 2;
                                                                                Pt.Y = Pt.Y;        // + 0.4F;
                                                                                break;
                                                                            case ChartType.Pie:
                                                                                //--Label's X, Y position will be calculated
                                                                                // on the basis of StartAngle & PieAngle of next subsequent Pie.
                                                                                if (!(string.IsNullOrEmpty(DataArr[i])) && DataValue > -1 && DataValueSum > 0)
                                                                                {
                                                                                    //- X
                                                                                    double angle;
                                                                                    angle = Math.PI * (StartAngle + (PieAngle / 2)) / 180.0;
                                                                                    double p = Math.Cos(angle);
                                                                                    Pt.X = (float)(((ChartExtent.Left + ChartExtent.Right) / 2) + (ChartExtent.Width / 1.7) * p);

                                                                                    //-Y
                                                                                    p = Math.Sin(angle);
                                                                                    Pt.Y = (float)(((ChartExtent.Top + ChartExtent.Bottom) / 2) + (ChartExtent.Height / 1.7) * p);
                                                                                }
                                                                                break;
                                                                            case ChartType.Line:
                                                                                Pt = LineEndPoint;
                                                                                Pt.Y += CurExt.Height / 100;    //- Drawing dataValue at some distance from actual plotted point.
                                                                                break;
                                                                        }

                                                                        PtData[0] = Pt;
                                                                        mTransMatrix.TransformPoints(PtData);
                                                                        //g.DrawString(DataValue.ToString(), TextFont, SystemBrushes.WindowText, PtData[0], _StringFormat);

                                                                        //-- Draw Data Value with orientation
                                                                        this.DrawString(g, DataValue.ToString(), true, TextFont, ChartDataLabelBrush, PtData[0], _Theme.ChartDataLabelSettings.YOffset, _StringFormat, _Theme.ChartDataLabelSettings.TextOrientationAngle);
                                                                    }

                                                                }
                                                                Pts = null;
                                                                #endregion
                                                            }
                                                        }
                                                        catch (Exception ex)
                                                        {
                                                            Console.Write(ex.Message);
                                                        }

                                                        j += 1;
                                                    }
                                                    //Subgroup Visibility
                                                }// Subgroups loop ends here.

                                                //BarCtr++;   // Bar counter increment to give gap between two timeSeries
                                            }

                                            #region "-- Draw TimePeriod in X Axis--"

                                            //-- Draw TimePeriod Text in X- Axis (Applicable in Column & Line)
                                            if (!(_Theme.DisplayChartMRD) && _Theme.ShowChartAxis && ChartData.Contains(TimePeriodKey) && _Theme.ChartTimePeriods[TimePeriodKey] == true && SpCnt > 0 && _Theme.ChartType != ChartType.Pie)
                                            {
                                                if (DataValueSum != 0)
                                                {
                                                    if (_Theme.ChartType == ChartType.Column)
                                                    {
                                                        //Pt.X = AxisPoint1.X + ((float)UnitWidth * SpCnt * TimeCtr) + (float)UnitWidth;
                                                        Pt.X = AxisPoint1.X + ((float)UnitWidth * (TimeVisibleCtr - 1) * SpCnt) + (ColumnGap * (TimeVisibleCtr - 1)) + (float)UnitWidth * 0.5F * SpCnt;
                                                        Pt.Y = AxisPoint1.Y - (CurExt.Height / 90);
                                                        PtData[0] = Pt;
                                                        mTransMatrix.TransformPoints(PtData);
                                                    }
                                                    else if (_Theme.ChartType == ChartType.Line && VisibleTimePeriods > 1)
                                                    {
                                                        PtData[0].X = LineEndPoint.X;
                                                        PtData[0].Y = AxisPoint1.Y - (CurExt.Height / 70);
                                                        mTransMatrix.TransformPoints(PtData);
                                                    }

                                                    //g.DrawString(TimePeriodKey.ToString(), ChartAxisLabelFont, ChartAxisLabelBrush, PtData[0], _StringFormat);

                                                    //-- Draw Data Value with orientation
                                                    this.DrawString(g, TimePeriodKey.ToString(), false, ChartAxisLabelFont, ChartAxisLabelBrush, PtData[0], _Theme.ChartAxisLabelSettings.YOffset, _StringFormat, _Theme.ChartAxisLabelSettings.TextOrientationAngle);
                                                }
                                            }

                                            if (((_Theme.DisplayChartMRD) && _Theme.ChartType == ChartType.Column) || (_Theme.ChartType == ChartType.Pie))
                                            {
                                                break;      // in MRD case, only Only Most recent dataValue for Subgroup/ Source series will be plotted in Column chart
                                            }
                                            #endregion

                                        }
                                    }

                                } // TimePeriod Loop ends

                                //For each subgroup
                                if (bSearch)
                                {
                                    if (AreaId != "")
                                    {
                                        gPath.Transform(mTransMatrix);
                                        return;
                                    }
                                    //TODO dispose objects
                                    //TODO case when same areaid might belong to multiple layers
                                    else
                                    {
                                        gPath.Reset();
                                    }
                                }
                            }
                            //Non Missing data Shapes
                        }
                        //Traverse Shapes
                    }
                    //Extent-Visibility-Type

                }
                //Traverse Layers collection

            }

            //*** Dispose
            //gPath = New GraphicsPath
            _Shape = null;
            // Pt = null;

            for (i = 0; i <= BrIS.Length - 1; i++)
            {
                BrIS[i].Dispose();
            }
            PnLeader.Dispose();
        }
Esempio n. 21
0
        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);
        }
Esempio n. 22
0
		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");
			}
		}
Esempio n. 23
0
        /// <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;
            var _brushIndex = 0;
            foreach (var face in frame)
            {
                var parr = face.Vertices.Select(p => new PointF((float)p.X, (float)p.Y)).ToArray();
                //Verbetering 1 : Minder Calls om objecten van BRush te Disposen

                if (face.Color == Color.Orange)
                {
                    _brushIndex = 0;
                }
                else if (face.Color == Color.Red)
                {
                    _brushIndex = 1;
                }
                else if (face.Color == Color.Yellow)
                {
                    _brushIndex = 2;
                }
                else if (face.Color == Color.White)
                {
                    _brushIndex = 3;
                }
                else if (face.Color == Color.Blue)
                {
                    _brushIndex = 4;
                }
                else if (face.Color == Color.Green)
                {
                    _brushIndex = 5;
                }
                //b = _brushes[_brushIndex];

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

                Brush b;
                if (this.MouseHandling)
                {
                    if (this._selections[facePos].HasFlag(Selection.Second))
                        b = this._brushes[_brushIndex + 6];
                    else if (this._selections[facePos].HasFlag(Selection.NotPossible))
                        b = this._brushes[_brushIndex + 12];
                    else if (this._selections[facePos].HasFlag(Selection.First))
                        b = this._brushes[_brushIndex + 18];
                    else if (this._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 = this._brushes[_brushIndex];
                }
                else
                    b = this._brushes[_brushIndex];

                g.FillPolygon(b, parr);
                using (var pen = new Pen(Color.Black, 1))
                {
                    g.DrawPolygon(pen, parr);
                }

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

            using (var solidBrush = new SolidBrush(this.BackColor))
            {
                g.FillRectangle(solidBrush, 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);

            using (var solidBrush = new SolidBrush(this.BackColor))
            {
                g.FillRectangle(solidBrush, 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;
        }
Esempio n. 24
0
        // Método para detectar posición en el panel donde se dibujará el nodo
        public bool DetectarPunto(Point p)
        {
            GraphicsPath posicion = new GraphicsPath();

            posicion.AddEllipse(new Rectangle(this._posicion.X - this.dimensiones.Width / 2,
                this._posicion.Y - this.dimensiones.Height / 2,
                this.dimensiones.Width, this.dimensiones.Height));

            bool retval = posicion.IsVisible(p);
            posicion.Dispose();
            return retval;
        }
Esempio n. 25
0
 public bool IsHit(System.Drawing.Point point)
 {
     return(_Geometry.IsVisible(point));
 }
Esempio n. 26
0
        /// <summary>
        /// Determine if the specified screen point lies inside the bounding box of this
        /// <see cref="BoxObj"/>.
        /// </summary>
        /// <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
            RectangleF pixRect = _location.TransformRect( pane );

            using ( GraphicsPath path = new GraphicsPath() )
            {
                path.AddEllipse( pixRect );
                return path.IsVisible( pt );
            }
        }
Esempio n. 27
0
        private void IsVisible2(Graphics g)
        {
            // Create a path and add an ellipse.
            GraphicsPath myPath = new GraphicsPath();
            myPath.AddEllipse(0, 0, 100, 100);

            g.DrawPath(Pens.Blue, myPath);

            // Test the visibility of point (50, 50).
            bool visible = myPath.IsVisible(new PointF(50, 50), g);
            g.FillRectangle(Brushes.Green, new Rectangle(48, 48, 2, 2));
            // Show the result.
            g.DrawString("Visible = " + visible, new Font("Arial", 12), Brushes.Green, 60, 50);

            visible = myPath.IsVisible(new PointF(90, 90), g);
            g.FillRectangle(Brushes.Red, new Rectangle(88, 88, 2, 2));
            // Show the result.
            g.DrawString("Visible = " + visible, new Font("Arial", 12), Brushes.Red, 100, 90);
        }
Esempio n. 28
0
        private Rectangle GetTabImageRect(GraphicsPath tabBorderPath)
        {
            Rectangle imageRect = new Rectangle();
            RectangleF rect = tabBorderPath.GetBounds();

            //	Make it shorter or thinner to fit the height or width because of the padding added to the tab for painting
            switch (this.Alignment) {
                case TabAlignment.Top:
                    rect.Y += 4;
                    rect.Height -= 6;
                    break;
                case TabAlignment.Bottom:
                    rect.Y += 2;
                    rect.Height -= 6;
                    break;
                case TabAlignment.Left:
                    rect.X += 4;
                    rect.Width -= 6;
                    break;
                case TabAlignment.Right:
                    rect.X += 2;
                    rect.Width -= 6;
                    break;
            }

            //	Ensure image is fully visible
            if (this.Alignment <= TabAlignment.Bottom) {
                if ((this._StyleProvider.ImageAlign & NativeMethods.AnyLeftAlign) != ((ContentAlignment) 0)){
                    imageRect = new Rectangle((int)rect.X, (int)rect.Y + (int)Math.Floor((double)((int)rect.Height - 16)/2), 16, 16);
                    while (!tabBorderPath.IsVisible(imageRect.X, imageRect.Y)) {
                        imageRect.X += 1;
                    }
                    imageRect.X += 4;

                } else if ((this._StyleProvider.ImageAlign & NativeMethods.AnyCenterAlign) != ((ContentAlignment) 0)){
                    imageRect = new Rectangle((int)rect.X + (int)Math.Floor((double)(((int)rect.Right - (int)rect.X - (int)rect.Height + 2)/2)), (int)rect.Y + (int)Math.Floor((double)((int)rect.Height - 16)/2), 16, 16);
                } else {
                    imageRect = new Rectangle((int)rect.Right, (int)rect.Y + (int)Math.Floor((double)((int)rect.Height - 16)/2), 16, 16);
                    while (!tabBorderPath.IsVisible(imageRect.Right, imageRect.Y)) {
                        imageRect.X -= 1;
                    }
                    imageRect.X -= 4;

                    //	Move it in further to allow for the tab closer
                    if (this._StyleProvider.ShowTabCloser && !this.RightToLeftLayout){
                        imageRect.X -= 10;
                    }
                }
            } else {
                if ((this._StyleProvider.ImageAlign & NativeMethods.AnyLeftAlign) != ((ContentAlignment) 0)){
                    imageRect = new Rectangle((int)rect.X + (int)Math.Floor((double)((int)rect.Width - 16)/2), (int)rect.Y, 16, 16);
                    while (!tabBorderPath.IsVisible(imageRect.X, imageRect.Y)) {
                        imageRect.Y += 1;
                    }
                    imageRect.Y += 4;
                } else if ((this._StyleProvider.ImageAlign & NativeMethods.AnyCenterAlign) != ((ContentAlignment) 0)){
                    imageRect = new Rectangle((int)rect.X + (int)Math.Floor((double)((int)rect.Width - 16)/2), (int)rect.Y + (int)Math.Floor((double)(((int)rect.Bottom - (int)rect.Y - (int)rect.Width + 2)/2)), 16, 16);
                } else {
                    imageRect = new Rectangle((int)rect.X + (int)Math.Floor((double)((int)rect.Width - 16)/2), (int)rect.Bottom , 16, 16);
                    while (!tabBorderPath.IsVisible(imageRect.X, imageRect.Bottom)) {
                        imageRect.Y -= 1;
                    }
                    imageRect.Y -= 4;

                    //	Move it in further to allow for the tab closer
                    if (this._StyleProvider.ShowTabCloser && !this.RightToLeftLayout){
                        imageRect.Y -= 10;
                    }
                }
            }
            return imageRect;
        }
Esempio n. 29
0
 /// <summary>
 /// 这个的选中只是选中最外边的边框就算选中了
 /// </summary>
 /// <param name="MousePoint"></param>
 /// <returns></returns>
 public override bool isContains(PointF MousePoint)
 {
     GraphicsPath path = new GraphicsPath();
     path.AddRectangle(getGraphicsPath().GetBounds());
     return path.IsVisible(MousePoint);
     //return base.isContains(MousePoint);
 }
Esempio n. 30
0
        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;
            }
        }
Esempio n. 31
-1
 //是否包含圖形的座標
 public override bool Contains(Point point)
 {
     GraphicsPath path = new GraphicsPath();
     path.FillMode = FillMode.Winding;
     path.AddLine(StartPosition.X, StartPosition.Y, StartPosition.X + Width, StartPosition.Y + Height);
     path.Widen(new Pen(Color.AliceBlue, PATH_WIDEN));
     return path.IsVisible(point.X, point.Y);
 }