Exemplo n.º 1
0
 private PSPDEV createline(SvgElement element)
 {
     PSPDEV pspDev = new PSPDEV();
     pspDev.SUID = Guid.NewGuid().ToString();
     pspDev.EleID = element.ID;
     pspDev.SvgUID = svgid;
     PSPDEV pspDev2 = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev);
     if (pspDev2 == null) {
         pspDev.Number = -1;
         pspDev.FirstNode = -1;
         pspDev.LastNode = -1;
         pspDev.Type = "Polyline";
         pspDev.Lable = "֧·";
         pspDev.Name = element.GetAttribute("info-name");
         IList list = Services.BaseService.GetList("SelectLineInfoByWhere", "eleid='" + pspDev.EleID + "'");
         if (list.Count > 0) {
             LineInfo line = list[0] as LineInfo;
             pspDev.Name = line.LineName;
             pspDev.VoltR = double.Parse(line.Voltage);
             pspDev.LineStatus = line.ObligateField1;
             try {
                 pspDev.LineLength = double.Parse(line.Length);
             } catch { }
             pspDev.LineType = line.LineType;
         }
         Services.BaseService.Create<PSPDEV>(pspDev);
     } else {
         pspDev = pspDev2;
     }
     return pspDev;
 }
Exemplo n.º 2
0
 // Methods
 public ConnectShape(SvgElement connect)
 {
     this.graphPath = null;
     this.element = connect;
     this.id = connect.GetAttribute("id");
     this.graphPath = ((ConnectLine)connect).ConnectPath();
 }
Exemplo n.º 3
0
 /// <summary>
 /// 判断是否节点设备
 /// </summary>
 /// <param name="element">图形</param>
 /// <returns>是否是线路节点</returns>
 public bool IsNodeElement(SvgElement element)
 {
     if (element != null && element.GetAttribute(SymbolTag) != "")
     {
         if (nodeSymbolIDList.IndexOf(GetElementDevType(element).ToString()) > -1 || IsBDZElement(element))
         {
             return true;
         }
     }
     return false;
 }
Exemplo n.º 4
0
        /// <summary>
        /// 获取指定线路的总长度
        /// </summary>
        /// <param name="strlineCode">线路代码,如果代码为空,则取当前选择的线路</param>
        /// <returns>总长度</returns>
        public double GetWholeLineLength(string strLineCode)
        {
            currentElement = xltDocument.CurrentElement;
            if (strLineCode == "" && (currentElement == null || !IsNodeElement(currentElement)))
            {
                return 0;
            }
            else if (strLineCode == "")
            {
                strLineCode = currentElement.GetAttribute(NodeXLDMTag);
            }

            SvgElement bdzElement = GetBDZElement(strLineCode);
            if (bdzElement == null)
            {
                return 0;
            }

            IGraph eg = bdzElement as IGraph;
            SvgElement nextElement = null;
            foreach (ConnectLine connectLine in eg.ConnectLines)
            {
                SvgElement endEle = connectLine.EndGraph as SvgElement;
                if (endEle != null && IsNodeElement(endEle)
                     && endEle.GetAttribute(NodeXLDMTag) == strLineCode)
                {
                    nextElement = endEle;
                    break;
                }
            }

            if (nextElement == null)
            {
                return 0;
            }

            SvgElement tempElemet = GetNextNode(nextElement);
            SvgElement endElement = null;
            while (tempElemet != null)
            {
                endElement = tempElemet;
                tempElemet = GetNextNode(endElement);
            }

            IGraph e2Next = nextElement as IGraph;

            return mapView.CountLength(eg.CenterPoint, e2Next.CenterPoint) + TryMeasureGT(nextElement, endElement);
        }
