Ejemplo n.º 1
0
 private void TextBox_MouseWheel(object sender, MouseWheelEventArgs e)
 {
     var tb = (TextBox)sender;
     
     if (tb.IsMouseOver)
     {
         int currentVal;
         if (int.TryParse(tb.Text, out currentVal))
         {
             if (e.Delta > 0)
             {
                 // Increment
                 tb.Text = (currentVal + 1).ToString();
             }
             else
             {
                 if (currentVal > 0)
                 {
                     // Decrement
                     tb.Text = (currentVal - 1).ToString();
                 }
             }
         }
     }
 }
Ejemplo n.º 2
0
 private void UIElement_OnMouseWheel(object sender, MouseWheelEventArgs e)
 {
     var st = (ScaleTransform)image.RenderTransform;
     double zoom = e.Delta > 0 ? .2 : -.2;
     st.ScaleX += zoom;
     st.ScaleY += zoom;
 }
Ejemplo n.º 3
0
        private void child_PreviewMouseWheel(object sender, MouseWheelEventArgs e)
        {

            var st = GetScaleTransform();
            var tt = GetTranslateTransform();

            double zoom = e.Delta > 0 ? .1 : -.1;
            if (!(e.Delta > 0) && (st.ScaleX < .4 || st.ScaleY < .4))
                return;

            Point relative = e.GetPosition(parent);
            double abosuluteX;
            double abosuluteY;

            abosuluteX = relative.X * st.ScaleX + tt.X;
            abosuluteY = relative.Y * st.ScaleY + tt.Y;

            st.ScaleX += zoom;
            st.ScaleY += zoom;

            tt.X = abosuluteX - relative.X * st.ScaleX;
            tt.Y = abosuluteY - relative.Y * st.ScaleY;          
                         

        }
Ejemplo n.º 4
0
        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;
            }
        }
Ejemplo n.º 5
0
		void ScaleElement_MouseWheel(object sender, MouseWheelEventArgs e) {
			if (Keyboard.Modifiers != ModifierKeys.Control)
				return;

			ZoomMouseWheel(e.Delta);
			e.Handled = true;
		}
Ejemplo n.º 6
0
 private void ZoomOneStep(object sender, MouseWheelEventArgs e)
 {
     _scale *= Math.Pow(ZoomStep, e.Delta/360.0);
     if (_scale < FullScreenScale) _scale = FullScreenScale;
     _tileContainer.LayoutTransform = new ScaleTransform(_scale, _scale);
     e.Handled = true;
 }
Ejemplo n.º 7
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);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// When user tries to use mouse wheel there can be several cases.
        /// </summary>
        private void OnPreviewMouseWheel(object sender, MouseWheelEventArgs e)
        {
            // Case 1: User scrolls the mouse wheel when Shift key is being held down. This 
            // action triggers a horizontal scroll on the library view (so that lengthy names 
            // can be revealed). Setting 'Handled' to 'false' allows the underlying scroll bar
            // to handle the mouse wheel event.
            if (Keyboard.IsKeyDown(Key.LeftShift) || Keyboard.IsKeyDown(Key.RightShift))
            {
                e.Handled = false;
                return;
            }

            // Case 2: If the mouse is outside of the library view, but mouse wheel messages 
            // get sent to it anyway. In such case there is nothing to change here. The 'Handled'
            // is not set to 'true' here because the mouse wheel messages should be routed to the 
            // ScrollViewer on tool-tip for further processing.
            if (!(sender as UIElement).IsMouseOver)
                return;

            // Case 3: Mouse wheel without any modifier keys, it scrolls the library view 
            // vertically. In this case 'VerticalOffset' is updated, 'Handled' is also set 
            // so that mouse wheel message routing ends here.
            ScrollViewer scv = (ScrollViewer)sender;
            scv.ScrollToVerticalOffset(scv.VerticalOffset - e.Delta);
            e.Handled = true;
        }
        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);
            }
        }
Ejemplo n.º 10
0
        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;
            }
        }
Ejemplo n.º 11
0
 private void OnMouseWheel(object sender, System.Windows.Input.MouseWheelEventArgs e)
 {
     if (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl))
     {
         //this.asmGrid.FontSize += e.Delta;
     }
 }
