Exemplo n.º 1
0
        /// <summary>
        /// Handles control's MouseMove event
        /// </summary>
        /// <param name="e"></param>
        protected override void OnMouseMove(MouseEventArgs e)
        {
            var s = CurrentScale;
            var c = new PointF(e.X - CtlCenter.X, e.Y - CtlCenter.Y);
            var p = new PointF(c.X / s - Offset.X, c.Y / s - Offset.Y);
            var d = new PointF(p.X - P0.X, p.Y - P0.Y);

            if (MoveMode && d != PointF.Empty)
            {
                Cursor = Cursors.SizeAll;
                Offset = new PointF(Offset.X + d.X, Offset.Y + d.Y);
                if (PositionChanged != null)
                {
                    PositionChanged.Invoke(this, EventArgs.Empty);
                }
                Invalidate();
                MapMoved = true;
            }
            MapPointed = new PointF(-p.X - MapCenter.X, -p.Y - MapCenter.Y);
            if (CursorPositionChanged != null)
            {
                CursorPositionChanged.Invoke(this, EventArgs.Empty);
            }
            base.OnMouseMove(e);
        }
Exemplo n.º 2
0
 void SetCurrentPosition(int position)
 {
     _nativeSelectionIsUpdating = true;
     CursorPosition             = position;
     CursorPositionChanged?.Invoke(this, EventArgs.Empty);
     _nativeSelectionIsUpdating = false;
 }
Exemplo n.º 3
0
        private void Brainf_ckEditBox_SelectionChanged(object sender, RoutedEventArgs e)
        {
            ScrollToSelection(out Rect rect);

            // Adjust the UI of the selected line highlight and the cursor indicator.
            // Both elements are translated to the right position and made visible
            // if the current selection is not collapsed to a single point, otherwise
            // they're both hidden. This is the same behavior of Visual Studio.
            if (_SelectionLength > 0)
            {
                _SelectionHighlightBorder !.Opacity    = 0;
                _CursorIndicatorRectangle !.Visibility = Visibility.Collapsed;
            }
            else
            {
                // Line highlight
                _SelectionHighlightBorder !.Opacity = 1;
                ((TranslateTransform)_SelectionHighlightBorder.RenderTransform).Y = rect.Top + Padding.Top;

                // Cursor indicator
                _CursorIndicatorRectangle !.Visibility = Visibility.Visible;
                TranslateTransform cursorTransform = (TranslateTransform)_CursorIndicatorRectangle.RenderTransform;
                cursorTransform.X = rect.X + Padding.Left;
                cursorTransform.Y = rect.Y + Padding.Top;
            }

            var position = Text.CalculateCoordinates(Document.Selection.EndPosition);
            var args     = new CursorPositionChangedEventArgs(position.Row + 1, position.Column + 1);

            // Signal the cursor movement
            CursorPositionChanged?.Invoke(this, args);
        }
Exemplo n.º 4
0
        private void OnCursorIndexChanged()
        {
            UpdateScrolling();

            CursorPositionChanged.Invoke(this);
        }
Exemplo n.º 5
0
        private void OnCursorIndexChanged()
        {
            UpdateScrolling();

            CursorPositionChanged?.Invoke(this, EventArgs.Empty);
        }
Exemplo n.º 6
0
 protected virtual void OnCursorPositionChanged(EventArgs e)
 {
     CursorPositionChanged?.Invoke(this, e);
 }
 public void RaiseCursorPositionChanged()
 {
     CursorPositionChanged?.Invoke(this, EventArgs.Empty);
 }
Exemplo n.º 8
0
 private void OnCursorPositionChanged(object o, MouseInputArgs e)
 {
     CursorPositionChanged?.Invoke(o, e);
 }