Exemplo n.º 5
0
 /// <summary>
 /// 当前选中的节点设备,如果选中的不是节点设备,则返回null
 /// </summary>
 //public SvgElement CurrentNodeElement
 //{
 //    get
 //    {
 //        currentElement = xltDocument.CurrentElement;
 //        if(currentElement != null && nodeSymbolIDList.IndexOf(GetElementDevType(currentElement).ToString()) > -1)
 //        {
 //            return currentElement;
 //        }
 //        return null;
 //    }
 //}
 //public Timer Timer
 //{
 //    get { return timer; }
 //    set { timer = value; }
 //}
 /// <summary>
 /// 取当前选中线路的线路代码
 /// </summary>
 public string GetCurrentLineCode()
 {
     currentElement = xltDocument.CurrentElement;
     if (IsNodeElement(currentElement))
     {
         return currentElement.GetAttribute(NodeXLDMTag);
     }
     else
     {
         return "";
     }
 }
Exemplo n.º 6
0
 /// <summary>
 /// 断开连接
 /// </summary>
 public void DisconnectLine()
 {
     currentElement = xltDocument.CurrentElement;
     if (currentElement != null && currentElement.GetAttribute("layer") == SvgDocument.currentLayer
         && nodeSymbolIDList.IndexOf(GetElementDevType(currentElement).ToString()) > -1)
     {
         ConnectLine cl = GetConnectLine(currentElement, false);
         if (cl != null)
         {
             cl.Visible = false;
             xltVectorCtrl.DrawArea.InvalidateElement(cl as SvgElement);
             ChangeSubLinesAttribute(currentElement as IGraph, Color.Red, "0");
         }
     }
 }
Exemplo n.º 7
0
        public bool DefsElementContains(SvgElement element)
        {
            XmlNode node1 = base.DocumentElement.SelectSingleNode("//*[@id='"+element.GetAttribute("id")+"']");

            return node1!=null;
        }
Exemplo n.º 8
0
        /// <summary>
        /// 取与指定节点与其它节点相连的连接线,只查找本线路的,分支不算
        /// </summary>
        /// <param name="e">指定的节点</param>
        /// <param name="bStart">指定节点是否为起始点</param>
        /// <returns>查找结果,如果没有,则为null</returns>
        private ConnectLine GetConnectLine(SvgElement e, bool bStart)
        {
            IGraph eg = e as IGraph;

            if (eg == null)
            {
                return null;
            }

            foreach (ConnectLine connectLine in eg.ConnectLines)
            {
                if (bStart)
                {
                    if (connectLine.StartGraph == eg)
                    {
                        SvgElement endEle = connectLine.EndGraph as SvgElement;
                        if (endEle != null && IsNodeElement(endEle)
                             && (endEle.GetAttribute(NodeXLDMTag) == e.GetAttribute(NodeXLDMTag) || IsBDZElement(e)))
                        {
                            return connectLine;
                        }
                    }
                }
                else
                {
                    if (connectLine.EndGraph == eg)
                    {
                        return connectLine;
                    }
                }

            }

            return null;
        }
Exemplo n.º 9
0
        /// <summary>
        /// 添加新节点设备,添加时根据连接情况设置连接线
        /// </summary>
        /// <param name="newElement">新节点设备</param>
        private void AddNewNodeDev(SvgElement newElement, bool isBranch)
        {
            SvgElement nextElement = GetNextNode(currentElement);
            if (IsBDZElement(currentElement))
            {
                nextElement = GetNextNode(currentElement, newElementXLDM);
            }

            if (nextElement != null)//如果当前节点有下一节点
            {
                nextElement.SetAttribute(PreNodeGuidTag, newElement.GetAttribute(NodeGuidTag));
                ConnectLine connectLine = GetConnectLine(nextElement, false);
                if (connectLine != null)
                {
                    connectLine.SetAttribute("devguid2", newElement.GetAttribute(NodeGuidTag));

                    connectLine.EndGraph = newElement as IGraph;
                }
                AddConnectline(newElement, nextElement);
            }
            else
            {
                AddConnectline(currentElement, newElement);
            }

            if (isBranch)
            {
                newElement.SetAttribute(BranchNodeGuidTag, currentElement.GetAttribute(NodeGuidTag));
            }
            else
            {
                newElement.SetAttribute(PreNodeGuidTag, currentElement.GetAttribute(NodeGuidTag));
            }
        }
