示例#1
0
        private void _form_Closed(object sender, EventArgs e)
        {
            // Decouple event handlers
            this._form.Closed-=new EventHandler(_form_Closed);
            this._form.ErrorSelection-=new ErrorSelectionEventHandler(_form_ErrorSelection);
            this._form.FilterChange-=new FilterChangeEventHandler(_form_FilterChange);
            this._form.StatusChange-=new StatusChangeEventHandler(_form_StatusChange);
            this._form.Zoom-=new ZoomEventHandler(_form_Zoom);
            this._form.Pan-=new EventHandler(_form_Pan);

            IMap theMap = this.Extension.FocusMap;
            try
            {
                // Stop listening to map selection events
                if (this._selectionEventHandler != null)
                {
                    try
                    {
                        ((IActiveViewEvents_Event)theMap).SelectionChanged -= this._selectionEventHandler;
                    }
                    catch (Exception ex) {
                        util.Logger.Write("Exception caught disposing selection evt handler in ErrorManagerCmd::_form_Closed(): " + Environment.NewLine
                            + ex.Message + Environment.NewLine + ex.StackTrace);
                    }
                    this._selectionEventHandler = null;
                }

                // Clean up the error layer in the map
                IFeatureLayer theErrorLayer = this.ErrorLayer;
                if (theErrorLayer != null)
                    theMap.DeleteLayer((ILayer)theErrorLayer);

                // Remove any extra feedback
                if (this._extraFeedback != null)
                {
                    IGraphicsContainer theGCont = util.GraphicsHelper.get_GraphicsContainer(theMap);
                    theGCont.DeleteElement(this._extraFeedback);
                    this._extraFeedback = null;
                }

                this._form.Dispose();

            }
            catch (Exception ex)
            {
                util.Logger.Write("Exception caught disposing of the Error Management form:" + Environment.NewLine
                    + ex.Message + ex.StackTrace);
            }
            finally
            {
                this._form = null;
                ((IActiveView)theMap).Refresh();
                Marshal.ReleaseComObject(theMap);
            }
        }
示例#2
0
        public void Open()
        {
            IMap theMap = this.Extension.FocusMap;
            try
            {
                if (this.Extension.QAManager.ErrorCount == 0)
                {
                    MessageBox.Show("No errors to show.", "Error Manager", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }

                // Make a note of the current transaction id
                this._transactionID = "-1";
                tm.Transaction theTX = this.Extension.TransactionManager.Current();
                if (theTX != null)
                    this._transactionID = theTX.TxId;

                // Show errors in the map
                this.CreateErrorLayer();

                // Create error management dialog
                this._form = new ErrorManagerForm(false);

                // Establish event handlers
                this._form.Closed+=new EventHandler(_form_Closed);
                this._form.ErrorSelection+=new ErrorSelectionEventHandler(_form_ErrorSelection);
                this._form.FilterChange+=new FilterChangeEventHandler(_form_FilterChange);
                this._form.StatusChange+=new StatusChangeEventHandler(_form_StatusChange);
                this._form.Zoom+=new ZoomEventHandler(_form_Zoom);
                this._form.Pan+=new EventHandler(_form_Pan);

                // Start listening to map selection events
                if (this._selectionEventHandler != null)
                {
                    try
                    {
                        ((IActiveViewEvents_Event)theMap).SelectionChanged -= this._selectionEventHandler;
                    }
                    catch (Exception ex)
                    {
                        util.Logger.Write("Exception caught disposing selection evt handler in ErrorManagerCmd::Open(): " + Environment.NewLine
                            + ex.Message + Environment.NewLine + ex.StackTrace);
                    }
                    this._selectionEventHandler = null;
                }

                try
                {
                    this._selectionEventHandler = new IActiveViewEvents_SelectionChangedEventHandler(ErrorManagerCmd_SelectionChanged);
                    ((IActiveViewEvents_Event)theMap).SelectionChanged += this._selectionEventHandler;
                }
                catch (Exception ex)
                {
                    util.Logger.Write("Exception caught creating selection evt handler in ErrorManagerCmd::Open(): " + Environment.NewLine
                        + ex.Message + Environment.NewLine + ex.StackTrace);
                }

                // Show the dialog non-modally
                SetWindowLongA(this._form.Handle.ToInt32(), GWL_HWNDPARENT, this._App.hWnd);
                this._form.Show();

                // Send it the list of errors
                this.FilterErrors("");
            }
            catch (Exception ex)
            {
                if (this._form != null)
                {
                    this._form.Dispose();
                    this._form = null;
                }

                util.Logger.Write("Exception caught opening the error manager: " + Environment.NewLine
                    + ex.Message + Environment.NewLine + ex.StackTrace);
            }
            finally
            {
                Marshal.ReleaseComObject(theMap);
            }
        }