コード例 #1
0
        protected override void OnMouseUp(MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                if (_isLeftMouseDown)
                {
                    double width = (double)(_lastMouseDownLocation.X - _lastInitialMouseDownLocation.X) / this.Width;
                    width = Math.Max(width, (double)10 / this.Width);

                    SelectionBoxEventArgs args = new SelectionBoxEventArgs()
                    {
                        X      = (double)_lastInitialMouseDownLocation.X / this.Width,
                        Y      = (double)_lastInitialMouseDownLocation.Y / this.Height,
                        Width  = width,
                        Height = width
                    };

                    _doubleClickTimer.Stop();
                    this.Invalidate();
                    if (_doubleClickTimer.ElapsedMilliseconds > 100)
                    {
                        SelectionBoxDrawn?.Invoke(args);
                    }
                }

                _isLeftMouseDown = false;
            }

            base.OnMouseUp(e);
        }
コード例 #2
0
ファイル: Viewer.cs プロジェクト: deblob/Mndl
        private void onSelectionBoxDrawn(Controls.SelectionBoxEventArgs e)
        {
            double newCenterX = (e.MiddleX * _currentValueRange) - (_currentValueRange / 2);
            double newCenterY = (e.MiddleY * _currentValueRange) - (_currentValueRange / 2);

            numXOffset.Value = (decimal)newCenterX;
            numYOffset.Value = (decimal)newCenterY;
            numScale.Value   = numScale.Value * (decimal)e.Width;

            _currentValueRange *= e.Width;
            btnPreview_Click(this, null);
        }