Beispiel #1
0
 private void myPath_MouseDown(object sender, MouseEventArgs e)
 {
     mouseVerticalPosition = e.GetPosition(scene).Y;
     mouseHorizontalPosition = e.GetPosition(scene).X;
     isDragging = true;
     ((Path)sender).CaptureMouse();
 }
        private void WindowSkin_TitleBarMouseMove(object sender, MouseEventArgs e)
        {
            if (_canRestore)
            {
                _canRestore = false;

                var percentHorizontal = e.GetPosition(this).X / ActualWidth;
                var targetHorizontal = RestoreBounds.Width * percentHorizontal;

                var percentVertical = e.GetPosition(this).Y / ActualHeight;
                var targetVertical = RestoreBounds.Height * percentVertical;

                WindowState = WindowState.Normal;

                var mousePosition = Utilities.Cursor.Position;
                Left = mousePosition.X - targetHorizontal;
                Top = mousePosition.Y - targetVertical;

                try
                {
                    DragMove();
                }
                catch (InvalidOperationException)
                {
                }
            }
        }
Beispiel #3
0
        public void Handle_MouseMove(object sender, MouseEventArgs args)
        {
            var item = sender as StackPanel;
            if (!_isMouseCaptured) return;

            // Calculate the current position of the object.
            var deltaV = args.GetPosition(null).Y - _mouseVerticalPosition;
            var deltaH = args.GetPosition(null).X - _mouseHorizontalPosition;
            var oldTop = (double)item.GetValue(Canvas.TopProperty);
            var oldLeft = (double)item.GetValue(Canvas.LeftProperty);
            var newTop = deltaV + (double) item.GetValue(Canvas.TopProperty);
            var newLeft = deltaH + (double) item.GetValue(Canvas.LeftProperty);

            // Set new position of object.
            item.SetValue(Canvas.TopProperty, newTop);
            item.SetValue(Canvas.LeftProperty, newLeft);

            var generalTransform = flagPanel.TransformToVisual(Current.Instance.MapControl);
            var childToParentCoordinates = generalTransform.Transform(new Point(0, 0));

            if(childToParentCoordinates.X <= 0)
                item.SetValue(Canvas.LeftProperty, oldLeft);
            if ((childToParentCoordinates.X + 1) + flagPanel.ActualWidth >= Current.Instance.MapControl.ActualWidth)
                item.SetValue(Canvas.LeftProperty, oldLeft);
            if (childToParentCoordinates.Y <= 0)
                item.SetValue(Canvas.TopProperty, oldTop);
            if ((childToParentCoordinates.Y + 1) + flagPanel.ActualHeight >= Current.Instance.MapControl.ActualHeight)
                item.SetValue(Canvas.TopProperty, oldTop);

            // Update position global variables.
            _mouseVerticalPosition = args.GetPosition(null).Y;
            _mouseHorizontalPosition = args.GetPosition(null).X;
        }
Beispiel #4
0
		protected override void OnMouseMove(MouseEventArgs e)
		{
			var p = e.GetPosition(this);

			if (_isSelecting)
			{
				Mouse.OverrideCursor = Cursors.IBeam;
				_selEnd = this.GetCharIndexAt(e.GetPosition(this));
				this.InvalidateVisual();
				e.Handled = true;
			}
			else if (_isDragging)
			{
				this.ColumnWidth = Math.Max(0.0, Math.Min(this.ViewportWidth / 2.0, p.X));
				this.FormatAll();
			}
			else if (this.UseTabularView && Math.Abs(p.X - (this.ColumnWidth + SeparatorPadding)) < SeparatorPadding / 2.0)
			{
				Mouse.OverrideCursor = Cursors.SizeWE;
			}
			else
			{
				Mouse.OverrideCursor = null;
				this.SelectedLink = this.HitTest(p);
				if (this.SelectedLink != null)
				{
					Mouse.OverrideCursor = Cursors.Hand;
				}
			}

			base.OnMouseMove(e);
		}
        public void AppendData(ref IDataObject data, MouseEventArgs e)
        {
            if (!(this.list.InputHitTest(e.GetPosition(e.OriginalSource as UIElement)) is ListBox)
                && !(this.list.InputHitTest(e.GetPosition(e.OriginalSource as UIElement)) is ScrollViewer)
                && !(e.OriginalSource is Thumb))
            {
                object o = this.list.SelectedItem;

                // This is cheating .. just for an example's sake..
                Debug.Assert(!data.GetDataPresent(DataFormats.Text));

                if (o.GetType() == typeof(XmlElement))
                {
                    data.SetData(DataFormats.Text, ((XmlElement)o).OuterXml);
                }
                else
                {
                    data.SetData(DataFormats.Text, o.ToString());
                }

                Debug.Assert(!data.GetDataPresent(o.GetType().ToString()));

                data.SetData(o.GetType().ToString(), o);
            }
            else
            {
                data = null;
            }
        }
        protected override void OnMouseMove(MouseEventArgs e)
        {
            base.OnMouseMove(e);

            if (isDraggingSelectionRect)
            {
                Point curMouseDownPoint = e.GetPosition(this);
                UpdateDragSelectionRect(origMouseDownPoint, curMouseDownPoint);

                e.Handled = true;
            }
            else if (isLeftMouseButtonDownOnWindow)
            {
                Point curMouseDownPoint = e.GetPosition(this);
                var dragDelta = curMouseDownPoint - origMouseDownPoint;
                double dragDistance = Math.Abs(dragDelta.Length);
                if (dragDistance > DragThreshold)
                {
                    isDraggingSelectionRect = true;

                    InitDragSelectionRect(origMouseDownPoint, curMouseDownPoint);
                }

                e.Handled = true;
            }
        }
        private void Resizeing_Form(object sender, MouseEventArgs e)
        {
            if (ResizeInProcess)
            {
                var senderRect = sender as Rectangle;

                if (senderRect != null)
                {
                    double width = e.GetPosition(this).X;

                    double height = e.GetPosition(this).Y;

                    senderRect.CaptureMouse();

                    if (senderRect.Name == "ResizeWidth")
                    {
                        width += 5;

                        if (width > 0)

                            Width = width;
                    }

                    else if (senderRect.Name == "ResizeHeigth")
                    {
                        height += 5;

                        if (height > 0)

                            Height = height;
                    }
                }
            }
        }
Beispiel #8
0
 void MouseDown(object sender, MouseEventArgs e)
 {
     if (can_move == 0 || can_edit == 0) return;
     MovingObject = sender;
     FirstX = e.GetPosition(sender as Control).X;
     FirstY = e.GetPosition(sender as Control).Y;
 }
Beispiel #9
0
        private void OnMouseMove(object sender, MouseEventArgs e)
        {
            if (!this.isMouseDown) return;

            double curx = e.GetPosition(null).X;
            double cury = e.GetPosition(null).Y;

            var r = new System.Windows.Shapes.Rectangle
            {
                Stroke = new SolidColorBrush(System.Windows.Media.Color.FromRgb(145, 0, 0)),
                StrokeThickness = 2,
                Fill = new SolidColorBrush(Colors.White),
                Width = Math.Abs(curx - this.x),
                Height = Math.Abs(cury - this.y)
            };

            cnv.Children.Clear();
            cnv.Children.Add(r);
            Canvas.SetLeft(r, this.x);
            Canvas.SetTop(r, this.y);

            if (e.LeftButton == MouseButtonState.Released)
            {
                cnv.Children.Clear();
                this.width = e.GetPosition(null).X - this.x;
                this.height = e.GetPosition(null).Y - this.y;
                this.CaptureScreen(this.x, this.y, this.width, this.height);
                this.x = this.y = 0;
                this.isMouseDown = false;
                this.Hide();
            }
        }
        void sp_MouseMove(object sender, MouseEventArgs e)
        {
            if (dragging_ && !firstDown_) {
                Point currentPosition = e.GetPosition(dragTarget_);

                var transform = dragTarget_.RenderTransform as TranslateTransform;
                if (transform == null) {
                    transform = new TranslateTransform();
                    dragTarget_.RenderTransform = transform;
                }

                transform.X += currentPosition.X - clickPosition.X;
                transform.Y += currentPosition.Y - clickPosition.Y;
                clickPosition = e.GetPosition(dragTarget_);
                //transform.X = currentPosition.X - clickPosition.X;
                //transform.Y = currentPosition.Y - clickPosition.Y;
                if (transform.X + dragTarget_.ActualWidth > canvas.MinWidth) {
                    canvas.MinWidth = canvas.Width = transform.X + dragTarget_.ActualWidth * 2;
                    canvas.InvalidateMeasure();
                    scroller.InvalidateMeasure();
                    scroller.InvalidateScrollInfo();
                }
            } else if (firstDown_)
                firstDown_ = false;
        }
Beispiel #11
0
        /// <summary>
        /// 鼠标在自定义控件上移动式时,提示框也跟随移动
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ti_MouseMove(object sender, MouseEventArgs e)
        {
            this.tip.IsOpen = true;
            this.tip.HorizontalOffset = e.GetPosition(null).X - 158;
            this.tip.VerticalOffset = e.GetPosition(null).Y - 202;

        }