Exemplo n.º 10
0
        /// <summary>
        /// 查找指定节点同一线路的上一个节点
        /// </summary>
        /// <param name="e">指定的节点</param>
        /// <returns>同一线路的上一个节点</returns>
        private SvgElement GetPreNode(SvgElement e)
        {
            IGraph eg = e as IGraph;
            foreach (ConnectLine connectLine in eg.ConnectLines)
            {
                if (connectLine.EndGraph == eg)
                {
                    SvgElement startEle = connectLine.StartGraph as SvgElement;
                    if (startEle != null && IsNodeElement(startEle)
                        && (startEle.GetAttribute(NodeXLDMTag) == e.GetAttribute(NodeXLDMTag) || IsBDZElement(startEle)))
                    {
                        return startEle;
                    }
                }
            }

            return null;
        }
Exemplo n.º 11
0
        /// <summary>
        /// 取节点的非主线路连接线,包括连设备的连接线、连分支的连接线
        /// </summary>
        /// <param name="e"></param>
        /// <returns></returns>
        private List<ConnectLine> GetNoneTrunkConnectLines(SvgElement e)
        {
            List<ConnectLine> rtList = new List<ConnectLine>();

            IGraph eg = e as IGraph;

            if (eg == null)
            {
                return rtList;
            }

            foreach (ConnectLine connectLine in eg.ConnectLines)
            {
                if (connectLine.StartGraph == eg)
                {
                    SvgElement endEle = connectLine.EndGraph as SvgElement;
                    if (endEle != null)
                    {
                        //同一线路,如果不是节点则满足条件
                        if (endEle.GetAttribute(NodeXLDMTag) == e.GetAttribute(NodeXLDMTag))
                        {
                        }
                        else//非同一线路,表示分支,满足条件
                        {
                            rtList.Add(connectLine);
                        }
                    }
                }
            }
            return rtList;
        }
Exemplo n.º 12
0
 private PSPDEV createsub(SvgElement element)
 {
     PSPDEV pspDev = new PSPDEV();
     pspDev.SUID = Guid.NewGuid().ToString();
     pspDev.EleID = element.ID;
     pspDev.SvgUID = svgid;
     PSPDEV pspDev2 = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev);
     if (pspDev2 == null) {
         pspDev.Number = -1;
         pspDev.FirstNode = -1;
         pspDev.LastNode = -1;
         pspDev.Type = "Use";
         pspDev.Lable = "���վ";
          pspDev.Name = element.GetAttribute("info-name");
         IList list = Services.BaseService.GetList("SelectsubstationByWhere", "eleid='" + pspDev.EleID + "'");
         if (list.Count > 0) {
             substation sub = list[0] as substation;
             pspDev.Name = sub.EleName;
             pspDev.VoltR = double.Parse(sub.ObligateField1);//��ѹ
             pspDev.Burthen = sub.Number;//����
         }
         Services.BaseService.Create<PSPDEV>(pspDev);
     } else {
         pspDev = pspDev2;
     }
     return pspDev;
 }
Exemplo n.º 13
0
 public XmlNode AddDefsElement(SvgElement element)
 {
     this.DefsChanged = true;
     bool flag1 = this.AcceptChanges;
     this.AcceptChanges = false;
     XmlNode node1 = base.DocumentElement.SelectSingleNode("*[name()='defs']");
     this.AcceptChanges = flag1;
     if (!(node1 is SvgElement))
     {
         this.AcceptChanges = false;
         node1 = this.CreateElement(this.Prefix, "defs", this.NamespaceURI);
         this.AcceptChanges = true;
         this.NumberOfUndoOperations++;
         base.DocumentElement.PrependChild(node1);
     }
     this.AcceptChanges = flag1;
     if (node1 is SvgElement)
     {
         string nid=element.GetAttribute("id");
         XmlNode node= node1.SelectSingleNode("svg/defs/*[@id='"+nid+"']");
         if(node !=null)
         {
             return node;
         }
         else
         {
             return ((SvgElement) node1).AppendChild(element);
         }
     }
     return null;
 }