Ejemplo n.º 12
0
        void HandleMouseWheel(System.Windows.Input.MouseWheelEventArgs e)
        {
            //zooming
            if (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl))
            {
                double scale = _scaleTransform.ScaleX;
                scale += (e.Delta > 0) ? 0.1 : -0.1;
                scale  = scale <= 0.2 ? 0.2 : scale;
                scale  = scale >= 5 ? 5 : scale;
                _scaleTransform.ScaleX = _scaleTransform.ScaleY = scale;

                e.Handled = true;

                RaiseZoomChanged();
            }
            else //scrolling
            {
                if (e.Delta > 0)
                {
                    ManageScroolUp();
                }
                else
                {
                    ManageScroolDown();
                }
            }
        }
Ejemplo n.º 13
0
        protected override void OnMouseWheel(MouseWheelEventArgs e)
        {
            base.OnMouseWheel(e);

            var zoomDelta = MouseWheelZoomDelta * (double)e.Delta / 120d;
            ZoomMap(e.GetPosition(this), TargetZoomLevel + zoomDelta);
        }
Ejemplo n.º 14
0
        /// <summary>
        /// This method is triggered on a MouseWheel preview event to check if the user
        /// is also holding down the CTRL Key and adjust the current font size if so.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void textEditor_PreviewMouseWheel(object sender, System.Windows.Input.MouseWheelEventArgs e)
        {
            if (Keyboard.Modifiers == ModifierKeys.Control)
            {
                double fontSize = this.FontSize + e.Delta / 25.0;

                if (fontSize < 6)
                {
                    this.FontSize = 6;
                }
                else
                {
                    if (fontSize > 200)
                    {
                        this.FontSize = 200;
                    }
                    else
                    {
                        this.FontSize = fontSize;
                    }
                }

                e.Handled = true;
            }
        }
 public void lbMatFile_MouseWheel(object sender, MouseWheelEventArgs e)
 {
     if (scrollViewer != null)
     {
         scrollViewer.ScrollToVerticalOffset(scrollViewer.VerticalOffset - e.Delta);
     }
 }
Ejemplo n.º 16
0
 public void scroll(object sender, MouseWheelEventArgs args)
 {
     if (!scrolling)
     {
         if (args.Delta < 120)
         {
             scrollAnimation.From = Canvas.GetTop(tasksItemsControl);
             if (space < tasksItemsControl.Items.Count)
             {
                 scrollAnimation.To = Canvas.GetTop(tasksItemsControl) - 98;
                 space++;
             }
         }
         else
         {
             scrollAnimation.From = Canvas.GetTop(tasksItemsControl);
             if (space > 0)
             {
                 scrollAnimation.To = Canvas.GetTop(tasksItemsControl) + 98;
                 space--;
             }
         }
         scrollAnimation.Completed += new EventHandler((o, a) =>
         {
             scrolling = false;
         });
         scrolling = true;
         tasksItemsControl.BeginAnimation(Canvas.TopProperty, scrollAnimation);
     }
 }
Ejemplo n.º 17
0
 private void img_MouseWheel(object sender, MouseWheelEventArgs e)
 {
     if (e.Delta > 0)
         IncreaseZoom();
     else
         DecreaseZoom();
 }
Ejemplo n.º 18
0
        private static void OnSelectorPreviewMouseWheel(object sender, MouseWheelEventArgs e)
        {
            if (e.Delta == 0)
            {
                // nothing to do
                return;
            }

            var selector = (Selector)sender;
            // get or stored scrollviewer
            var lbScrollViewer = GetScrollViewer(selector);
            if (lbScrollViewer != null)
            {
                var scrollingLines = GetScrollingLines(selector);
                for (var i = 0; i < scrollingLines; i++)
                {
                    if (e.Delta < 0)
                    {
                        lbScrollViewer.LineDown();
                    }
                    else
                    {
                        lbScrollViewer.LineUp();
                    }
                }
                e.Handled = true;
            }
        }
 protected override void OnMouseWheel(MouseWheelEventArgs e)
 {
     if (VerticalScrollBarVisibility != ScrollBarVisibility.Disabled)
     {
         base.OnMouseWheel(e);
     }
 }
        /// <summary>
        /// Handles the PreviewMouseWheel event of the ScrollViewer control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="MouseWheelEventArgs"/> instance containing the event data.</param>
        private void ScrollViewer_PreviewMouseWheel(object sender, MouseWheelEventArgs e)
        {
            try
            {
                var scrollviewer = sender as ScrollViewer;
                if (e.Delta > 0)
                {
                    if (scrollviewer != null)
                    {
                        scrollviewer.LineUp();
                    }
                }
                else
                {
                    if (scrollviewer != null)
                    {
                        scrollviewer.LineDown();
                    }
                }

                e.Handled = true;
            }
            catch
            {
                // Do nothing.
            }
        }
