Exemple #1
0
        /// <summary>
        /// 自定义快捷键
        /// 添加针对单个控件的[Ctrl+C]组合键,执行控件的拷贝功能
        /// </summary>
        /// <param oldName="msg"></param>
        /// <param oldName="keyData"></param>
        /// <returns></returns>
        protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
        {
            switch (keyData)
            {
            case Keys.Control | Keys.C:
                SVSelectPanelObjs.copyOperator();
                return(true);
            }

            return(base.ProcessCmdKey(ref msg, keyData));
        }
Exemple #2
0
        /// <summary>
        /// 初始化控件移动事件
        /// </summary>
        private void initControlMove()
        {
            Point pos = new Point();

            this.MouseDown += new MouseEventHandler((sender, e) =>
            {
                if (!IsMoved)
                {
                    return;
                }

                if (e.Button != MouseButtons.Left)
                {
                    return;
                }

                pos = new Point(e.X, e.Y);
            });

            this.MouseMove += new MouseEventHandler((sender, e) =>
            {
                Cursor.Current = Cursors.Hand;

                if (!IsMoved)
                {
                    return;
                }

                if (e.Button != MouseButtons.Left)
                {
                    return;
                }

                Int32 cX = e.X - pos.X;
                Int32 cY = e.Y - pos.Y;

                ///防止控件在拖动过程中发生滑动
                double disIValue = Math.Sqrt(cX * cX + cY * cY);
                if (!_isMouseDown)
                {
                    if (disIValue > 5)
                    {
                        _isMouseDown = true;
                    }
                    return;
                }

                ///移动选中的所有控件
                SVSelectPanelObjs.moveSelectControls(this, cX, cY);

                this.clearFocus();
            });

            this.MouseUp += new MouseEventHandler((sender, e) =>
            {
                if (!IsMoved)
                {
                    return;
                }

                Cursor.Current = Cursors.SizeAll;

                if (e.Button != MouseButtons.Left)
                {
                    return;
                }

                this.Selected = true;
                SVSelectPanelObjs.moveSelectMouseUp();
                _isMouseDown = false;
            });
        }