Exemplo n.º 14
0
        /// <summary>
        /// 恢复连接
        /// </summary>
        public void ReConnectLine()
        {
            currentElement = xltDocument.CurrentElement;
            if (currentElement != null && currentElement.GetAttribute("layer") == SvgDocument.currentLayer
                && nodeSymbolIDList.IndexOf(GetElementDevType(currentElement).ToString()) > -1)
            {
                ConnectLine cl = GetConnectLine(currentElement, false);
                if (cl != null)
                {
                    cl.Visible = true;
                    xltVectorCtrl.DrawArea.InvalidateElement(cl as SvgElement);

                    //if (!cl.SvgAttributes.ContainsKey("stroke") || (cl.SvgAttributes.ContainsKey("stroke") && cl.SvgAttributes["stroke"].ToString() != ColorFunc.GetColorString(Color.Red) && cl.SvgAttributes["stroke"].ToString() != ColorFunc.GetColorString(Color.Yellow) && cl.SvgAttributes["stroke"].ToString() != ColorFunc.GetColorString(Color.Green)))
                    if (cl.GetAttribute(ConnectionTag) != "0")
                    {
                        ChangeSubLinesAttribute(currentElement as IGraph, Color.Black, "1");
                    }
                }
            }
        }
Exemplo n.º 15
0
 /// <summary>
 /// 判断是否变电站
 /// </summary>
 /// <param name="element"></param>
 /// <returns></returns>
 private bool IsBDZElement(SvgElement element)
 {
     if (element != null && element.GetAttribute(SymbolTag).IndexOf(BDZTag) > -1)
     {
         return true;
     }
     return false;
 }
Exemplo n.º 16
0
        /// <summary>
        /// 在2个元件之间添加连接线
        /// </summary>
        /// <param name="e1"></param>
        /// <param name="e2"></param>
        /// <param name="sampleCL"></param>
        private void AddConnectline(SvgElement e1, SvgElement e2, ConnectLine sampleCL)
        {
            if (e1 == null || e2 == null)
            {
                return;
            }

            ConnectLine newConnectLine = xltDocument.CreateElement("connectline") as ConnectLine;
            newConnectLine.SetAttribute("type", "line");
            newConnectLine.IsLock = false;
            newConnectLine.SetAttribute("layer", SvgDocument.currentLayer);
            newConnectLine.SetAttribute("devguid1", e1.GetAttribute(NodeGuidTag));
            newConnectLine.SetAttribute("devguid2", e2.GetAttribute(NodeGuidTag));
            newConnectLine.SetAttribute(NodeXLDMTag, e2.GetAttribute(NodeXLDMTag));
            //AttributeFunc.SetAttributeValue(newConnectLine, "start", "#" + e1.ID + ".4");
            //AttributeFunc.SetAttributeValue(newConnectLine, "end", "#" + e2.ID + ".4");
            newConnectLine.StartGraph = e1 as IGraph;
            newConnectLine.EndGraph = e2 as IGraph;

            ConnectLine cl = GetConnectLine(e1, false);
            if (cl != null && (!cl.Visible || cl.GetAttribute(ConnectionTag) == "0"))
            {
                newConnectLine.SetAttribute(ConnectionTag, "0");
            }

            if (sampleCL != null)
            {

            }

            (xltDocument.RootElement.AppendChild(newConnectLine) as ConnectLine).CanSelect = true;
        }
Exemplo n.º 17
0
        private double MeasureGTDifferentLine(SvgElement e1, SvgElement e2)
        {
            double d = double.NaN;
            string xldm1 = e1.GetAttribute(NodeXLDMTag);
            string xldm2 = e2.GetAttribute(NodeXLDMTag);
            int nSubLen = 3;

            while (xldm1.Length >= nSubLen && xldm2.Length >= nSubLen
                && xldm1.Substring(0, nSubLen) == xldm2.Substring(0, nSubLen))
            {
                nSubLen += 3;
            }

            nSubLen -= 3;

            //两节点汇集的线路代码
            string sameXldm = xldm1.Substring(0, nSubLen);

            SvgElement rtE1;
            SvgElement rtE2;
            double d1 = MeasurePathToParent(e1, sameXldm, out rtE1);
            double d2 = MeasurePathToParent(e2, sameXldm, out rtE2);

            d = d1 + d2;
            if (rtE2 != rtE1)
            {
                d += MeasureGTSameLine(rtE1, rtE2);
            }

            return d;
        }