Beispiel #12
0
        private void EmbeddedMap_MouseMove(object sender, MouseEventArgs e)
        {
            if (image.IsMouseCaptured)
            {
                Debug.WriteLine("Capture Move");
                var tt = (TranslateTransform) ((TransformGroup) image.RenderTransform)
                                                  .Children.First(tr => tr is TranslateTransform);
                Vector v = start - e.GetPosition(border);
                tt.X = origin.X - v.X;
                tt.Y = origin.Y - v.Y;
            }
            else
            {
                Debug.WriteLine("Normal Move");
                Point p = e.GetPosition(image);
                double scale = 360/image.ActualWidth;
                Point pGeo = new Point(p.X*scale - 180, 90 - p.Y*scale);
                locationLong.Text = string.Format("{0}", pGeo.X);
                locationLat.Text = string.Format("{0}", pGeo.Y);

                //Transform to UTM
                CoordinateTransformationFactory ctfac = new CoordinateTransformationFactory();
                ICoordinateSystem wgs84geo = ProjNet.CoordinateSystems.GeographicCoordinateSystem.WGS84;
                int zone = (int) Math.Ceiling((pGeo.X + 180)/6);
                //ICoordinateSystem utm = ProjNet.CoordinateSystems.ProjectedCoordinateSystem.WGS84_UTM(zone, pGeo.Y > 0);
                //ICoordinateTransformation trans = ctfac.CreateFromCoordinateSystems(wgs84geo, utm);
                //Point pUtm = trans.MathTransform.Transform(pGeo);
                //locationX.Text = string.Format("N{0}", pUtm.Y);
                //locationY.Text = string.Format("E{0}", pUtm.X);
                locationZone.Text = string.Format("Zone {0}{1}", zone, pGeo.Y > 0 ? 'N' : 'S');
            }
        }
Beispiel #13
0
        private void Window_MouseMove(object sender, MouseEventArgs e)
        {
            //si la souris bouge
            if (e.LeftButton == MouseButtonState.Pressed)
            {
                mousePosMove.X = e.GetPosition(this.mainGrid).X;
                mousePosMove.Y = e.GetPosition(this.mainGrid).Y;

                double deplX = mousePosDown.X - mousePosMove.X;

                //Déplacement du mainComponent
                this.mainComponent.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
                this.mainComponent.Margin = new Thickness(-deplX, 0, 0, 0);
                this.mainComponent.Width = 500;

                //déplacement de la souris vers la gauche avec bouton gauche enfoncé
                if (this.mainComponent.Margin.Left <= -350)
                {
                    for (int i = 0; i < 250; i++)
                    {
                        this.mainComponent.Margin = new Thickness(this.mainComponent.Margin.Left - 1, 0, 0, 0);
                    }
                    this.mainGrid.Children.Remove(mainComponent);

                    //ajout brikComponent
                    ajoutBrikComponent();
                }
            }
        }
        // The DrawPixel method updates the WriteableBitmap by using
        // unsafe code to write a pixel into the back buffer.
        static void DrawPixel(MouseEventArgs e)
        {
            int column = (int)e.GetPosition(i).X;
            int row = (int)e.GetPosition(i).Y;

            // Reserve the back buffer for updates.
            writeableBitmap.Lock();

            unsafe
            {
                // Get a pointer to the back buffer.
                int pBackBuffer = (int)writeableBitmap.BackBuffer;

                // Find the address of the pixel to draw.
                pBackBuffer += row * writeableBitmap.BackBufferStride;
                pBackBuffer += column * 4;

                // Compute the pixel's color.
                int color_data = 255 << 16; // R
                color_data |= 128 << 8;   // G
                color_data |= 255 << 0;   // B

                // Assign the color data to the pixel.
                *((int*)pBackBuffer) = color_data;
            }

            // Specify the area of the bitmap that changed.
            writeableBitmap.AddDirtyRect(new Int32Rect(column, row, 1, 1));

            // Release the back buffer and make it available for display.
            writeableBitmap.Unlock();
        }
Beispiel #15
0
 void item_PreviewMouseMove(object sender, MouseEventArgs e)
 {
     if (e.LeftButton == MouseButtonState.Pressed && sender == MovingObject)
     {
         (sender as Control).SetValue(LeftProperty, e.GetPosition((sender as Control).Parent as Control).X - FirstXPos - 20);
         (sender as Control).SetValue(TopProperty, e.GetPosition((sender as Control).Parent as Control).Y - FirstYPos - 20);
     }
 }
Beispiel #16
0
        void MyDragView_Dragging(object sender, MouseEventArgs e)
        {
            System.Diagnostics.Debug.WriteLine("DRAGGING");

            DragView dv = (DragView)sender;
            dv.SetValue(Canvas.LeftProperty, e.GetPosition(null).X - (dv.Width / 2));
            dv.SetValue(Canvas.TopProperty, e.GetPosition(null).Y - (dv.Height / 2));
        }
 private void VerticalRotatorImage_OnMouseMove(object sender, MouseEventArgs e)
 {
     if (!_isLeftMouseButtonDown) return;
     var currentPosition = e.GetPosition(null);
     var rotation = 0.005f * (float)(_previousMousePosition.Y - currentPosition.Y);
     _camera.VerticalAngle += rotation;
     _previousMousePosition = e.GetPosition(null);
 }
Beispiel #18
0
        protected override void OnMouseMove(MouseEventArgs e)
        {
            base.OnMouseMove(e);

            var pos = new Vector2((float)e.GetPosition(this.image).X, (float)e.GetPosition(this.image).Y);
            if (ViewModel != null)
                ViewModel.OnMouseMove(pos, e);
        }
 private void canvas1_MouseMove(object sender, MouseEventArgs e)
 {
     //マウスが青い四角領域(canvas1)上で動く度に呼び出されるメソッド
     double x = e.GetPosition(canvas1).X; //canvas1の左上をゼロとした座標
     double y = e.GetPosition(canvas1).Y;
     // カンマで区切ったマウスのxy座標を送信
     sendMessage(x + "," + y);
 }
 private void KKBOXNavigationBar_MouseMove(object sender, MouseEventArgs e)
 {
     if (this.isWndMove)
     {
         this.Left = this.Left + e.GetPosition(this).X - this.curr_x;
         this.Top = this.Top + e.GetPosition(this).Y - this.curr_y;
     }
 }
Beispiel #21
0
 public void MousePressed(object sender, MouseEventArgs e)
 {
     // TODO: is Shift down -> fastMode=true
     Debug.WriteLine("MousePressed!!");
     startPoint.ProjectionStoE((int)e.GetPosition((UIElement)sender).X, (int)e.GetPosition((UIElement)sender).Y,
                                 model.GetSOrigin(), model.GetSMax());
     isDragging = true;
 }
 public void Handle_MouseDown(object sender, MouseEventArgs args)
 {
     Canvas item = sender as Canvas;
     mouseVerticalPosition = args.GetPosition(null).Y;
     mouseHorizontalPosition = args.GetPosition(null).X;
     isMouseCaptured = true;
     item.CaptureMouse();
 }
Beispiel #23
0
        /// <summary>
        /// Handles mouse move to draw the line and intensity histograms
        /// </summary>
        private void ThrottledEvent_ThrottledMouseMove(object sender, MouseEventArgs e)
        {
            if (!this.leftButtonDown)
            {
                return;
            }

            line.X2 = e.GetPosition(grid).X;
            line.Y2 = e.GetPosition(grid).Y;

            // compute distance between the points
            double distance = Math.Sqrt((line.X1 - line.X2) * (line.X1 - line.X2) + (line.Y1 - line.Y2) * (line.Y1 - line.Y2));

            this.redLine.Points.Clear();
            this.greenLine.Points.Clear();
            this.blueLine.Points.Clear();

            int b = 16;
            var histoR = new int[256 / b];
            var histoG = new int[256 / b];
            var histoB = new int[256 / b];

            // build the charts
            int n = 0;
            for (double pt = 0; pt < distance; pt++)
            {
                double xPos = line.X1 + (line.X2 - line.X1) * pt / distance;
                double yPos = line.Y1 + (line.Y2 - line.Y1) * pt / distance;

                var xIndex = (int)xPos;
                var yIndex = (int)yPos;

                int pixel = this.pixelData[xIndex + (yIndex * 300)];

                // the RGB values are 'packed' into an int, here we unpack them
                var blue = (byte)(pixel & 0xFF);
                pixel >>= 8;
                var green = (byte)(pixel & 0xFF);
                pixel >>= 8;
                var red = (byte)(pixel & 0xFF);

                histoR[red / b]++;
                histoG[green / b]++;
                histoB[blue / b]++;
                n++;
            }

            double xScale = 100.0 / histoR.Length;
            for (int i = 0; i < histoR.Length; i++)
            {
                double x = i * xScale;
                this.redLine.Points.Add(new DataPoint(x, (double)histoR[i] / n));
                this.greenLine.Points.Add(new DataPoint(x, (double)histoG[i] / n));
                this.blueLine.Points.Add(new DataPoint(x, (double)histoB[i] / n));
            }

            chart.InvalidatePlot();
        }
 private void CanvasPreviewOnMouseMove(object sender, MouseEventArgs e)
 {
     TbStatusText.Text = string.Format("X: {0}, Y: {1:0}", e.GetPosition(CanvasPreview).X, e.GetPosition(CanvasPreview).Y);
     if (e.LeftButton != MouseButtonState.Pressed) return;
     if (SkinController.SelectedElement != null) {
         PgElement.SelectedObject = null;
         PgElement.SelectedObject = SkinController.SelectedElement.SkinElement;
     }
 }
