Exemple #1
0
        /// <span class="code-SummaryComment"><summary></span>
        /// Releases the mouse, and raises the CropImage Event
        /// <span class="code-SummaryComment"></summary></span>
        protected override void OnMouseLeftButtonUp(MouseButtonEventArgs e)
        {
            base.OnMouseLeftButtonUp(e);

            if (this.IsMouseCaptured)
            {
                DisplayCanvasEventArgs args;
                switch (m_mode)
                {
                case DisplayCanvasModeID.FocusPoint:
                    args        = new DisplayCanvasEventArgs(DisplayCanvasEventID.FocusPointed);
                    args.clip.X = (int)e.GetPosition(this).X;
                    args.clip.Y = (int)e.GetPosition(this).Y;
                    RunEvent(this, args);
                    break;

                case DisplayCanvasModeID.BoxCreate:
                    args        = new DisplayCanvasEventArgs(DisplayCanvasEventID.NodeCreated);
                    args.clip   = rubber.GetClientRect();
                    args.HasBox = true;
                    RunEvent(this, args);
                    break;

                case DisplayCanvasModeID.BoxUpdate:
                    if (anchors.activeAnchorID != AnchorID.None)
                    {
                        args        = new DisplayCanvasEventArgs(DisplayCanvasEventID.NodeUpdated);
                        args.clip   = rubber.GetClientRect();
                        args.HasBox = true;
                        rubber.ReInit();     // Фиксируем изменения рамки
                    }
                    else
                    {
                        // Нажали мимо рамки - потеря фокуса
                        args        = new DisplayCanvasEventArgs(DisplayCanvasEventID.FocusPointed);
                        args.clip.X = (int)e.GetPosition(this).X;
                        args.clip.Y = (int)e.GetPosition(this).Y;
                        args.HasBox = false;
                    }
                    RunEvent(this, args);
                    break;

                case DisplayCanvasModeID.Passive:
                case DisplayCanvasModeID.Disabled:
                    break;

                default:
                    throw new Exception("Unsupported canvas mode detected!");
                }
                this.ReleaseMouseCapture();
            }
        }
 /// <span class="code-SummaryComment"><summary></span>
 /// <summary>
 /// Raised by the <span class="code-SummaryComment"><see cref="selectionCanvas">selectionCanvas</see></span>
 /// when the new crop shape (rectangle) has been drawn. This event
 /// then replaces the current selectionCanvas with a
 //        <see cref="DragCanvas">DragCanvas</see>
 /// which can then be used to drag the crop area around
 /// within a Canvas
 /// </summary>
 private void OnCanvasEvent(object sender, DisplayCanvasEventArgs args)
 {
     // Вызываем внешний обработчик события
     args.ControlID = m_controlID;
     RunCanvasEvent(this, args);
 }