public void OnEvent(object MapEvent) { FormGeoProcessor dlg = (_doc != null && _doc.FocusMap != null) ? new FormGeoProcessor(_doc.FocusMap.MapElements) : new FormGeoProcessor(); dlg.ShowInTaskbar = false; if (dlg.ShowDialog() == DialogResult.OK) { IActivity activity = dlg.Activity; if (activity != null) { Thread thread = new Thread(new ParameterizedThreadStart(StartProgress)); IProgressDialog progress = ProgressDialog.CreateProgressDialogInstance(); progress.ShowProgressDialog(activity, activity, thread); if (_datas != null && _doc != null && _doc.FocusMap != null) { if (MessageBox.Show("Add new feature class to map?", "Add", MessageBoxButtons.YesNo) == DialogResult.Yes) { foreach (IActivityData data in _datas) { if (data == null || data.Data == null || data.Data.Class == null) { continue; } ILayer layer = LayerFactory.Create(data.Data.Class); _doc.FocusMap.AddLayer(layer, 0); } } if (_doc.Application is IMapApplication) { ((IMapApplication)_doc.Application).RefreshActiveMap(DrawPhase.All); } } } } }
public IDatasetElement this[string title] { get { foreach (IDatasetElement element in _elements) { if (element == null) { continue; } if (element.Title == title) { return(element); } } try { if (title.ToLower().EndsWith(".shp")) { title = title.Substring(0, title.Length - 4); } DirectoryInfo di = new DirectoryInfo(_connectionString); FileInfo[] fi = di.GetFiles(title + ".shp"); if (fi.Length == 0) { _errMsg = "Can't find shapefile..."; return(null); } SHPFile shpFile = new SHPFile(fi[0].FullName); FileInfo idx = new FileInfo(shpFile.IDX_Filename); if (!idx.Exists || idx.LastWriteTime < shpFile.LastWriteTime) { DualTree tree = new DualTree(500); CreateSpatialIndexTree creator = new CreateSpatialIndexTree(shpFile, tree, (IEnvelope)(new Envelope(shpFile.Header.Xmin, shpFile.Header.Ymin, shpFile.Header.Xmax, shpFile.Header.Ymax))); if (_useGUI) { IProgressDialog progress = ProgressDialog.CreateProgressDialogInstance(); if (progress != null && progress.UserInteractive) { Thread thread = new Thread(new ThreadStart(creator.Create)); progress.Text = "Create Spatial Index..."; progress.ShowProgressDialog(tree, null, thread); } else { creator.Create(); } } else { creator.Create(); } } gView.Framework.FDB.IIndexTree iTree = null; if (shpFile.IDX_Exists) { iTree = new IDXIndexTree(shpFile.IDX_Filename); } ShapeDatasetElement element = new ShapeDatasetElement(shpFile, this, iTree); _elements.Add(element); return(element); } catch (Exception ex) { _errMsg = ex.Message; } return(null); } }