Ejemplo n.º 21
0
 private void AssociatedObject_PreviewMouseWheel(object sender, System.Windows.Input.MouseWheelEventArgs e)
 {
     if (this.TargetElement != null)
     {
         this.TargetElement.ScrollToVerticalOffset(this.TargetElement.VerticalOffset - e.Delta);
     }
 }
 private static void ListBoxOnPreviewMouseWheel(object sender, MouseWheelEventArgs e)
 {
     var lb = sender as ListBox;
     if (lb != null)
     {
         // get or store scrollviewer
         var lbScrollViewer = GetScrollViewer(lb);
         if (lbScrollViewer != null)
         {
             var scrollingLines = GetScrollingLines(lb);
             if (e.Delta < 0)
             {
                 for (var i = 0; i < scrollingLines; i++)
                 {
                     lbScrollViewer.LineDown();
                 }
             }
             else
             {
                 for (var i = 0; i < scrollingLines; i++)
                 {
                     lbScrollViewer.LineUp();
                 }
             }
             e.Handled = true;
         }
     }
 }
        private void ItemsControl_MouseWheel(object sender, MouseWheelEventArgs e)
        {
            var x = Math.Pow(2, e.Delta / 3.0 / Mouse.MouseWheelDeltaForOneLine);
            _zoomableCanvas.Scale *= x;

            e.Handled = true;
        }
Ejemplo n.º 24
0
 private void TreeView_MouseWheel_1(object sender, System.Windows.Input.MouseWheelEventArgs e)
 {
     if (_ScrollViewer != null)
     {
         _ScrollViewer.ScrollToVerticalOffset(_ScrollViewer.VerticalOffset - e.Delta);
     }
 }
Ejemplo n.º 25
0
 public MouseWheelInputEventArgs(IMouseWheelController controller, MouseWheel wheel, MouseWheelEventArgs nativeEventArgs)
   : base(nativeEventArgs.MouseDevice, nativeEventArgs.Timestamp)
 {
   Controller = controller;
   Wheel = wheel;
   NativeEventArgs = nativeEventArgs;
 }
        private void OnRootControlMouseWheel(object sender, MouseWheelEventArgs e)
        {
            var handler = MouseWheel;

            if (handler != null)
                handler(e, new MouseStateEventArgs(_mousePosition, Vector2.Zero, MouseButton.None, 0, e.Delta));
        }
Ejemplo n.º 27
0
        protected override void OnPreviewMouseWheel(MouseWheelEventArgs args)
        {
            base.OnPreviewMouseWheel(args);
            Transform temptransform;

               // Debug.WriteLine("Mouse wheel " + args.Delta);

               // ImageDisp.LayoutTransform=new ScaleTransform(2.0,2.0) ;

            if (args.Delta > 0)
               dScale+=0.10;

            if (args.Delta < 0)
            {
                dScale -= 0.10;
                if (dScale < 1.0)
                    dScale = 1.0;
            }

             //Debug.WriteLine(" dScale " +dScale);
             //Debug.WriteLine(" ImageDisp.LayoutTransform " + ImageDisp.LayoutTransform);
             ImageDisp.RenderTransform = new ScaleTransform(dScale, dScale,(double)(pixelwidth / 2.0f), (double)(pixelheight / 2.0f));
               ImageDisp.
             Debug.WriteLine("Transform");
             Debug.WriteLine("W " + bmpImage.PixelWidth + " H " + bmpImage.PixelHeight);
             Debug.WriteLine("Dpi X " + bmpImage.DpiX + " Dpi Y " + bmpImage.DpiY);
             Debug.WriteLine("Source X " + bmpImage.SourceRect.X + " Source Y " + bmpImage.SourceRect.Y);

               // ImageDisp.InvalidateMeasure();
            //ImageDisp.InvalidateVisual();
            //ImageDisp.
        }
        private void UI_MouseWheel(object sender, System.Windows.Input.MouseWheelEventArgs e)
        {
            var image = sender as FrameworkElement;

            if (image == null)
            {
                return;
            }


            double zoom          = e.Delta > 0 ? .05 : -.05;
            var    mousePosition = Mouse.GetPosition(image);

            var st = image.RenderTransform as ScaleTransform;

            if (st == null)
            {
                ScaleTransform scaleTransform1 = new ScaleTransform(zoom + 1, zoom + 1, image.ActualWidth / 2, image.ActualHeight / 2);
                image.RenderTransform = scaleTransform1;
            }
            else
            {
                if (st.ScaleX + zoom < 0.2)
                {
                    return;
                }
                st.ScaleX += zoom;
                st.ScaleY += zoom;
                System.Diagnostics.Debug.WriteLine(st.ScaleX);
            }
        }
