当前位置: 首页>>代码示例>>C#>>正文


C# MouseWheelEventArgs.GetPosition方法代码示例

本文整理汇总了C#中System.Windows.Input.MouseWheelEventArgs.GetPosition方法的典型用法代码示例。如果您正苦于以下问题:C# MouseWheelEventArgs.GetPosition方法的具体用法?C# MouseWheelEventArgs.GetPosition怎么用?C# MouseWheelEventArgs.GetPosition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Input.MouseWheelEventArgs的用法示例。


在下文中一共展示了MouseWheelEventArgs.GetPosition方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: MouseWheel

        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;
            }
        }
开发者ID:fcostacampos,项目名称:WPF-Magnifier,代码行数:30,代码来源:ImagingProvider.cs

示例2: PlotControl_MouseWheel

        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);
        }
开发者ID:aleksanderkobylak,项目名称:oxyplot,代码行数:7,代码来源:MouseAction.cs

示例3: OnMouseWheel

		private void OnMouseWheel(object sender, MouseWheelEventArgs e) {
			if (!e.Handled) {
				Point mousePos = e.GetPosition(this);
				int delta = -e.Delta;
				MouseWheelZoom(mousePos, delta);
			}
		}
开发者ID:XiBeichuan,项目名称:hydronumerics,代码行数:7,代码来源:MouseNavigation.cs

示例4: MapLayoutPanel_MouseWheel

        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;
            }
        }
开发者ID:strommen,项目名称:tcxamlug-jul2012,代码行数:32,代码来源:MainWindow.xaml.cs

示例5: OnMouseWheel

        protected override void OnMouseWheel(MouseWheelEventArgs e)
        {
            base.OnMouseWheel(e);

            var zoomDelta = MouseWheelZoomDelta * (double)e.Delta / 120d;
            ZoomMap(e.GetPosition(this), TargetZoomLevel + zoomDelta);
        }
开发者ID:reecebedding,项目名称:gw2pao,代码行数:7,代码来源:Map.cs

示例6: OnGraphControlMouseWheel

        private void OnGraphControlMouseWheel(object sender, MouseWheelEventArgs e)
        {
            ZoomAndPanControl.ZoomAboutPoint(
                ZoomAndPanControl.ContentScale + e.Delta / 1000.0f,
                e.GetPosition(GraphControl));

            e.Handled = true;
        }
开发者ID:praveenv4k,项目名称:indriya,代码行数:8,代码来源:GraphView.xaml.cs

示例7: source_MouseWheel

 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);
 }
开发者ID:ravidasghodse,项目名称:genericva,代码行数:9,代码来源:PanAndZoom.cs

示例8: timelineCanvas_MouseWheel

 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));
 }
开发者ID:KineticIsEpic,项目名称:OpenUtau,代码行数:10,代码来源:MainWindow.xaml.cs

示例9: player_MouseWheel

		//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;
		}
开发者ID:zzilla,项目名称:ONVIF-Device-Manager,代码行数:59,代码来源:DepthCalibrationView.xaml.cs

示例10: OnMouseWheel

        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);
        }
开发者ID:rexperalta,项目名称:OCTGN,代码行数:11,代码来源:TableTabView.xaml.cs

示例11: image_MouseWheel

        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);
        }
开发者ID:whztt07,项目名称:BCFier,代码行数:18,代码来源:SnapWin.xaml.cs

示例12: HandleMouseWheel

        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;
        }
开发者ID:tumcms,项目名称:TUM.CMS.VPLControl,代码行数:18,代码来源:ZoomCanvas.cs

示例13: Zoom_PreviewMouseWheel

        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);




        }
开发者ID:ychost,项目名称:PowerControlSimulation,代码行数:19,代码来源:PCS-221G.xaml.cs

示例14: child_MouseWheel

 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;
     }
 }
开发者ID:mistopportunity,项目名称:Image-Viewer,代码行数:23,代码来源:ZoomBorder.cs

示例15: Content_MouseWheel

 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);
 }
开发者ID:noamkfir,项目名称:snoopwpf,代码行数:6,代码来源:Zoomer.xaml.cs


注:本文中的System.Windows.Input.MouseWheelEventArgs.GetPosition方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。