private void ShowLoadingForm(string filename) { _loadingForm = new ProjectLoadingView(filename); _context.View.ShowChildView(_loadingForm, false); Application.DoEvents(); }
/// <summary> /// Restores the state of application by populating application _context after project file was deserialized. /// </summary> public bool Restore(XmlProject project, ProjectLoadingView loadingForm) { _context.MainView.Lock(); System.IO.FileInfo fileInfo = new FileInfo(project.Settings.LoadAsFilename); _basePath = fileInfo.DirectoryName; try { //因为插件引导的时候需要读取项目文档里面的配置,因此,这个参数必须在插件引导前赋值 loadingForm.ShowProgress(30, "正在加载地图"); _context.YutaiProject = project; RestoreMxdDocument(project); // RestoreSxdDocument(project); loadingForm.ShowProgress(100, "正在加载插件"); RestorePlugins(project); //loadingForm.ShowProgress(100, "正在设置视图范围"); //RestoreExtents(project); return(true); } finally { _context.YutaiProject = project; _context.MainView.Unlock(); //_broadcaster.BroadcastEvent(p => p.ProjectOpened_, this, null); } }
public static XmlProject CreateReProject(IAppContext context, string name, string parentPath, int epsgCode) { ProjectLoadingView _loadingForm; _loadingForm = new ProjectLoadingView(name); context.View.ShowChildView(_loadingForm, false); Application.DoEvents(); context.View.Lock(); _loadingForm.ShowProgress(10, "创建项目目录"); DirectoryInfo info = new DirectoryInfo(parentPath + "\\" + name); if (info.Exists == false) { info.Create(); } info.CreateSubdirectory("Database"); info.CreateSubdirectory("Attachments"); _loadingForm.ShowProgress(30, "创建项目数据库"); IREDatabase reDatabase = new ReDatabase(Path.Combine(info.FullName, "Database\\redatabase.db")); string errMsg = ""; _loadingForm.ShowProgress(50, "初始化项目数据库,数据较多,请耐心等待"); reDatabase.InitREDatabase(epsgCode, _loadingForm, out errMsg); string projectFile = Path.Combine(info.FullName, name + ".vgproj"); XmlProject project = new XmlProject(context as ISecureContext, projectFile); project.ProjectName = name; project.Database = "Database\\redatabase.db"; project.AttachmentPath = "Attachments"; _loadingForm.Close(); _loadingForm.Dispose(); context.View.Unlock(); _loadingForm = null; return(project); }
public bool InitREDatabase(int epsgCode, ProjectLoadingView loadingForm, out string errorMsg) { errorMsg = ""; if (string.IsNullOrEmpty(_databaseName)) { errorMsg = "没有设置数据库!"; return false; } _epsgCode = epsgCode; FileInfo info = new FileInfo(_databaseName); if (!info.Exists) { loadingForm.ShowProgress(60,"创建数据库"); System.IO.FileInfo tmpFileInfo = SQLiteHelpers.GetTemplateDBInfo(); tmpFileInfo.CopyTo(_databaseName); } using (SQLiteConnection connection = new SQLiteConnection(SQLiteHelpers.ConnectionStringBuilder(_databaseName))) { connection.Open(); SpatialiteSharp.SpatialiteLoader.Load(connection); loadingForm.ShowProgress(70, "创建系统表"); CreateRESystemTables(connection); loadingForm.ShowProgress(70, "创建数据字典"); ImportDictionary(connection); loadingForm.ShowProgress(80, "创建地籍表"); CreateREZDTables(connection); loadingForm.ShowProgress(90, "创建居民地底图表"); CreateREBasemapTables(connection,"JMD"); loadingForm.ShowProgress(92, "创建道路底图表"); CreateREBasemapTables(connection, "DL"); loadingForm.ShowProgress(93, "创建水系底图表"); CreateREBasemapTables(connection, "SX"); loadingForm.ShowProgress(94, "创建地貌底图表"); CreateREBasemapTables(connection, "DMTZ"); loadingForm.ShowProgress(95, "创建独立地物底图表"); CreateREBasemapTables(connection, "DLDW"); loadingForm.ShowProgress(96, "创建其他底图表"); CreateREBasemapTables(connection, "QT"); loadingForm.ShowProgress(97, "创建注记底图表"); CreateREBasemapTables(connection, "ZJ",true,true,false,true); loadingForm.ShowProgress(90, "创建临时表"); CreateRECADTempTables(connection); } return true; }
/// <summary> /// Restores the state of application by populating application _context after project file was deserialized. /// </summary> public bool Restore(XmlProject project, ProjectLoadingView loadingForm) { _context.View.Lock(); try { loadingForm.ShowProgress(30, "正在加载数据库"); //((ISecureContext) _context).VastProject = project; loadingForm.ShowProgress(100, "正在加载插件"); RestorePlugins(project); return(true); } finally { _context.VastProject = project; _context.View.Unlock(); } }
public override void OnClick() { OpenFileDialog dialog = new OpenFileDialog(); dialog.Filter = "DXF图形(*.dxf)|*.dxf"; if (dialog.ShowDialog() != DialogResult.OK) { return; } if (((IRealEstateContext)_context).RealEstateDatabase != null) { ProjectLoadingView _loadingForm; _loadingForm = new ProjectLoadingView("导入DXF操作:" + dialog.FileName); _context.View.ShowChildView(_loadingForm, false); Application.DoEvents(); _context.View.Lock(); ((IRealEstateContext)_context).RealEstateDatabase.ImportDxfDrawing(dialog.FileName, _loadingForm); _context.View.Unlock(); _loadingForm.Close(); _loadingForm.Dispose(); } }
public void ImportDxfDrawing(string dxfName, ProjectLoadingView loadingForm) { loadingForm.ShowProgress(0,"导入环境初始化..."); //DbConnection.GetConnection().Open(); MainService mainService = ServiceFactory.GetMainService(); TmpCaddService caddService = ServiceFactory.GetTmpCaddService(); TmpCadxService cadxService = ServiceFactory.GetTmpCadxService(); TmpCadmService cadmService = ServiceFactory.GetTmpCadmService(); TmpCadzjService cadzjService = ServiceFactory.GetTmpCadzjService(); TmpCadxdataService cadxdataService = ServiceFactory.GetTmpCadxdataService(); int srid = mainService.GetGeometryColumnSRID("tmpcadd", "geometry"); mainService.ClearCADTemps(); DataSource ds = Ogr.Open(dxfName, 0); Driver drv = ds.GetDriver(); loadingForm.ShowProgress(0, "导入图形数据..."); for (int i = 0; i < ds.GetLayerCount(); i++) { Layer pLayer = ds.GetLayerByIndex(i); Feature feat = pLayer.GetNextFeature(); while (feat != null) { string handle = feat.GetFieldAsString(4); string typeName = feat.GetFieldAsString(1).Trim().Replace("AcDbEntity:",""); string geomtryStr = ""; Geometry geometry = feat.GetGeometryRef(); geometry.FlattenTo2D(); geometry.ExportToWkt(out geomtryStr); switch (typeName) { case "AcDbPolyline": case "AcDbLine": TmpCadx cadx = new TmpCadx(handle, geomtryStr, "POLYLINE", dxfName); cadxService.Create(cadx); break; case "AcDbBlockReference": //TmpCadd cadd=new TmpCadd(handle, geomtryStr, "POINT"); //caddService.Create(cadd); //因为GDAL直接读取了块图形,因此,块在下面的方法和属性一起读取 break; case "AcDbText:AcDbText": TmpCadzj cadzj = new TmpCadzj(handle, geomtryStr, "TEXT", dxfName); cadzjService.Create(cadzj); break; } feat.Dispose(); feat = pLayer.GetNextFeature(); } } //开始使用netDxf读取数据 DxfDocument doc=DxfDocument.Load(dxfName); //开始读取点数据 loadingForm.ShowProgress(40, "导入块参照属性..."); for (int i = 0; i < doc.Inserts.Count; i++) { Insert insert= doc.Inserts[i]; TmpCadd cadd=new TmpCadd(); cadd.Handle = insert.Handle; cadd.EntityType = "POINT"; cadd.FileName = dxfName; cadd.Geometry = DbGeometry.FromText(string.Format("POINT({0} {1})", insert.Position.X, insert.Position.Y)); caddService.Create(cadd); TmpCadxdata cadxdata = new TmpCadxdata(); cadxdata.Handle = insert.Handle; cadxdata.Tc = insert.Layer.Name; cadxdata.Fh = insert.Block.Name; cadxdata.Fhdx = insert.Scale.X; cadxdata.Xzjd = insert.Rotation; cadxdata.FileName = dxfName; cadxdata = ReadXData(cadxdata, insert.XData); cadxdataService.Create(cadxdata); } //开始读取点数据 loadingForm.ShowProgress(50, "导入文本数据..."); for (int i = 0; i < doc.Texts.Count; i++) { Text insert = doc.Texts[i]; //TmpCadd cadd = new TmpCadd(); //cadd.Handle = insert.Handle; //cadd.EntityType = "POINT"; //cadd.Geometry = // DbGeometry.FromText(string.Format("POINT({0} {1})", insert.Position.X, insert.Position.Y)); //caddService.Create(cadd); TmpCadxdata cadxdata = new TmpCadxdata(); cadxdata.Handle = insert.Handle; cadxdata.Tc = insert.Layer.Name; cadxdata.Fh = insert.Style.FontFamilyName; cadxdata.Fhdx = insert.Height; cadxdata.Xzjd = insert.Rotation; cadxdata.Wbnr = insert.Value; cadxdata.FileName = dxfName; cadxdata = ReadXData(cadxdata, insert.XData); cadxdataService.Create(cadxdata); } //开始读取线数据 loadingForm.ShowProgress(60, "导入线数据..."); for (int i = 0; i < doc.Lines.Count; i++) { Line insert = doc.Lines[i]; //TmpCadd cadd = new TmpCadd(); //cadd.Handle = insert.Handle; //cadd.EntityType = "POINT"; //cadd.Geometry = // DbGeometry.FromText(string.Format("POINT({0} {1})", insert.Position.X, insert.Position.Y)); //caddService.Create(cadd); TmpCadxdata cadxdata = new TmpCadxdata(); cadxdata.Handle = insert.Handle; cadxdata.Tc = insert.Layer.Name; cadxdata.Fh = insert.Linetype.Name; cadxdata.Fhdx = insert.LinetypeScale; cadxdata.Xzjd = 0.0; cadxdata.Wbnr = ""; cadxdata.FileName = dxfName; cadxdata = ReadXData(cadxdata, insert.XData); cadxdataService.Create(cadxdata); } loadingForm.ShowProgress(80, "导入多边形数据..."); for (int i = 0; i < doc.LwPolylines.Count; i++) { LwPolyline insert = doc.LwPolylines[i]; if (insert.IsClosed) { //插入多边形 TmpCadx cadx = cadxService.GetTmpCadx(insert.Handle); if (cadx != null) { TmpCadm cadm=new TmpCadm() {Handle = cadx.Handle,EntityType="POLYGON",FileName=dxfName}; string wkt = cadx.Geometry.AsText(); Geometry geometry = Ogr.ForceToPolygon(Geometry.CreateFromWkt(wkt)); string geomStr = ""; geometry.ExportToWkt(out geomStr); geomStr = geomStr.Replace("LINESTRING", "POLYGON (") + ")"; cadm.Geometry = DbGeometry.FromText(geomStr); cadmService.Create(cadm); } } //TmpCadd cadd = new TmpCadd(); //cadd.Handle = insert.Handle; //cadd.EntityType = "POINT"; //cadd.Geometry = // DbGeometry.FromText(string.Format("POINT({0} {1})", insert.Position.X, insert.Position.Y)); //caddService.Create(cadd); TmpCadxdata cadxdata = new TmpCadxdata(); cadxdata.Handle = insert.Handle; cadxdata.Tc = insert.Layer.Name; cadxdata.Fh = insert.Linetype.Name; cadxdata.Fhdx = insert.LinetypeScale; cadxdata.Xzjd = 0.0; cadxdata.Wbnr = ""; cadxdata.FileName = dxfName; cadxdata = ReadXData(cadxdata, insert.XData); cadxdataService.Create(cadxdata); } for (int i = 0; i < doc.Polylines.Count; i++) { Polyline insert = doc.Polylines[i]; if (insert.IsClosed) { //插入多边形 TmpCadx cadx = cadxService.GetTmpCadx(insert.Handle); if (cadx != null) { TmpCadm cadm = new TmpCadm() { Handle = cadx.Handle, EntityType = "POLYGON" ,FileName = dxfName}; string wkt = cadx.Geometry.AsText(); Geometry geometry = Ogr.ForceToPolygon(Geometry.CreateFromWkt(wkt)); string geomStr = ""; geometry.ExportToWkt(out geomStr); geomStr=geomStr.Replace("LINESTRING", "POLYGON (")+")"; cadm.Geometry = DbGeometry.FromText(geomStr); cadmService.Create(cadm); } } //TmpCadd cadd = new TmpCadd(); //cadd.Handle = insert.Handle; //cadd.EntityType = "POINT"; //cadd.Geometry = // DbGeometry.FromText(string.Format("POINT({0} {1})", insert.Position.X, insert.Position.Y)); //caddService.Create(cadd); TmpCadxdata cadxdata = new TmpCadxdata(); cadxdata.Handle = insert.Handle; cadxdata.Tc = insert.Layer.Name; cadxdata.Fh = insert.Linetype.Name; cadxdata.Fhdx = insert.LinetypeScale; cadxdata.Xzjd = 0.0; cadxdata.Wbnr = ""; cadxdata.FileName = dxfName; cadxdata = ReadXData(cadxdata, insert.XData); cadxdataService.Create(cadxdata); } loadingForm.ShowProgress(100, "导入完成..."); //mainService.Close(); }
private void HideLoadingForm() { _loadingForm.Close(); _loadingForm.Dispose(); _loadingForm = null; }