示例#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("保存成功,需要重新启动程序才有效。");
                }
            }
        }
示例#2
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("����ɹ�����Ҫ��������������Ч��");
                }
            }
        }