Ejemplo n.º 29
0
 void OnPreviewMouseWheel(object sender, System.Windows.Input.MouseWheelEventArgs e)
 {
     e.Handled = true;
     if (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl))
     {
         e.Handled = true;
         if (this.FontSize + e.Delta / 60 < MinFontSize)
         {
             this.FontSize = MinFontSize;
         }
         else if (this.FontSize + e.Delta / 60 > MaxFontSize)
         {
             this.FontSize = MaxFontSize;
         }
         else
         {
             this.FontSize += (e.Delta / 60);
         }
     }
     else
     {
         if (this.VerticalOffset - e.Delta < 0)
         {
             this.VerticalOffset = 0;
         }
         else if (this.VerticalOffset - e.Delta > this.ScrollingLimit)
         {
             this.VerticalOffset = this.ScrollingLimit;
         }
         else
         {
             this.VerticalOffset -= e.Delta;
         }
     }
 }
Ejemplo n.º 30
0
 private void ChangeScaleIndex(object sender, System.Windows.Input.MouseWheelEventArgs e)
 {
     if (e.Delta < 0)
     {
         if (totalScale <= 0.15)
         {
             scaleFactor = 0.98;
         }
         else
         {
             scaleFactor = 0.9;
         }
         if (totalScale * 2 * scaleFactor > 0.05)
         {
             totalScale *= scaleFactor;
             Draw();
         }
     }
     else if (e.Delta > 0)
     {
         scaleFactor = 1.1;
         if (totalScale * 2 * scaleFactor < 4)
         {
             totalScale *= scaleFactor;
             Draw();
         }
     }
 }
Ejemplo n.º 31
0
 private void CProgressBar_MouseWheel(object sender, MouseWheelEventArgs e)
 {
     if (e.Delta > 0)
         Value += Maximum * 0.02;
     else
         Value -= Maximum * 0.02;
 }
Ejemplo n.º 32
0
 private void TreeView_OnPreviewMouseWheel(object sender, MouseWheelEventArgs e) {
     e.Handled = true;
     (((FrameworkElement)sender).Parent as UIElement)?.RaiseEvent(new MouseWheelEventArgs(e.MouseDevice, e.Timestamp, e.Delta) {
         RoutedEvent = MouseWheelEvent,
         Source = sender
     });
 }
Ejemplo n.º 33
0
		private void OnMouseWheel(object sender, MouseWheelEventArgs e) {
			if (!e.Handled) {
				Point mousePos = e.GetPosition(this);
				int delta = -e.Delta;
				MouseWheelZoom(mousePos, delta);
			}
		}
Ejemplo n.º 34
0
        private void lbDocumentThumbnails_PreviewMouseWheel(object sender, System.Windows.Input.MouseWheelEventArgs e)
        {
            // Find Descendant

            var d            = sender as DependencyObject;
            var scrollViewer = FindDescendant <ScrollViewer>(d);


            if (Keyboard.Modifiers == ModifierKeys.Alt && scrollViewer != null)
            {
                if (e.Delta < 0)
                {
                    scrollViewer.LineRight();
                    e.Handled = true;
                }
                else
                {
                    scrollViewer.LineLeft();
                    e.Handled = true;
                }
            }

            if (!e.Handled)
            {
                e.Handled = true;
                var eventArg = new MouseWheelEventArgs(e.MouseDevice, e.Timestamp, e.Delta);
                eventArg.RoutedEvent = UIElement.MouseWheelEvent;
                eventArg.Source      = sender;
                var parent = ((Control)sender).Parent as UIElement;
                parent.RaiseEvent(eventArg);
            }
        }
