Exemple #1
0
        private void button2_Click(object sender, EventArgs e)
        {
            Button button1 = sender as Button;

            ItopVector.Core.Document.SvgDocument doc = this.document;
            string filepath = string.Empty;

            if (doc == null)
            {
                filepath = Application.StartupPath + @"\symbol\symbol.xml";
                if (!File.Exists(filepath))
                {
                    filepath = string.Empty;
                    OpenFileDialog opendlg = new OpenFileDialog();
                    opendlg.Filter = "xml文件(*.xml)|*.xml";
                    if (opendlg.ShowDialog(this) == DialogResult.OK)
                    {
                        filepath = opendlg.FileName;
                    }
                }
                if (File.Exists(filepath))
                {
                    try
                    {
                        doc = ItopVector.Selector.SymbolGroup.LoadSymbol(filepath);
                    }
                    catch (Exception err)
                    {
                        MessageBox.Show(err.Message);
                    }
                }
            }
            if (doc != null)
            {
                XmlNode node = doc.SelectSingleNode("//*[@id='" + this.curElement.ID + "']");

                if (node != null)
                {
                    MessageBox.Show("已存在名为'" + this.curElement.ID + "'组或图元!", "增加图元");
                    return;
                }

                SymbolGroupDialog dlg = new SymbolGroupDialog();
                dlg.SymbolDoc       = doc;
                dlg.ToInsertElement = this.curElement;
                if (dlg.ShowDialog(this) == DialogResult.OK)
                {
                    if (this.symbolSelector != null)
                    {
                        this.symbolSelector.AddSymbol(this.curElement as Symbol, dlg.SelectedElement.GetAttribute("id"));
                    }
                    else
                    {
                        dlg.SelectedElement.AppendChild(this.document.ImportNode(this.curElement, true));
                    }
                    doc.Save(doc.FilePath);
//					MessageBox.Show("保存成功,需要重新启动程序才有效。");
                }
            }
        }
Exemple #2
0
 public static XmlNode GetRefNode(string refid, SvgDocument doc)
 {
     refid = refid.Trim();
     while (refid.EndsWith(";"))
     {
         refid = refid.Substring(0, refid.Length - 1);
     }
     string text1 = refid;
     if (text1.Trim().StartsWith("url"))
     {
         int num1 = text1.Trim().IndexOf("#", 0, text1.Trim().Length);
         int num2 = text1.Trim().IndexOf(")", 0, text1.Trim().Length);
         text1 = text1.Trim().Substring(num1 + 1, (num2 - num1) - 1);
     }
     if (text1.Trim().StartsWith("#"))
     {
         text1 = text1.Trim().Substring(1, text1.Trim().Length - 1);
     }
     string text2 = "//*[@id='" + text1 + "']";
     bool flag1 = doc.AcceptChanges;
     doc.AcceptChanges = false;
     XmlNode node1 = doc.SelectSingleNode(text2);
     doc.AcceptChanges = flag1;
     return node1;
 }