public static void MouseWheel(Canvas c, TransformGroup tg, MouseWheelEventArgs e)
        {
            int deltaValue;
            deltaValue = e.Delta;
            TranslateTransform tt = (TranslateTransform)tg.Children[1];
            ScaleTransform st = (ScaleTransform)tg.Children[0];
            double xSpot = e.GetPosition(c).X;
            double ySpot = e.GetPosition(c).Y;

            Double x = e.GetPosition(c).X - tt.X;
            Double y = e.GetPosition(c).Y - tt.Y;

            Double centerX = st.CenterX * (st.ScaleX - 1);
            Double centerY = st.CenterY * (st.ScaleY - 1);

            st.CenterX = x;
            st.CenterY = y;

            if (deltaValue > 0)
            {
                st.ScaleX *= 1.25;
                st.ScaleY *= 1.25;
            }
            else
            {

                st.ScaleX *= 0.75;
                st.ScaleY *= 0.75;
            }
        }
Beispiel #2
0
        private void canvas_MouseWheel(object sender, System.Windows.Input.MouseWheelEventArgs e)
        {
            if (mapInfo == null)
            {
                return;
            }

            double zoom = e.Delta > 0 ? .3 * scaleMap.ScaleX : -.3 * scaleMap.ScaleX;

            var x = e.GetPosition(mapLayer).X / mapLayer.ActualWidth;
            var y = e.GetPosition(mapLayer).Y / mapLayer.ActualHeight;

            x = Math.Max(Math.Min(x, 1), 0);
            y = Math.Max(Math.Min(y, 1), 0);
            var dX = (x - mapLayer.RenderTransformOrigin.X) * mapLayer.ActualWidth * (1 - scaleMap.ScaleX);
            var dY = (y - mapLayer.RenderTransformOrigin.Y) * mapLayer.ActualHeight * (1 - scaleMap.ScaleY);

            translateMap.X -= dX;
            translateMap.Y -= dY;
            mapLayer.RenderTransformOrigin = new Point(x, y);

            scaleMap.ScaleX += zoom;
            scaleMap.ScaleY += zoom;

            scaleOfPlayerIcon.ScaleX = 1 / scaleMap.ScaleX;
            scaleOfPlayerIcon.ScaleY = 1 / scaleMap.ScaleY;
        }
        private void Texture_Canvas_MouseWheel(object sender, System.Windows.Input.MouseWheelEventArgs e)
        {
            bool IsPlus = false;

            if (e.Delta > 0)
            {
                IsPlus = true;
            }
            Point MousePoint = e.GetPosition(Texture_Canvas);

            foreach (Texture_Info Info in Core.All_Textures)
            {
                Matrix matrix = ((MatrixTransform)Info.Texture_Image.Texture_Image.RenderTransform).Matrix;
                if (IsPlus && matrix.M11 < 9)
                {
                    Core.Zoom = Set_Texture_Zoom(Info, MousePoint, 1.1);
                }
                else if (!IsPlus && matrix.M11 > 0.12)
                {
                    Core.Zoom = Set_Texture_Zoom(Info, MousePoint, 1 / 1.1);
                }
            }
            if (Select_Texture != null)
            {
                Set_Dollet_Line(Select_Texture);
            }
        }
Beispiel #4
0
        //滚轮缩放
        private void image_PreviewMouseWheel(object sender, System.Windows.Input.MouseWheelEventArgs e)
        {
            //获取当前坐标
            System.Windows.Point point = e.GetPosition(gridDraw);
            //转换坐标到原始位置
            System.Windows.Point pt = this.gridDraw.RenderTransform.Inverse.Transform(point);
            //平移
            this.tlt.X = (point.X - pt.X) * this.sfr.ScaleX;
            this.tlt.Y = (point.Y - pt.Y) * this.sfr.ScaleY;

            this.sfr.CenterX = point.X;
            this.sfr.CenterY = point.Y;

            //获取缩放方向
            int scaleDir = Math.Abs(e.Delta) / e.Delta;

            //设置放大或缩小10%
            this.sfr.ScaleX += sfr.ScaleX * 0.1 * scaleDir;
            this.sfr.ScaleY += sfr.ScaleY * 0.1 * scaleDir;
            if (this.sfr.ScaleX < 0.5)
            {
                this.sfr.ScaleX = 0.5;
                this.sfr.ScaleY = 0.5;
            }
            //更新缩放比例,保留两位小数
            MapOperate.ViewInfo.Scale = Math.Round(this.sfr.ScaleX, 1);
        }