Ejemplo n.º 35
0
        private void viewport3d_MouseWheel(object sender, System.Windows.Input.MouseWheelEventArgs e)
        {
            double s = 240;

            ppc.Position = new Point3D(ppc.Position.X, ppc.Position.Y, ppc.Position.Z - e.Delta / s);
            // 在此处添加事件处理程序实现。
        }
Ejemplo n.º 36
0
        private void ScrollViewer_PreviewMouseWheel(object sender, System.Windows.Input.MouseWheelEventArgs e)
        {
            var scrollViewer = (ScrollViewer)sender;

            if (scrollViewer == null || (scrollViewer.Tag is bool && (bool)scrollViewer.Tag))
            {
                return;
            }

            if (Keyboard.Modifiers != ModifierKeys.Shift && scrollViewer.ComputedVerticalScrollBarVisibility == Visibility.Visible)
            {
                return;
            }

            if (e.Delta < 0)
            {
                scrollViewer.LineRight();
            }
            else
            {
                scrollViewer.LineLeft();
            }

            e.Handled = true;
        }
Ejemplo n.º 37
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())));
     }
 }
Ejemplo n.º 38
0
        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
                }
            }
        }
Ejemplo n.º 39
0
        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);
        }
Ejemplo n.º 40
0
 void SeeThruListView_PreviewMouseWheel(object sender, MouseWheelEventArgs e)
 {
     e.Handled = true;
     var e2 = new MouseWheelEventArgs(e.MouseDevice, e.Timestamp, e.Delta);
     e2.RoutedEvent = UIElement.MouseWheelEvent;
     RaiseEvent(e2);
 }
Ejemplo n.º 41
0
 public void controlMouseWheel(object sender, MouseWheelEventArgs args)
 {
     var img = sender as Image;
     if (img == null) return;
     var transform = (TransformGroup)img.RenderTransform;
     foreach (var child in transform.Children.OfType<ScaleTransform>())
     {
         var delta = args.Delta > 0 ? StepSize : -StepSize;
         var newScale = child.ScaleX + delta;
         if (newScale >= 1)
         {
             child.ScaleX = newScale;
             child.ScaleY = newScale;
             ((ImageParams)img.Tag).Scale = newScale;
         }
     }
     foreach (var translate in transform.Children.OfType<TranslateTransform>())
     {
         var scale = ((ImageParams)img.Tag).Scale;
         var relY = (img.ActualHeight * scale - img.ActualHeight) / 2;
         var relX = (img.ActualWidth * scale - MagicalNumberOfLogic.ActualWidth) / 2;
         if (translate.Y < -relY || translate.Y > relY)
         {
             var step = StepToOriginal(translate.Y, scale, StepSize);
             translate.Y -= step;
         }
         if (translate.X < -relX || translate.X > relX)
         {
             var step = StepToOriginal(translate.X, scale, StepSize);
             translate.X -= step;
         }
     }
 }
Ejemplo n.º 42
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;
        }
Ejemplo n.º 43
0
        private void TabControl_PreviewMouseWheel(object sender, MouseWheelEventArgs e)
        {
            if (e.Delta > 0)
            {
                if (SelectedIndex < Items.Count - 1)
                    SelectedIndex++;
                else
                    SelectedIndex = 0;
            }
            else
            {

                if (SelectedIndex > 0)
                    SelectedIndex--;
                else
                    SelectedIndex = Items.Count - 1;
            }

            if (!_tabPanel.Children[SelectedIndex].IsEnabled)
            {
                if (_tabPanel.Children.OfType<TabItem>().All(x => !x.IsEnabled))
                {
                    SelectedIndex = -1;
                    return;
                }

                TabControl_PreviewMouseWheel(sender, e);
            }

            TabItem_PreviewMouseDown(sender, null);
            ChangeVisibility();
        }
        private void ScrollConLaRuedaDelRaton(object sender, System.Windows.Input.MouseWheelEventArgs e)
        {
            ScrollViewer scroll = (ScrollViewer)sender;

            scroll.ScrollToVerticalOffset(scroll.VerticalOffset - e.Delta);
            e.Handled = true;
        }
