// Methods public ConnectShape(SvgElement connect) { this.graphPath = null; this.element = connect; this.id = connect.GetAttribute("id"); this.graphPath = ((ConnectLine)connect).ConnectPath(); }
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; }
public void AddElement(SvgElement element) { if (!this.flowChilds.Contains(element)) { this.flowChilds.Add(element); } if (element.ShowParticular) { this.flowChilds.AddRange(element.AnimateList); } if (element is IGraph) { ClipPath path1 = ((IGraph) element).ClipPath; if (path1 != null) { this.AddElement(path1); } } if ((element is IContainer) && element.ShowChilds) { SvgElementCollection.ISvgElementEnumerator enumerator1 = ((IContainer) element).ChildList.GetEnumerator(); while (enumerator1.MoveNext()) { SvgElement element1 = (SvgElement) enumerator1.Current; this.AddElement(element1); } } }
public static object GetDefaultValue(SvgElement element, string attributename) { string text1; DomType type1 = DomTypeFunc.GetTypeOfAttributeName(attributename); if ((text1 = attributename) != null) { text1 = string.IsInterned(text1); if (((text1 == "fill-opacity") || (text1 == "opacity")) || (((text1 == "stroke-opacity") || (text1 == "stroke-width")) || (text1 == "stop-opacity"))) { return 1f; } } switch (type1) { case DomType.SvgNumber: { return 0f; } case DomType.SvgString: { return string.Empty; } case DomType.SvgColor: { return string.Empty; } } return string.Empty; }
// Methods public KeyUndoOperation() { this.ChangeElement = null; this.OldList = null; this.NewList = null; this.OldControlTime = 0; this.NewControlTime = 0; }
// Methods internal Arrow(SvgElement element) { this.svgElement = null; this.id = null; if (element.Name != "marker") { throw new Exception("��Ч�Ľڵ�"); } this.svgElement = element; }
public static object FindAttribute(string key, SvgElement node) { if (node.SvgAnimAttributes.ContainsKey(key)) { return node.SvgAnimAttributes[key]; } if ((node is Text) && ((Text) node).OwnerTextElement.SvgAnimAttributes.ContainsKey(key)) { return ((Text) node).OwnerTextElement.SvgAnimAttributes[key]; } return string.Empty; }
public KeyUndoOperation(SvgElement element, ArrayList oldlist, ArrayList newlist) { this.ChangeElement = null; this.OldList = null; this.NewList = null; this.OldControlTime = 0; this.NewControlTime = 0; this.ChangeElement = element; element.pretime = -1; this.OldList = oldlist; this.NewList = newlist; this.OldControlTime = element.OwnerDocument.OldControlTime; this.NewControlTime = element.OwnerDocument.ControlTime; }
// Methods public UnDoOperation(SvgDocument doc, XmlNode changeelement, XmlNode oldparent, XmlNode newparent, XmlNodeChangedAction action, SvgElement changeparent) { this.oldvalue = string.Empty; this.newvalue = string.Empty; this.changeParent = changeparent; this.document = doc; this.changeAction = action; this.oldParent = oldparent; this.newParent = newparent; this.changeElement = changeelement; this.nextSibling = this.changeElement.NextSibling; this.preSibling = this.changeElement.PreviousSibling; if (this.changeElement is SvgElement) { while (this.nextSibling != null) { if (this.nextSibling is SvgElement) { break; } this.nextSibling = this.nextSibling.NextSibling; } while (this.preSibling != null) { if (this.preSibling is SvgElement) { break; } this.preSibling = this.preSibling.PreviousSibling; } } if (this.changeElement != null) { this.newvalue = this.changeElement.Value; } if (this.changeParent != null) { this.oldvalue = this.changeParent.BeforeChangeValueStr; } }
public static string CreateString(SvgElement element, string key) { string text1; // int num1 = 0; Regex regex1 = new Regex("[A-Za-z]*"); Match match1 = regex1.Match(key); if (match1.Success) { key = match1.Groups[0].Value; } while (true) { // num1=random.Next(0,99999); text1 = key + Guid.NewGuid().ToString().Substring(24); // if ( (NodeFunc.GetRefNode(text1, element.OwnerDocument) == null)) { return text1; } } }
// Methods internal SvgElement(string prefix, string localname, string ns, SvgDocument doc) : base(prefix, localname, ns, doc) { this.timeLineVisible = true; KeyInfo[] infoArray1 = new KeyInfo[1] { new KeyInfo(0, 0) } ; this.infoList = new ArrayList(infoArray1); this.showParticular = false; this.inKey = false; this.animatelist = new SvgElementCollection(); this.svgAttributes = new Hashtable(0x10); this.svgAnimAttributes = new Hashtable(0x10); this.svgStyleAttributes = new Hashtable(0x10); this.beforeChangeValueStr = string.Empty; this.showchild = true; this.pretime = -1; this.AnimateNameValues = new Hashtable(0x10); this.AttributePos = new Hashtable(); this.FormatOutXml = true; this.UseElement = null; this.CreateParse = true; this.ownerDocument = doc; this.FormatElement = false; this.AllowRename = true; }
// Methods public ExportSymbolDialog(ItopVector.DrawArea.DrawArea vectorcontrol, string filefilter) { this.firstload = true; this.components = null; this.vectorcontrol = null; this.allSymbol = null; this.allShape = null; this.selectionSymbol = null; this.selectionShape = null; this.document = null; this.InitializeComponent(); this.saveFileDialog1.Filter = "SVG�ļ�(*.svg)|*.svg"; if (filefilter.Trim().Length > 0) { this.saveFileDialog1.Filter = this.saveFileDialog1.Filter + "|" + filefilter; } this.vectorcontrol = vectorcontrol; this.symbolSelector = vectorcontrol.SymbolSelector; if(this.symbolSelector!=null) { this.document = vectorcontrol.SymbolSelector.SymbolDoc; } }
/// <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)); } }
/// <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; }
private void AddNewAccDev(SvgElement newElement) { AddConnectline(currentElement, newElement); }
/// <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"); } } } }
private void AddConnectline(SvgElement e1, SvgElement e2) { AddConnectline(e1, e2, null); }
/// <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; }
/// <summary> /// 计算同一分支2点之间距离,包含中之间的结点,如果没有匹配上,则返回Double.NaN /// </summary> /// <param name="e1">起始点</param> /// <param name="e2">结束点</param> /// <returns>长度,如果没匹配上,则返回Double.NaN</returns> private Double TryMeasureGT(SvgElement e1, SvgElement e2) { Double d = 0; bool bMeet = false; SvgElement e = GetNextNode(e1); SvgElement oldE = e1; while (e != null) { IGraph gh1 = oldE as IGraph; IGraph gh2 = e as IGraph; if (mapView == null) { d = 0; } else { d += mapView.CountLength(gh1.CenterPoint, gh2.CenterPoint); } oldE = e; if (e == e2) { bMeet = true; break; } e = GetNextNode(e); } if (bMeet) { return d; } else { return double.NaN; } }
/// <summary> /// 取得与变电站相连的线路代码 /// </summary> /// <param name="e">变电站</param> /// <returns>线路代码</returns> private List<string> GetBDZConnectLines(SvgElement e) { List<string> rtList = new List<string>(); if (!IsBDZElement(e)) { return rtList; } IGraph eg = e as IGraph; if (eg == null) { return rtList; } foreach (ConnectLine connectLine in eg.ConnectLines) { SvgElement endEle = connectLine.EndGraph as SvgElement; if (endEle != null) { rtList.Add(endEle.GetAttribute(NodeXLDMTag)); } } return rtList; }
/// <summary> /// 删除节点 /// </summary> /// <param name="e"></param> private void DeleteNodeElement(SvgElement e) { if (!IsNodeElement(e) || IsBDZElement(e)) { return; } ConnectLine beforeLine = GetConnectLine(e, false); ConnectLine afterLine = GetConnectLine(e, true); if (beforeLine != null) { SvgElement preElement = beforeLine.StartGraph as SvgElement; if (afterLine != null) { SvgElement nextElement = afterLine.EndGraph as SvgElement; if (nextElement != null) { nextElement.SetAttribute(PreNodeGuidTag, preElement.GetAttribute(NodeGuidTag)); beforeLine.SetAttribute("devguid2", nextElement.GetAttribute(NodeGuidTag)); beforeLine.EndGraph = nextElement as IGraph; } xltDocument.CurrentElement = afterLine; xltVectorCtrl.Delete(); } else { xltDocument.CurrentElement = beforeLine; xltVectorCtrl.Delete(); } } xltDocument.CurrentElement = e; xltVectorCtrl.Delete(); }
/// <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"); } } }
/// <summary> /// 删除当前选中的图元,多选情况下只删除一个,如果想删除当前所选的所有,请调用Delete方法 /// </summary> public void DeleteElement() { currentElement = xltDocument.CurrentElement; if (currentElement == null || (currentElement as ConnectLine) != null) { return; } if (IsNodeElement(currentElement)) { if (IsBDZElement(currentElement)) { IGraph gh = currentElement as IGraph; if (gh.ConnectLines.Count == 0) { xltVectorCtrl.Delete(); } } else { DeleteNodeElement(currentElement); } } else { xltVectorCtrl.Delete(); } }
private double XX(SvgElement e1, SvgElement e2, ConnectLine cl) { IGraph gh1 = e1 as IGraph; foreach (ConnectLine connectLine in gh1.ConnectLines) { if (cl == connectLine) { continue; } SvgElement e = null; if (connectLine.StartGraph == gh1) { e = connectLine.EndGraph as SvgElement; } else if (connectLine.EndGraph == gh1) { e = connectLine.StartGraph as SvgElement; } if (e != null && e != e1 && nodeSymbolIDList.IndexOf(GetElementDevType(e).ToString()) > -1) { if (e == e2) { IGraph gh2 = e2 as IGraph; if (mapView == null) { return 0; } else { return mapView.CountLength(gh1.CenterPoint, gh2.CenterPoint); } } else { double d = XX(e, e2, connectLine); if (d >= 0) { IGraph gh = e as IGraph; if (mapView == null) { return 0; } else { return mapView.CountLength(gh1.CenterPoint, gh.CenterPoint) + d; } } } } } return -1; }
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; } } } }
/// <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); }
/// <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; }
/// <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; }
/// <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 ""; } }
/// <summary> /// 测量2个节点之间的距离,包含之间的节点 /// </summary> /// <param name="e1">节点1</param> /// <param name="e2">节点2</param> /// <returns>总距离</returns> public Double MeasureGT(SvgElement e1, SvgElement e2) { //if (e1.GetAttribute(NodeXLDMTag) == e2.GetAttribute(NodeXLDMTag)) //{ // return MeasureGTSameLine(e1, e2); //} //else //{ // return MeasureGTDifferentLine(e1, e2); //} return XX(e1, e2, null); }