private void BuildDefaultDocument() { _doc = new OdbcConfigurationDocument(); var xmlDoc = new XmlDocument(); XmlNamespaceManager mgr = new XmlNamespaceManager(xmlDoc.NameTable); mgr.AddNamespace("xs", XmlNamespaces.XS); //NOXLATE mgr.AddNamespace("xsi", XmlNamespaces.XSI); //NOXLATE mgr.AddNamespace("fdo", XmlNamespaces.FDO); //NOXLATE mgr.AddNamespace("gml", XmlNamespaces.GML); //NOXLATE mgr.AddNamespace("xlink", XmlNamespaces.XLINK); //NOXLATE mgr.AddNamespace("fds", XmlNamespaces.FDS); //NOXLATE //This may have changed, so reapply var props = Use64BitDriver ? this.ChildEditor.Get64BitConnectionProperties() : this.ChildEditor.ConnectionProperties; _fs.ApplyConnectionProperties(props); _service.SyncSessionCopy(); try { var schemaName = _service.CurrentConnection.FeatureService.GetSchemas(_fs.ResourceID)[0]; var classNames = _service.CurrentConnection.FeatureService.GetClassNames(_fs.ResourceID, schemaName); var diag = new FilteredLogicalSchemaDialog(classNames); if (diag.ShowDialog() == DialogResult.Cancel) { throw new ApplicationException(Strings.TextNoItemSelected); } var names = diag.ClassNames; BusyWaitDelegate worker = () => { classNames = names.Select(x => x.Contains(":") ? x.Split(':')[1] : x).ToArray(); //NOXLATE var schema = _service.CurrentConnection.FeatureService.DescribeFeatureSourcePartial(_fs.ResourceID, schemaName, classNames); _doc.AddSchema(schema); //Only one schema is supported by ODBC so this is ok var scList = _service.CurrentConnection.FeatureService.GetSpatialContextInfo(_fs.ResourceID, false); foreach (var sc in scList.SpatialContext) { _doc.AddSpatialContext(sc); } return(null); }; BusyWaitDialog.Run(Strings.TextPreparingConfigurationDocument, worker, (obj, ex) => { if (ex != null) { throw ex; } //Done }); } catch (Exception ex) { _doc = null; MessageBox.Show(ex.Message); } }
/// <summary> /// Reloads the tree. /// </summary> /// <param name="fsId">The fs id.</param> /// <param name="caps">The caps.</param> public void ReloadTree(string fsId, IFdoProviderCapabilities caps) { currentFsId = fsId; _caps = caps; ClearPreviewPanes(); trvSchema.Nodes.Clear(); BusyWaitDialog.Run(Strings.FetchingSchemaNames, () => { return(_edSvc.CurrentConnection.FeatureService.GetSchemas(currentFsId)); }, (res, ex) => { if (ex != null) { ErrorDialog.Show(ex); } else { string[] schemaNames = (string[])res; foreach (var s in schemaNames) { var schemaNode = new TreeNode(s); schemaNode.Tag = new SchemaNodeTag(s); schemaNode.ImageIndex = schemaNode.SelectedImageIndex = IDX_SCHEMA; schemaNode.Nodes.Add(Strings.TextLoading); trvSchema.Nodes.Add(schemaNode); } } }); }
/// <summary> /// Previews the specified resource /// </summary> /// <param name="res">The resource to be previewed</param> /// <param name="edSvc">The editor service</param> /// <param name="locale">The locale to use if launching a viewer-based preview</param> public void Preview(IResource res, IEditorService edSvc, string locale) { //TODO: Prompt for symbol parameters if there are any, as these can affect the rendered output //and it is a nice way to test symbol parameters wrt to rendering IServerConnection conn = edSvc.CurrentConnection; BusyWaitDelegate worker = () => { //Save the current resource to another session copy string resId = "Session:" + edSvc.SessionID + "//" + res.ResourceType.ToString() + "Preview" + Guid.NewGuid() + "." + res.ResourceType.ToString(); //NOXLATE var resSvc = edSvc.CurrentConnection.ResourceService; resSvc.SaveResourceAs(res, resId); resSvc.CopyResource(res.ResourceID, resId, true); var previewCopy = resSvc.GetResource(resId); if (previewCopy.ResourceType == ResourceTypes.SymbolDefinition.ToString() && conn.SiteVersion >= new Version(2, 0)) { return(GenerateSymbolDefinitionPreview(conn, previewCopy, 100, 100)); } else { //Now feed it to the preview engine var url = new ResourcePreviewEngine(edSvc).GeneratePreviewUrl(previewCopy, locale); return(new UrlPreviewResult() { Url = url }); } }; Action <object, Exception> onComplete = (result, ex) => { if (ex != null) { ErrorDialog.Show(ex); } else { var urlResult = result as UrlPreviewResult; var imgResult = result as ImagePreviewResult; if (urlResult != null) { var url = urlResult.Url; _launcher.OpenUrl(url); } else if (imgResult != null) { new SymbolPreviewDialog(imgResult.ImagePreview).Show(null); } } }; BusyWaitDialog.Run(Strings.PrgPreparingResourcePreview, worker, onComplete); }
/// <summary> /// Uploads the file. /// </summary> /// <param name="fileName">Name of the file.</param> public void UploadFile(string fileName) { //TODO: Obviously support progress BusyWaitDelegate method = () => { DoFileUpload(fileName); return(null); }; BusyWaitDialog.Run(Strings.TextUploading, method, (obj, ex) => { LoadResourceData(); OnDataListChanged(); this.ResourceDataUploaded?.Invoke(Path.GetFileName(fileName), fileName); }); }
/// <summary> /// Performs any pre-save validation logic. The base implementation performs /// a <see cref="ResourceValidatorSet"/> validation (non-casccading) on the /// edited resource before attempting a save into the session repository /// (triggering any errors relating to invalid XML content). Override this /// method if the base implementation just described does not cover your /// validation needs. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected virtual void OnBeforeSave(object sender, CancelEventArgs e) { //We've been editing an in-memory model of the session copy //so we need to save this model back to the session copy before Save() //commits the changes back to the original resource _svc.UpdateResourceContent(GetXmlContent()); try { var validate = PropertyService.Get(ConfigProperties.ValidateOnSave, true); if (this.IsDirty && validate) { BusyWaitDelegate del = () => { var errors = new List <ValidationIssue>(ValidateEditedResource()).ToArray(); return(errors); }; BusyWaitDialog.Run(Strings.PrgPreSaveValidation, del, (result, ex) => { if (ex != null) { throw ex; } ValidationIssue[] errors = result as ValidationIssue[]; if (errors.Length > 0) { MessageService.ShowError(Strings.FixErrorsBeforeSaving); ValidationResultsDialog diag = new ValidationResultsDialog(this.Resource.ResourceID, errors, OpenAffectedResource); diag.ShowDialog(Workbench.Instance); e.Cancel = true; } else { e.Cancel = false; } }); } else { LoggingService.Info("Skipping validation on save"); //NOXLATE e.Cancel = false; } } catch (Exception ex) { ErrorDialog.Show(ex); e.Cancel = true; } }
private void lnkViewer_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { TreeNode root = MapTree.SelectedNode; while (root.Parent != null) { root = root.Parent; } IMapDefinition mdf = root.Tag as IMapDefinition; if (mdf != null) { BusyWaitDelegate worker = () => { IMappingService mapSvc = (IMappingService)m_connection.GetService((int)ServiceType.Mapping); var rtMap = mapSvc.CreateMap(mdf); return(rtMap); }; Action <object, Exception> onComplete = (obj, ex) => { if (ex != null) { throw ex; } if (obj != null) { var rtMap = (RuntimeMap)obj; using (var diag = new MapExtentsDialog(rtMap)) { if (diag.ShowDialog() == DialogResult.OK) { var env = diag.GetEnvelope(); txtLowerX.Text = env.MinX.ToString(CultureInfo.InvariantCulture); txtLowerY.Text = env.MinY.ToString(CultureInfo.InvariantCulture); txtUpperX.Text = env.MaxX.ToString(CultureInfo.InvariantCulture); txtUpperY.Text = env.MaxY.ToString(CultureInfo.InvariantCulture); } } } }; BusyWaitDialog.Run(Strings.PreparingMap, worker, onComplete); } }
private void RenderPreview(ResourceListResourceDocument doc) { BusyWaitDialog.Run(Strings.PrgPreparingResourcePreview, () => { var res = _conn.ResourceService.GetResource(doc.ResourceId); return(DefaultResourcePreviewer.GenerateSymbolDefinitionPreview(_conn, res, picPreview.Width, picPreview.Height)); }, (res, ex) => { if (ex != null) { ErrorDialog.Show(ex); } else { picPreview.Image = ((DefaultResourcePreviewer.ImagePreviewResult)res).ImagePreview; } }); }
private void btnFeatureCount_Click(object sender, EventArgs e) { var rules = _rules; var ldf = ((ILayerDefinition)_edSvc.GetEditedResource()); var fsId = ldf.SubLayer.ResourceId; if (ldf.SubLayer is IVectorLayerDefinition vl) { var conn = _edSvc.CurrentConnection; BusyWaitDialog.Run(Strings.CalculatingFeatureCount, () => { var totals = new List <RuleCountTotal>(); foreach (IRuleModel r in rules) { if (string.IsNullOrEmpty(r.Filter)) { totals.Add(new RuleCountTotal(r.Filter, r.LegendLabel, -1)); } else { int total = conn.GetFeatureCount(vl.ResourceId, vl.FeatureName, r.Filter); totals.Add(new RuleCountTotal(r.Filter, r.LegendLabel, total)); } } return(totals); }, (res, ex) => { if (ex != null) { ErrorDialog.Show(ex); } else if (res is List <RuleCountTotal> totals) { using (var diag = new RuleFeatureCountDialog(totals)) { diag.ShowDialog(); } } }); } }
private void btnDownload_Click(object sender, EventArgs e) { var item = this.SelectedItem; if (item != null) { using (var save = DialogFactory.SaveFile()) { save.FileName = item.Name; if (save.ShowDialog() == DialogResult.OK) { var fn = save.FileName; try { //TODO: Obviously support progress BusyWaitDelegate method = () => { IResource res = _edSvc.GetEditedResource(); var stream = _edSvc.CurrentConnection.ResourceService.GetResourceData(res.ResourceID, item.Name); using (var fs = File.OpenWrite(fn)) { Utility.CopyStream(stream, fs); } return(null); }; BusyWaitDialog.Run(Strings.TextDownloading, method, (obj, ex) => { if (ex != null) { throw ex; } MessageBox.Show(string.Format(Strings.FileDownloaded, fn)); }); } catch (Exception ex) { MessageBox.Show(NestedExceptionMessageProcessor.GetFullMessage(ex), Strings.TitleError, MessageBoxButtons.OK, MessageBoxIcon.Error); } } } } }
private void LoadFeatureClassesAsync() { btnCreate.Enabled = false; string fsId = txtFeatureSource.Text; BusyWaitDialog.Run(null, () => { return(_conn.FeatureService.GetClassNames(fsId, null)); }, (result, ex) => { if (ex != null) { ErrorDialog.Show(ex); } else { lstFeatureClasses.DataSource = result; EvalButtonState(); } }); }
private void UpdateRulePreviewsAsync(IEnumerable <IRuleModel> visibleRules) { int?styleType = null; switch (_style.StyleType) { case StyleType.Point: styleType = 1; break; case StyleType.Line: styleType = 2; break; case StyleType.Area: styleType = 3; break; case StyleType.Composite: styleType = 4; break; } var scale = 0.0; //The min scale is part of the scale range, max scale is not if (_parentScaleRange.MinScale.HasValue) { scale = _parentScaleRange.MinScale.Value; } var layerId = _edSvc.EditedResourceID; var editedRes = _edSvc.GetEditedResource(); var conn = _edSvc.CurrentConnection; var mapSvc = (IMappingService)conn.GetService((int)ServiceType.Mapping); var themeOffset = this.ThemeIndexOffest; BusyWaitDialog.Run(Strings.UpdatingStylePreviews, () => { //Background thread worker var icons = new Dictionary <int, Image>(); foreach (var rule in visibleRules) { var img = mapSvc.GetLegendImage(scale, layerId, themeOffset + rule.Index, styleType.Value, 50, 16, "PNG"); Debug.WriteLine("Requested theme icon (index: " + (themeOffset + rule.Index) + ", type: " + styleType.Value + ")"); icons[rule.Index] = img; } return(icons); }, (res, ex) => { //Run completion if (ex != null) { ErrorDialog.Show(ex); } else { if (res != null) { var icons = (Dictionary <int, Image>)res; int updated = 0; //We're back on the GUI thread now foreach (var rule in visibleRules) { if (icons.ContainsKey(rule.Index)) { rule.SetRuleStylePreview(icons[rule.Index]); updated++; } } Debug.WriteLine("Updated style previews for " + updated + " rules"); } } }); }
public override void Bind(IEditorService service) { try { _init = true; _edsvc = service; _edsvc.RegisterCustomNotifier(this); var res = service.GetEditedResource() as ILayerDefinition; Debug.Assert(res != null); _vl = res.SubLayer as IVectorLayerDefinition; Debug.Assert(_vl != null); txtFeatureClass.Text = _vl.FeatureName; txtGeometry.Text = _vl.Geometry; ResetErrorState(); if (string.IsNullOrEmpty(txtFeatureClass.Text) || string.IsNullOrEmpty(txtGeometry.Text)) { TryFillUIFromNewFeatureSource(_vl.ResourceId); if (!_edsvc.CurrentConnection.ResourceService.ResourceExists(_vl.ResourceId)) { errorProvider.SetError(txtFeatureSource, Strings.LayerEditorFeatureSourceNotFound); MessageBox.Show(Strings.LayerEditorHasErrors); } } else { bool bShowErrorMessage = false; txtFeatureSource.Text = _vl.ResourceId; string featureClass = txtFeatureClass.Text; string geometry = txtGeometry.Text; BusyWaitDialog.Run(null, () => { var errors = new List <string>(); if (!_edsvc.CurrentConnection.ResourceService.ResourceExists(_vl.ResourceId)) { errors.Add(Strings.LayerEditorFeatureSourceNotFound); } if (!string.IsNullOrEmpty(featureClass)) { ClassDefinition clsDef = null; try { clsDef = _edsvc.CurrentConnection.FeatureService.GetClassDefinition(_vl.ResourceId, featureClass); } catch { errors.Add(Strings.LayerEditorFeatureClassNotFound); //These property mappings will probably be bunk if this is the case, so clear them _vl.ClearPropertyMappings(); } if (clsDef != null) { GeometricPropertyDefinition geom = clsDef.FindProperty(geometry) as GeometricPropertyDefinition; if (geom == null) { errors.Add(Strings.LayerEditorGeometryNotFound); } } else { //This is probably true errors.Add(Strings.LayerEditorGeometryNotFound); } } return(errors); }, (result, ex) => { if (ex != null) { ErrorDialog.Show(ex); } else { var list = (List <string>)result; foreach (var err in list) { if (err == Strings.LayerEditorGeometryNotFound) { errorProvider.SetError(txtGeometry, err); bShowErrorMessage = true; } else if (err == Strings.LayerEditorFeatureSourceNotFound) { errorProvider.SetError(txtFeatureSource, err); //Don't show error message here if this is the only error as the user //will get a repair feature source prompt down the road } else if (err == Strings.LayerEditorFeatureClassNotFound) { errorProvider.SetError(txtFeatureClass, err); bShowErrorMessage = true; } } if (bShowErrorMessage) { MessageBox.Show(Strings.LayerEditorHasErrors); } } }); } txtFilter.Text = _vl.Filter; //Loose bind this one because 2.4 changes this behaviour making it //unsuitable for databinding via TextBoxBinder txtHyperlink.Text = _vl.Url; txtTooltip.Text = _vl.ToolTip; //This is not the root object so no change listeners have been subscribed _vl.PropertyChanged += WeakEventHandler.Wrap <PropertyChangedEventHandler>(OnVectorLayerPropertyChanged, (eh) => _vl.PropertyChanged -= eh); } finally { _init = false; } }
private void TryCalcMpu(string mapDef) { BusyWaitDialog.Run(Strings.CalculatingMpu, () => { var currentPath = Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath); var mpuCalc = Path.Combine(currentPath, "AddIns/Local/MpuCalc.exe"); //NOXLATE if (!File.Exists(mpuCalc) && mapDef.EndsWith(ResourceTypes.MapDefinition.ToString())) { int[] cmdTypes = m_connection.Capabilities.SupportedCommands; if (Array.IndexOf(cmdTypes, (int)OSGeo.MapGuide.MaestroAPI.Commands.CommandType.CreateRuntimeMap) < 0) { IMapDefinition mdf = (IMapDefinition)m_connection.ResourceService.GetResource(mapDef); var calc = m_connection.GetCalculator(); return(new MpuCalcResult() { Method = MpuMethod.BuiltIn, Result = Convert.ToDecimal(calc.Calculate(mdf.CoordinateSystem, 1.0)) }); } else { ICreateRuntimeMap create = (ICreateRuntimeMap)m_connection.CreateCommand((int)OSGeo.MapGuide.MaestroAPI.Commands.CommandType.CreateRuntimeMap); create.MapDefinition = mapDef; create.RequestedFeatures = (int)RuntimeMapRequestedFeatures.None; var info = create.Execute(); return(new MpuCalcResult() { Method = MpuMethod.CreateRuntimeMap, Result = Convert.ToDecimal(info.CoordinateSystem.MetersPerUnit) }); } } else { IResource res = m_connection.ResourceService.GetResource(mapDef); ITileSetDefinition tsd = res as ITileSetDefinition; IMapDefinition mdf = res as IMapDefinition; string coordSys = null; if (mdf != null) { coordSys = mdf.CoordinateSystem; } else if (tsd != null) { coordSys = tsd.GetDefaultCoordinateSystem(); } string output = string.Empty; if (coordSys != null) { var proc = new Process { StartInfo = new ProcessStartInfo { FileName = mpuCalc, Arguments = coordSys, UseShellExecute = false, RedirectStandardOutput = true, CreateNoWindow = true } }; proc.Start(); StringBuilder sb = new StringBuilder(); while (!proc.StandardOutput.EndOfStream) { string line = proc.StandardOutput.ReadLine(); // do something with line sb.AppendLine(line); } output = sb.ToString(); } double mpu; if (double.TryParse(output, out mpu)) { return new MpuCalcResult() { Method = MpuMethod.MpuCalcExe, Result = Convert.ToDecimal(mpu) } } ; else { return(string.Format(Strings.FailedToCalculateMpu, output)); } } }, (res, ex) => { if (ex != null) { ErrorDialog.Show(ex); } else { var mres = res as MpuCalcResult; if (mres != null) { MetersPerUnit.Value = mres.Result; if (mres.Method == MpuMethod.BuiltIn) { MessageBox.Show(Strings.ImperfectMpuCalculation); } } else { MessageBox.Show(res.ToString()); } } }); }
/// <summary> /// Previews the given resource /// </summary> /// <param name="res"></param> /// <param name="edSvc"></param> /// <param name="locale"></param> public void Preview(IResource res, IEditorService edSvc, string locale) { IServerConnection conn = edSvc.CurrentConnection; if (this.UseLocal && IsLocalPreviewableType(res) && SupportsMappingService(conn)) { BusyWaitDelegate worker = () => { IMappingService mapSvc = (IMappingService)conn.GetService((int)ServiceType.Mapping); IMapDefinition previewMdf = null; switch (res.ResourceType) { case "LayerDefinition": { ILayerDefinition ldf = (ILayerDefinition)res; string layerName = string.Empty; if (edSvc.IsNew) { layerName = ResourceIdentifier.GetName(ldf.SubLayer.ResourceId); } else { layerName = ResourceIdentifier.GetName(edSvc.ResourceID); } previewMdf = ResourcePreviewEngine.CreateLayerPreviewMapDefinition(ldf, edSvc.SessionID, layerName, conn); } break; case "WatermarkDefinition": { previewMdf = Utility.CreateWatermarkPreviewMapDefinition((IWatermarkDefinition)res); } break; case "MapDefinition": { previewMdf = (IMapDefinition)res; } break; } if (string.IsNullOrEmpty(previewMdf.ResourceID)) { var sessionId = edSvc.SessionID; var mdfId = "Session:" + sessionId + "//" + Guid.NewGuid() + ".MapDefinition"; //NOXLATE conn.ResourceService.SaveResourceAs(previewMdf, mdfId); previewMdf.ResourceID = mdfId; } if (previewMdf != null) { return(mapSvc.CreateMap(previewMdf, false)); } else { return(null); } }; Action <object, Exception> onComplete = (obj, ex) => { if (ex != null) { throw ex; } if (obj != null) { var rtMap = (RuntimeMap)obj; if (_viewManager != null) { _viewManager.OpenContent(ViewRegion.Document, () => new MapPreviewViewContent(rtMap, _launcher, (edSvc.IsNew) ? null : edSvc.ResourceID)); } else { var diag = new MapPreviewDialog(rtMap, _launcher, (edSvc.IsNew) ? null : edSvc.ResourceID); diag.Show(null); } } else //Fallback, shouldn't happen { _inner.Preview(res, edSvc, locale); } }; BusyWaitDialog.Run(Strings.PrgPreparingResourcePreview, worker, onComplete); } else { _inner.Preview(res, edSvc, locale); } }
private void trvSchema_AfterExpand(object sender, TreeViewEventArgs e) { var schTag = e.Node.Tag as SchemaNodeTag; var clsTag = e.Node.Tag as ClassNodeTag; if (schTag != null) { if (schTag.Loaded) { return; } e.Node.Nodes.Clear(); string schemaName = schTag.SchemaName; BusyWaitDialog.Run(Strings.FetchingClassNames, () => { return(_edSvc.CurrentConnection.FeatureService.GetClassNames(currentFsId, schemaName)); }, (res, ex) => { if (ex != null) { ErrorDialog.Show(ex); } else { var classNames = (string[])res; foreach (var qClsName in classNames) { var clsName = qClsName.Split(':')[1]; //NOXLATE var node = new TreeNode(clsName); node.Text = clsName; node.Tag = new ClassNodeTag(schTag.SchemaName, clsName); node.ImageIndex = node.SelectedImageIndex = IDX_CLASS; node.Nodes.Add(Strings.TextLoading); e.Node.Nodes.Add(node); } schTag.Loaded = true; } }); } else if (clsTag != null) { if (clsTag.Loaded) { return; } string classNameQualified = clsTag.QualifiedName; BusyWaitDialog.Run(Strings.FetchingClassDefinition, () => { return(_edSvc.CurrentConnection.FeatureService.GetClassDefinition(currentFsId, classNameQualified)); }, (res, ex) => { if (ex != null) { ErrorDialog.Show(ex); } else { var cls = (ClassDefinition)res; clsTag.Class = cls; UpdateClassNode(e.Node, cls); } }); } }
public override void Run() { var wb = Workbench.Instance; if (wb != null) { if (wb.ActiveSiteExplorer != null) { var items = wb.ActiveSiteExplorer.SelectedItems; if (items.Length == 1) { var it = items[0]; if (it.ResourceType == ResourceTypes.LayerDefinition.ToString()) { var connMgr = ServiceRegistry.GetService <ServerConnectionManager>(); var conn = connMgr.GetConnection(wb.ActiveSiteExplorer.ConnectionName); BusyWaitDialog.Run(Strings.RetrievingSpatialContextForLayer, () => { var resId = it.ResourceId; var ldf = (ILayerDefinition)conn.ResourceService.GetResource(resId); //If selected item is a Layer, it must be pointing to a Feature Source and not a Drawing Source if (ldf.SubLayer.ResourceId.EndsWith(ResourceTypes.FeatureSource.ToString())) { var ltype = ldf.SubLayer.LayerType; if (ltype == LayerType.Vector || ltype == LayerType.Raster) { var sc = ldf.GetSpatialContext(conn); if (sc == null) { if (ltype == LayerType.Vector) { IVectorLayerDefinition vl = (IVectorLayerDefinition)ldf.SubLayer; throw new SpatialContextNotFoundException(string.Format(Strings.GeometryPropertyNotFound, vl.Geometry)); } else //Raster { IRasterLayerDefinition rl = (IRasterLayerDefinition)ldf.SubLayer; throw new SpatialContextNotFoundException(string.Format(Strings.RasterPropertyNotFound, rl.Geometry)); } } return(sc); } else { throw new SpatialContextNotFoundException(string.Format(Strings.NonApplicableLayerType, ldf.SubLayer.LayerType)); } } else { throw new SpatialContextNotFoundException(string.Format(Strings.NonApplicableLayerType, ldf.SubLayer.LayerType)); } }, (res, ex) => { if (ex != null) { var nf = ex as SpatialContextNotFoundException; if (nf != null) { MessageService.ShowMessage(nf.Message); } else { ErrorDialog.Show(ex); } } else { var sc = res as IFdoSpatialContext; if (sc != null) { new SpatialContextInfoDialog(sc).ShowDialog(); } } }); } } } } }