public override void OnKeyDown(int keyCode, int Shift)
 {
     if (keyCode == 27)
     {
         EnumDrawType drawType = this.DrawType;
         if (drawType != EnumDrawType.circle)
         {
             if (drawType == EnumDrawType.polygon)
             {
                 if (this.m_polygonFeedback != null)
                 {
                     this.m_polygonFeedback.Stop();
                 }
                 this.m_polygonFeedback = null;
             }
         }
         else
         {
             if (this.m_circleFeedback != null)
             {
                 this.m_circleFeedback.Stop();
             }
             this.m_circleFeedback = null;
         }
         this.m_mapControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
     }
 }
        public override void OnMouseDown(int Button, int Shift, int X, int Y)
        {
            if (Button == 1)
            {
                IPoint point = this.m_mapControl.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y);
                switch (this.DrawType)
                {
                case EnumDrawType.circle:
                    if (this.m_circleFeedback == null)
                    {
                        this.m_circleFeedback         = new NewCircleFeedbackClass();
                        this.m_circleFeedback.Display = this.m_mapControl.ActiveView.ScreenDisplay;
                        this.m_circleFeedback.Start(point);
                    }
                    break;

                case EnumDrawType.ellipse:
                    this.DrawEllipse();
                    break;

                case EnumDrawType.square:
                    if (this.m_rectangleFeedback == null)
                    {
                        this.m_rectangleFeedback         = new NewRectangleFeedbackClass();
                        this.m_rectangleFeedback.Display = this.m_mapControl.ActiveView.ScreenDisplay;
                        this.m_rectangleFeedback.Start(point);
                    }
                    break;

                case EnumDrawType.rectangle:
                    this.DrawRectangle();
                    break;

                case EnumDrawType.polygon:
                    if (this.m_polygonFeedback == null)
                    {
                        this.m_polygonFeedback         = new NewPolygonFeedbackClass();
                        this.m_polygonFeedback.Display = this.m_mapControl.ActiveView.ScreenDisplay;
                        ISimpleLineSymbol simpleLineSymbol = new SimpleLineSymbolClass();
                        this.m_polygonFeedback.Start(point);
                    }
                    else
                    {
                        this.m_polygonFeedback.AddPoint(point);
                    }
                    break;
                }
            }
        }
        public override void OnMouseUp(int Button, int Shift, int X, int Y)
        {
            IPoint    point    = this.m_mapControl.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y);
            IGeometry geometry = null;
            IElement  element  = null;

            switch (this.DrawType)
            {
            case EnumDrawType.circle:
                if (this.m_circleFeedback != null)
                {
                    ICircularArc circularArc = this.m_circleFeedback.Stop();
                    this.m_circleFeedback = null;
                    if (circularArc == null || circularArc.IsPoint)
                    {
                        return;
                    }
                    geometry = MapAPI.ConvertCircularArcToPolygon(circularArc);
                    element  = new CircleElementClass();
                }
                break;

            case EnumDrawType.square:
                if (this.m_rectangleFeedback != null)
                {
                    geometry = this.m_rectangleFeedback.Stop(point);
                    if ((geometry as IPointCollection).PointCount == 2)
                    {
                        this.m_rectangleFeedback = null;
                        return;
                    }
                    this.m_rectangleFeedback = null;
                    element = new PolygonElementClass();
                }
                break;
            }
            if (geometry != null)
            {
                element.Geometry = geometry;
                this.AppendNodeToTreeList(element);
            }
        }