//TODO TabStop
 private void DataGridRowGroupHeader_PointerPressed(PointerPressedEventArgs e)
 {
     if (OwningGrid == null)
     {
         return;
     }
     if (e.GetCurrentPoint(this).Properties.IsLeftButtonPressed)
     {
         if (OwningGrid.IsDoubleClickRecordsClickOnCall(this) && !e.Handled)
         {
             ToggleExpandCollapse(!RowGroupInfo.IsVisible, true);
             e.Handled = true;
         }
         else
         {
             //if (!e.Handled && OwningGrid.IsTabStop)
             if (!e.Handled)
             {
                 OwningGrid.Focus();
             }
             e.Handled = OwningGrid.UpdateStateOnMouseLeftButtonDown(e, OwningGrid.CurrentColumnIndex, RowGroupInfo.Slot, allowEdit: false);
         }
     }
     else if (e.GetCurrentPoint(this).Properties.IsRightButtonPressed)
     {
         if (!e.Handled)
         {
             OwningGrid.Focus();
         }
         e.Handled = OwningGrid.UpdateStateOnMouseRightButtonDown(e, OwningGrid.CurrentColumnIndex, RowGroupInfo.Slot, allowEdit: false);
     }
 }
Example #2
0
 private void TrackPressed(object sender, PointerPressedEventArgs e)
 {
     if (e.GetCurrentPoint(this).Properties.IsLeftButtonPressed)
     {
         MoveToPoint(e.GetCurrentPoint(_track));
         _isDragging = true;
     }
 }
Example #3
0
        private void DecreaseButton_PointerPressed(object sender, PointerPressedEventArgs e)
        {
            if (!e.GetCurrentPoint(this).Properties.IsLeftButtonPressed)
            {
                return;
            }

            var x = e.GetCurrentPoint(_track);

            Value = x.Position.X / _track.Bounds.Width;
        }
Example #4
0
        protected override void OnPointerPressed(PointerPressedEventArgs e)
        {
            // in the same frame got focus and pressed button, ignore the event
            if (lastGotFocusFrame == frame)
            {
                return;
            }
            var left  = e.GetCurrentPoint(this).Properties.IsLeftButtonPressed;
            var right = e.GetCurrentPoint(this).Properties.IsRightButtonPressed;

            engine?.inputManager.mouse.MouseDown((left ? MouseButton.Left : MouseButton.None) | (right ? MouseButton.Right : MouseButton.None));
            base.OnPointerPressed(e);
        }
Example #5
0
 private void ImgResize_OnPointerPressed(object?sender, PointerPressedEventArgs e)
 {
     if (e.GetCurrentPoint(this).Properties.IsLeftButtonPressed)
     {
         BeginResizeDrag(WindowEdge.SouthEast, e);
     }
 }
Example #6
0
 private void InputElement_OnPointerPressed(object?sender, PointerPressedEventArgs e)
 {
     if (e.GetCurrentPoint(this).Properties.IsLeftButtonPressed)
     {
         BeginMoveDrag(e);
     }
 }
Example #7
0
 // Handlers:
 public void OnComponentClick(Component sender, PointerPressedEventArgs e)
 {
     if (_buffer == null)
     {
         _buffer = sender;
         var pos = ToGridCoordinates(e.GetCurrentPoint(Canvas).Position);
         Canvas.Children.Add(_previewConnection = new Polyline {
             Points = new List <Point> {
                 pos, pos
             }
         });
     }
     else
     {
         if (!(sender is ObservingComponent))
         {
             Connections.Add(new Connection(sender, (ObservingComponent)_buffer, _previewConnection));
         }
         else if (!(_buffer is Output))
         {
             Connections.Add(new Connection(_buffer, (ObservingComponent)sender, _previewConnection));
         }
         else
         {
             Connections.Add(new Connection((ObservingComponent)sender, (Output)_buffer, _previewConnection));
         }
         _buffer = null;
         Canvas.Children.Remove(_previewConnection);
         _previewConnection = null;
         FileHandler.Changed();
     }
 }
Example #8
0
        private async void OpenInViewer(object?sender, PointerPressedEventArgs e)
        {
            try
            {
                if (e.GetCurrentPoint(this).Properties.IsLeftButtonPressed&&
                    sender is Grid grid &&
                    grid.Children[0] is Image image)
                {
                    e.Handled = true;

                    if ((e.KeyModifiers & KeyModifiers.Control) != 0)
                    {
                        var mediaUrl = (image.DataContext as Media)?.MediaUrl;
                        App.Commands.AddToHiddenImages.Execute((mediaUrl, this.PointToScreen(new Point(5, 10))));
                    }
                    else
                    {
                        await ImageService.OpenInViewer(image);
                    }
                }
            }
            catch (Exception ex)
            {
                TraceService.Message(ex.Message);
            }
        }
