Exemplo n.º 1
0
        private void layerImport()
        {
            frmLayerInPut dlgInPut = new frmLayerInPut();
            string ss2="";
            dlgInPut.InitData(SVGUID);
            string layerOutXml = null;
            if (dlgInPut.ShowDialog(this) == DialogResult.OK) {
                FlashWindow frmLoad = new FlashWindow();
                foreach (LayerFile layer in dlgInPut.InputLayerList) {
                    if (Layer.CkLayerExist(layer.LayerFileName, tlVectorControl1.SVGDocument)) {
                        if (MessageBox.Show("文档中已经存在同名图层,是否覆盖原图层。", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) {
                            if (layerOutXml == null)
                            {
                                layerOutXml = layer.LayerOuterXml;
                            }
                            else
                            {
                                layerOutXml = SvgDocument.Union(layerOutXml, layer.LayerOuterXml);
                            }
                            Services.BaseService.Update("DeleteLayerFile", layer);
                            frmlar.DeleteLayer(getlayer(layer.LayerFileName, tlVectorControl1.SVGDocument.getLayerList()));
                        }

                    } else {
                        if (layerOutXml == null) {
                            layerOutXml = layer.LayerOuterXml;
                        } else {
                            layerOutXml = SvgDocument.Union(layerOutXml, layer.LayerOuterXml);
                        }
                        Services.BaseService.Update("DeleteLayerFile", layer);

                        //frmlar.DeleteLayer(getlayer(layer.LayerFileName, tlVectorControl1.SVGDocument.getLayerList()));
                    }

                    //FileStream a = new FileStream("c:\\1.xml",FileMode.OpenOrCreate);
                    //StreamWriter str= new StreamWriter(a);
                    //str.Write(layerOutXml);
                    //str.Close();
                }
                dlgInPut.Close();
                dlgInPut.Dispose();
                //string ss= tlVectorControl1.SVGDocument.CurrentLayer.ID;
                //layerOutXml = layerOutXml.Replace(ss2,ss);
                if (layerOutXml != null) {
                    string svgName = tlVectorControl1.SVGDocument.FileName;
                    string svgUid = tlVectorControl1.SVGDocument.SvgdataUid;
                    ItopVector.SpecialCursors.LoadCursors();
                    frmLoad.Show();
                    frmLoad.RefleshStatus("正在导入图层...");
                    Application.DoEvents();
                    frmLoad.SplashData();
                    frmLoad.Owner = tlVectorControl1.ParentForm;
                    frmLoad.Refresh();

                    //tlVectorControl1.SVGDocument.LoadXml(SvgDocument.Union(tlVectorControl1.SVGDocument.OuterXml, lay.LayerOuterXml));
                    tlVectorControl1.SVGDocument = LoadXMLToCtrl(SvgDocument.Union(tlVectorControl1.SVGDocument.OuterXml, layerOutXml));
                    tlVectorControl1.PropertyGrid = propertyGrid;
                    tlVectorControl1.SVGDocument.SvgdataUid = svg.SUID;
                    //tlVectorControl1.SVGDocument.SvgdataUid = svgUid;
                    tlVectorControl1.SVGDocument.FileName = svgName;
                    tlVectorControl1.IsModified = true;

                    frmlar.SymbolDoc = tlVectorControl1.SVGDocument;
                    frmlar.InitData();
                    MessageBox.Show("图层已成功导入", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                //if (dlgInPut.InputText != "")
                //{

                //    LayerFile temp = new LayerFile();
                //    temp.LayerFileName = dlgInPut.InputText;
                //    temp.SvgDataUid = tlVectorControl1.SVGDocument.SvgdataUid;
                //    LayerFile lay = (LayerFile)Services.BaseService.GetObject("SelectLayerFileByNameAndSvgDataUid", temp);

                //if (lay != null)
                //{
                //    if (Layer.CkLayerExist(dlgInPut.InputText, tlVectorControl1.SVGDocument))
                //    {
                //        if (MessageBox.Show("文档中已经存在同名图层,是否覆盖原图层。", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
                //        {
                //            frmlar.DeleteLayer(getlayer(dlgInPut.InputText, tlVectorControl1.SVGDocument.getLayerList()));
                //            string svgName = tlVectorControl1.SVGDocument.FileName;
                //            string svgUid = tlVectorControl1.SVGDocument.SvgdataUid;
                //            ItopVector.SpecialCursors.LoadCursors();
                //            frmLoad.Show();
                //            frmLoad.RefleshStatus("正在导入图层...");
                //            Application.DoEvents();
                //            frmLoad.SplashData();
                //            frmLoad.Owner = tlVectorControl1.ParentForm;
                //            frmLoad.Refresh();

                //            //tlVectorControl1.SVGDocument.LoadXml(SvgDocument.Union(tlVectorControl1.SVGDocument.OuterXml, lay.LayerOuterXml));
                //            tlVectorControl1.SVGDocument = LoadXMLToCtrl(SvgDocument.Union(tlVectorControl1.SVGDocument.OuterXml, lay.LayerOuterXml));
                //            tlVectorControl1.PropertyGrid = propertyGrid;
                //            tlVectorControl1.SVGDocument.SvgdataUid = svg.SUID;
                //            //tlVectorControl1.SVGDocument.SvgdataUid = svgUid;
                //            tlVectorControl1.SVGDocument.FileName = svgName;
                //            tlVectorControl1.IsModified = true;

                //            frmlar.SymbolDoc = tlVectorControl1.SVGDocument;
                //            frmlar.InitData();
                //            Services.BaseService.Update("DeleteLayerFile", lay);
                //            MessageBox.Show("图层已成功导入", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                //        }

                //    }
                //    else
                //    {
                //        string svgName = tlVectorControl1.SVGDocument.FileName;
                //        string svgUid = tlVectorControl1.SVGDocument.SvgdataUid;
                //        ItopVector.SpecialCursors.LoadCursors();

                //        frmLoad.Show();
                //        frmLoad.RefleshStatus("正在导入图层...");
                //        Application.DoEvents();
                //        frmLoad.SplashData();
                //        frmLoad.Owner = tlVectorControl1.ParentForm;
                //        frmLoad.Refresh();

                //        tlVectorControl1.SVGDocument = LoadXMLToCtrl(SvgDocument.Union(tlVectorControl1.SVGDocument.OuterXml, lay.LayerOuterXml));
                //        tlVectorControl1.PropertyGrid = propertyGrid;
                //        tlVectorControl1.SVGDocument.SvgdataUid = svgUid;
                //        tlVectorControl1.SVGDocument.FileName = svgName;
                //        tlVectorControl1.IsModified = true;
                //        frmlar.SymbolDoc = tlVectorControl1.SVGDocument;
                //        frmlar.InitData();
                //        Services.BaseService.Update("DeleteLayerFile", lay);
                //        MessageBox.Show("图层已成功导入", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                //    }
                //}
                //}
            }
        }