Beispiel #5
0
        protected override void OnMouseWheel(MouseWheelEventArgs e)
        {
            base.OnMouseWheel(e);

            var zoomDelta = MouseWheelZoomDelta * (double)e.Delta / 120d;
            ZoomMap(e.GetPosition(this), TargetZoomLevel + zoomDelta);
        }
        private void canvas_MouseWheel_1(object sender, System.Windows.Input.MouseWheelEventArgs e)
        {
            if (mode.Zoom == true)
            {
                //scroller.CanContentScroll = false;
                zoom += zoomSpeed * e.Delta; // Ajust zooming speed (e.Delta = Mouse spin value )
                if (zoom < zoomMin)
                {
                    zoom = zoomMin;
                }                                       // Limit Min Scale
                if (zoom > zoomMax)
                {
                    zoom = zoomMax;
                }                                       // Limit Max Scale

                Point mousePos = e.GetPosition(canvas);

                if (zoom > 1)
                {
                    canvas.RenderTransform = new ScaleTransform(zoom, zoom, mousePos.X, mousePos.Y); // transform Canvas size from mouse position
                }
                else
                {
                    canvas.RenderTransform = new ScaleTransform(zoom, zoom); // transform Canvas size
                }
            }
        }
		private void OnMouseWheel(object sender, MouseWheelEventArgs e) {
			if (!e.Handled) {
				Point mousePos = e.GetPosition(this);
				int delta = -e.Delta;
				MouseWheelZoom(mousePos, delta);
			}
		}
Beispiel #8
0
 void _element_MouseWheel(object sender, System.Windows.Input.MouseWheelEventArgs e)
 {
     if (this._wheel != null)
     {
         this.OnWheel(new MouseWheelEventArgs((double)(e.Delta / 120), e.GetPosition(this._element.GetRootVisual())));
     }
 }
        void PlotControl_MouseWheel(object sender, MouseWheelEventArgs e)
        {
            bool control = (Keyboard.IsKeyDown(Key.LeftCtrl));
            bool shift = (Keyboard.IsKeyDown(Key.LeftShift));

            OnMouseWheel(e.GetPosition(pc), e.Delta, control, shift);
        }
        private void MapLayoutPanel_MouseWheel(object sender, MouseWheelEventArgs e)
        {
            if (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl))
            {
                var map = (VirtualizingZoomablePanel)sender;
                var scrollViewer = Utils.FindAncestor<ScrollViewer>(map);
                var mousePos = e.GetPosition(map);
                if (map is System.Windows.Controls.Primitives.IScrollInfo)
                {
                    mousePos.X += scrollViewer.HorizontalOffset;
                    mousePos.Y += scrollViewer.VerticalOffset;
                }
                var logicalPos = map.PixelsToLogical(mousePos, map.Scale, map.displayOffset);
                double lat, lon;
                UsaCities.EarthLocation.MercatorUnProject(logicalPos.X, logicalPos.Y, out lat, out lon);
                if (e.Delta > 0)
                {
                    map.Scale *= 1.1;
                }
                else if (e.Delta < 0)
                {
                    map.Scale /= 1.1;
                }
                map.UpdateLayout();
                var newDisplayPos = map.LogicalToPixels(logicalPos, map.Scale, map.displayOffset);

                scrollViewer.ScrollToHorizontalOffset(scrollViewer.HorizontalOffset + (newDisplayPos.X - mousePos.X));
                scrollViewer.ScrollToVerticalOffset(scrollViewer.VerticalOffset + (newDisplayPos.Y - mousePos.Y));

                e.Handled = true;
            }
        }
Beispiel #11
0
        private void Window_MouseWheel(object sender, System.Windows.Input.MouseWheelEventArgs e)
        {
            var zoom = ((MatrixTransform)canvas.RenderTransform).Matrix;

            zoom.ScaleAt(1 + e.Delta / 1000D, 1 + e.Delta / 1000D, e.GetPosition(this).X, e.GetPosition(this).Y);

            canvas.RenderTransform = new MatrixTransform(zoom);
        }
Beispiel #12
0
        private void OnGraphControlMouseWheel(object sender, MouseWheelEventArgs e)
        {
            ZoomAndPanControl.ZoomAboutPoint(
                ZoomAndPanControl.ContentScale + e.Delta / 1000.0f,
                e.GetPosition(GraphControl));

            e.Handled = true;
        }
Beispiel #13
0
        private void canvas_MouseWheel(object sender, System.Windows.Input.MouseWheelEventArgs e)
        {
            var element  = this.canvas as UIElement;
            var position = e.GetPosition(element);
            var scale    = e.Delta >= 0 ? 1.1 : (1.0 / 1.1); // choose appropriate scaling factor

            ScaleCanvas(scale, position);
        }