Beispiel #25
0
        protected override void OnMouseMove(MouseEventArgs e)
        {
            base.OnMouseMove(e);

            if (_isDVD && (VlcMediaPlayer != null) && State == MediaState.Playing &&
                (LibVlcManager.LibVlcVersion.DevString == "Meta"))
                VlcMediaPlayer.SetMouseCursor(0, GetVideoPositionX(e.GetPosition(this).X),
                    GetVideoPositionY(e.GetPosition(this).Y));
        }
 /// <summary>
 /// 设备移动中的逻辑
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 /// <param name="Inst"></param>
 /// <param name="pos"></param>
 /// <param name="isDragDropInEffect"></param>
 public static void Move_MouseMove(object sender, MouseEventArgs e, UserControl Inst, ref Point pos,  bool isDragDropInEffect) {
     if (isDragDropInEffect) {
         FrameworkElement currEle = Inst;
         double xPos = e.GetPosition(null).X - pos.X + currEle.Margin.Left;
         double yPos = e.GetPosition(null).Y - pos.Y + currEle.Margin.Top;
         currEle.Margin = new Thickness(xPos, yPos, 0, 0);
         pos = e.GetPosition(null);
     }
 }
        private void drawingCanvas_MouseMove(object sender, MouseEventArgs e)
        {
            if (IsMouseDown)
            {
                pointEnd = new Point(e.GetPosition(drawingCanvas).X, e.GetPosition(drawingCanvas).Y);

                DrawRect(pointEnd);
            }
        }
 private void UpdateLabelInfo(MouseEventArgs e)
 {
     this.labelInfo.Visibility = this.InputHitTest(e.GetPosition(this)) == this.image ? Visibility.Visible : Visibility.Hidden;
     Point p = e.GetPosition(this.image);
     double scale = this.bitmapImage.PixelWidth / this.image.Width;
     int actualX = (int)(scale * p.X);
     int actualY = (int)(scale * p.Y);
     this.labelInfo.Text = actualX + " x " + actualY;
 }
Beispiel #29
0
 void rect_MouseMove(object sender, MouseEventArgs e)
 {
     if (isRectMouseCapture)
     {
         Meeple meeple = (Meeple)sender;
         Canvas.SetLeft(meeple.rect, e.GetPosition(this).X - clickPosition.X);
         Canvas.SetTop(meeple.rect, e.GetPosition(this).Y - clickPosition.Y);
         Canvas.SetZIndex(meeple, 99);
     }
 }
Beispiel #30
0
        private void Canvas_MouseMove(object sender, MouseEventArgs e)
        {
            if (e.LeftButton == MouseButtonState.Pressed)
            {
                double x = e.GetPosition(this.CanvasItemsControl).X;
                double y = e.GetPosition(this.CanvasItemsControl).Y;

                (this.DataContext as MainViewModel).UpdateEdgePosition(x, y);
            }
        }
Beispiel #31
0
    void listbox_MouseMove(object sender, System.Windows.Input.MouseEventArgs e)
    {
        var pos = e.GetPosition(null);

        if (!isMoving)
        {
            manipulationStart = pos.Y;
        }
        else
        {
            manipulationEnd = pos.Y;
        }

        isMoving = true;
    }
Beispiel #32
0
 protected override void OnMouseMove(System.Windows.Input.MouseEventArgs e)
 {
     updateLastMouse(e.GetPosition(this));
 }
Beispiel #33
0
        //鼠标移动
        private void imageRobot_PreviewMouseMove(object sender, System.Windows.Input.MouseEventArgs e)
        {
            //获取当前坐标
            Point nowPoint = e.GetPosition(gridDraw);

            MapOperate.NowPoint = nowPoint;
            //显示当前坐标到界面
            MapOperate.ViewInfo.View = new Point(Math.Round(nowPoint.X, 0), Math.Round(nowPoint.Y, 0));
            //计算左键按下移动偏差
            MapOperate.mouseLeftBtnDownMoveDiff.X = nowPoint.X - MapOperate.mouseLeftBtnDownToMap.X;
            MapOperate.mouseLeftBtnDownMoveDiff.Y = nowPoint.Y - MapOperate.mouseLeftBtnDownToMap.Y;
            //判断左键按下后是否发生移动
            if (e.LeftButton == MouseButtonState.Pressed)
            {
                if (MapOperate.mouseLeftBtnDownToMap.X != nowPoint.X ||
                    MapOperate.mouseLeftBtnDownToMap.Y != nowPoint.Y)
                {
                    //标记左键按下移动状态【是否按住左键移动过】
                    MapOperate.MovedAfterLeftBtn = true;
                }
            }

            //移动视图【如果右键按下】
            if (e.RightButton == MouseButtonState.Pressed)
            {
                System.Windows.Point position  = e.GetPosition(cvMap);
                System.Windows.Point position1 = e.GetPosition(drawViewScroll);

                tlt.X += (position.X - MapOperate.mouseRightBtnDownPoint.X) * MapOperate.ViewInfo.Scale;
                tlt.Y += (position.Y - MapOperate.mouseRightBtnDownPoint.Y) * MapOperate.ViewInfo.Scale;

                //更新圆点坐标,保留两位小数
                MapOperate.ViewInfo.Origin = new Point(Math.Round(tlt.X, 0), Math.Round(tlt.Y, 0));
            }

            //编辑单个元素
            if (MapOperate.NowMode == MapOperate.EnumMode.EditElement)
            {
                //左键按住移动位置【调整元素位置】
                if (e.LeftButton == MouseButtonState.Pressed)
                {
                    //左键按下后,鼠标不移动也会进入移动事件,
                    //导致如果点击的位置不是中心,标签会动一下,
                    //很不美好,所以加坐标比较,没有变化就不进行移动
                    if (MapOperate.MovedAfterLeftBtn == false)
                    {
                        return;
                    }
                    if (MapOperate.NowSelectIndex != -1)
                    {
                        //移动标签
                        if (MapOperate.NowType == MapOperate.EnumElementType.RFID)
                        {
                            MapFunction.MoveRFIDTo(MapOperate.NowSelectIndex, nowPoint);
                        }
                        else
                        //移动直线
                        if (MapOperate.NowType == MapOperate.EnumElementType.RouteLine)
                        {
                            switch (MapOperate.ElementEditMode)
                            {
                            case MapOperate.EnumElementEditMode.Start:
                                MapFunction.MoveRouteLineStart(MapOperate.NowSelectIndex, nowPoint);
                                break;

                            case MapOperate.EnumElementEditMode.End:
                                MapFunction.MoveRouteLineEnd(MapOperate.NowSelectIndex, nowPoint);
                                break;

                            case MapOperate.EnumElementEditMode.All:
                                MapFunction.MoveRouteLineAll(MapOperate.NowSelectIndex, nowPoint);
                                break;

                            default:
                                break;
                            }
                        }
                        else
                        //移动分叉【圆弧】
                        if (MapOperate.NowType == MapOperate.EnumElementType.RouteForkLine)
                        {
                            switch (MapOperate.ElementEditMode)
                            {
                            case MapOperate.EnumElementEditMode.Start:
                                MapFunction.MoveForkLineStartForAdd(MapOperate.NowSelectIndex, nowPoint);
                                break;

                            case MapOperate.EnumElementEditMode.End:
                                MapFunction.MoveForkLineEnd(MapOperate.NowSelectIndex, nowPoint);
                                break;

                            case MapOperate.EnumElementEditMode.All:
                                MapFunction.MoveForkLineAll(MapOperate.NowSelectIndex, nowPoint);
                                break;

                            default:
                                break;
                            }
                        }
                    }
                }
            }
            else
            //多选模式
            if (MapOperate.NowMode == MapOperate.EnumMode.MultiSelect)
            {
                //绘制选择框
                MapOperate.DrawMultiSelectRect(nowPoint);
            }
            else
            //多编辑模式
            if (MapOperate.NowMode == MapOperate.EnumMode.MultiEdit)
            {
                //如果按住左键,则移动对象
                if (e.LeftButton == MouseButtonState.Pressed)
                {
                    //移动所以选中的元素
                    MapFunction.MoveMultiSelected(nowPoint, MapOperate.MultiSelected);
                }
            }
            else
            //粘贴模式
            if (MapOperate.NowMode == MapOperate.EnumMode.Paste)
            {
                //移动所以选中的元素
                MapFunction.MoveMultiSelected(nowPoint, MapOperate.PastedObject);
            }
            else
            //添加新元素
            if (MapOperate.NowMode == MapOperate.EnumMode.AddElement)
            {
                if (MapOperate.NowType == MapOperate.EnumElementType.RFID)
                {
                    MapFunction.MoveRFIDTo(MapOperate.NowSelectIndex, nowPoint);
                }
                else
                if (MapOperate.NowType == MapOperate.EnumElementType.RouteLine)
                {
                    if (MapOperate.AddStep == 1)
                    {
                        MapFunction.MoveRouteLineStartForAdd(MapOperate.NowSelectIndex, nowPoint);
                    }
                    else
                    {
                        MapFunction.MoveRouteLineEnd(MapOperate.NowSelectIndex, nowPoint);
                    }
                }
                else
                if (MapOperate.NowType == MapOperate.EnumElementType.RouteForkLine)
                {
                    if (MapOperate.AddStep == 1)
                    {
                        MapFunction.MoveForkLineStartForAdd(MapOperate.NowSelectIndex, nowPoint);
                    }
                    else
                    {
                        MapFunction.MoveForkLineEnd(MapOperate.NowSelectIndex, nowPoint);
                    }
                }
            }
        }
        public override void _presenter_MouseMove(object sender, System.Windows.Input.MouseEventArgs e)
        {
            if (pressedMouseLeftButtonDown)
            {
                if (_startPoint != null)
                {
                    current = e.GetPosition(_inkCanvas);
                    switch (MoveOrZoom)
                    {
                    case "Move":
                        double offsetx = current.X - _prepoint.X;
                        double offsety = current.Y - _prepoint.Y;
                        _inkCollector.IsAutoMove = true;

                        //移动Mybutton
                        foreach (MyButton myButton in _inkCollector.SelectButtons)
                        {
                            myButton.InkFrame._inkCanvas.CaptureMouse();
                            ButtonMoveCommand bmc = new ButtonMoveCommand(myButton, offsetx, offsety, _inkCollector);
                            bmc.execute();
                        }

                        //移动MyImage
                        foreach (MyImage image in _inkCollector.SelectedImages)
                        {
                            ImageMoveCommand imc = new ImageMoveCommand(image, offsetx, offsety);
                            imc.execute();
                            image.adjustBound();
                            foreach (ImageConnector connector in image.ConnectorCollection)
                            {
                                connector.adjustConnector();
                            }
                        }

                        //移动笔迹
                        if (_inkCollector.SelectedStrokes.Count > 0)
                        {
                            foreach (MyStroke myStroke in _inkCollector.SelectedStrokes)
                            {
                                MoveCommand mc = new MoveCommand(myStroke, offsetx, offsety);
                                mc.execute();
                            }
                        }

                        //移动图形
                        if (SelectedMyGraphics.Count > 0)
                        {
                            MyGraphicsMoveCommand mgsmc = new MyGraphicsMoveCommand(SelectedMyGraphics, offsetx, offsety, _inkCollector);
                            mgsmc.execute();
                        }

                        //移动文本
                        foreach (MyRichTextBox myRichTextBox in _inkCollector.SelectedMyRichTextBoxs)
                        {
                            Command tmc = new TextMoveCommand(myRichTextBox, offsetx, offsety);
                            tmc.execute();
                        }
                        break;

                    case "Zoom":

                        _inkCollector.IsAutoMove = false;
                        StylusPoint curr = new StylusPoint(current.X, current.Y);
                        StylusPoint pre  = new StylusPoint(_prepoint.X, _prepoint.Y);

                        foreach (MyButton myButton in _inkCollector.SelectButtons)
                        {
                            double dist1 = MathTool.getInstance().distanceP2P(MathTool.getInstance().getMyButtonCenter(myButton), curr);
                            double dist2 = MathTool.getInstance().distanceP2P(MathTool.getInstance().getMyButtonCenter(myButton), pre);
                            if (dist2 == 0)
                            {
                                dist2 = 1;
                            }
                            double            scaling = dist1 / dist2;
                            ButtonZoomCommand bmc     = new ButtonZoomCommand(myButton, scaling, _inkCollector, myButton.Angle);
                            bmc.execute();
                        }
                        foreach (MyImage image in _inkCollector.SelectedImages)
                        {
                            double dist1 = MathTool.getInstance().distanceP2P(MathTool.getInstance().getImageCenter(image), curr);
                            double dist2 = MathTool.getInstance().distanceP2P(MathTool.getInstance().getImageCenter(image), pre);
                            if (dist2 == 0)
                            {
                                dist2 = 1;
                            }
                            double           scaling = dist1 / dist2;
                            ImageZoomCommand izc     = new ImageZoomCommand(image, scaling);
                            izc.execute();
                            image.adjustBound();
                            foreach (ImageConnector connector in image.ConnectorCollection)
                            {
                                connector.adjustConnector();
                            }
                        }
                        break;
                    }


                    _prepoint = current;
                }
            }
        }