Example #9
0
        private void HandlePointerPressed(PointerPressedEventArgs e)
        {
            var properties = e.GetCurrentPoint(RelativeTo).Properties;

            if (properties.IsLeftButtonPressed)
            {
                if (InputTarget != null)
                {
                    var point = AdjustGetPosition(e.GetPosition(RelativeTo));
                    var args  = new InputArgs(point.X, point.Y, GetModifier(e.KeyModifiers));
                    if (InputTarget.IsLeftDownAvailable())
                    {
                        InputTarget.LeftDown(args);
                    }
                }
            }
            else if (properties.IsRightButtonPressed)
            {
                if (InputTarget != null)
                {
                    var point = AdjustGetPosition(e.GetPosition(RelativeTo));
                    var args  = new InputArgs(point.X, point.Y, GetModifier(e.KeyModifiers));
                    if (InputTarget.IsRightDownAvailable())
                    {
                        InputTarget.RightDown(args);
                    }
                }
            }
        }
Example #10
0
        public void DragFailed(PointerPressedEventArgs e)
        {
            PointerUpdateKind MouseButton = e.GetCurrentPoint(this).Properties.PointerUpdateKind;

            if (MouseButton == PointerUpdateKind.RightButtonPressed)
            {
                ApolloContextMenu menu      = DeviceContextMenu;
                List <ISelect>    selection = Track.Get(_device)?.Window?.Selection.Selection;

                if (selection.Count == 1)
                {
                    if (selection[0] is Group group && group.Count == 1)
                    {
                        menu = GroupContextMenu;
                    }

                    else if (selection[0] is Choke)
                    {
                        menu = ChokeContextMenu;
                    }
                }

                DeviceMute.Header = GroupMute.Header = ChokeMute.Header = ((Device)selection.First()).Enabled? "Mute" : "Unmute";

                menu.Open(Draggable);
            }
        protected override void OnPointerPressed(PointerPressedEventArgs e)
        {
            base.OnPointerPressed(e);

            if (!e.GetCurrentPoint(this).Properties.IsRightButtonPressed)
            {
                e.Handled = true;
                return;
            }

            var cm    = new ContextMenu();
            var items = new List <MenuItem>();

            for (var i = 0; i < 100; ++i)
            {
                items.Add(new MenuItem {
                    Header = $"Item {i}"
                });
            }

            cm.Items = items;

            ContextMenu         = cm;
            cm.PlacementAnchor  = Avalonia.Controls.Primitives.PopupPositioning.PopupAnchor.TopLeft;
            cm.PlacementGravity = Avalonia.Controls.Primitives.PopupPositioning.PopupGravity.BottomRight;
            cm.PlacementMode    = PlacementMode.AnchorAndGravity;
            cm.PlacementRect    = new Avalonia.Rect(100, 100, 1, 1);
            cm.Open();
            e.Handled = true;
        }
Example #12
0
 /// <summary>
 /// just sets is handled to true
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void EllipsePointer_MouseLeftButtonDown(object sender, PointerPressedEventArgs e)
 {
     if (e.GetCurrentPoint(_ellipsePointer).Properties.IsLeftButtonPressed)
     {
         e.Handled = true;
     }
 }
Example #13
0
        // 鼠标按下
        protected override void OnPointerPressed(PointerPressedEventArgs e)
        {
            base.OnPointerPressed(e);

            //if (e.MouseButton != MouseButton.Left)
            //    return;
            if (e.GetCurrentPoint(this).Properties.PointerUpdateKind != PointerUpdateKind.LeftButtonPressed)
            {
                return;
            }

            // 所在面板无法在构造函数里求得
            if (parentIVisual == null)
            {
                parentIVisual = this.Parent.Parent.Parent;
            }

            isPressed   = true;
            pressPoint  = e.GetPosition(parentIVisual);
            oldLocation = new Point(NetworkItemVM.X, NetworkItemVM.Y);

            // 记录每个锚点的旧位置
            if (NetworkItemVM.ConnectorVMs != null)
            {
                foreach (Connector_VM connectorVM in NetworkItemVM.ConnectorVMs)
                {
                    connectorVM.OldPos = connectorVM.Pos;
                }
            }

            //ResourceManager.mainWindowVM.Tips = "鼠标按下,记录图形位置:" + oldLocation;

            e.Handled = true;
        }
        public void ExpCanvasPointerPressed(object sender, PointerPressedEventArgs args)
        {
            lyricBox?.EndEdit();
            if (ViewModel.NotesViewModel.Part == null)
            {
                return;
            }
            var canvas = (Canvas)sender;
            var point  = args.GetCurrentPoint(canvas);

            if (editState != null)
            {
                return;
            }
            if (point.Properties.IsLeftButtonPressed)
            {
                editState = new ExpSetValueState(canvas, ViewModel, expValueTip !);
            }
            else if (point.Properties.IsRightButtonPressed)
            {
                editState = new ExpResetValueState(canvas, ViewModel);
                Cursor    = ViewConstants.cursorNo;
            }
            if (editState != null)
            {
                editState.Begin(point.Pointer, point.Position);
                editState.Update(point.Pointer, point.Position);
            }
        }
        public void NotesCanvasPointerPressed(object sender, PointerPressedEventArgs args)
        {
            lyricBox?.EndEdit();
            if (ViewModel.NotesViewModel.Part == null)
            {
                return;
            }
            var canvas = (Canvas)sender;
            var point  = args.GetCurrentPoint(canvas);

            if (editState != null)
            {
                return;
            }
            if (point.Properties.IsLeftButtonPressed)
            {
                NotesCanvasLeftPointerPressed(canvas, point, args);
            }
            else if (point.Properties.IsRightButtonPressed)
            {
                ViewModel.NotesViewModel.DeselectNotes();
                editState = new NoteEraseEditState(canvas, ViewModel);
                Cursor    = ViewConstants.cursorNo;
            }
            else if (point.Properties.IsMiddleButtonPressed)
            {
                editState = new NotePanningState(canvas, ViewModel);
                Cursor    = ViewConstants.cursorHand;
            }
            if (editState != null)
            {
                editState.Begin(point.Pointer, point.Position);
                editState.Update(point.Pointer, point.Position);
            }
        }
Example #16
0
 private void TitleBarPressedEventHandler(object sender, PointerPressedEventArgs e)
 {
     if (e.GetCurrentPoint(this).Properties.IsLeftButtonPressed)
     {
         ((Window)this.VisualRoot).BeginMoveDrag(e);
     }
 }
Example #17
0
 private void Calendar_PointerPressed(object sender, PointerPressedEventArgs e)
 {
     if (e.GetCurrentPoint(this).Properties.IsLeftButtonPressed)
     {
         e.Handled = true;
     }
 }
Example #18
0
 private static void HandlePointerPressed <TControl>(TControl sender, PointerPressedEventArgs e) where TControl : Control
 {
     if (e.GetCurrentPoint(sender).Properties.IsLeftButtonPressed)
     {
         ((IPseudoClasses)sender.Classes).Set(":pressed", true);
     }
 }
 private void CardRenderTarget_PointerPressed(object sender, PointerPressedEventArgs e)
 {
     if (VM.CursorMode && CardRenderTarget.Children.Count > 0 && CardRenderTarget.Children[0] is Canvas renderedCard)
     {
         _dragStartingPoint = e.GetCurrentPoint(renderedCard).Position;
     }
 }
Example #20
0
        /// <inheritdoc/>
        protected override void OnPointerPressed(PointerPressedEventArgs e)
        {
            base.OnPointerPressed(e);

            if (e.GetCurrentPoint(this).Properties.IsLeftButtonPressed&& e.Pointer.Type == PointerType.Mouse)
            {
                e.Handled = UpdateSelectionFromEventSource(e.Source);
            }
        }
Example #21
0
        /// <summary>
        /// Provides class handling for the MouseLeftButtonDown event that
        /// occurs when the left mouse button is pressed while the mouse pointer
        /// is over this control.
        /// </summary>
        /// <param name="e">The event data. </param>
        /// <exception cref="System.ArgumentNullException">
        /// e is a null reference (Nothing in Visual Basic).
        /// </exception>
        /// <remarks>
        /// This method marks the MouseLeftButtonDown event as handled by
        /// setting the MouseButtonEventArgs.Handled property of the event data
        /// to true when the button is enabled and its ClickMode is not set to
        /// Hover.  Since this method marks the MouseLeftButtonDown event as
        /// handled in some situations, you should use the Click event instead
        /// to detect a button click.
        /// </remarks>
        protected override void OnPointerPressed(PointerPressedEventArgs e)
        {
            base.OnPointerPressed(e);

            if (e.GetCurrentPoint(this).Properties.IsLeftButtonPressed)
            {
                CalendarLeftMouseButtonDown?.Invoke(this, e);
            }
        }
Example #22
0
        protected override void OnPointerPressed(PointerPressedEventArgs e)
        {
            var p = e.GetCurrentPoint(this);

            if (DataContext is EditProjectVM ed)
            {
                ed.Canvas_MouseDown(ScreenPointToDominoCoordinates(p.Position), e);
            }
        }
Example #23
0
        protected override void OnPointerPressed(PointerPressedEventArgs e)
        {
            base.OnPointerPressed(e);

            e.GetCurrentPoint(this).Position.Deconstruct(out double x, out double y);
            Color c = SquareRender.HitOn(new Avalonia.PixelPoint((int)x, (int)y));

            Debug.WriteLine($"The hit color is: \"{c}\" ");
        }
Example #24
0
        void Select(PointerPressedEventArgs e)
        {
            PointerUpdateKind MouseButton = e.GetCurrentPoint(this).Properties.PointerUpdateKind;

            if (MouseButton == PointerUpdateKind.LeftButtonPressed || (MouseButton == PointerUpdateKind.RightButtonPressed && !selected))
            {
                _pattern.Window?.Selection.Select(Viewer.Frame, e.KeyModifiers.HasFlag(KeyModifiers.Shift));
            }
        }
Example #25
0
        protected override void OnPointerPressed(PointerPressedEventArgs e)
        {
            base.OnPointerPressed(e);

            if (e.GetCurrentPoint(this).Properties.IsLeftButtonPressed == true)
            {
                switch (Orientation)
                {
                case Orientation.Horizontal:
                    SelectableThumbs.Insert((int)e.GetCurrentPoint(this).Position.X, new SelectableThumb <TCustomValue>());
                    break;

                case Orientation.Vertical:
                    SelectableThumbs.Insert((int)e.GetCurrentPoint(this).Position.Y, new SelectableThumb <TCustomValue>());
                    break;
                }
            }
        }
Example #26
0
        protected override void OnPointerPressed(PointerPressedEventArgs e)
        {
            base.OnPointerPressed(e);

            if (e.GetCurrentPoint(this).Properties.IsLeftButtonPressed)
            {
                StartTimer();
            }
        }
Example #27
0
        void Click(object sender, PointerPressedEventArgs e)
        {
            PointerUpdateKind MouseButton = e.GetCurrentPoint(this).Properties.PointerUpdateKind;

            if (MouseButton == PointerUpdateKind.LeftButtonPressed)
            {
                Selected?.Invoke(Program.Project.Undo.History.IndexOf(_entry));
            }
        }
        public void picTileset_Click(object sender, PointerPressedEventArgs e)
        {
            PointerPoint         pt = e.GetCurrentPoint((IVisual)sender);
            TileBrowserViewModel vm = (TileBrowserViewModel)DataContext;

            Loc clickedLoc = new Loc((int)pt.Position.X / vm.TileSize, (int)pt.Position.Y / vm.TileSize);

            vm.SelectTile(clickedLoc, (e.InputModifiers & InputModifiers.RightMouseButton) != InputModifiers.None, (e.KeyModifiers & KeyModifiers.Shift) != KeyModifiers.None);
        }
Example #29
0
        public void Select(PointerPressedEventArgs e)
        {
            PointerUpdateKind MouseButton = e.GetCurrentPoint(this).Properties.PointerUpdateKind;

            if (MouseButton == PointerUpdateKind.LeftButtonPressed || (MouseButton == PointerUpdateKind.RightButtonPressed && !Selected))
            {
                Track.Get(_chain)?.Window?.Selection.Select(_chain, e.KeyModifiers.HasFlag(KeyModifiers.Shift));
            }
        }
Example #30
0
        void MouseDown(object sender, PointerPressedEventArgs e)
        {
            PointerUpdateKind MouseButton = e.GetCurrentPoint(this).Properties.PointerUpdateKind;

            if (MouseButton == PointerUpdateKind.LeftButtonPressed || MouseButton == PointerUpdateKind.RightButtonPressed)
            {
                mouseHeld = true;
            }
        }