Beispiel #14
0
        /// <summary>
        /// 鼠标的滚动事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void DrawingControl_MouseWheel(object sender, System.Windows.Input.MouseWheelEventArgs e)
        {
            if (!IsDraging)
            {
                if (e.Delta > 0)
                {
                    KernelProperty.ZoomIn(e.GetPosition(this));
                }
                else
                {
                    KernelProperty.ZoomOut(e.GetPosition(this));
                }

                this.Update();

                this.RemoveTemporaryVisualsByType(0);
            }
        }
Beispiel #15
0
 void source_MouseWheel(object sender, MouseWheelEventArgs e)
 {
     // zoom into the content.  Calculate the zoom factor based on the direction of the mouse wheel.
     double zoomFactor = this.DefaultZoomFactor;
     if (e.Delta <= 0) zoomFactor = 1.0 / this.DefaultZoomFactor;
     // DoZoom requires both the logical and physical location of the mouse pointer
     var physicalPoint = e.GetPosition(this);
     DoZoom(zoomFactor, this.transformGroup.Inverse.Transform(physicalPoint), physicalPoint);
 }
 private void timelineCanvas_MouseWheel(object sender, MouseWheelEventArgs e)
 {
     const double zoomSpeed = 0.0012;
     Point mousePos = e.GetPosition((UIElement)sender);
     double zoomCenter;
     if (trackVM.OffsetX == 0 && mousePos.X < 128) zoomCenter = 0;
     else zoomCenter = (trackVM.OffsetX + mousePos.X) / trackVM.QuarterWidth;
     trackVM.QuarterWidth *= 1 + e.Delta * zoomSpeed;
     trackVM.OffsetX = Math.Max(0, Math.Min(trackVM.TotalWidth, zoomCenter * trackVM.QuarterWidth - mousePos.X));
 }
		//static internal Uri doGetImageSourceFromResource(string psAssemblyName, string psResourceName) {
		//    Uri oUri = new Uri("pack://application:,,,/" + psAssemblyName + ";component/" + psResourceName, UriKind.RelativeOrAbsolute);
		//    return oUri;
		//}
		void player_MouseWheel(object sender, MouseWheelEventArgs e) {
			if (e.Delta > 0) {
				if (Double.IsNaN(viewPortContainer.Height)) {
					scroller.HorizontalScrollBarVisibility = ScrollBarVisibility.Auto;
					scroller.VerticalScrollBarVisibility = ScrollBarVisibility.Auto;

					viewPortContainer.Height = viewPortContainer.ActualHeight;
					viewPortContainer.Width = viewPortContainer.ActualWidth;
				}
				viewPortContainer.Height += 20;
				viewPortContainer.Width += 20;

				double actualH = scroller.ActualHeight; 
				double actualW = scroller.ActualWidth;

				Point mousePointer = e.GetPosition(scroller);

				if (mousePointer.X < actualW/2) {
				}else{
					scroller.LineRight();
				}
				if (mousePointer.Y < actualH / 2) {
				} else {
					scroller.LineDown();
				}

			} else {
				double actualH = scroller.ActualHeight;
				if (actualH <= viewPortContainer.ActualHeight) {
					viewPortContainer.Height = Double.NaN;
					viewPortContainer.Width = Double.NaN;

					scroller.HorizontalScrollBarVisibility = ScrollBarVisibility.Disabled;
					scroller.VerticalScrollBarVisibility = ScrollBarVisibility.Disabled;
				} else {
					viewPortContainer.Height -= 20;
					viewPortContainer.Width -= 20;

					double actualW = scroller.ActualWidth;

					Point mousePointer = e.GetPosition(scroller);

					if (mousePointer.X < actualW / 2) {
						scroller.LineUp();
					} else {
					}
					if (mousePointer.Y < actualH / 2) {
						scroller.LineLeft();
					} else {
					}
				}
			}

			e.Handled = true;
		}
Beispiel #18
0
        protected override void OnMouseWheel(MouseWheelEventArgs e)
        {
            e.Handled = true;

            Point center = e.GetPosition(cardsView);

            var mess = new MouseWheelTableZoom(e.Delta,center);
            Messenger.Default.Send(mess);

            base.OnMouseWheel(e);
        }
Beispiel #19
0
        //对IMG使用滚轮
        private void IMG1_MouseWheel(object sender, System.Windows.Input.MouseWheelEventArgs e)
        {
            var img = sender as ContentControl;

            if (img == null)
            {
                return;
            }
            var point = e.GetPosition(img);
            var group = IMG1.FindResource("Imageview") as TransformGroup;
            var delta = e.Delta > 0 ? 1 : -1;

            DowheelZoom(group, point, delta);
        }
