Beispiel #1
0
        // Occurs when MouseUp TooLStripItem glyph
        public override bool OnMouseUp(Glyph g, MouseButtons button)
        {
            ToolStripItemGlyph glyph     = g as ToolStripItemGlyph;
            ToolStripItem      glyphItem = glyph.Item;

            if (MouseHandlerPresent(glyphItem))
            {
                return(false);
            }

            SetParentDesignerValuesForDragDrop(glyphItem, false, Point.Empty);
            if (_doubleClickFired)
            {
                if (glyph != null && button == MouseButtons.Left)
                {
                    ISelectionService selSvc = GetSelectionService(glyphItem);
                    if (selSvc is null)
                    {
                        return(false);
                    }

                    ToolStripItem selectedItem = selSvc.PrimarySelection as ToolStripItem;
                    // Check if this item is already selected ...
                    if (selectedItem == glyphItem)
                    {
                        // If timer != null.. we are in DoubleClick before the "InSitu Timer" so KILL IT.
                        if (_timer != null)
                        {
                            _timer.Enabled = false;
                            _timer.Tick   -= new System.EventHandler(OnDoubleClickTimerTick);
                            _timer.Dispose();
                            _timer = null;
                        }

                        // If the Selecteditem is already in editmode ... bail out
                        if (selectedItem != null)
                        {
                            ToolStripItemDesigner selectedItemDesigner = glyph.ItemDesigner;
                            if (selectedItemDesigner != null && selectedItemDesigner.IsEditorActive)
                            {
                                return(false);
                            }

                            selectedItemDesigner.DoDefaultAction();
                        }

                        _doubleClickFired = false;
                        _mouseUpFired     = false;
                    }
                }
            }
            else
            {
                _mouseUpFired = true;
            }

            return(false);
        }
        public override bool OnMouseUp(Glyph g, MouseButtons button)
        {
            ToolStripItemGlyph glyph = g as ToolStripItemGlyph;
            ToolStripItem      item  = glyph.Item;

            if (!this.MouseHandlerPresent(item))
            {
                this.SetParentDesignerValuesForDragDrop(item, false, Point.Empty);
                if (this.doubleClickFired)
                {
                    if ((glyph != null) && (button == MouseButtons.Left))
                    {
                        ISelectionService selectionService = this.GetSelectionService(item);
                        if (selectionService == null)
                        {
                            return(false);
                        }
                        ToolStripItem primarySelection = selectionService.PrimarySelection as ToolStripItem;
                        if (primarySelection == item)
                        {
                            if (this._timer != null)
                            {
                                this._timer.Enabled = false;
                                this._timer.Tick   -= new EventHandler(this.OnDoubleClickTimerTick);
                                this._timer.Dispose();
                                this._timer = null;
                            }
                            if (primarySelection != null)
                            {
                                ToolStripItemDesigner itemDesigner = glyph.ItemDesigner;
                                if ((itemDesigner != null) && itemDesigner.IsEditorActive)
                                {
                                    return(false);
                                }
                                itemDesigner.DoDefaultAction();
                            }
                            this.doubleClickFired = false;
                            this.mouseUpFired     = false;
                        }
                    }
                }
                else
                {
                    this.mouseUpFired = true;
                }
            }
            return(false);
        }