Exemplo n.º 9
0
        /// <param name="win">Окно управления</param>
        public Controller(Control win)
        {
            Form main = win.FindForm();

            win.MouseDown += (s, e) =>
            {
                switch (e.Button)
                {
                case MouseButtons.Left:
                    _isLeftMouseDown     = true;
                    CurrentMousePosition = new Point(e.X, e.Y);
                    break;

                case MouseButtons.Right:
                    _isRightMouseDown    = true;
                    CurrentMousePosition = new Point(e.X, e.Y);
                    break;

                case MouseButtons.Middle:
                    _isMiddleMouseDown   = true;
                    CurrentMousePosition = new Point(e.X, e.Y);
                    break;
                }
            };
            win.MouseUp += (s, e) =>
            {
                switch (e.Button)
                {
                case MouseButtons.Left:
                    _isLeftMouseDown = false;
                    break;

                case MouseButtons.Right:
                    _isRightMouseDown = false;
                    break;

                case MouseButtons.Middle:
                    _isMiddleMouseDown = false;
                    break;
                }
            };
            win.MouseMove += (s, e) =>
            {
                CursorPositionChanged?.Invoke(e.X, e.Y);
                // определить обработку только одной кнопки мыши
                if (_isLeftMouseDown)
                {
                    ShiftByPixel?.Invoke(e.X - CurrentMousePosition.X, e.Y - CurrentMousePosition.Y);
                    CurrentMousePosition = new Point(e.X, e.Y);
                }
                else if (_isMiddleMouseDown)
                {
                    main.Location = new Point(main.Location.X + e.X - CurrentMousePosition.X, main.Location.Y + e.Y - CurrentMousePosition.Y);
                }
            };
            win.MouseWheel += (s, e) =>
            {
                if (e.Delta > 0)
                {
                    ZoomIn?.Invoke(e.X, e.Y);
                }
                else
                {
                    ZoomOut?.Invoke(e.X, e.Y);
                }
            };
            win.KeyUp += (s, e) =>
            {
                Console.WriteLine(e.KeyValue);
                // нажатия на цифру и
                // ЛКМ - уменьшение параметра
                // ПКМ - увеличение параметра
                if (e.KeyValue > 48 && e.KeyValue < 58)
                {
                    if (_isLeftMouseDown)
                    {
                        ParameterReduced?.Invoke(e.KeyValue - 48);
                    }
                    if (_isRightMouseDown)
                    {
                        ParameterIncreased?.Invoke(e.KeyValue - 48);
                    }
                }
                switch ((HotKeys)e.KeyCode)
                {
                case HotKeys.SpeedDown:
                    SpeedDown?.Invoke();
                    break;

                case HotKeys.SpeedUp:
                    SpeedUp?.Invoke();
                    break;

                case HotKeys.StopPlay:
                    StopPlay?.Invoke();
                    break;

                case HotKeys.Statistic:
                    StatisticModeChange?.Invoke();
                    break;

                case HotKeys.ChangeWindowMode:
                    WindowModeChanged?.Invoke();
                    break;

                case HotKeys.FpsUp:
                case HotKeys.FpsUp2:
                    FpsUp?.Invoke();
                    break;

                case HotKeys.FpsDown:
                case HotKeys.FpsDown2:
                    FpsDown?.Invoke();
                    break;

                case HotKeys.SpfUp:
                    StagesByFrameUp?.Invoke();
                    break;

                case HotKeys.SpfDown:
                    StagesByFrameDown?.Invoke();
                    break;

                case HotKeys.Exit:
                    Exit?.Invoke();
                    break;
                }
            };
        }
Exemplo n.º 10
0
 /// <summary>
 /// Raises the <see cref="CursorPositionChanged"/> event
 /// </summary>
 /// <param name="sender">The <see cref="Brainf_ckEditBox"/> instance in use</param>
 /// <param name="args">The arguments for the cursor movement</param>
 private void CodeEditBox_CursorPositionChanged(Brainf_ckEditBox sender, CursorPositionChangedEventArgs args)
 {
     CursorPositionChanged?.Invoke(this, args);
 }