Beispiel #20
0
        private void OnZoom(object sender, MouseWheelEventArgs e)
        {
            var scale    = e.Delta >= 0 ? 1.1 : 1.0 / 1.1;
            var position = e.GetPosition(DesignArea);
            var matrix   = PreviewTransform.Matrix;

            matrix.ScaleAtPrepend(scale, scale, position.X, position.Y);

            if (scale < 1 && matrix.M11 < 1)
            {
                var m = PreviewTransform.Matrix;
                m.OffsetX = m.OffsetY = 0;
                PreviewTransform.Matrix = m;
                return;
            }

            PreviewTransform.Matrix = matrix;
        }
Beispiel #21
0
        private void image_MouseWheel(object sender, MouseWheelEventArgs e)
        {
          var mousePosition = e.GetPosition(snap);
          snap.RenderTransformOrigin = new Point(mousePosition.X / snap.ActualWidth, mousePosition.Y / snap.ActualHeight); 
        
          var transformGroup = (TransformGroup)snap.RenderTransform;
          var transform = (ScaleTransform)transformGroup.Children[0];
          
          
          double zoom = e.Delta > 0 ? .2 : -.2;
          if ((transform.ScaleX > 0.21 && zoom < 0) || (zoom > 0 && transform.ScaleX < 4))
          {
            transform.ScaleX += zoom;
            transform.ScaleY += zoom;
          }

          Console.WriteLine(transform.ScaleX);
        }
Beispiel #22
0
        protected virtual void HandleMouseWheel(object sender, MouseWheelEventArgs e)
        {
            var zoom = e.Delta > 0 ? .2 : -.2;

            if (!(e.Delta > 0) && (ScaleTransform.ScaleX < .4 || ScaleTransform.ScaleY < .4))
                return;

            foreach (Border child in Children)
            {
                child.UpdateLayout();

                var position = e.GetPosition(child);
                child.RenderTransformOrigin = new Point(position.X/child.ActualWidth, position.Y/child.ActualHeight);
            }

            ScaleTransform.ScaleX += zoom;
            ScaleTransform.ScaleY += zoom;
        }
        private void Zoom_PreviewMouseWheel(object sender,MouseWheelEventArgs e) {
            if(!(Keyboard.Modifiers == ModifierKeys.Control))
                return;

            Point pos = e.GetPosition(this);
            double scaleFactor = 0.0;
            if(e.Delta > 0) {
                scaleFactor = e.Delta / 100.0;
            } else if(e.Delta < 0) {
                scaleFactor = 100.0 / -e.Delta;
            }


            EquipmentScaleUtilis.SetScaleFactor(scaleFactor,this,Equipment_Viewbox);




        }
Beispiel #24
0
        public static MouseEventArgs ToEto(this swi.MouseWheelEventArgs e, sw.IInputElement control, swi.MouseButtonState buttonState = swi.MouseButtonState.Pressed)
        {
            var buttons = MouseButtons.None;

            if (e.LeftButton == buttonState)
            {
                buttons |= MouseButtons.Primary;
            }
            if (e.RightButton == buttonState)
            {
                buttons |= MouseButtons.Alternate;
            }
            if (e.MiddleButton == buttonState)
            {
                buttons |= MouseButtons.Middle;
            }
            var modifiers = KeyMap.Convert(swi.Key.None, swi.Keyboard.Modifiers);
            var location  = e.GetPosition(control).ToEto();
            var delta     = new SizeF(0, (float)e.Delta / WheelDelta);

            return(new MouseEventArgs(buttons, modifiers, location, delta));
        }
        private void ZoomViewbox_MouseWheel(object sender, System.Windows.Input.MouseWheelEventArgs e)
        {
            var position = e.GetPosition(gridMap);

            stMap.CenterX = position.X;
            stMap.CenterY = position.Y;


            if (e.Delta > 0)
            {
                stMap.ScaleX += 0.2;
                stMap.ScaleY += 0.2;
            }
            else
            {
                if (stMap.ScaleX > 1 && stMap.ScaleY > 1)
                {
                    stMap.ScaleX -= 0.2;
                    stMap.ScaleY -= 0.2;
                }
            }
        }
 public void child_MouseWheel(object sender,MouseWheelEventArgs e)
 {
     if(!(child.IsMouseCaptured) && enabled) {
         ScaleTransform scaleTransform = GetScaleTransform(child);
         TranslateTransform translateTransform = GetTranslateTransform(child);
         double zoom;
         if(e.Delta > 0) {
             zoom = 0.5;
         } else {
             zoom = -0.5;
         }
         if((!(e.Delta < 0) && (scaleTransform.ScaleX > 4.5 || scaleTransform.ScaleY > 4.5)) || (!(e.Delta > 0) && (scaleTransform.ScaleX < 1.0 || scaleTransform.ScaleY < 1.0))) {
             return;
         }
         Point relative = e.GetPosition(child);
         double abosuluteX = relative.X* scaleTransform.ScaleX + translateTransform.X;
         double abosuluteY = relative.Y * scaleTransform.ScaleY + translateTransform.Y;
         scaleTransform.ScaleX += zoom;
         scaleTransform.ScaleY += zoom;
         translateTransform.X = abosuluteX - relative.X * scaleTransform.ScaleX;
         translateTransform.Y = abosuluteY - relative.Y * scaleTransform.ScaleY;
     }
 }
        private void GridScreen_MouseWheel(object sender, MouseWheelEventArgs e)
        {
            long len = Common.GetTimeMilliLen(WheelTime, DateTime.Now);
            if (len < 500)
                return;
            WheelTime = DateTime.Now;

            var point = e.GetPosition(GridScreen);
            if (e.Delta > 0 && _sacleIndex < ScaleArray.Length - 1)
            {
                ++_sacleIndex;
                ScaleCanvas(point);
            }
            else if(e.Delta < 0 && _sacleIndex > 1)
            {
                --_sacleIndex;
                ScaleCanvas(point);
            }
        }