Beispiel #35
0
 private void SkyControl_MouseMove(object sender, System.Windows.Input.MouseEventArgs e)
 => UpdateMousePos(e.GetPosition(this));
Beispiel #36
0
 public Point GetRelativPosition(System.Windows.Input.MouseEventArgs e)
 {
     return(e.GetPosition(DrawingSurface));
 }
Beispiel #37
0
 void UpdateLastMousePosition(object sender, System.Windows.Input.MouseEventArgs e)
 {
     _lastMousePosition = e.GetPosition(containerCanvas);
 }
        private void Windows_MouseMove(object sender, System.Windows.Input.MouseEventArgs e)
        {
            if (BrushEllipse == null)
            {
                return;
            }

            if (pointList == null || pointList.Count == 0)
            {
                return;
            }

            var pos = e.GetPosition(PreviewCanvas);

            if (pos.X < 0 || pos.Y < 0 ||
                pos.X > PreviewCanvas.Width || pos.Y > PreviewCanvas.Height)
            {
                return;
            }

            if (!int.TryParse(OrderTextBox.Text, out var order))
            {
                WarningLabel.Content = $"{lang["ExpectionError"]}{lang["ExpectionWrongOrderShouldBeNumber"]}";
                return;
            }

            var mousePos = new Point(pos.X, pos.Y);

            if (e.LeftButton == MouseButtonState.Pressed)
            {
                for (var i = 0; i < pointList.Count; ++i)
                {
                    if (lastSetPropertyPointIndex != -1 &&
                        Math.Abs(lastSetPropertyPointIndex - i) > BrushSlider.Value &&
                        ContinueCheckBox.IsChecked.Value)
                    {
                        continue;
                    }

                    var point = pointList[i];

                    if (point.Distane(mousePos) > BrushSlider.Value / 2)
                    {
                        continue;
                    }

                    point.isTunnel = TunnelCheckBox.IsChecked.Value;
                    point.order    = order;
                    isDirty        = true;

                    lastSetPropertyPointIndex = i;
                }
            }
            else
            {
                lastSetPropertyPointIndex = -1;
            }

            if (isDirty)
            {
                RefreshPath();
            }

            BrushEllipse.Margin = new Thickness(
                e.GetPosition(this).X - BrushEllipse.Width / 2,
                e.GetPosition(this).Y - BrushEllipse.Height / 2,
                0, 0);
        }
        protected override void OnMouseMove(System.Windows.Input.MouseEventArgs e)
        {
            base.OnMouseMove(e);
            using (var ctx = CreateInvalidationContext())
            {
                var pt = e.GetPosition(Image);

                _mouseIsBehindLeft   = pt.X < 0;
                _mouseIsBehindRight  = pt.X > Image.ActualWidth;
                _mouseIsBehindTop    = pt.Y < 0;
                _mouseIsBehindBottom = pt.Y > Image.ActualHeight;

                pt.X *= DpiDetector.DpiXKoef;
                pt.Y *= DpiDetector.DpiYKoef;
                _mouseCursorPoint = pt;
                var cell = GetCellAddress(pt);
                _mouseMoveRow    = GetSeriesIndexOnPosition(pt.Y, HeaderHeight, _rowSizes, FirstVisibleRowScrollIndex);
                _mouseMoveColumn = GetSeriesIndexOnPosition(pt.X, HeaderWidth, _columnSizes, FirstVisibleColumnScrollIndex);

                if (_resizingColumn.HasValue)
                {
                    var newSize = _resizingColumnStartSize.Value + (int)Math.Round(pt.X - _resizingColumnOrigin.Value.X);
                    if (newSize < MinColumnWidth)
                    {
                        newSize = MinColumnWidth;
                    }
                    if (newSize > GridScrollAreaWidth)
                    {
                        newSize = GridScrollAreaWidth;
                    }
                    _columnSizes.Resize(_resizingColumn.Value, newSize);
                    if (_resizingColumn < _columnSizes.FrozenCount)
                    {
                        SetScrollbarMargin();
                    }
                    AdjustScrollbars();
                    InvalidateAll();
                }
                else
                {
                    var column = GetResizingColumn(pt);
                    if (column != null)
                    {
                        Cursor = Cursors.SizeWE;
                    }
                    else
                    {
                        Cursor = Cursors.Arrow;
                    }
                }

                if (_dragStartCell.IsCell && cell.IsCell ||
                    _dragStartCell.IsRowHeader && cell.Row.HasValue ||
                    _dragStartCell.IsColumnHeader && cell.Column.HasValue)
                {
                    SetSelectedRectangle(_dragStartCell, cell);
                }

                SetHoverRow(cell.IsCell ? cell.Row.Value : (int?)null);
                SetHoverColumn(cell.IsCell ? cell.Column.Value : (int?)null);
                SetHoverRowHeader(cell.IsRowHeader ? cell.Row.Value : (int?)null);
                SetHoverColumnHeader(cell.IsColumnHeader ? cell.Column.Value : (int?)null);
                SetHoverCell(cell);

                var currentRegion = CurrentCellActiveRegions.FirstOrDefault(x => x.Rect.Contains(pt));
                if (currentRegion != CurrentHoverRegion)
                {
                    InvalidateCell(cell);
                }
            }

            HandleMouseMoveTooltip();
        }
 /// <summary>
 /// 当鼠标移动时
 /// </summary>
 /// <param name="e"></param>
 protected override void OnMouseMove(System.Windows.Input.MouseEventArgs e)
 {
     End     = e.GetPosition(View);
     CanDrop = DoDrag();
     Mouse.OverrideCursor = CanDrop ? Cursor : Cursors.No;
 }