Exemplo n.º 18
0
        void DrawArea_BeforeAddSvgElement(object sender, ItopVector.DrawArea.AddSvgElementEventArgs e)
        {
            symbolElement = e.SvgElement as Use;

            if (symbolElement == null)
            {
                return;
            }

            isNewElementBranch = false;

            currentElement = xltDocument.CurrentElement;

            if (symbolElement.GraphId.IndexOf(BDZTag) < 0 && !CheckCanInsert())
            {
                xltVectorCtrl.CurrentOperation = ToolOperation.Select;
                xltVectorCtrl.DrawArea.PreGraph = null;

                e.Cancel = true;
                return;
            }

            if (currentElement != null)
            {
                newElementXLDM = currentElement.GetAttribute(NodeXLDMTag);
            }

            newElementGuid = Guid.NewGuid().ToString();

            //要插入的为变电站
            if (symbolElement.GraphId.IndexOf(BDZTag) > -1)
            {
                newElementName = "变电站";
                newElementXLDM = "";
            }
            else//要插入的为其它设备
            {
                newElementName = "节点";
                if (IsBDZElement(currentElement) && OnNewLine != null)
                {
                    List<string> listLineCode = GetBDZConnectLines(currentElement);
                    newElementXLDM = OnNewLine(listLineCode);
                }
            }
            if (IsBDZElement(currentElement))
            {
                List<string> listLineCode = GetBDZConnectLines(currentElement);
                string strEleID="'m0y4'";
                for(int i=0;i<listLineCode.Count;i++){
                    strEleID = strEleID + ",'" + listLineCode[i]+"'";
                }
                if (listLineCode.Count > 0)
                {
                    LineInfo l = new LineInfo();
                    l.SvgUID = xltVectorCtrl.SVGDocument.SvgdataUid;
                    l.EleID=strEleID;
                    IList lineList= Services.BaseService.GetList("SelectLineInfoByEleIDList",l);

                    frmAddLineSel f = new frmAddLineSel();
                    f.StrList = listLineCode;
                    f.LineList = lineList;
                    if (f.ShowDialog() == DialogResult.OK)
                    {
                        if (f.newLine)
                        {
                            newElementXLDM = OnNewLine(listLineCode);
                        }
                        else
                        {
                            newElementXLDM = f.LineCode;
                        }
                    }
                    else
                    {
                        e.Cancel = true;
                        return;
                    }
                }
            }
        }
Exemplo n.º 19
0
        private double MeasurePathToParent(SvgElement e, string pXLDM, out SvgElement pEle)
        {
            double d = 0;
            if (pXLDM == e.GetAttribute(NodeXLDMTag))
            {
                pEle = e;
                return d;
            }

            SvgElement preE = GetPreNode2(e);
            while (preE != null)
            {
                IGraph gh1 = preE as IGraph;
                IGraph gh2 = e as IGraph;

                if (mapView == null)
                {
                    d = 0;
                }
                else
                {
                    d += mapView.CountLength(gh1.CenterPoint, gh2.CenterPoint);
                }

                e = preE;

                if (pXLDM == preE.GetAttribute(NodeXLDMTag))
                {
                    pEle = e;
                    return d;
                }
                preE = GetPreNode2(e);
            }
            pEle = e;
            return d;
        }
Exemplo n.º 20
0
        /// <summary>
        /// 得到指定设备的类型枚举值
        /// </summary>
        /// <param name="element"></param>
        /// <returns></returns>
        private NodeDevType GetElementDevType(SvgElement element)
        {
            if (element != null)
            {
                return GetElementDevType(element.GetAttribute(SymbolTag).Replace("#", ""));//前面有个#号,去掉
            }

            return NodeDevType.SB_NONE;
        }
Exemplo n.º 21
0
 public bool DefsElementContains(SvgElement element,out IGraph graph)
 {
     XmlNode node1 = base.DocumentElement.SelectSingleNode("//*[@id='"+element.GetAttribute("id")+"']");
     graph=null;
     if (node1 !=null)graph = node1 as IGraph;
     return node1!=null;
 }