Beispiel #28
0
 private void MouseWheelOnRoll(object sender, MouseWheelEventArgs e)
 {
     if (ZoomingAxis == AxisTags.None) return;
     e.Handled = true;
     if (e.Delta > 0) ZoomIn(e.GetPosition(this));
     else ZoomOut(e.GetPosition(this));
 }
 private void OnMouseWheel(object sender, MouseWheelEventArgs e)
 {
     var zoomChange = MouseWheelZoomDelta * (double)e.Delta / 120d;
     ZoomMap(e.GetPosition(this), TargetZoomLevel + zoomChange);
 }
        private void ViewportMouseWheel(object sender, MouseWheelEventArgs e)
        {
            var cargs = new TileMouseEventArgs
                            {
                                Tile = GetTileAtPixel(e.GetPosition((IInputElement)sender)),
                                LeftButton = e.LeftButton,
                                RightButton = e.RightButton,
                                MiddleButton = e.MiddleButton,
                                WheelDelta = e.Delta
                            };

            var vm = (WorldViewModel)DataContext;
            var partView = (ScrollViewer)FindName("WorldScrollViewer");

            double initialZoom = vm.Zoom;
            var initialScrollPosition = new Point(partView.HorizontalOffset, partView.VerticalOffset);
            var initialCenterTile =
                new PointInt32((int)(partView.HorizontalOffset / initialZoom + (partView.ActualWidth / 2) / initialZoom),
                               (int)(partView.VerticalOffset / initialZoom + (partView.ActualHeight / 2) / initialZoom));

            if (vm.MouseWheelCommand.CanExecute(cargs))
                vm.MouseWheelCommand.Execute(cargs);

            double finalZoom = vm.Zoom;
            //var finalScrollPosition = new Point(partView.HorizontalOffset, partView.VerticalOffset);
            double zoomRatio = 1 - finalZoom / initialZoom;
            var scaleCenterTile = new PointInt32(
                (int)(initialCenterTile.X - ((cargs.Tile.X - initialCenterTile.X) * zoomRatio)),
                (int)(initialCenterTile.Y - ((cargs.Tile.Y - initialCenterTile.Y) * zoomRatio)));
            ScrollToTile(scaleCenterTile);

            ViewportRerender(sender, null);  // scroll/zoom change needs a re-render
        }
Beispiel #31
0
 private void MouseZoom(object sender, MouseWheelEventArgs e)
 {
     Point position = ViewWindow.VisualToCorePosition(e.GetPosition(canvas));
     ViewWindow.SetZoom(e.Delta / 120.0, position);
 }
Beispiel #32
0
 private void Map_MouseWheel(object sender, MouseWheelEventArgs e)
 {
     ViewModel.ZoomBy(e.Delta, e.GetPosition(map));
 }