Beispiel #41
0
        private void _resizer_MouseMove(object sender, System.Windows.Input.MouseEventArgs e)
        {
            UIElement dragElement = sender as UIElement;

            if (dragElement.IsMouseCaptured)
            {
                Point       ptMoveDrag      = e.GetPosition(dragElement);
                AnchorStyle CorrectedAnchor = Anchor;

                if (CorrectedAnchor == AnchorStyle.Left && FlowDirection == FlowDirection.RightToLeft)
                {
                    CorrectedAnchor = AnchorStyle.Right;
                }
                else if (CorrectedAnchor == AnchorStyle.Right && FlowDirection == FlowDirection.RightToLeft)
                {
                    CorrectedAnchor = AnchorStyle.Left;
                }

                double deltaX = FlowDirection == FlowDirection.LeftToRight ? ptMoveDrag.X - ptStartDrag.X : ptStartDrag.X - ptMoveDrag.X;

                if (CorrectedAnchor == AnchorStyle.Left)
                {
                    if (Width + deltaX < 4.0)
                    {
                        Width = 4.0;
                    }
                    else
                    {
                        Width += deltaX;
                    }
                }
                else if (CorrectedAnchor == AnchorStyle.Top)
                {
                    if (Height + (ptMoveDrag.Y - ptStartDrag.Y) < 4.0)
                    {
                        Height = 4.0;
                    }
                    else
                    {
                        Height += ptMoveDrag.Y - ptStartDrag.Y;
                    }
                }
                else if (CorrectedAnchor == AnchorStyle.Right)
                {
                    if (Width - (deltaX) < 4)
                    {
                        Left  = originalLeft + originalWidth - 4;
                        Width = 4;
                    }
                    else
                    {
                        Left  += deltaX;
                        Width -= deltaX;
                    }
                }
                else if (CorrectedAnchor == AnchorStyle.Bottom)
                {
                    if (Height - (ptMoveDrag.Y - ptStartDrag.Y) < 4)
                    {
                        Top    = originalTop + originalHeight - 4;
                        Height = 4;
                    }
                    else
                    {
                        Top    += ptMoveDrag.Y - ptStartDrag.Y;
                        Height -= ptMoveDrag.Y - ptStartDrag.Y;
                    }
                }

                ResizingPanel.SetResizeHeight(ReferencedPane, ReferencedPane.ActualHeight);
                ResizingPanel.SetResizeWidth(ReferencedPane, ReferencedPane.ActualWidth);
            }
        }
Beispiel #42
0
        private void Canvas_MouseMove(object sender, System.Windows.Input.MouseEventArgs e)
        {
            if (this.drawingLineMode)
            {
                if (this.currentDrawingLine != null)
                {
                    this.canvas.Children.Remove(this.currentDrawingLine);
                }

                this.DrawLine(this.startDrawingMousePosition.X, this.startDrawingMousePosition.Y, e.GetPosition((Canvas)sender).X, e.GetPosition((Canvas)sender).Y - 10);
            }
            else if (!this.removeMode)
            {
                IInputElement element = Mouse.DirectlyOver;
                if (element is Ellipse)
                {
                    Mouse.OverrideCursor = Cursors.Hand;
                }
                else
                {
                    Mouse.OverrideCursor = null;
                }
            }
        }
 private void Canvas_PreviewMouseMove(object sender, System.Windows.Input.MouseEventArgs e)
 {
     ((DrawingVueModel)this.DataContext).MouseMove.Execute(e.GetPosition((IInputElement)sender));
 }
