Exemplo n.º 1
0
        public override void HandleMouseUp(MouseEventArgs e)
        {
            if (_Tool != null && _Tool.HandleMouseUp(e))
            {
                return;
            }

            if (e.Button == MouseButtons.Right)
            {
                /// コンテキストメニューの表示

                _contextMenu.Items.Clear();
                _miniToolBar.Items.Clear();

                var fig = Target as IFigure;
                if (fig != null && fig.GetRole() == EditorConsts.FocusFigureFigureRole)
                {
                    /// FocusのFigureならば
                    var focus = fig.GetFocus();
                    if (focus != null)
                    {
                        var menu = focus.GetContextMenuProvider().GetContextMenu(e);
                        ToolStripManager.Merge(menu, _contextMenu);
                    }
                }
                else
                {
                    var defaultMenu = _canvas.ContextMenuProvider.GetContextMenu(e);
                    if (Target != null)
                    {
                        if (fig != null && fig.GetEditor() != null)
                        {
                            /// EditorFigureかEditorFigureのPartsであればGetEditor()でEditorが取れる
                            var targetUI = fig.GetEditor().Controller.UIProvider;
                            if (targetUI != null)
                            {
                                var targetMenu = targetUI.GetContextMenu(e);
                                if (targetMenu != null)
                                {
                                    ToolStripManager.Merge(targetMenu, _contextMenu);
                                    if (_contextMenu.Items.Count > 0 && defaultMenu.Items.Count > 0)
                                    {
                                        _contextMenu.Items.Add(new ToolStripSeparator());
                                    }
                                }

                                var targetMiniToolBar = targetUI.GetMiniToolBar(e);
                                if (targetMiniToolBar != null && targetMiniToolBar.Items.Count > 0)
                                {
                                    PrepareMiniToolBar(targetMiniToolBar);
                                    ToolStripManager.Merge(targetMiniToolBar, _miniToolBar);
                                }
                            }
                        }
                    }

                    ToolStripManager.Merge(defaultMenu, _contextMenu);
                }

                if (_miniToolBar.Items.Count > 0)
                {
                    /// ツールバー・メニュー位置の調整
                    var loc      = _canvas.PointToScreen(_canvas.TranslateToControlPoint(e.Location));
                    var screenPt = Point.Empty;
                    var area     = Screen.GetWorkingArea(e.Location);
                    if (loc.Y + _contextMenu.Height < area.Bottom)
                    {
                        /// context menuが下にはみ出ない
                        screenPt = new Point(loc.X, loc.Y - _miniToolBar.Height - UISpace);
                    }
                    else
                    {
                        /// context menuが下にはみ出る

                        if (loc.Y + _miniToolBar.Height < area.Bottom)
                        {
                            /// mini tool barは下にはみ出ない
                            screenPt = new Point(loc.X, loc.Y + UISpace);
                        }
                        else
                        {
                            /// mini tool barも下にはみ出る
                            screenPt = new Point(loc.X, loc.Y - _contextMenu.Height - UISpace - _miniToolBar.Height);
                        }
                    }

                    _isMouseOnMiniToolBar             = false;
                    _needCloseMiniToolBarOnMouseLeave = false;
                    _miniToolBar.Show(screenPt);
                }
                else
                {
                    _contextMenu.Show(_canvas, _canvas.TranslateToControlPoint(e.Location));
                }
            }

            base.HandleMouseUp(e);
        }
Exemplo n.º 2
0
 // ========================================
 // method
 // ========================================
 public override bool HandleMouseDown(MouseEventArgs e)
 {
     _prevLocation = _canvas.TranslateToControlPoint(e.Location);
     OnMouseDown(e);
     return(true);
 }