Beispiel #33
0
        /// <summary>
        /// Gère l'évènement PreviewMouseWheel.
        /// </summary>
        /// <param name="sender">La source de l'évènement.</param>
        /// <param name="e">Les <see cref="System.Windows.Input.MouseWheelEventArgs"/> contenant les données de l'évènement.</param>
        private void AssociatedObject_PreviewMouseWheel(object sender, System.Windows.Input.MouseWheelEventArgs e)
        {
            var zoomable = this.ExternalZoomable;

            if ((Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl)) &&
                (Keyboard.IsKeyDown(Key.LeftShift) || Keyboard.IsKeyDown(Key.RightShift)))
            {
                // Zoom horizontal
                // Vérifier que le scroll se fasse bien au dessus d'un chart
                var mousePosition = e.GetPosition(this.AssociatedObject);
                var chart         = GetHitChart(mousePosition);
                if (chart != null)
                {
                    EnsureOperations(zoomable, chart);

                    mousePosition = e.GetPosition(chart);

                    if (e.Delta < 0)
                    {
                        _zoomOperations.OnNext(new ZoomAction {
                            Action = ZoomActionEnum.ZoomXOut, MousePosition = mousePosition
                        });
                    }
                    else
                    {
                        _zoomOperations.OnNext(new ZoomAction {
                            Action = ZoomActionEnum.ZoomXIn, MousePosition = mousePosition
                        });
                    }
                    e.Handled = true;

                    SetBusy(true, chart);
                }
            }
            else if (Keyboard.IsKeyDown(Key.LeftShift) || Keyboard.IsKeyDown(Key.RightShift))
            {
                // Shift = Scroll horizontal
                var chart = GetHitChart(e.GetPosition(this.AssociatedObject));
                if (chart != null)
                {
                    EnsureOperations(zoomable, chart);
                    bool toRight = e.Delta < 0;

                    double horizontalOffset = chart.ScrollHorizontalOffset;

                    if (toRight)
                    {
                        _zoomOperations.OnNext(new ZoomAction {
                            Action = ZoomActionEnum.ScrollRight
                        });
                    }
                    else
                    {
                        _zoomOperations.OnNext(new ZoomAction {
                            Action = ZoomActionEnum.ScrollLeft
                        });
                    }

                    SetBusy(true, chart);

                    _zoomOperations.OnCompleted();

                    e.Handled = true;
                }
            }
            else if (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl))
            {
                // Ctrl + Shift = Zoom vertical
                var chart = GetHitChart(e.GetPosition(this.AssociatedObject));
                if (chart != null)
                {
                    EnsureOperations(zoomable, chart);

                    var mousePosition = e.GetPosition(chart);

                    if (e.Delta < 0)
                    {
                        _zoomOperations.OnNext(new ZoomAction {
                            Action = ZoomActionEnum.ZoomYOut, MousePosition = mousePosition
                        });
                    }
                    else
                    {
                        _zoomOperations.OnNext(new ZoomAction {
                            Action = ZoomActionEnum.ZoomYIn, MousePosition = mousePosition
                        });
                    }
                    e.Handled = true;

                    SetBusy(true, chart);
                }
            }
        }
		protected override void OnMouseWheel(MouseWheelEventArgs e)
		{
			Point mousePos = e.GetPosition(this);
			int delta = -e.Delta;

			Point zoomTo = mousePos.ScreenToViewport(Transform);

			double zoomSpeed = Math.Abs(delta / Mouse.MouseWheelDeltaForOneLine);
			zoomSpeed *= wheelZoomSpeed;
			if (delta < 0)
			{
				zoomSpeed = 1 / zoomSpeed;
			}

			Rect visible = Plotter2D.Viewport.Visible.Zoom(zoomTo, zoomSpeed);
			Rect oldVisible = Plotter2D.Viewport.Visible;
			if (orientation == Orientation.Horizontal)
			{
				visible.Y = oldVisible.Y;
				visible.Height = oldVisible.Height;
			}
			else
			{
				visible.X = oldVisible.X;
				visible.Width = oldVisible.Width;
			}
			Plotter2D.Viewport.Visible = visible;

			e.Handled = true;
		}
        protected override void OnMouseWheel(MouseWheelEventArgs e)
        {
            var point = e.GetPosition(this);

            var browser = GetBrowser();

            if (browser != null)
            {
                browser.SendMouseWheelEvent(
                    (int)point.X,
                    (int)point.Y,
                    deltaX: 0,
                    deltaY: e.Delta,
                    modifiers: CefEventFlags.None);
            }
        }
Beispiel #36
0
 private void Content_MouseWheel(object sender, MouseWheelEventArgs e)
 {
     double zoom = Math.Pow(Zoomer.ZoomFactor, e.Delta / 120.0);
     Point offset = e.GetPosition(this.Viewbox);
     this.Zoom(zoom, offset);
 }
		public void DoMouseWheel(object sender, MouseWheelEventArgs e)
		{
			if (IsValidTarget)
			{
				double zoom = Math.Pow(ZoomFactor, e.Delta / 120.0);
				Point offset = e.GetPosition(this.Viewbox);
				this.Zoom(zoom, offset);
			}
		}