Beispiel #44
0
        protected override void HandleMouseMove(object sender, MouseEventArgs e)
        {
            if (mouseMode == MouseMode.PreSelectionRectangle || mouseMode == MouseMode.SelectionRectangle)
            {
                if (e.LeftButton == MouseButtonState.Pressed)
                {
                    mouseMode = MouseMode.SelectionRectangle;

                    if (selectionRectangle == null)
                    {
                        selectionRectangle = new Border
                        {
                            // Move to WPF style
                            Background  = Brushes.Transparent,
                            BorderBrush =
                                new SolidColorBrush(Application.Current.Resources["ColorBlue"] is Color
                                    ? (Color)Application.Current.Resources["ColorBlue"]
                                    : new Color()),
                            CornerRadius    = new CornerRadius(5),
                            BorderThickness = new Thickness(2)
                        };

                        SetLeft(selectionRectangle, startSelectionRectanglePoint.X);
                        SetTop(selectionRectangle, startSelectionRectanglePoint.Y);

                        Children.Add(selectionRectangle);
                    }

                    var currentPosition = Mouse.GetPosition(this);
                    var delta           = Point.Subtract(currentPosition, startSelectionRectanglePoint);

                    if (delta.X < 0)
                    {
                        SetLeft(selectionRectangle, currentPosition.X);
                    }

                    if (delta.Y < 0)
                    {
                        SetTop(selectionRectangle, currentPosition.Y);
                    }

                    selectionRectangle.Width  = Math.Abs(delta.X);
                    selectionRectangle.Height = Math.Abs(delta.Y);

                    foreach (var node in NodeCollection)
                    {
                        SelectedNodes.Remove(node);

                        if (node.Left >= GetLeft(selectionRectangle) &&
                            node.Left + node.ActualWidth <= GetLeft(selectionRectangle) + selectionRectangle.Width &&
                            node.Top >= GetTop(selectionRectangle) &&
                            node.Top + node.ActualHeight <= GetTop(selectionRectangle) + selectionRectangle.Height)
                        {
                            node.IsSelected = true;
                            SelectedNodes.Add(node);
                        }
                        else
                        {
                            node.IsSelected = false;
                        }
                    }
                }
            }
            else if (mouseMode == MouseMode.Panning)
            {
                var v = start - e.GetPosition(this);

                TranslateTransform.X = origin.X - v.X;
                TranslateTransform.Y = origin.Y - v.Y;
            }


            switch (SplineMode)
            {
            case SplineModes.Nothing:
                ClearTempLine();
                break;

            case SplineModes.First:
                break;

            case SplineModes.Second:
                if (TempLine == null)
                {
                    TempLine = new Line {
                        Style = FindResource("VplLineStyle") as Style
                    };
                    Children.Add(TempLine);
                }

                TempLine.X1 = TempStartPort.Origin.X;
                TempLine.Y1 = TempStartPort.Origin.Y;
                TempLine.X2 = Mouse.GetPosition(this).X;
                TempLine.Y2 = Mouse.GetPosition(this).Y;

                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Beispiel #45
0
        protected override void OnPreviewMouseMove(System.Windows.Input.MouseEventArgs e)
        {
            base.OnPreviewMouseMove(e);

            Move(e.GetPosition(this));
        }
Beispiel #46
0
 protected override void OnMouseEnter(System.Windows.Input.MouseEventArgs e)
 {
     mousePosition = e.GetPosition(this);
 }
        /******************************/
        /*  EventToCommandsFunctions  */
        /******************************/
        #region EventToCommandsFunctions

        /// <summary>
        /// MouseMoveCF
        /// </summary>
        /// <param name="obj"></param>
        public void MouseMoveCF(object obj)
        {
            System.Windows.Input.MouseEventArgs Mea = (System.Windows.Input.MouseEventArgs)obj;
            MouseCoordinates = "X=" + Mea.GetPosition((Canvas)((RoutedEventArgs)((MouseEventArgs)obj)).Source).X.ToString() + ";Y=" + Mea.GetPosition((Canvas)((RoutedEventArgs)((MouseEventArgs)obj)).Source).Y.ToString();
        }
        //ImageBackground是一个Image对象,在UserControl.xaml的119行定义
        //当ImageBackground被鼠标按下时的事件处理器,事件由UserControl.xaml的119行145列挂载
        private void ImageBackground_MouseDown(object sender, System.Windows.Input.MouseEventArgs e)
        {
            //LawnScene是一个Grid对象,在UserControl.xaml的120行定义,有6行9列
            Point  pos        = e.GetPosition(LawnScene);                     //获取鼠标相对于LawnScene的位置
            double gridWidth  = LawnScene.Width / 9;                          //得到一格的宽度
            double gridHeight = LawnScene.Height / 6;                         //得到一格的高度

            int row    = Math.Max(0, Math.Min((int)(pos.Y / gridHeight), 5)); //得到鼠标点击的行,并限制其范围在0到5之间
            int column = Math.Max(0, Math.Min((int)(pos.X / gridWidth), 8));  //得到鼠标点击的列,并限制其范围在0到8之间

            //如果鼠标左键是按下状态而鼠标右键是松开状态
            if (e.LeftButton == MouseButtonState.Pressed && e.RightButton == MouseButtonState.Released)
            {
                //BtnShovel是一个ToggleButton对象,在UserControl.xaml的147行定义
                //如果按钮铲子(BtnShovel)已经按下
                if (BtnShovel.IsChecked == true)
                {
                    Image rmi = null;                                                 //临时变量,因为在foreach中无法操作被遍历集合

                    foreach (Image img in LawnScene.Children)                         //对于LawnScene中的每一个Image对象
                    {
                        if (Grid.GetRow(img) == row && Grid.GetColumn(img) == column) //如果存在一个img的行和列等于鼠标点击的行和列
                        {
                            rmi = img;                                                //获取这个img对象
                        }
                    }
                    //遍历结束后将其从LawnScene中移除,因为在foreach中无法移除
                    LawnScene.Children.Remove(rmi);
                    //结束返回
                    return;
                }

                //************以下是按钮铲子没有被按下的情况***************



                if (SelectedCard == -1)
                {
                    return;                               //如果没有选中任何卡片即返回
                }
                foreach (Image img in LawnScene.Children) //对于LawnScene中的每一个Image对象
                {
                    //Tag是一个用于快捷存放属性的变量,每个ui控件都有,想用来存放什么就存放什么
                    PVZ.PlantType pType = (PVZ.PlantType)img.Tag;                         //获得这个Image对象对应的植物类型(Tag)
                    if (pType == PVZ.PlantType.Tallnut)                                   //如果这个对象是高建国
                    {
                        if (Grid.GetRow(img) == row - 1 && Grid.GetColumn(img) == column) //并且行列等于鼠标的行列(由于高建国竖占2行,所以判断时减去一行)
                        {
                            //并且选择的卡片不是南瓜头,睡莲,花盆
                            if (SelectedCard != (int)PVZ.PlantType.Pumpkin && SelectedCard != (int)PVZ.PlantType.LilyPad && SelectedCard != (int)PVZ.PlantType.Pot && SelectedCard != (int)PVZ.PlantType.CoffeeBean)
                            {
                                //则判断该位置被占用,什么也不做直接返回
                                return;
                            }
                        }
                    }
                    else
                    {
                        //不是高建国则普通的判断行列是否等于鼠标的行列
                        if (Grid.GetRow(img) == row && Grid.GetColumn(img) == column)
                        {
                            //如果这个对象等于被选中的卡片(否则就能无限叠花盆),或选择的卡片不是南瓜头,睡莲,花盆
                            if ((int)img.Tag == SelectedCard || (SelectedCard != (int)PVZ.PlantType.Pumpkin &&
                                                                 SelectedCard != (int)PVZ.PlantType.LilyPad &&
                                                                 SelectedCard != (int)PVZ.PlantType.Pot &&
                                                                 SelectedCard != (int)PVZ.PlantType.CoffeeBean &&
                                                                 (int)img.Tag != (int)PVZ.PlantType.Pumpkin &&
                                                                 (int)img.Tag != (int)PVZ.PlantType.LilyPad &&
                                                                 (int)img.Tag != (int)PVZ.PlantType.Pot &&
                                                                 (int)img.Tag != (int)PVZ.PlantType.CoffeeBean))
                            {
                                //则判断该位置被占用,什么也不做直接返回
                                return;
                            }
                        }
                    }
                }
                //*************以下是位置没有被占用的情况**************


                Image image = new Image();                          //创建一个Image对象
                image.Source           = PlantImages[SelectedCard]; //图片设置为当前选中的卡片的图片
                image.Tag              = SelectedCard;              //Tag设置为当前选中的卡片
                image.IsHitTestVisible = false;                     //设置图片不响应鼠标的点击
                //将image放到Grid的指定行列
                Grid.SetRow(image, row);
                Grid.SetColumn(image, column);

                //如果是玉米加农炮,设置横占两列(否则玉米加农炮的图片会缩在一格里)
                if (SelectedCard == (int)PVZ.PlantType.CobCannon)
                {
                    Grid.SetColumnSpan(image, 2);
                }
                //如果是高建国,设置竖占两行,并行数坐标-1(否则高建国的图片会缩在一格里)
                if (SelectedCard == (int)PVZ.PlantType.Tallnut)
                {
                    Grid.SetRow(image, Math.Max(0, row - 1));
                    Grid.SetRowSpan(image, 2);
                }
                //将image加入到LawnScene中
                LawnScene.Children.Add(image);
            }
            //如果按下的是右键而左键松开
            else if (e.RightButton == MouseButtonState.Pressed && e.LeftButton == MouseButtonState.Released)
            {
                Image rmi = null;
                foreach (Image img in LawnScene.Children)//对于LawnScene中的每一个Image对象
                {
                    //如果这个对象的行列等于鼠标的行列
                    if ((int)img.Tag == (int)PVZ.PlantType.Tallnut)
                    {
                        if (Grid.GetRow(img) == row - 1 && Grid.GetColumn(img) == column)
                        {
                            rmi = img;
                        }
                    }
                    else
                    {
                        if (Grid.GetRow(img) == row && Grid.GetColumn(img) == column)
                        {
                            rmi = img;
                        }
                    }
                }
                //遍历结束后将其从LawnScene中移除
                LawnScene.Children.Remove(rmi);
            }
        }
 public override void _presenter_MouseMove(object sender, System.Windows.Input.MouseEventArgs e)
 {
     if (this.VideoSummarizationControl == null)
     {
         this.VideoSummarizationControl = _inkCollector._mainPage.VideoSummarizationControl;
     }
     if (_startPoint.X == 0 && _startPoint.Y == 0)
     {
         _currPoint    = e.GetPosition(_inkCanvas);
         _currPoint.X -= inkCanvasSpiralSummarizationMargin.Left;
         _currPoint.Y -= inkCanvasSpiralSummarizationMargin.Top;
         currIndex     = videoSummarization.getSelectedKeyFrameIndex(_currPoint);
         //记录操作类型与持续时间
         recordOperateTrace("MOVE");
         if (currIndex != int.MinValue && currIndex != preIndex && _inkCollector.IsShowUnbrokenKeyFrame)
         {
             moveTimerSecond = 0;
             MoveTimer.Start();
             clearPreMessage();
             currIndex = currIndex >= videoSummarization.ShowKeyFrames.Count ? videoSummarization.ShowKeyFrames.Count - 1 : currIndex;
             currIndex = (currIndex == -1 ? 0 : currIndex);
             Image currImage = InkConstants.getImageFromName(videoSummarization.ShowKeyFrames[currIndex].ImageName);
             currImage.Width  = 300;
             currImage.Height = 200;
             currImage.Margin = new Thickness((VideoSummarizationControl.summarization._inkCanvas.ActualWidth - currImage.Width) / 2,
                                              200, 0, 0);
             tapestrySummarization.ParentInkcanvas.Children.Add(currImage);
             preImage = currImage;
             preIndex = currIndex;
         }
         else if (currIndex == int.MinValue)
         {
             if (preImage != null)
             {
                 _inkCanvas.Children.Remove(preImage);
             }
             moveTimerSecond = 0;
         }
         //显示移动轨迹
         if (moveStroke != null)
         {
             moveStroke.StylusPoints.Add(new StylusPoint(_currPoint.X, _currPoint.Y));
             if (moveStroke.StylusPoints.Count > 300)
             {
                 moveStroke.StylusPoints.RemoveAt(0);
             }
         }
         else
         {
             StylusPointCollection spc = new StylusPointCollection();
             spc.Add(new StylusPoint(_currPoint.X, _currPoint.Y));
             moveStroke = new Stroke(spc);
             moveStroke.DrawingAttributes.Color  = Colors.Transparent;
             moveStroke.DrawingAttributes.Width  = 3;
             moveStroke.DrawingAttributes.Height = 3;
             _inkCanvas.Strokes.Add(moveStroke);
         }
     }
     else
     {
         _currPoint = e.GetPosition(_inkCanvas);
         if (startIndex != int.MinValue && _currPoint.X > 0)
         {
             left = videoSummarization.InkCanvas.Margin.Left + _currPoint.X - _prePoint.X;
             //if (left <= 0 && left >VideoSummarizationControl.summarization._inkCanvas.ActualWidth -tapestrySummarization.Width  )
             //{
             videoSummarization.InkCanvas.Margin = new Thickness(left,
                                                                 videoSummarization.InkCanvas.Margin.Top, 0, 0);
             //}
             if (left > 0)
             {
                 left = 0;
                 timebar.Show_EndTime = VideoSummarizationControl.summarization._inkCanvas.ActualWidth - videoSummarization.InkCanvas.Margin.Left;
             }
             else if (left < -tapestrySummarization.Width + VideoSummarizationControl.summarization._inkCanvas.ActualWidth)
             {
                 left = videoSummarization.InkCanvas.Margin.Left;
                 timebar.Show_EndTime = -left + tapestrySummarization.Width + videoSummarization.InkCanvas.Margin.Left;
             }
             else
             {
                 timebar.Show_EndTime = -left + VideoSummarizationControl.summarization._inkCanvas.ActualWidth;
             }
             timebar.Show_StartTime = -left;
             // timebar.Show_EndTime = -left + VideoSummarizationControl.summarization._inkCanvas.ActualWidth;
             timebar.computeLocation();
             _prePoint = _currPoint;
         }
         if (startIndex == int.MinValue && mouseGesture != null)
         {
             mouseGesture.Capturing((int)_currPoint.X, (int)_currPoint.Y);
         }
         //记录操作类型与持续时间
         recordOperateTrace("MOVE");
     }
 }
Beispiel #50
0
 /// <summary>ウィンドウ上にマウスが入り込んだ時に発生します。</summary>
 protected override void OnMouseEnter(System.Windows.Input.MouseEventArgs e)
 {
     base.OnMouseEnter(e);
     _previousPos = e.GetPosition(this);
 }
Beispiel #51
0
        /*
         * The mouse related methods are available alongside TouchlessController
         * Mouse movement disables the visual feedback and takes back control instead of the hands
         */
        #region Mouse Related Methods (For additional user input)

        private void VisualFeedbackGrid_OnMouseMove(object sender, MouseEventArgs e)
        {
            Point p = new Point(e.GetPosition(VisualFeedbackGrid).X, e.GetPosition(VisualFeedbackGrid).Y);

            Dispatcher.BeginInvoke((Action)(() => UpdateGestureText(String.Format("Mouse at x: {0}, y: {1}", p.X, p.Y))));
        }
Beispiel #52
0
 private void digitCanvas_MouseMove(object sender, MouseEventArgs e)
 {
     Interaction_Progress(e.GetPosition(sender as FrameworkElement));
 }
Beispiel #53
0
        private void OnViewportMouseMove(object sender, System.Windows.Input.MouseEventArgs e)
        {
            System.Windows.Point pos = e.GetPosition(m_Viewport);
            var hitRes = VisualTreeHelper.HitTest(m_Viewport, pos);
            RayMeshGeometry3DHitTestResult rayMeshRes = hitRes as RayMeshGeometry3DHitTestResult;

            if (rayMeshRes != null)
            {
                if (e.LeftButton == MouseButtonState.Pressed)
                {
                    OnViewMove(rayMeshRes.VisualHit, new Vector2(rayMeshRes.PointHit.X, rayMeshRes.PointHit.Y), MouseButton.Left);
                }
                else if (e.RightButton == MouseButtonState.Pressed)
                {
                    OnViewMove(rayMeshRes.VisualHit, new Vector2(rayMeshRes.PointHit.X, rayMeshRes.PointHit.Y), MouseButton.Right);
                }
                else if (e.MiddleButton == MouseButtonState.Pressed)
                {
                    OnViewMove(rayMeshRes.VisualHit, new Vector2(rayMeshRes.PointHit.X, rayMeshRes.PointHit.Y), MouseButton.Middle);
                }
            }

            double factor;

            if (m_Mode == Mode.Calibration)
            {
                double xDelta = pos.X - m_LastHoveredPos.X;
                double yDelta = pos.Y - m_LastHoveredPos.Y;
                m_LastHoveredPos = pos;

                if (m_MouseMovesCamera)
                {
                    factor = 0.1;
                    var cPos      = m_Camera.Position;
                    var newCamPos = new Point3D(cPos.X - factor * xDelta, cPos.Y - factor * yDelta, cPos.Z);
                    m_Camera.Position = newCamPos;
                    SettingsManager.Instance.Settings.SettingsTable.ProjCamPosition = newCamPos;
                }
                if (m_MouseMovesCameraAngle)
                {
                    factor = 0.001;
                    var cAngle      = m_Camera.LookDirection;
                    var newCamAngle = new Vector3D(cAngle.X, cAngle.Y - factor * yDelta, cAngle.Z);
                    m_Camera.LookDirection = newCamAngle;
                    SettingsManager.Instance.Settings.SettingsTable.ProjCamLookDirection = newCamAngle;
                }
                if (m_MouseMovesCameraFOV)
                {
                    factor = 0.01;
                    double newFOV = m_Camera.FieldOfView + factor * xDelta;
                    m_Camera.FieldOfView = newFOV;
                    SettingsManager.Instance.Settings.SettingsTable.ProjCamFOV = newFOV;
                }
            }
            else
            {
                if (rayMeshRes != null)
                {
                    m_HoveredPoint = rayMeshRes.PointHit;
                }
                if (hitRes != null)
                {
                    if (hitRes.VisualHit is SceneItem)
                    {
                        if ((hitRes.VisualHit as SceneItem).Touchy == true)
                        {
                            Mouse.OverrideCursor = Cursors.SizeAll;
                        }
                        else
                        {
                            Mouse.OverrideCursor = Cursors.No;
                        }
                    }
                    else
                    {
                        Mouse.OverrideCursor = null;
                    }
                }

                if (SceneManager.Instance.CurrentScene.SelectedItem != null && isDragged == true)
                {
                    if (SceneManager.Instance.CurrentScene.SelectedItem is ScenePolygon)
                    {
                        (SceneManager.Instance.CurrentScene.SelectedItem as ScenePolygon).Move(m_HoveredPoint.X - m_LastHoveredPoint.X, m_HoveredPoint.Y - m_LastHoveredPoint.Y);
                    }
                    else
                    {
                        SceneManager.Instance.CurrentScene.SelectedItem.Move(m_HoveredPoint.X - m_LastHoveredPoint.X, m_HoveredPoint.Y - m_LastHoveredPoint.Y);
                    }
                    m_LastHoveredPoint = m_HoveredPoint;
                }
            }
        }
Beispiel #54
0
        public void OnMouseMove(System.Windows.IInputElement sender, System.Windows.Input.MouseEventArgs e)
        {
            Point p = new Point((int)e.GetPosition(sender).X, (int)e.GetPosition(sender).Y);

            if (e.LeftButton == MouseButtonState.Pressed) //left button is pressed
            {
                if (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl))
                {
                    View.Zoom(myXmax, myYmax, p.X, p.Y);
                    myXmax = p.X;
                    myYmax = p.Y;
                }
                else
                {
                    switch (CurrentMode)
                    {
                    case CurrentAction3d.CurAction3d_Nothing:
                        myXmax = p.X;
                        myYmax = p.Y;
                        break;

                    case CurrentAction3d.CurAction3d_DynamicZooming:
                        View.Zoom(myXmax, myYmax, p.X, p.Y);
                        myXmax = p.X;
                        myYmax = p.Y;
                        break;

                    case CurrentAction3d.CurAction3d_WindowZooming:
                        myXmax = p.X;
                        myYmax = p.Y;
                        break;

                    case CurrentAction3d.CurAction3d_DynamicPanning:
                        View.Pan(p.X - myXmax, myYmax - p.Y);
                        myXmax = p.X;
                        myYmax = p.Y;
                        break;

                    case CurrentAction3d.CurAction3d_GlobalPanning:
                        break;

                    case CurrentAction3d.CurAction3d_DynamicRotation:
                        View.Rotation(p.X, p.Y);
                        View.RedrawView();
                        break;

                    default:
                        break;
                    }
                }
            }
            else if (e.MiddleButton == MouseButtonState.Pressed) //middle button is pressed
            {
                if (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl))
                {
                    View.Pan(p.X - myXmax, myYmax - p.Y);
                    myXmax = p.X;
                    myYmax = p.Y;
                }
            }
            else if (e.RightButton == MouseButtonState.Pressed) //right button is pressed
            {
                if (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl))
                {
                    View.Rotation(p.X, p.Y);
                }
            }
            else // no buttons are pressed
            {
                myXmax = p.X;
                myYmax = p.Y;
                View.MoveTo(p.X, p.Y);
            }
        }
        //private void overlayForm_MouseLeave(object sender, System.Windows.Input.MouseEventArgs e)
        //{
        //    System.Windows.Forms.Cursor.Show();
        //}

        //private void overlayForm_MouseEnter(object sender, System.Windows.Input.MouseEventArgs e)
        //{
        //    System.Windows.Forms.Cursor.Hide();
        //}

        private void overlayForm_MouseMove(object sender, System.Windows.Input.MouseEventArgs e)
        {
            System.Windows.Point pos = e.GetPosition(this.overlayForm);
            MouseMove((int)(pos.X / this.scaleX), (int)(pos.Y / this.scaleY));
        }