Ejemplo n.º 45
0
        private void txtUrl_PreviewMouseWheel(object sender, System.Windows.Input.MouseWheelEventArgs e)
        {
            if (Keyboard.Modifiers != ModifierKeys.Control)
            {
                return;
            }
            e.Handled = true;
            var fontSize = txtUrl.FontSize;

            if (e.Delta > 0)
            {
                ++fontSize;
            }
            else
            {
                --fontSize;
            }
            if (fontSize < this.FontSize)
            {
                fontSize = this.FontSize;
            }
            if (fontSize > (3 * this.FontSize))
            {
                fontSize = 3 * this.FontSize;
            }
            txtUrl.FontSize = fontSize;
        }
        private static void PreviewMouseWheel(Object sender, MouseWheelEventArgs e)
        {
            if (Keyboard.Modifiers == ModifierKeys.Control)
            {
                Control zoomableControl = (Control)sender;

                double zoomAmount = (double)zoomableControl.GetValue(ZoomAmountProperty);
                double zoomMinimum = (double)zoomableControl.GetValue(ZoomMinimumProperty);
                double zoomMaximum = (double)zoomableControl.GetValue(ZoomMaximumProperty);

                if (e.Delta > 0)
                    zoomAmount *= 1.1;
                else
                    zoomAmount *= 0.90909090909090906;

                if (zoomAmount > zoomMaximum)
                    zoomAmount = zoomMaximum;
                else if (zoomAmount < zoomMinimum)
                    zoomAmount = zoomMinimum;

                zoomAmount = Math.Round(zoomAmount, 2);

                zoomableControl.SetValue(ZoomAmountProperty, zoomAmount);
            }
        }
Ejemplo n.º 47
0
        private static void HandlePreviewMouseWheel(object sender, MouseWheelEventArgs e)
        {
            var scrollControl = sender as ScrollViewer;
            if (!e.Handled && sender != null && !reentrantList.Contains(e))
            {
                var previewEventArg = new MouseWheelEventArgs(e.MouseDevice, e.Timestamp, e.Delta)
                {
                    RoutedEvent = UIElement.PreviewMouseWheelEvent,
                    Source = sender
                };
                var originalSource = e.OriginalSource as UIElement;
                reentrantList.Add(previewEventArg);
                if (originalSource!=null) originalSource.RaiseEvent(previewEventArg);
                reentrantList.Remove(previewEventArg);
                // at this point if no one else handled the event in our children, we do our job

                if (!previewEventArg.Handled && ((e.Delta > 0 && scrollControl.VerticalOffset == 0)
                    || (e.Delta <= 0 && scrollControl.VerticalOffset >= scrollControl.ExtentHeight - scrollControl.ViewportHeight)))
                {
                    e.Handled = true;
                    var eventArg = new MouseWheelEventArgs(e.MouseDevice, e.Timestamp, e.Delta);
                    eventArg.RoutedEvent = UIElement.MouseWheelEvent;
                    eventArg.Source = sender;
                    var parent = (UIElement)((FrameworkElement)sender).Parent;
                    parent.RaiseEvent(eventArg);
                }
            }
        }
Ejemplo n.º 48
0
 private void timelineView_MouseWheel_1(object sender, MouseWheelEventArgs e)
 {
     var delta = e.Delta < 0 ? 0.5 : -0.5;
     var newZoom = zoomSlider.Value + delta;
     if (zoomSlider.Minimum <= newZoom && newZoom <= zoomSlider.Maximum)
         zoomSlider.Value = newZoom;
 }