Beispiel #38
0
        protected override void HandleMouseWheel(object sender, MouseWheelEventArgs e)
        {
            if (!Keyboard.IsKeyDown(Key.LeftCtrl) && !Keyboard.IsKeyDown(Key.RightCtrl)) return;

            mouseMode = MouseMode.Zooming;

            var zoom = e.Delta > 0 ? .2 : -.2;

            if (!(e.Delta > 0) && (ScaleTransform.ScaleX < .4 || ScaleTransform.ScaleY < .4))
                return;

            var elementsToZoom = new List<UIElement>();
            elementsToZoom.AddRange(Children.OfType<Border>());
            elementsToZoom.AddRange(Children.OfType<Ellipse>());
            elementsToZoom.AddRange(Children.OfType<Path>());

            foreach (var element in elementsToZoom)
            {
                element.UpdateLayout();

                var position = e.GetPosition(element);
                double width = 0;
                double height = 0;

                if (element is Border)
                {
                    var border = element as Border;

                    width = border.ActualWidth;
                    height = border.ActualHeight;
                }
                else if (element is Ellipse)
                {
                    var ellipse = element as Ellipse;

                    width = ellipse.ActualWidth;
                    height = ellipse.ActualHeight;
                }
                else if (element is Path)
                {
                    var path = element as Path;

                    width = path.ActualWidth;
                    height = path.ActualHeight;
                }

                if (width > 0 && height > 0)
                {
                    element.RenderTransformOrigin = new Point(position.X/width, position.Y/height);
                }
            }

            ScaleTransform.ScaleX += zoom;
            ScaleTransform.ScaleY += zoom;

            mouseMode = MouseMode.Nothing;
        }
Beispiel #39
0
        protected override void OnMouseWheel(MouseWheelEventArgs e)
        {
            //don't allow zooming if panning
            if (!ZoomEnabled || _mousePanning) return;

            double previousZoom = _currentZoom;

            if (e.Delta > 0)
            {
                _currentZoom += ZoomStep;
            }
            else
            {
                _currentZoom -= ZoomStep;
            }
            if (_currentZoom > MaxZoom)
                _currentZoom = MaxZoom;
            if (_currentZoom < MinZoom)
                _currentZoom = MinZoom;

            _currentZoom = Math.Round(_currentZoom, 2);
            double m11 = _currentZoom;
            double m22 = _currentZoom;

            Point mousePos = e.GetPosition(this);

            if (!_storyboardActive || _panningWhilstZooming)
            {
                //takes snap shot of board location
                MatrixTransform relativeTransform = (MatrixTransform)_container.TransformToVisual(this);
                double deltaX = mousePos.X - relativeTransform.Matrix.OffsetX;
                double deltaY = mousePos.Y - relativeTransform.Matrix.OffsetY;
                double offsetX = relativeTransform.Matrix.OffsetX + deltaX * (1 - _currentZoom / previousZoom);
                double offsetY = relativeTransform.Matrix.OffsetY + deltaY * (1 - _currentZoom / previousZoom);
                _currentOffset.X = offsetX;
                _currentOffset.Y = offsetY;
                _zoomX.To = _currentZoom;
                _zoomY.To = _currentZoom;
                _panX.To = _currentOffset.X;
                _panY.To = _currentOffset.Y;
                _deltaMousePosition.X = 0;
                _deltaMousePosition.Y = 0;
                _zoomStoryboard.Begin();
                _storyboardActive = true;
                _mouseZooming = true;
                _panningWhilstZooming = false;
            }
            else
            {
                //storyboard is currently running - so use the offset of where we want toend up after the animation has finshed
                double deltaX = mousePos.X - _currentOffset.X;
                double deltaY = mousePos.Y - _currentOffset.Y;
                double offsetX = _currentOffset.X + deltaX * (1 - _currentZoom / previousZoom);
                double offsetY = _currentOffset.Y + deltaY * (1 - _currentZoom / previousZoom);
                _currentOffset.X = offsetX;
                _currentOffset.Y = offsetY;
                _zoomX.To = _currentZoom;
                _zoomY.To = _currentZoom;
                _panX.To = _currentOffset.X;
                _panY.To = _currentOffset.Y;
                _deltaMousePosition.X = 0;
                _deltaMousePosition.Y = 0;
                _zoomStoryboard.Begin();

            }

            //not sure if this is required
            base.OnMouseWheel(e);
        }