Beispiel #56
0
        public void canvasMain_MouseMove(object sender, MouseEventArgs e)
        {
            if (Left1Drag && CanvasMain.Contains(LeftEye1) && _allowDrawEyes)
            {
                Point point1;
                int   num;
                if (e.GetPosition(CanvasMain).X >= 0.0)
                {
                    point1 = e.GetPosition(CanvasMain);
                    if (point1.Y >= 0.0)
                    {
                        point1 = e.GetPosition(CanvasMain);
                        if (point1.X <= CanvasMain.Width)
                        {
                            point1 = e.GetPosition(CanvasMain);
                            num    = point1.Y > CanvasMain.Height ? 1 : 0;
                            goto label_6;
                        }
                    }
                }
                num = 1;
label_6:
                if (num == 0)
                {
                    var myVisual = LeftEye1;
                    point1 = e.GetPosition(CanvasMain) + ClickOffset;
                    var x = point1.X + 20.0;
                    point1 = e.GetPosition(CanvasMain) + ClickOffset;
                    var y      = point1.Y + 20.0;
                    var point2 = new Point(x, y);
                    myVisual.Position = point2;
                }
                DrawEyes();
            }
            else if (Right1Drag && CanvasMain.Contains(RightEye1) && _allowDrawEyes)
            {
                Point point1;
                int   num;
                if (e.GetPosition(CanvasMain).X >= 0.0)
                {
                    point1 = e.GetPosition(CanvasMain);
                    if (point1.Y >= 0.0)
                    {
                        point1 = e.GetPosition(CanvasMain);
                        if (point1.X <= CanvasMain.Width)
                        {
                            point1 = e.GetPosition(CanvasMain);
                            num    = point1.Y > CanvasMain.Height ? 1 : 0;
                            goto label_15;
                        }
                    }
                }
                num = 1;
label_15:
                if (num == 0)
                {
                    var myVisual = RightEye1;
                    point1 = e.GetPosition(CanvasMain) + ClickOffset;
                    var x = point1.X + 20.0;
                    point1 = e.GetPosition(CanvasMain) + ClickOffset;
                    var y      = point1.Y + 20.0;
                    var point2 = new Point(x, y);
                    myVisual.Position = point2;
                }
                DrawEyes();
            }
            else if (e.RightButton == MouseButtonState.Pressed)
            {
                TranslateTransform1.X = e.GetPosition(this).X - CanvasMainPoint.X;
                TranslateTransform1.Y = e.GetPosition(this).Y - CanvasMainPoint.Y;
            }
            else
            {
                if (e.LeftButton != MouseButtonState.Pressed || Mainform.btEye.Down)
                {
                    return;
                }
                SelectionBorder1.NextPoint = e.GetPosition(CanvasMain);
                SelectArea();
            }
        }
 private void SpectrumToolWindowControlBase_MouseMove(object sender, System.Windows.Input.MouseEventArgs e)
 {
     Vm.HandleSizing(e.GetPosition(this));
 }