Ejemplo n.º 49
0
        private void ListViewScrollViewer_PreviewMouseWheel(object sender, System.Windows.Input.MouseWheelEventArgs e)
        {
            ScrollViewer scv = (ScrollViewer)sender;

            scv.ScrollToVerticalOffset(scv.VerticalOffset - e.Delta);
            e.Handled = true;
        }
        protected override void OnPreviewMouseWheel(System.Windows.Input.MouseWheelEventArgs e)
        {
            // TIP: to use scroll instead of default Zoom feature just hold 'Control' key and scroll Mouse Wheel
            if (Keyboard.Modifiers != ModifierKeys.Control)
            {
                LastMousePositionOnTarget = Mouse.GetPosition(this.Content as IInputElement);
                double val = Math.Round(Zoom, 1);

                if (e.Delta > 0)
                {
                    if (val < 1)
                    {
                        val += 0.1;
                    }
                    else if (val >= 1 && val < 2.2)
                    {
                        val += 0.4;
                    }
                    else if (val >= 2.2 && val < 4)
                    {
                        val += 0.6;
                    }
                    else if (val >= 4)
                    {
                        val += 0.8;
                    }
                }
                if (e.Delta < 0)
                {
                    if (val <= 1)
                    {
                        val -= 0.1;
                    }
                    else if (val > 1 && val <= 2.2)
                    {
                        val -= 0.4;
                    }
                    else if (val > 2.2 && val <= 4)
                    {
                        val -= 0.6;
                    }
                    else if (val > 4)
                    {
                        val -= 0.8;
                    }
                }

                if (val >= Minimum && val <= Maximum)
                {
                    Zoom = val;
                }

                e.Handled = true;
            }
            else
            {
                base.OnPreviewMouseWheel(e);
            }
        }
Ejemplo n.º 51
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);
        }
Ejemplo n.º 52
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);
        }
Ejemplo n.º 53
0
        void MediaEl_MouseWheel(object sender, System.Windows.Input.MouseWheelEventArgs e)
        {
            var timeGap     = 0.04M;
            var newPosition = Convert.ToDecimal(this.MediaEl.Position) + timeGap * (e.Delta > 0 ? MediaEl.SpeedRatio : -MediaEl.SpeedRatio);

            newPosition      = SnapTo(0.04M, newPosition);
            MediaEl.Position = newPosition;
        }
Ejemplo n.º 54
0
 private void slider1_PreviewMouseWheel(object sender, System.Windows.Input.MouseWheelEventArgs e)
 {
     base.OnPreviewMouseWheel(e);
     if (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl))
     {
         slider1.Value += (e.Delta > 0) ? 0.1 : -0.1;
     }
 }
Ejemplo n.º 55
0
//</SnippetUIElementMouseCapture>
        void OnMouseWheel(object sender, System.Windows.Input.MouseWheelEventArgs e)
        {
            e.Handled = true;

            _scaleDelta += (double)((double)e.Delta / (double)1000);
            Quaternion q = _rotation;

            UpdateSlaves(q, _scale * _scaleDelta, _translate);
        }
Ejemplo n.º 56
0
        public void PreprocessMouseWheel(System.Windows.Input.MouseWheelEventArgs e)
        {
            IMouseProcessor processor = Content as IMouseProcessor;

            if (processor != null)
            {
                processor.PreprocessMouseWheel(e);
            }
        }
Ejemplo n.º 57
0
 protected override void OnMouseWheel(System.Windows.Input.MouseWheelEventArgs e)
 {
     fsurface.Zoom += e.Delta / 4 / 100.0f;
     if (fsurface.Zoom < 0.05)
     {
         fsurface.Zoom = 0.05f;
     }
     this.InvalidateVisual();
 }
Ejemplo n.º 58
0
        private void ScrollViewer_MouseWheel(object sender, System.Windows.Input.MouseWheelEventArgs e)
        {
            if (ScrollViewer.VerticalOffset != ScrollViewer.ScrollableHeight || SearchBar.TextBox.Text.Length <= AppData.START_SEARCHING_ADDON_AT_TEXT_LENGTH)
            {
                return;
            }
            var CurrentAddonCount = AddonContainer.Children.Count;

            UIManager.CreateAddonList(CurrentAddonCount);
        }
        void WinFormsControl_MouseWheel(object sender, swf.MouseEventArgs e)
        {
            var args = new swi.MouseWheelEventArgs(swi.InputManager.Current.PrimaryMouseDevice, Environment.TickCount, e.Delta)
            {
                RoutedEvent = swi.Mouse.MouseWheelEvent,
                Source      = Control
            };

            Control.RaiseEvent(args);
        }
Ejemplo n.º 60
0
 private void Owner_MouseWheel(object sender, System.Windows.Input.MouseWheelEventArgs e)
 {
     if (e.Delta > 0)
     {
         ++Vertices;
     }
     else
     {
         --Vertices;
     }
 }