/// <summary> /// Determines whether [is double click] [the specified element]. /// </summary> /// <param name="element">The element.</param> /// <param name="e">The <see cref="System.Windows.Input.MouseButtonEventArgs"/> instance containing the event data.</param> /// <param name="clickTime">The click time.</param> /// <returns><c>true</c> if [is double click] [the specified element]; otherwise, <c>false</c>.</returns> public bool IsDoubleClick( UIElement element, MouseButtonEventArgs e, DateTime clickTime ) { var isDoubleClick = false; var span = clickTime - _firstClickTime; if ( span.TotalMilliseconds > 300 || _firstClickDone == false ) { _firstClickPosition = e.GetPosition ( element ); _firstClickDone = true; _firstClickTime = DateTime.Now; } else { var position = e.GetPosition ( element ); if ( Math.Abs ( _firstClickPosition.X - position.X ) < 4 && Math.Abs ( _firstClickPosition.Y - position.Y ) < 4 ) { isDoubleClick = true; } _firstClickDone = false; } return isDoubleClick; }
private void canvasDrawingArea_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { Shape shapeToRender = null; // Configure the correct shape to draw. switch (currentShape) { case SelectedShape.Circle: shapeToRender = new Ellipse() { Fill = Brushes.Green, Height = 35, Width = 35 }; break; case SelectedShape.Rectangle: shapeToRender = new Rectangle() { Fill = Brushes.Red, Height = 35, Width = 35, RadiusX = 10, RadiusY = 10 }; break; case SelectedShape.Line: shapeToRender = new Line() { Fill = Brushes.Blue, StrokeThickness = 10, X1 = 0, X2 = 50, Y1 = 0, Y2 = 50 }; break; default: return; } // Set top/left position to draw in the canvas. Canvas.SetLeft(shapeToRender, e.GetPosition(canvasDrawingArea).X); Canvas.SetTop(shapeToRender, e.GetPosition(canvasDrawingArea).Y); // Draw shape! canvasDrawingArea.Children.Add(shapeToRender); }
// Event raised on mouse down in the ZoomAndPanControl public static void MouseDown(object sender, MouseButtonEventArgs e,Panel p, ZoomAndPanControl z) { p.Focus(); Keyboard.Focus(p); mouseButtonDown = e.ChangedButton; origZoomAndPanControlMouseDownPoint = e.GetPosition(z); origContentMouseDownPoint = e.GetPosition(p); if ((Keyboard.Modifiers & ModifierKeys.Shift) != 0 && (e.ChangedButton == MouseButton.Left || e.ChangedButton == MouseButton.Right)) { // Shift + left- or right-down initiates zooming mode. mouseHandlingMode = MouseHandlingMode.Zooming; } else if (mouseButtonDown == MouseButton.Left) { // Just a plain old left-down initiates panning mode. mouseHandlingMode = MouseHandlingMode.Panning; } if (mouseHandlingMode != MouseHandlingMode.None) { // Capture the mouse so that we eventually receive the mouse up event. z.CaptureMouse(); e.Handled = true; } }
private void MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { _popup.Child.CaptureMouse(); _mouseCaptured = true; _mouseY = e.GetPosition(null).Y; _mouseX = e.GetPosition(null).X; }
public void GameObjectsGrid_MouseDown(object sender, MouseButtonEventArgs e) { if (sender is UIElement) { UIElement uiElement = sender as UIElement; uiElement.Focus(); } if (e.LeftButton == MouseButtonState.Pressed || e.RightButton == MouseButtonState.Pressed) { if (e.LeftButton == MouseButtonState.Pressed) { m_leftDown = true; } m_oldPos = e.GetPosition((Canvas)sender); if (Main.ObjectBuilder.click(e.GetPosition((Canvas)sender)) != null) { // we're done return; } if (e.LeftButton == MouseButtonState.Pressed) { // start selecting m_selection.startSelection(m_oldPos, sender as Canvas); } } if (e.MiddleButton == MouseButtonState.Pressed) { m_oldPos = e.GetPosition((Canvas)sender); m_middleDown = true; } //this.Canvas1.InvalidateVisual(); }
public void MyOnPreviewMouseLeftButtonDown(MouseButtonEventArgs e) { //Console.WriteLine(string.Format("Left click on {0}, handled {1}.", this.Name, e.Handled)); // super call base.OnPreviewMouseLeftButtonDown(e); // check if we clicked inside the color circle var clickPosition = e.GetPosition(colorCircle); var circleCenter = new Point(colorCircle.Width / 2, colorCircle.Height / 2); var circleRadius = colorCircle.Width / 2; var clickDistanceFromCenter = (clickPosition - circleCenter).Length; var nearEnough = clickDistanceFromCenter < circleRadius; if (!nearEnough) return; // save current values of rotation and scale var arrow = (Arrow)DataContext; var position = e.GetPosition(this); arrowDraggingData = new ArrowDraggingData( arrow.Angle, arrow.NormalizedLength, position, new Point(ActualWidth / 2, ActualHeight / 2)); IsDragging = true; // tell the event has been handled e.Handled = true; }
private void canvasDrawingArea_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { Shape shapeToRender = null; switch (currentShape) { case SelectedShape.Circle: shapeToRender = new Ellipse() { Fill = Brushes.Green, Height = 35, Width = 35 }; break; case SelectedShape.Rectangle: shapeToRender = new Rectangle() { Fill = Brushes.Red, Height = 35, Width = 35 ,RadiusX = 10, RadiusY = 10}; break; case SelectedShape.Line: shapeToRender = new Line() { Stroke = Brushes.Blue, StrokeThickness = 10, X1 = 0, X2 = 50, Y1 = 0, Y2 = 50, StrokeStartLineCap = PenLineCap.Triangle, StrokeEndLineCap = PenLineCap.Round }; break; default: return; } Canvas.SetLeft(shapeToRender, e.GetPosition(canvasDrawingArea).X); Canvas.SetTop(shapeToRender, e.GetPosition(canvasDrawingArea).Y); canvasDrawingArea.Children.Add(shapeToRender); }
void lineBetweenElipses(object sender, MouseButtonEventArgs e) { boolean = true; if (_lineStart == null) { _lineStart = e.GetPosition(this); } else { _lineEnd = e.GetPosition(this); Line lne = new Line(); lne.X1 = _lineStart.Value.X; lne.X2 = _lineEnd.Value.X; lne.Y1 = _lineStart.Value.Y; lne.Y2 = _lineEnd.Value.Y; lne.Stroke = Brushes.Red; lne.StrokeThickness = 2; Canvas.SetLeft(lne, 0); Canvas.SetTop(lne, 0); canvas.Children.Add(lne); _lineStart = null; } // bool isSecondElipse = false; // if (isSecondElipse == false) // { //} }
private void DragWindow(object sender, MouseButtonEventArgs e) { if (e.GetPosition(this).Y < 36 || e.GetPosition(this).Y > this.Height - 43) { this.DragMove(); } }
private void maingrid_MouseDown(object sender, MouseButtonEventArgs e) { _mousePosition = e.GetPosition(this); if (OnMouseMoveDown != null) OnMouseMoveDown(e.GetPosition(this)); }
/// <summary> /// Event raised on mouse down in the NetworkView. /// </summary> private void NetworkControl_MouseDown(object sender, MouseButtonEventArgs e) { NetworkView networkView = sender as NetworkView; networkView.Focus(); Keyboard.Focus(networkView); mouseButtonDown = e.ChangedButton; origZoomAndPanControlMouseDownPoint = e.GetPosition(zoomAndPanControl); origContentMouseDownPoint = e.GetPosition(networkView); if ((Keyboard.Modifiers & ModifierKeys.Shift) != 0 && (e.ChangedButton == MouseButton.Left || e.ChangedButton == MouseButton.Right)) { // Shift + left- or right-down initiates zooming mode. mouseHandlingMode = MouseHandlingMode.Zooming; } else if (mouseButtonDown == MouseButton.Left && (Keyboard.Modifiers & ModifierKeys.Control) == 0) { // // Initiate panning, when control is not held down. // When control is held down left dragging is used for drag selection. // After panning has been initiated the user must drag further than the threshold value to actually start drag panning. // mouseHandlingMode = MouseHandlingMode.Panning; } if (mouseHandlingMode != MouseHandlingMode.None) { // Capture the mouse so that we eventually receive the mouse up event. networkView.CaptureMouse(); e.Handled = true; } }
private void Window_MouseDown(object sender, MouseButtonEventArgs e) { // Создадим элллипс Ellipse эллипс = new Ellipse(); // Создадим SolidColorBrush, который заполнит эллипс SolidColorBrush цветЭллипса = new SolidColorBrush(); // Задаётся цвет случайными значениями от 100 Random r = new Random(); цветЭллипса.Color = Color.FromArgb((byte)r.Next(0, 255), (byte)r.Next(0, 255), (byte)r.Next(0, 255), 0);// Заполняем случайным цветом эллипс.Fill = цветЭллипса; эллипс.StrokeThickness = 1;// Толщина линии эллипс.Stroke = Brushes.Red;// Цвет линии красный // Установим ширину и высоту эллипса - случайные числа от 50 до 700 int ширина = r.Next(50,700); int высота = r.Next(50, 700); // Установим координаты центра - это те координаты, которые получились в результате клика мышью double X = (e.GetPosition(null)).X; double Y = (e.GetPosition(null)).Y; // Установим ширину и высоту эллипса эллипс.Width = ширина; эллипс.Height = высота; // И поставим эллипс в координаты эллипс.Margin = new Thickness(X-ширина/2,Y-высота/2,0,0); // На нашу канву добавим новый созданный эллипс canv.Children.Add(эллипс); }
public void MouseDownEvent(MouseButtonEventArgs e) { if (e.ButtonState != MouseButtonState.Pressed) return; if (!_bDrawStarted) { Mouse.Capture(_mainCanvas); _pMouseStart = e.GetPosition(_mainCanvas); _pMouseEnd = e.GetPosition(_mainCanvas); _mainCanvas.MouseMove += MainCanvas_MouseMove; DoLinePreviewDraw(); } else { if (_bShiftMode) { DoLineDraw(); Mouse.Capture(_mainCanvas); DoLinePreviewDraw(); _pMouseStart = e.GetPosition(_mainCanvas); } else { Mouse.Capture(null); _pMouseEnd = e.GetPosition(_mainCanvas); DoLineDraw(); _mainCanvas.MouseMove -= MainCanvas_MouseMove; } } }
private void canvasClicked(object sender, MouseButtonEventArgs e) { int x = (int)((e.GetPosition(mapCanvas).X - squareSpacing) / (squareWidth + squareSpacing)); int y = (int)((e.GetPosition(mapCanvas).Y - squareSpacing) / (squareHeight + squareSpacing)); switch (tool) { case ToolOptions.OBJECTIVE: tool = ToolOptions.NONE; mapSpace.setObjective(x, y); break; case ToolOptions.OBSTACLE: mapSpace.setObstacle(x, y); break; case ToolOptions.ROBOT: tool = ToolOptions.NONE; mapSpace.SetRobot(x, y); break; case ToolOptions.NONE: default: break; } drawMap(); }
private void TextBlock_MouseRightButtonDown(object sender, MouseButtonEventArgs e) { var textblock = (TextBlock)sender; OperationViewModel operation = textblock.DataContext as OperationViewModel; ContextMenu contextMenu = new ContextMenu(); CustomerViewModel vm = Customer.Data as CustomerViewModel; if (vm.Tags != null) { foreach (TagViewModel tag in vm.Tags) { contextMenu.Items.Add(new MenuItem { Header = tag.Title, Command = operation.TagCommand, CommandParameter = tag }); } } contextMenu.Items.Add(new Separator()); var referentialVM = App.Current.Resources["Referential"] as ReferentialDataViewModel; foreach (TagViewModel tag in referentialVM.StandardTags) { contextMenu.Items.Add(new MenuItem { Header = tag.Title, Command = operation.TagCommand, CommandParameter = tag }); } ContextMenuService.SetContextMenu(textblock, contextMenu); contextMenu.HorizontalOffset = e.GetPosition(null).X; contextMenu.VerticalOffset = e.GetPosition(null).Y; contextMenu.IsOpen = true; e.Handled = true; }
private void Canvas_MouseUp(object sender, MouseButtonEventArgs e) { double x = e.GetPosition(this.CanvasItemsControl).X; double y = e.GetPosition(this.CanvasItemsControl).Y; (this.DataContext as MainViewModel).AddEdgeFinish(x, y); }
private void Window_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { beginX = (int)e.GetPosition(null).X; beginY = (int)e.GetPosition(null).Y; isMousePressed = true; Boarder.Margin = new Thickness(100, 100, 100, 100); }
private void OnInboundParamComp_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { Point currPos = new Point(e.GetPosition(ParamCanvas).X, e.GetPosition(ParamCanvas).Y); ParameterModel model = GetParamModelByCoord(currPos); currModel = model; ObservableCollection<ParameterModel> models = new ObservableCollection<ParameterModel>(); for (int i = 0; i < model.SiblingModels.Length; i++) models.Add(model.SiblingModels[i]); ParamValueEditor valueEditor = new ParamValueEditor() { DataContext = models, }; valueEditor.OnRefresh += new ParamValueEditor.RefreshEventHandler(valueEditor_OnRefresh); valueEditor.ParamDataForm.CurrentItem = model; valueEditor.Show(); ParamValueChangesEvent(new EventArgs()); //Commitment was made }
private void PointGrid_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) { if (_currentPoint == null) return; int x = (int)e.GetPosition(PointGrid).X; int y = (int)e.GetPosition(PointGrid).Y; if (x < _currentPoint.X || x > _currentPoint.X + MyPoint.WIDTH || y < _currentPoint.Y || y > _currentPoint.Y + MyPoint.HEIGHT || !_game.JumpToCell(x, y, _currentPoint)) { Cell tmp = _currentPoint.CurrentCell; _currentPoint.SetNewLocation(tmp.X, tmp.Y); } ShowState(); if (_game.FreeCellsAmount == 0) MessageBox.Show(String.Format("Game over! The winner is {0}", _game.DarkCount < _game.LightCount ? "Red team" : "Green team")); else if (_game.IsLocked) { int lightCount = _game.LightCount + (_game.IsLightTurn ? 0 : _game.FreeCellsAmount); int darkCount = _game.DarkCount + (_game.IsLightTurn ? _game.FreeCellsAmount : 0); MessageBox.Show(String.Format("Game over! The winner is: {0}", (lightCount > darkCount) ? "Red team" : "Green team")); } _currentPoint.SetToBack(); _currentPoint = null; }
private void LayoutRoot_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { e.Handled = true; if (ScrollOrientation.Equals(orientation.Horizontal)) pos = e.GetPosition(null).X; else pos = e.GetPosition(null).Y; }
void Border_MouseDown(object sender, MouseButtonEventArgs e) { position = e.GetPosition(Canvas); iPosition = e.GetPosition(Border); Canvas.SetLeft(Shadow, position.X - iPosition.X); Canvas.SetTop(Shadow, position.Y - iPosition.Y); Shadow.Visibility = Visibility.Visible; }
protected void onMouseDown(Object sender, MouseButtonEventArgs e) { Rectangle rect = sender as Rectangle; _beginX = e.GetPosition(mainCanvas).X; _beginY = e.GetPosition(mainCanvas).Y; _IsMouseDown = true; rect.CaptureMouse(); }
/// <summary>${ui_action_MapAction_event_onMouseDown_D}</summary> /// <param name="e">${ui_action_MapAction_event_onMouseDown_param_e}</param> public override void OnMouseLeftButtonDown(MouseButtonEventArgs e) { oldMouseX = e.GetPosition(Map).X; oldMouseY = e.GetPosition(Map).Y; isMouseCaptured = true; //e.Handled = true; base.OnMouseLeftButtonDown(e); }
private static void substractSelectedArea(MouseButtonEventArgs e, InkPresenter inkCanvas, int clickedLayer, WriteableBitmap compressedBitmap, WriteableBitmap clickedBitmap) { Color targetColor = Common.getTargetColor(e, inkCanvas, compressedBitmap); Fill.floodFill(new Point((int)e.GetPosition(inkCanvas).X, (int)e.GetPosition(inkCanvas).Y), targetColor, Color.FromArgb(0, 0, 0, 0), compressedBitmap, clickedBitmap); MainPage.layerList[clickedLayer].wb = clickedBitmap; MainPage.layerList[clickedLayer].img.Source = clickedBitmap; }
void item_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e) { FirstXPos = e.GetPosition(sender as Control).X; FirstYPos = e.GetPosition(sender as Control).Y; FirstArrowXPos = e.GetPosition((sender as Control).Parent as Control).X - FirstXPos - 20; FirstArrowYPos = e.GetPosition((sender as Control).Parent as Control).Y - FirstYPos - 20; MovingObject = sender; }
private void OnMouseButtonUp(object sender, MouseButtonEventArgs mouseButtonEventArgs) { var delta = _mouseDownPosition - mouseButtonEventArgs.GetPosition(Application.Current.MainWindow); if (delta.Length < 1) { Click?.Invoke(_element, mouseButtonEventArgs.GetPosition(_element)); } }
protected override void OnMouseUp(MouseButtonEventArgs e) { base.OnMouseUp(e); var pos = new Vector2((float)e.GetPosition(this.image).X, (float)e.GetPosition(this.image).Y); if (ViewModel != null) ViewModel.OnMouseUp(pos, e); }
private static void keepSelectedArea(MouseButtonEventArgs e, InkPresenter inkCanvas, int clickedLayer, WriteableBitmap compressBitmap, WriteableBitmap tempBitmap, WriteableBitmap outputBitmap, ref Color targetColor, ref Color tempColor) { Fill.floodFill(new Point((int)e.GetPosition(inkCanvas).X, (int)e.GetPosition(inkCanvas).Y), targetColor, tempColor, compressBitmap, tempBitmap); Fill.floodFill(new Point((int)e.GetPosition(inkCanvas).X, (int)e.GetPosition(inkCanvas).Y), tempColor, targetColor, tempBitmap, outputBitmap); MainPage.layerList[clickedLayer].wb = outputBitmap; MainPage.layerList[clickedLayer].img.Source = outputBitmap; }
private void image_MouseDown(object sender, MouseButtonEventArgs e) { // start dragging and get the offset of the mouse // relative to the element _isDragging = true; _offset1 = e.GetPosition(image1); _offset2 = e.GetPosition(image2); this.Cursor = Cursors.Hand; }
private void ParentEl_MouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e) { if (e == null) { return; } MyCanvas = (Canvas)VisualTreeHelper.GetParent(ParentEl); Mouse.Capture(ParentEl); IsMove = true; if (!IsSelected) { IsSelected = true; } Panel.SetZIndex(ParentEl, 1); MousePositionCurr = e.GetPosition(MyCanvas); }
protected override void OnMouseUp(System.Windows.Input.MouseButtonEventArgs e) { if (e.MouseDevice.Captured == this) { if (SuppressMouseClick()) { e.Handled = true; return; } Point location = e.GetPosition(this); Visual.MouseUp(location); e.MouseDevice.Capture(null); ReleaseMouseCapture(); e.Handled = true; } }
private void LayoutRoot_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e) { _isPressed = true; GoToState(true); BringToFront(); Click(this, EventArgs.Empty); _mousePosition = e.GetPosition(null); e.Handled = true; LayoutRoot.CaptureMouse(); LayoutRoot.MouseLeftButtonUp += LayoutRoot_MouseLeftButtonUp; LayoutRoot.MouseMove += LayoutRoot_MouseMove; }
private void Canvas_MouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e) { //if (e.ButtonState == MouseButtonState.Pressed) //{ currentPoint = GetCurrentPoint(e.GetPosition(paintSurface)).ToList(); //brushIndex++; //if (brushIndex >= brushes.Length) //{ // brushIndex = 0; //} //} if (colorMode == 1) { hue += 70;//360和70相约=36和7,所以为36色,7次循环后回到最初色 } }
void RatingControl_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e) { if (IsEditable && IsEnabled && Visibility == Visibility.Visible && e != null && e.OriginalSource is UIElement) { e.Handled = true; Point p = e.GetPosition(e.OriginalSource as UIElement); if (p != null) { ChangeItemsValue(p.X); if (DEBUG_MODE) { System.Diagnostics.Debug.WriteLine("PointerMoved {0} - {1}", DateTime.Now, p.X); } } } }
// Capture the mouse event and hit test the coordinate point value against // the child visual objects. void MouseLeftButtonDownHandler(object sender, System.Windows.Input.MouseButtonEventArgs e) { ToolTipController.Hide(); // Retreive the coordinates of the mouse button event. Point pt = e.GetPosition(this); DrawingVisual hit = VisualTreeHelper.HitTest(this, pt).VisualHit as DrawingVisual; if (hit != null) { string tag = hit.ReadLocalValue(FrameworkElement.TagProperty) as string; if (tag != null) { // TODO : check if double click --> if yes --> check if end of run --> if yes --> select all of the nodes if (Keyboard.IsKeyDown(Key.RightCtrl) || Keyboard.IsKeyDown(Key.LeftCtrl)) { selectedNodes.Add(tag); } else { selectedNodes.RemoveRange(0, selectedNodes.Count); selectedNodes.Add(tag); foreach (DrawingVisual v in _graph.Children) { v.BitmapEffect = null; } } SetGlowOnDrawingVisual(hit, Colors.DarkRed); if (e.ClickCount >= 2) { MouseDoubleClickOnGraphElement(this, new MouseDoubleClickEventArgs() { Node = tag }); // TODO : az értesítés, hogy dupla klikk volt és hol --> itt lesz event, ami elsütõdik és a DotViewer feliratkozott rá // TODO : A DotViewerben is lesz egy esemény amit az elõzõ eventkezelõ elsüt. Erre iratkozik fel a MainWindow // TODO : A MainWindow-ból már minden elintézhetõ --> FONTOS: a kijeölt node száma fel kell hogy szivárogjon innen } } } }
private void MaterialCard_MouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e) { if (WaveFeedback) { double radius = Math.Max(ActualHeight, ActualWidth) * 2; ellipse2SizeAnim.To = radius; Point p = e.GetPosition((IInputElement)sender); fixAnim.To = new Thickness(-radius / 2, -radius / 2, 0, 0); Color c = new Color(); if (Background is SolidColorBrush) { c = (Background as SolidColorBrush).Color; SolidColorBrush background = (Background as SolidColorBrush); originBrush = background.Clone(); Color c3 = originBrush.Color; Color c2 = Color.FromArgb(255, (byte)(c.R * 0.96), (byte)(c.G * 0.96), (byte)(c.B * 0.96)); backgroundAnimUsingKey.KeyFrames.Clear(); backgroundAnimUsingKey.KeyFrames.Add(new EasingColorKeyFrame(c2) { EasingFunction = easeFunction }); backgroundAnimUsingKey.KeyFrames.Add(new EasingColorKeyFrame(c) { EasingFunction = easeFunction }); background = new SolidColorBrush(Color.FromArgb(c3.A, c3.R, c3.G, c3.B));//防冻结 background.BeginAnimation(SolidColorBrush.ColorProperty, backgroundAnimUsingKey); } else if (BorderBrush is SolidColorBrush) { c = (BorderBrush as SolidColorBrush).Color; } ellipse2.Fill = new SolidColorBrush(new Color() { A = (byte)(Math.Min(((byte)1.2 * c.A), 255) + 40), R = (byte)(c.R * 0.8), B = (byte)(c.B * 0.8), G = (byte)(c.G * 0.8) }); ellipse2.RenderTransform = new TranslateTransform(p.X, p.Y); ellipse2.BeginAnimation(WidthProperty, ellipse2SizeAnim); ellipse2.BeginAnimation(HeightProperty, ellipse2SizeAnim); ellipse2.BeginAnimation(OpacityProperty, ellipse2OpacityAnim); ellipse2.BeginAnimation(MarginProperty, fixAnim); } }
private void OnMouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e) { if (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl)) { // different gesture then. return; } StopTimer(); m_tracking = true; m_YRotation = 0; m_XRotation = 0; m_PreviousXRotation = 0; m_PreviousYRotation = 0; m_start = e.GetPosition(container); m_StartRotation = this.Rotation; this.captured = this.container.CaptureMouse(); }
private void Thumbnail_MouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e) { System.Windows.Point mousePoint = e.GetPosition(this.canvas_Thumbnail); double x = mousePoint.X - areaSimle.Width / 2; double y = mousePoint.Y - areaSimle.Height / 2; Canvas.SetLeft(areaSimle, x); Canvas.SetTop(areaSimle, y); System.Windows.Point imgPanelPonsition = new System.Windows.Point(); imgPanelPonsition.X = (x - moveX) * scaleX; imgPanelPonsition.Y = (y - moveY) * scaleY; Canvas.SetLeft(canvas_Seat, -imgPanelPonsition.X); Canvas.SetTop(canvas_Seat, -imgPanelPonsition.Y); e.Handled = true; }
public override void _presenter_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e) { _inkCanvas.CaptureMouse();//捕捉鼠标 Point start = e.GetPosition(_inkCanvas); _startPoint = new StylusPoint(start.X, start.Y); center = _inkCollector.CenterSelect; selectedStrokes = _inkCollector.SelectedStrokes; selectedImages = _inkCollector.SelectedImages; selectedButtons = _inkCollector.SelectButtons; _prepoint = _startPoint; foreach (MyButton myButton in selectedButtons) { preMyButtonInkFrameList.Add(myButton.Width / myButton.InkFrame.Width); } pressedMouseLeftButtonDown = true; }
private void uiAudioList_PreviewMouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e) { ListBoxItem item = sender as ListBoxItem; this.draggedItem = null; if (IsLyrics(uiAudioList, e)) { return; } if (item != null) { this.draggedItem = item; dragPosition = e.GetPosition(this.draggedItem); } }
void DockManager_MouseUp(object sender, System.Windows.Input.MouseButtonEventArgs e) { if (IsMouseCaptured) { ReleaseMouseCapture(); mMouseWin.Hide(); var pos = e.GetPosition(this); pos = this.PointToScreen(pos); EndDrag(pos); foreach (var win in mCloseWinList) { win.Close(); } } }
private void Cvs_MouseLeftButtonUp(object sender, System.Windows.Input.MouseButtonEventArgs e) { if (e.LeftButton == MouseButtonState.Released) { if (IsCropMode) { CropEnd = e.GetPosition(Cvs); if (CropEnd.X > ImageEndPoint.X) { CropEnd.X = ImageEndPoint.X; } if (CropEnd.X < ImageStartPoint.X) { CropEnd.X = ImageStartPoint.X; } if (CropEnd.Y > ImageEndPoint.Y) { CropEnd.Y = ImageEndPoint.Y; } if (CropEnd.Y < ImageStartPoint.Y) { CropEnd.Y = ImageStartPoint.Y; } //切割圖片 ImageSource imageSource = image.Source; System.Drawing.Bitmap bitmap = ImageHelper.ImageSourceToBitmap(imageSource); BitmapSource bitmapSource = ImageHelper.BitmapToBitmapImage(bitmap); double ratio = heightRatio > 0 ? heightRatio : widthRatio; BitmapSource newBitmapSource = ImageHelper.CutImage(bitmapSource, new Int32Rect((int)((rect2.Left - ImageStartPoint.X) / ratio), (int)((rect2.Top - ImageStartPoint.Y) / ratio), (int)(cropWidth / ratio), (int)(cropHeight / ratio))); //先清除CANVAS原本圖片 Cvs.Children.Remove(image); Cvs.Children.Remove(path); //結束編輯 IsCropMode = false; //設定新圖片 SettingImage(newBitmapSource); //執行過編輯 可以復原 buttonUndo.IsEnabled = true; //執行過編輯 可以儲存 buttonSure.IsEnabled = true; } } }
// This is triggered when the mouse button is pressed // on the element being hooked static void element_PreviewMouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e) { // Ensure it's a framework element as we'll need to // get access to the visual tree FrameworkElement element = sender as FrameworkElement; if (element == null) { return; } // start dragging and get the offset of the mouse // relative to the element _isDragging = true; _offset = e.GetPosition(element); }
void NetworkControl_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e) { // Save starting point, used later when determining how much to scroll. _scrollStartPoint = e.GetPosition(this); // Update the cursor if can scroll or not. #if SILVERLIGHT gridZoom.Cursor = Cursors.Hand; #else gridZoom.Cursor = Cursors.ScrollAll; #endif gridZoom.CaptureMouse(); _isMouseCaptured = true; e.Handled = true; }
protected override void OnMouseDown(System.Windows.Input.MouseButtonEventArgs e) { base.OnMouseDown(e); Point pnt = e.GetPosition(this); int XDown = (int)pnt.X; int YDown = (int)pnt.Y; GMap.NET.PointLatLng Position = FromLocalToLatLng(XDown, YDown); if (e.LeftButton == System.Windows.Input.MouseButtonState.Pressed) { MapMouseEventArgsWPF me = new MapMouseEventArgsWPF(); me.MapXLongLatWGS84 = Position.Lng; me.MapYLongLatWGS84 = Position.Lat; me.X = pnt.X; me.Y = pnt.Y; try { VMMainViewModel.Instance.NotifyMouseLeftClickOnMapEvent(me); } catch (Exception ex) { } } else if (e.RightButton == System.Windows.Input.MouseButtonState.Pressed) { MapMouseEventArgsWPF me = new MapMouseEventArgsWPF(); me.MapXLongLatWGS84 = Position.Lng; me.MapYLongLatWGS84 = Position.Lat; me.X = pnt.X; me.Y = pnt.Y; try { VMMainViewModel.Instance.NotifyMouseRightClickOnMapEvent(me); } catch (Exception ex) { } } }
private void Element_MouseLeftButtonUp(object sender, System.Windows.Input.MouseButtonEventArgs e) { if (_positionElement.TryGetTarget(out var positionElement)) { _lastLeftClickTime = DateTime.Now; _lastLeftClickPoint = e.GetPosition(positionElement); switch (_leftClickState) { case CurrentState.Idle: break; case CurrentState.FirstClickDown: _leftClickState = CurrentState.FirstClickUp; if (!_leftMouseMoved && UseLeftClickCancelling) { OnLeftSingleClick(); } break; case CurrentState.FirstClickDownHeld: if (!_leftMouseMoved) { OnLeftSingleClick(); } LeftReset(); break; case CurrentState.SecondClickDown: if (!_leftMouseMoved) { if (UseLeftClickCancelling) { OnCancelLeftSingleClick(); } OnLeftDoubleClick(); } LeftReset(); break; } } else { Dispose(); } }
private void Grid_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e) { Point mouse = e.GetPosition(MainImage); double actheight = MainImage.ActualHeight; double actwidth = MainImage.ActualWidth; mouse.X = (mouse.X / actwidth) * 1067; mouse.Y = (mouse.Y / actheight) * 657; if (!polygonFinished && polygonStarted) { Vertex v = new Vertex(mouse); if (!IsDrawing) { vm.Start = mouse; IsDrawing = true; } else { if (vm.Polygon.IsStartPoint(mouse)) { polygonFinished = true; IsDrawing = false; Bresenham.CalculateBresenhamLine((int)vm.NewLine.X, (int)vm.NewLine.Y, (int)vm.Polygon.Edges[0].Vertices[0].GetX(), (int)vm.Polygon.Edges[0].Vertices[0].GetY(), out line); } vm.Polygon.AddLine(new Edge(new Vertex(line[0]), new Vertex(line[1]))); vm.DrawPolygons(wbmap); } vm.NewLine = mouse; } else { if (vm.IsPointInPolygonVertices(mouse)) { vm.DraggedVertex = vm.Polygon.GetVertexFromPoint(mouse); vm.Adjacent = vm.Polygon.GetAdjacentEdges(mouse); VertexDrag = true; } else if (vm.IsPointInPolygonLines(mouse)) { PolygonDrag = true; vm.Waypoint = mouse; } } }
private void Rectangle_MouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e) { switch (e.ClickCount) { case 1: { mOffsetPoint = e.GetPosition(this); mStartDrag = true; } break; case 2: { Button_Maximized_Click(null, null); } break; } }
public bool IsPostion(DataGrid dtg, System.Windows.Input.MouseButtonEventArgs e) { Point aP = e.GetPosition(dtg); IInputElement obj = dtg.InputHitTest(aP); DependencyObject target = obj as DependencyObject; bool rowhit = false; while (target != null) { if (target is DataGridRow) { rowhit = true; break; } target = VisualTreeHelper.GetParent(target); } return(rowhit); }
private void Item_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e) { var control = sender as ActionItem; if (!noMoveActionTypes.Contains(control.Action.ActionType)) { isClick = true; oldPoint = e.GetPosition(null); //Debug.WriteLine(oldPoint.Y); control.CaptureMouse(); control.Cursor = Cursors.SizeAll; control.SetValue(Panel.ZIndexProperty, 1); oldMoveItemY = (control.RenderTransform as TranslateTransform).Y; HandleMoveStart(control); } }
private void AssociatedObject_MouseLeftButtonUp(object sender, System.Windows.Input.MouseButtonEventArgs e) { if (_canvas == null) { this._canvas = (VisualTreeHelper.GetParent(AssociatedObject) as Canvas); } if (_canvas == null) { Log.Error("Canvas==null"); } else { this._isDraging = true; this._offset = e.GetPosition(AssociatedObject); this._originLocation = this.GetLocation(); base.AssociatedObject.CaptureMouse(); } }
void VisualCanvas_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e) { if (IsEditable) { Mouse.Capture(this, CaptureMode.SubTree); this.IsDragStart = true; IEditableCollectionViewAddNewItem items = this.Items; StartMousePoint = e.GetPosition(sender as IInputElement); Debug.WriteLine(StartMousePoint); if (items.CanAddNewItem) { NewItem = items.AddNew(); items.CommitNew(); Canvas.SetLeft(NewCanvasItem, StartMousePoint.X); Canvas.SetTop(NewCanvasItem, StartMousePoint.Y); } } }
private static void WindowsExplorerMode_ListView_PreviewMouseLeftButtonUp(object sender, System.Windows.Input.MouseButtonEventArgs e) { var listView = sender as ListView; // select the item clicked if (!IsCtrlShiftDown()) { HitTestResult hitTestResult = VisualTreeHelper.HitTest(listView, e.GetPosition(listView)); var hitItem = hitTestResult == null ? null : GetAncestorListViewItem(hitTestResult.VisualHit); if (hitItem != null) { listView.UnselectAll(); hitItem.Focus(); hitItem.IsSelected = true; listView.GetType().GetProperty("AnchorItem", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.GetProperty).SetValue(listView, hitItem.DataContext); } } }
public override void _presenter_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e) { _inkCanvas.CaptureMouse();//捕捉鼠标 lastPoint = e.GetPosition(_inkCanvas); if (multiCustomGesture.seconds < DWELLTIME) { multiCustomGesture.seconds = 0; multiCustomGesture.timer.Stop(); if (GlobalValues.MyGraphic_IsDirectionRecognize && multiCustomGesture.strokes.Count == 0)//画的是第一条笔迹时开始捕捉笔迹 { if (multiCustomGesture.Gesture == null) { multiCustomGesture.createGesture(); } multiCustomGesture.Gesture.StartCapture((int)lastPoint.X, (int)lastPoint.Y); } } }
private void onMouseUp(object sender, System.Windows.Input.MouseButtonEventArgs e) { if (m_dragging) { if (e.ChangedButton == MouseButton.Left) { m_dragging = false; m_mousePos = e.GetPosition(m_image); applyDragToView(); render(); } else { m_dragging = false; drawDragIndicator(); } } }
private void OnViewportMouseDown(object pSender, System.Windows.Input.MouseButtonEventArgs e) { System.Windows.Point pos = e.GetPosition(m_Viewport); var hitRes = VisualTreeHelper.HitTest(m_Viewport, pos); RayMeshGeometry3DHitTestResult rayMeshRes = hitRes as RayMeshGeometry3DHitTestResult; if (rayMeshRes != null) { OnViewDown(rayMeshRes.VisualHit, new Vector2(rayMeshRes.PointHit.X, rayMeshRes.PointHit.Y), e.ChangedButton); } if (m_Mode == Mode.Calibration) { m_LastHoveredPos = pos; if (e.LeftButton == MouseButtonState.Pressed) { m_MouseMovesCamera = true; } else if (e.RightButton == MouseButtonState.Pressed) { m_MouseMovesCameraAngle = true; } else if (e.MiddleButton == MouseButtonState.Pressed) { m_MouseMovesCameraFOV = true; } } else { if (hitRes != null) { if (hitRes.VisualHit is SceneItem && (hitRes.VisualHit as SceneItem).Touchy == true) { SceneItem s = hitRes.VisualHit as SceneItem; SceneManager.Instance.CurrentScene.SelectedItem = s; isDragged = true; BackendControl.Instance.refreshGUI(); } m_LastHoveredPoint = m_HoveredPoint; } } }
protected override void OnPreviewMouseDown(System.Windows.Input.MouseButtonEventArgs e) { MultiSeleted = null; if (e.Source == this) { this.ClearAllSelection(); this.MultiSeleted = e.GetPosition(this); if (!this.Children.Contains(this.MultiSeletedRect)) { this.MultiSeletedRect.Height = 0; this.MultiSeletedRect.Width = 0; this.MultiSeletedRect.StrokeThickness = 1; this.MultiSeletedRect.Stroke = Brushes.LightSlateGray; this.MultiSeletedRect.StrokeDashArray = new DoubleCollection { 2, 2 }; this.Children.Add(this.MultiSeletedRect); Canvas.SetLeft(this.MultiSeletedRect, this.MultiSeleted.Value.X); Canvas.SetTop(this.MultiSeletedRect, this.MultiSeleted.Value.Y); } } else if (e.Source is DesignTemplate) { DesignTemplate step = e.Source as DesignTemplate; if ((Keyboard.Modifiers & (ModifierKeys.Shift | ModifierKeys.Control)) != ModifierKeys.None) { if (step.IsSelected) { this.ClearSelection(step); } else { this.AddSelection(step); } } else if (!step.IsSelected) { this.Selected(step); } } base.OnPreviewMouseDown(e); }
private void EventSource_MouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e) { _isMouseDown = true; _viewport.Children.Remove(_hoverLight); if (this.CapturingMouse != null) { // Give the listener a chance to make other controls under _eventSource non hit testable this.CapturingMouse(this, new EventArgs()); } // By capturing the mouse, mouse events will still come in even when they are moving the mouse // outside the element/form Mouse.Capture(_eventSource, CaptureMode.SubTree); // I had a case where I used the grid as the event source. If they clicked one of the 3D objects, the scene would jerk. But by saying subtree, I still get the event _previousPosition2D = e.GetPosition(_eventSource); _previousPosition3D = ProjectToTrackball(_eventSource.ActualWidth, _eventSource.ActualHeight, _previousPosition2D); }
protected override void OnMouseLeftButtonDown(System.Windows.Input.MouseButtonEventArgs e) { base.OnMouseLeftButtonDown(e); Model.IsActive = true; var layoutDocument = Model as LayoutDocument; if ((layoutDocument != null) && !layoutDocument.CanMove) { return; } if (e.ClickCount == 1) { _mouseDownPoint = e.GetPosition(this); _isMouseDown = true; } }
private void canvas1_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { if (toolState == 0) { canvas1.CaptureMouse(); if (!activelyDrawing && toolState == 0) //just started to draw, save state first (in order to undo) { updateUndoList(); activelyDrawing = true; } cur_p.x = (short)e.GetPosition(canvas1).X; cur_p.y = (short)e.GetPosition(canvas1).Y; prev_p = cur_p; } else if (toolState == 2) { bm = new WriteableBitmap(canvas1, null); Globals.scb.Color = bm.GetPixel((int)e.GetPosition(canvas1).X, (int)e.GetPosition(canvas1).Y); border2.Background = Globals.scb; makeToast("Color Sampled", ""); toolState++; fillClick(null, null); //to move to pencil mode //NavigationService.Navigate(new Uri("/ColorPicker.xaml", UriKind.Relative)); } }