当前位置: 首页>>代码示例>>C#>>正文


C# IDrawableContainer.HandleMouseDown方法代码示例

本文整理汇总了C#中IDrawableContainer.HandleMouseDown方法的典型用法代码示例。如果您正苦于以下问题:C# IDrawableContainer.HandleMouseDown方法的具体用法?C# IDrawableContainer.HandleMouseDown怎么用?C# IDrawableContainer.HandleMouseDown使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IDrawableContainer的用法示例。


在下文中一共展示了IDrawableContainer.HandleMouseDown方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SurfaceMouseDown

        /// <summary>
        /// This event handler is called when someone presses the mouse on a surface.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void SurfaceMouseDown(object sender, MouseEventArgs e)
        {
            _mouseStart = e.Location;

            // check contextmenu
            if (e.Button == MouseButtons.Right)
            {
                DrawableContainerList selectedList = null;
                if (selectedElements != null && selectedElements.Count > 0)
                {
                    selectedList = selectedElements;
                }
                else
                {
                    // Single element
                    IDrawableContainer rightClickedContainer = _elements.ClickableElementAt(_mouseStart.X, _mouseStart.Y);
                    if (rightClickedContainer != null)
                    {
                        selectedList = new DrawableContainerList(ID);
                        selectedList.Add(rightClickedContainer);
                    }
                }
                if (selectedList != null && selectedList.Count > 0)
                {
                    selectedList.ShowContextMenu(e, this);
                }
                return;
            }

            _mouseDown = true;
            _isSurfaceMoveMadeUndoable = false;

            if (_cropContainer != null && ((_undrawnElement == null) || (_undrawnElement != null && DrawingMode != DrawingModes.Crop)))
            {
                RemoveElement(_cropContainer, false);
                _cropContainer = null;
                _drawingElement = null;
            }

            if (_drawingElement == null && DrawingMode != DrawingModes.None)
            {
                if (_undrawnElement == null)
                {
                    DeselectAllElements();
                    if (_undrawnElement == null)
                    {
                        CreateUndrawnElement();
                    }
                }
                _drawingElement = _undrawnElement;
                // if a new element has been drawn, set location and register it
                if (_drawingElement != null)
                {
                    _drawingElement.Status = _undrawnElement.DefaultEditMode;
                    _drawingElement.PropertyChanged += ElementPropertyChanged;
                    if (!_drawingElement.HandleMouseDown(_mouseStart.X, _mouseStart.Y))
                    {
                        _drawingElement.Left = _mouseStart.X;
                        _drawingElement.Top = _mouseStart.Y;
                    }
                    AddElement(_drawingElement);
                    _drawingElement.Selected = true;
                }
                _undrawnElement = null;
            }
            else
            {
                // check whether an existing element was clicked
                // we save mouse down element separately from selectedElements (checked on mouse up),
                // since it could be moved around before it is actually selected
                _mouseDownElement = _elements.ClickableElementAt(_mouseStart.X, _mouseStart.Y);

                if (_mouseDownElement != null)
                {
                    _mouseDownElement.Status = EditStatus.MOVING;
                }
            }
        }
开发者ID:BallisticLingonberries,项目名称:ShareX,代码行数:83,代码来源:Surface.cs


注:本文中的IDrawableContainer.HandleMouseDown方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。