Example #1
0
        public void AddNewPage(String fileName)
        {
            var svgForm = new WorkspaceHolder {
                Dock = DockStyle.Fill, Name = fileName
            };

            svgForm.svgDrawForm.ToolDone      += OnToolDoneComplete;
            svgForm.svgDrawForm.ItemsSelected += SvgDrawFormItemsSelected;
            tabbedView.Add(svgForm);
        }
Example #2
0
        public void OpenDocument(String fileName)
        {
            var svgForm = new WorkspaceHolder {
                Dock = DockStyle.Fill, Name = fileName
            };

            svgForm.svgDrawForm.ToolDone      += OnToolDoneComplete;
            svgForm.svgDrawForm.ItemsSelected += SvgDrawFormItemsSelected;
            svgForm.svgDrawForm.OpenFile(fileName);
            tabbedView.Add(svgForm);
            svgForm.Refresh();
        }
Example #3
0
        public bool LoadModelFromXml(string fileName)
        {
            var svgForm = new WorkspaceHolder {
                Dock = DockStyle.Fill, Name = fileName
            };

            svgForm.svgDrawForm.ToolDone      += OnToolDoneComplete;
            svgForm.svgDrawForm.ItemsSelected += SvgDrawFormItemsSelected;

            svgForm.svgDrawForm.drawArea.Width  = 1600;
            svgForm.svgDrawForm.drawArea.Height = 900;

            XmlTextReader reader = null;

            //XmlReader reader = null;
            //var txt = File.ReadAllText(fileName);
            try
            {
                // FileStream fs = new FileStream(fileName,FileMode.Open);


                //reader =  XmlReader.Create(fileName);
                reader = new XmlTextReader(fileName);//从本地读取xml文件

                SVGErr.Log("DrawArea", "LoadFromXML", "", SVGErr._LogPriority.Info);
                var svg = new SVGWord();
                if (!svg.LoadFromFile(reader))
                {
                    return(false);
                }
                SVGRoot root = svg.GetSvgRoot();

                if (root == null)
                {
                    return(false);
                }
                SVGUnit ele = root.getChild();
                if (ele != null)
                {
                    //1 收集symbol获取svg上的设备
                    //2 从svg元数据中收集symbol之间的关系
                    //3 将所有use的设备实体生成
                    //4 绘制list集合将图素绘制出来
                    SVGFactory.CreateProjectFromXML(ele, svgForm.svgDrawForm.drawArea.GraphicsList);
                }
            }
            catch (Exception ex)
            {
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
            }

            tabbedView.Add(svgForm);
            svgForm.Refresh();

            return(true);
        }