Beispiel #40
0
        private void imagescrollviewer_MouseWheel(object sender, MouseWheelEventArgs e)
        {
            if (importbitmap==null || isdragingimage)
            {
                e.Handled = true;
                return;
            }
            if (e.Delta>0)
            {
                tempbindgroup.Zoomsize += zoomdelta;
            }
            else
            {
                tempbindgroup.Zoomsize -= zoomdelta;

            }

            //double x = imagescrollviewer.ContentHorizontalOffset;
            //double y = imagescrollviewer.ContentVerticalOffset;
            System.Windows.Point ptINimage = e.GetPosition((IInputElement)imageshowbox);
            System.Windows.Point ptINviewer = e.GetPosition((IInputElement)imagescrollviewer);
            double newXinimage = ptINimage.X * imageWidth * tempbindgroup.Zoomsize / 100 / imageshowbox.Width;
            double newYinimage = ptINimage.Y * imageWidth * tempbindgroup.Zoomsize / 100 / imageshowbox.Width;
            double newoffsetx = newXinimage - ptINviewer.X;
            double newoffsety = newYinimage - ptINviewer.Y;
            imageshowbox.Width = (double)imageWidth * tempbindgroup.Zoomsize / 100;
            //这里主要实现以鼠标位置为缩放中心的缩放
            if (newoffsetx>0)
            {
                imagescrollviewer.ScrollToHorizontalOffset(newoffsetx);
            }
            if (newoffsety > 0)
            {
                imagescrollviewer.ScrollToVerticalOffset(newoffsety);
            }
            e.Handled = true;
        }
Beispiel #41
0
        /// <summary>
        /// Event raised by rotating the mouse wheel
        /// </summary>
        private void zoomAndPanControl_MouseWheel(object sender, MouseWheelEventArgs e) {
            e.Handled = true;

            if (e.Delta > 0) {
                Point curContentMousePoint = e.GetPosition(mapCanvas);
                ZoomIn(curContentMousePoint);
            }
            else if (e.Delta < 0) {
                Point curContentMousePoint = e.GetPosition(mapCanvas);
                ZoomOut(curContentMousePoint);
            }
        }
Beispiel #42
0
 private void WidgetMouseWheelHandler(object sender, MouseWheelEventArgs e)
 {
     mouseScrollCumulation += e.Delta;
     int jumps = mouseScrollCumulation / 120;
     mouseScrollCumulation %= 120;
     var p = e.GetPosition(Widget);
     Context.InvokeUserCode (delegate {
         for (int i = 0; i < jumps; i++) {
             eventSink.OnMouseScrolled(new MouseScrolledEventArgs(
                 e.Timestamp, p.X * WidthPixelRatio, p.Y * HeightPixelRatio, ScrollDirection.Up));
         }
         for (int i = 0; i > jumps; i--) {
             eventSink.OnMouseScrolled(new MouseScrolledEventArgs(
                 e.Timestamp, p.X * WidthPixelRatio, p.Y * HeightPixelRatio, ScrollDirection.Down));
         }
     });
 }
Beispiel #43
0
        void OnPreviewMouseWheel(object sender, MouseWheelEventArgs e)
        {
            _lastMousePositionOnTarget = e.GetPosition(_grid);

            switch (Keyboard.Modifiers)
            {
                case ModifierKeys.Control:

                    #region Zoom

                    if (e.Delta > 0)
                    {
                        if (Zoom < 5.0)
                            Zoom += 0.1;
                    }
                    if (e.Delta < 0)
                    {
                        if (Zoom > 0.2)
                            Zoom -= 0.1;
                    }

                    _scaleTransform.ScaleX = Zoom;
                    _scaleTransform.ScaleY = Zoom;

                    var centerOfViewport = new Point(_scrollViewer.ViewportWidth / 2, _scrollViewer.ViewportHeight / 2);
                    _lastCenterPositionOnTarget = _scrollViewer.TranslatePoint(centerOfViewport, _grid);

                    #endregion

                    break;

                case ModifierKeys.Alt:

                    double verDelta = e.Delta > 0 ? -10.5 : 10.5;
                    _scrollViewer.ScrollToVerticalOffset(_scrollViewer.VerticalOffset + verDelta);

                    break;

                case ModifierKeys.Shift:

                    double horDelta = e.Delta > 0 ? -10.5 : 10.5;
                    _scrollViewer.ScrollToHorizontalOffset(_scrollViewer.HorizontalOffset + horDelta);

                    break;
            }

            e.Handled = true;
        }