//public void editModeChanged(MODETYPE_OPERATION p_EditMode)
        //{
        //    try
        //    {
        //        //Thread safe method for updating controls -  Thread is not the form thread we have to Invoke the method for thread safety.
        //        if (IsHandleCreated)
        //        {
        //            lblMode.Invoke((MethodInvoker)delegate
        //            {
        //                this.ModeTypeOperation = p_EditMode;
        //                switch (p_EditMode)
        //                {
        //                    case MODETYPE_OPERATION.EditAddCoordinate:
        //                        lblMode.Text = "Mode: Edit Add Coordinate";
        //                        break;
        //                    case MODETYPE_OPERATION.EditDeleteCoordinate:
        //                        lblMode.Text = "Mode: Edit Delete Coordinate";
        //                        break;
        //                    case MODETYPE_OPERATION.SnapModeEnabled:
        //                        lblMode.Text = "Mode: Edit Snap To Parcel";
        //                        break;
        //                    case MODETYPE_OPERATION.DrawArea:
        //                        lblMode.Text = "Mode: Draw Polygon";
        //                        break;
        //                    case MODETYPE_OPERATION.EditModeEnabled:
        //                        lblMode.Text = "Mode: Edit Move Coordinate";
        //                        break;
        //                    default:
        //                        lblMode.Text = "Mode: Select";
        //                        break;
        //                }
        //            });
        //        }
        //    }
        //    catch (Exception)
        //    {
        //    }
        //    finally
        //    {
        //    }
        //}
        //public void EventHandler_onModeTypeOperationChanged(object sender, ModeTypeEventArgs p_ModeType)
        //{
        //    try
        //    {
        //        if (inEventModeTypeOperationChanged == false)
        //        {
        //            inEventModeTypeOperationChanged = true;
        //            if (this.ModeTypeOperation != p_ModeType.MODETYPE_OPERATION)
        //            {
        //                this.ModeTypeOperation = p_ModeType.MODETYPE_OPERATION;
        //            }
        //            if (this._EditFactory != null)
        //            {
        //                if (this._EditFactory.EditModeOperation != p_ModeType.MODETYPE_OPERATION)
        //                {
        //                    this._EditFactory.OnMapModeTypeChanged(p_ModeType);
        //                }
        //            }
        //            //if (this._SnapFactory != null)
        //            //{
        //            //    if (this._SnapFactory.EditModeOperation != p_ModeType.MODETYPE_OPERATION)
        //            //    {
        //            //        this._SnapFactory.OnMapModeTypeChanged(p_ModeType);
        //            //    }
        //            //}
        //        }
        //    }
        //    catch (Exception objEx)
        //    {
        //        throw;
        //    }
        //    finally
        //    {
        //        inEventModeTypeOperationChanged = false;
        //    }
        //}
        public void EventHandler_onEditModeChanged(object sender, ModeTypeEventArgs changeArgs)
        {
            if (this.ModeTypeOperation != changeArgs.MODETYPE_OPERATION)
            {
                try
                {
                    if (IsHandleCreated)
                    {
                        axComponentControl1.MouseMode = Manifold.Interop.ControlMouseMode.ControlMouseModeNone;
                        this.ModeTypeOperation = changeArgs.MODETYPE_OPERATION;
                        gbEditMode.Text = "  Edit Mode - Disabled:  ";
                        gbDrawControls.Enabled = true;

                        if (this._EditFactory != null)
                        {
                            if (this._EditFactory.EditModeOperation != changeArgs.MODETYPE_OPERATION)
                            {
                                this._EditFactory.OnMapModeTypeChanged(changeArgs);
                            }
                        }

                        switch (changeArgs.MODETYPE_OPERATION)
                        {
                            case MODETYPE_OPERATION.SelectMode:
                                lblMode.Text = "Mode: Select";
                                Utility.unsetSelection(axComponentControl1, DrawingOriginal);
                                break;
                            case MODETYPE_OPERATION.EditModeEnabled:
                                gbDrawControls.Enabled = false;

                                gbEditMode.Text = "  Edit Mode - Enabled:  ";
                                lblMode.Text = "Mode: Edit-Move Coordinate";
                                btnEditAddCoordinate.Enabled = true;
                                btnEditDeleteCoordinate.Enabled = true;
                                btnEditMoveGeom.Enabled = true;
                                break;
                            case MODETYPE_OPERATION.EditMoveGeom:
                                gbDrawControls.Enabled = false;
                                gbEditMode.Text = "  Edit Mode - Move Geom:  ";
                                lblMode.Text = "Mode: Edit-Move Geom";
                                btnEditAddCoordinate.Enabled = true;
                                btnEditDeleteCoordinate.Enabled = true;
                                btnEditMoveGeom.Enabled = true;
                                break;
                            case MODETYPE_OPERATION.EditAddCoordinate:
                                gbDrawControls.Enabled = false;

                                gbEditMode.Text = "  Edit Mode - Add Coordinate:  ";
                                lblMode.Text = "Mode: Edit-Add Coordinate";
                                btnEditAddCoordinate.Enabled = true;
                                btnEditDeleteCoordinate.Enabled = true;
                                btnEditMoveGeom.Enabled = true;
                                break;
                            case MODETYPE_OPERATION.EditDeleteCoordinate:
                                gbDrawControls.Enabled = false;
                                gbEditMode.Text = "  Edit Mode - Delete Coordinate:  ";
                                lblMode.Text = "Mode: Edit-Delete Coordinate";
                                btnEditAddCoordinate.Enabled = true;
                                btnEditDeleteCoordinate.Enabled = true;
                                btnEditMoveGeom.Enabled = true;
                                break;
                            case MODETYPE_OPERATION.DrawArea:
                                axComponentControl1.MouseMode = Manifold.Interop.ControlMouseMode.ControlMouseModeGenericArea;
                                lblMode.Text = "Mode: Draw Area";
                                break;
                            case MODETYPE_OPERATION.DrawLine:
                                axComponentControl1.MouseMode = Manifold.Interop.ControlMouseMode.ControlMouseModeGenericLine;
                                lblMode.Text = "Mode: Draw Line";
                                break;
                            case MODETYPE_OPERATION.DrawPoint:
                                axComponentControl1.MouseMode = Manifold.Interop.ControlMouseMode.ControlMouseModeGenericPoint;
                                lblMode.Text = "Mode: Draw Point";
                                break;
                            default:
                                break;
                        }
                    }
                }
                catch (Exception err)
                {
                    MessageBox.Show("ERROR:" + err.Message);
                }
                finally
                {
                }
            }
        }
        /// <summary>
        /// If the ModeType for the MapControl is changed then raise this event to inform any LISTNERS of
        /// the change.
        /// </summary>
        /// <param name="e"></param>
        public virtual void OnMapModeTypeChanged(ModeTypeEventArgs e)
        {
            try
            {
                // Make a temporary copy of the event to avoid possibility of
                // a race condition if the last subscriber unsubscribes
                // immediately after the null check and before the event is raised.
                EventHandler<ModeTypeEventArgs> handler = MapModeTypeChanged;
                if (handler != null)
                {
                    if (inEventModeTypeOperationChanged == false)
                    {
                        inEventModeTypeOperationChanged = true;
                        // Call the Event
                        handler(this, e);

                        if (this._EditModeOperation != e.MODETYPE_OPERATION)
                        {
                            this.EditModeOperation = e.MODETYPE_OPERATION;
                        }
                    }
                }
            }
            catch (Exception objEx)
            {
                throw;
            }
            finally
            {
                inEventModeTypeOperationChanged = false;
            }
        }