Beispiel #58
0
        protected override void OnPreviewMouseMove(MouseEventArgs e)
        {
            base.OnPreviewMouseMove(e);

            if (DynamoSelection.Instance.Selection.Count == 0 || !this.isDragInProgress)
            {
                return;
            }

            // Get the position of the mouse cursor, relative to the Canvas.
            Point cursorLocation = e.GetPosition(this);

            #region Calculate Offsets

            int count = 0;
            foreach (ISelectable sel in DynamoSelection.Instance.Selection)
            {
                OffsetData od = offsets[count];

                // Determine the horizontal offset.
                if (od.ModifyLeftOffset)
                {
                    od.NewHorizontalOffset = od.OriginalHorizontalOffset + (cursorLocation.X - this.origCursorLocation.X);
                }
                else
                {
                    od.NewHorizontalOffset = od.OriginalHorizontalOffset - (cursorLocation.X - this.origCursorLocation.X);
                }

                // Determine the vertical offset.
                if (od.ModifyTopOffset)
                {
                    od.NewVerticalOffset = od.OriginalVerticalOffset + (cursorLocation.Y - this.origCursorLocation.Y);
                }
                else
                {
                    od.NewVerticalOffset = od.OriginalVerticalOffset - (cursorLocation.Y - this.origCursorLocation.Y);
                }

                //Debug.WriteLine(string.Format("New h:{0} v:{1}", od.NewHorizontalOffset, od.NewVerticalOffset));
                count++;
            }

            #endregion // Calculate Offsets

            if (!this.AllowDragOutOfView)
            {
                #region Verify Drag Element Location

                count = 0;
                foreach (ISelectable sel in DynamoSelection.Instance.Selection)
                {
                    var el = sel as ILocatable;
                    if (el == null)
                    {
                        continue;
                    }

                    OffsetData od = offsets[count];

                    // Get the bounding rect of the drag element.
                    Rect elemRect = this.CalculateDragElementRect(el, od.NewHorizontalOffset, od.NewVerticalOffset, od.ModifyLeftOffset, od.ModifyTopOffset);

                    // If the element is being dragged out of the viewable area,
                    // determine the ideal rect location, so that the element is
                    // within the edge(s) of the canvas.
                    //
                    bool leftAlign  = elemRect.Left < 0;
                    bool rightAlign = elemRect.Right > this.ActualWidth;

                    if (leftAlign)
                    {
                        od.NewHorizontalOffset = od.ModifyLeftOffset ? 0 : this.ActualWidth - elemRect.Width;
                    }
                    else if (rightAlign)
                    {
                        od.NewHorizontalOffset = od.ModifyLeftOffset ? this.ActualWidth - elemRect.Width : 0;
                    }

                    bool topAlign    = elemRect.Top < 0;
                    bool bottomAlign = elemRect.Bottom > this.ActualHeight;

                    if (topAlign)
                    {
                        od.NewVerticalOffset = od.ModifyTopOffset ? 0 : this.ActualHeight - elemRect.Height;
                    }
                    else if (bottomAlign)
                    {
                        od.NewVerticalOffset = od.ModifyTopOffset ? this.ActualHeight - elemRect.Height : 0;
                    }
                    count++;
                }

                #endregion // Verify Drag Element Location
            }

            #region Move Drag Element
            count = 0;
            this.Dispatcher.Invoke(new Action(
                                       delegate
            {
                foreach (ISelectable sel in DynamoSelection.Instance.Selection)
                {
                    var el = sel as ILocatable;
                    if (el == null)
                    {
                        continue;
                    }

                    var od = offsets[count];

                    if (od.ModifyLeftOffset)
                    {
                        //Canvas.SetLeft(el, od.NewHorizontalOffset);
                        el.X = od.NewHorizontalOffset;
                    }
                    else
                    {
                        //Canvas.SetRight(el, od.NewHorizontalOffset);
                        el.X = od.NewHorizontalOffset + el.Width;
                    }
                    if (od.ModifyTopOffset)
                    {
                        //Canvas.SetTop(el, od.NewVerticalOffset);
                        el.Y = od.NewVerticalOffset;
                    }
                    else
                    {
                        //Canvas.SetBottom(el, od.NewVerticalOffset);
                        el.Y = od.NewHorizontalOffset + el.Height;
                    }
                    count++;
                }
            }
                                       ), DispatcherPriority.Render, null);
            #endregion // Move Drag Element
        }
Beispiel #59
0
        private void Canvas_MouseMove(object sender, System.Windows.Input.MouseEventArgs e)
        {
            if (line && e.LeftButton == MouseButtonState.Pressed)
            {
                _line                    = new Line();
                _line.Stroke             = Color;
                _line.StrokeStartLineCap = PenLineCap.Round;
                _line.StrokeEndLineCap   = PenLineCap.Round;
                _line.StrokeThickness    = Thickness;
                _line.X1                 = currentPosition.X;
                _line.Y1                 = currentPosition.Y - 80;
                _line.X2                 = e.GetPosition(this).X;
                _line.Y2                 = e.GetPosition(this).Y - 80;
                currentPosition          = e.GetPosition(this);
                Canvas.Children.Add(_line);
                HistoryElement.Add(_line);
            }
            if (rectangle && e.LeftButton == MouseButtonState.Pressed)
            {
                _rectangle.Stroke          = Color;
                _rectangle.StrokeThickness = Thickness;
                if ((bool)fill)
                {
                    _rectangle.Fill = Color;
                }
                Canvas.SetLeft(_rectangle, currentPosition.X);
                Canvas.SetTop(_rectangle, currentPosition.Y);
                var pos = e.GetPosition(Canvas);

                var x = Math.Min(pos.X, currentPosition.X);
                var y = Math.Min(pos.Y, currentPosition.Y);

                var w = Math.Max(pos.X, currentPosition.X) - x;
                var h = Math.Max(pos.Y, currentPosition.Y) - y;

                _rectangle.Width  = w;
                _rectangle.Height = h;

                Canvas.SetLeft(_rectangle, x);
                Canvas.SetTop(_rectangle, y);
            }
            if (ellipse && e.LeftButton == MouseButtonState.Pressed)
            {
                _ellipse.Stroke          = Color;
                _ellipse.StrokeThickness = Thickness;
                if ((bool)fill)
                {
                    _ellipse.Fill = Color;
                }
                Canvas.SetLeft(_ellipse, currentPosition.X);
                Canvas.SetTop(_ellipse, currentPosition.Y);
                var pos = e.GetPosition(Canvas);

                var x = Math.Min(pos.X, currentPosition.X);
                var y = Math.Min(pos.Y, currentPosition.Y);

                var w = Math.Max(pos.X, currentPosition.X) - x;
                var h = Math.Max(pos.Y, currentPosition.Y) - y;

                _ellipse.Width  = w;
                _ellipse.Height = h;

                Canvas.SetLeft(_ellipse, x);
                Canvas.SetTop(_ellipse, y);
            }

            if (triangle && e.LeftButton == MouseButtonState.Pressed)
            {
                _triangle.Stroke          = Color;
                _triangle.StrokeThickness = Thickness;
                if ((bool)fill)
                {
                    _triangle.Fill = Color;
                }
                Canvas.SetLeft(_triangle, currentPosition.X);
                Canvas.SetTop(_triangle, currentPosition.Y);
                var pos = e.GetPosition(Canvas);

                Point p1 = new Point(0, pos.Y - currentPosition.Y);
                Point p2 = new Point(pos.X - currentPosition.X, pos.Y - currentPosition.Y);
                Point p3 = new Point((pos.X - currentPosition.X) / 2, 0);
                _triangle.Points[0] = p1;
                _triangle.Points[1] = p2;
                _triangle.Points[2] = p3;

                Canvas.SetLeft(_triangle, currentPosition.X);
                Canvas.SetTop(_triangle, currentPosition.Y);
            }
        }
Beispiel #60
0
        private void Canvas_MouseMove(object sender, System.Windows.Input.MouseEventArgs e)
        {
            Point p = e.GetPosition(Canvas);

            textBlockPosition.Text = Math.Round(p.X) + ", " + Math.Round(p.Y) + "px";
        }