async private Task Trace(object arg) { NetworkProgressReporter reporter = arg as NetworkProgressReporter; if (_doc == null || _module == null) { return; } if (reporter != null && _module.SelectedNetworkTracer is IProgressReporterEvent) { ((IProgressReporterEvent)_module.SelectedNetworkTracer).ReportProgress += reporter.FireProgressReporter; } NetworkTracerOutputCollection outputCollection = await _module.SelectedNetworkTracer.Trace( _module.SelectedNetworkFeatureClass, TracerInput(), reporter != null?reporter.CancelTracker : null); IDisplay display = (IDisplay)_doc.FocusMap; _module.RemoveAllNetworkGraphicElements(display); if (outputCollection != null) { foreach (INetworkTracerOutput output in outputCollection) { if (output is NetworkEdgeCollectionOutput) { IFeatureCursor cursor = await _module.NetworkPathEdges((NetworkEdgeCollectionOutput)output); if (cursor == null) { return; } IFeature feature; while ((feature = await cursor.NextFeature()) != null) { if (!(feature.Shape is IPolyline)) { continue; } display.GraphicsContainer.Elements.Add(new GraphicNetworkPathEdge((IPolyline)feature.Shape)); } } else if (output is NetworkPolylineOutput) { display.GraphicsContainer.Elements.Add(new GraphicNetworkPathEdge(((NetworkPolylineOutput)output).Polyline)); } else if (output is NetworkFlagOutput) { NetworkFlagOutput flag = (NetworkFlagOutput)output; string text = flag.UserData != null?flag.UserData.ToString() : "Flag"; display.GraphicsContainer.Elements.Add(new GraphicFlagPoint(flag.Location, text)); } } } }
async public Task <bool> OnEvent(object MapEvent) { if (_module != null && _module.SelectedNetworkTracer != null) { if (_module.SelectedNetworkTracer is INetworkTracerProperties && await((INetworkTracerProperties)_module.SelectedNetworkTracer).NetworkTracerProperties(_module.SelectedNetworkFeatureClass, TracerInput()) != null) { FormTracerProperties dlg = new FormTracerProperties( await((INetworkTracerProperties)_module.SelectedNetworkTracer).NetworkTracerProperties(_module.SelectedNetworkFeatureClass, TracerInput())); if (dlg.ShowDialog() != System.Windows.Forms.DialogResult.OK) { return(false); } } if (_module.SelectedNetworkTracer is IProgressReporterEvent) { NetworkProgressReporter reporter = new NetworkProgressReporter(_doc); FormTaskProgress dlg = new FormTaskProgress(); dlg.ShowProgressDialog(reporter, this.Trace(reporter)); } else { await Trace(null); } ((MapEvent)MapEvent).drawPhase = DrawPhase.Graphics; ((MapEvent)MapEvent).refreshMap = true; } return(true); }
public void OnEvent(object MapEvent) { if (_module != null && _module.SelectedNetworkTracer != null) { if (_module.SelectedNetworkTracer is INetworkTracerProperties && ((INetworkTracerProperties)_module.SelectedNetworkTracer).NetworkTracerProperties(_module.SelectedNetworkFeatureClass, TracerInput()) != null) { FormTracerProperties dlg = new FormTracerProperties( ((INetworkTracerProperties)_module.SelectedNetworkTracer).NetworkTracerProperties(_module.SelectedNetworkFeatureClass, TracerInput())); if (dlg.ShowDialog() != System.Windows.Forms.DialogResult.OK) { return; } } if (_module.SelectedNetworkTracer is IProgressReporterEvent) { NetworkProgressReporter reporter = new NetworkProgressReporter(_doc); Thread thread = new Thread(new ParameterizedThreadStart(this.Trace)); FormProgress dlg = new FormProgress(); dlg.ShowProgressDialog(reporter, reporter, thread); } else { Trace(null); } ((MapEvent)MapEvent).drawPhase = DrawPhase.Graphics; ((MapEvent)MapEvent).refreshMap = true; } }