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


C# PointerRoutedEventArgs.GetPosition方法代码示例

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


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

示例1: OnDragging

		private static void OnDragging( object sender, PointerRoutedEventArgs e )
#endif
        {
            var obj = sender as DependencyObject;
            if (!GetIsDragging(obj))
                return;

#if WPF
            Point pos = e.GetPosition(obj as IInputElement);
#elif METRO
            Point pos = e.GetCurrentPoint(obj as UIElement).Position;
#endif
            double horizontalChange = (pos.X - GetOriginalX(obj)) * _scale.X;
            double verticalChange = (pos.Y - GetOriginalY(obj)) * _scale.Y;
            if (GetIsTagged(obj))
            {
                var vc = obj as VertexControl;
                if (vc == null)
                {
                    Debug.WriteLine("OnDragging() -> Tagged and dragged the wrong object?");
                    return;
                }
                foreach (var item in vc.RootArea.GetAllVertexControls())
                    if (GetIsTagged(item))
                        UpdateCoordinates(item, horizontalChange, verticalChange);
            }
            else UpdateCoordinates(obj, horizontalChange, verticalChange);
            e.Handled = true;
        }
开发者ID:aliaspilote,项目名称:TX52,代码行数:29,代码来源:DragBehaviour.cs

示例2: OnDragStarted

		private static void OnDragStarted( object sender, PointerRoutedEventArgs e )
#endif
        {
            var obj = sender as DependencyObject;
            //we are starting the drag
            SetIsDragging(obj, true);

#if WPF
            var pos = e.GetPosition(obj as IInputElement);
#elif METRO
			var pos = e.GetCurrentPoint(obj as UIElement).Position;
#endif

            //save the position of the mouse to the start position
            SetOriginalX(obj, pos.X);
            SetOriginalY(obj, pos.Y);

            //capture the mouse
#if WPF
            var element = obj as IInputElement;
            if (element != null)
            {
                element.CaptureMouse();
                element.MouseMove += OnDragging;
            }
            //else throw new GX_InvalidDataException("The control must be a descendent of the FrameworkElement or FrameworkContentElement!");
            e.Handled = false;
#elif METRO
            var element = obj as FrameworkElement;
			if ( element != null )
			{
				element.CapturePointer(e.Pointer);
				element.PointerMoved += OnDragging;
			}
            e.Handled = true;
#endif
        }
开发者ID:aliaspilote,项目名称:TX52,代码行数:37,代码来源:DragBehaviour.cs

示例3: GetHorizontalPanelMousePosition

        private double? GetHorizontalPanelMousePosition(PointerRoutedEventArgs e)
#endif
        {
            // take into account the scrubber _horizontalThumb size
            double thumbWidth = (ThumbElement == null) ? 0 : ThumbElement.ActualWidth;
            double panelWidth = Panel.ActualWidth - thumbWidth;

            if (panelWidth > 0)
            {
                double range = Maximum - Minimum;

                // calculate the new newValue based on mouse position
#if SILVERLIGHT
                Point mousePosition = e.GetPosition(Panel);
#else
                Point mousePosition = e.GetCurrentPoint(Panel).Position;
#endif
                double x = mousePosition.X - thumbWidth / 2;
                x = Math.Min(Math.Max(0, x), panelWidth);
                double value = (x * range) / panelWidth;

                // offset from the min newValue
                value += Minimum;

                return value;
            }
            else return null;
        }
开发者ID:bondarenkod,项目名称:pf-arm-deploy-error,代码行数:28,代码来源:SeekableSlider.cs

示例4: GetVerticalPanelMousePosition

        private double? GetVerticalPanelMousePosition(PointerRoutedEventArgs e)
#endif
        {
            // take into account the scrubber _horizontalThumb size
            double thumbHeight = (ThumbElement == null) ? 0 : ThumbElement.ActualHeight;
            double panelHeight = Panel.ActualHeight - thumbHeight;

            if (panelHeight > 0)
            {
                double range = Maximum - Minimum;

                // calculate the new newValue based on mouse position
#if SILVERLIGHT
                Point mousePosition = e.GetPosition(Panel);
#else
                Point mousePosition = e.GetCurrentPoint(Panel).Position;
#endif
                double y = mousePosition.Y - thumbHeight / 2;
                y = Math.Min(Math.Max(0, y), panelHeight);
                double value = ((panelHeight - y) * range) / panelHeight;

                // offset from the min newValue
                value += Minimum;

                return value;
            }
            else return null;
        }
开发者ID:bondarenkod,项目名称:pf-arm-deploy-error,代码行数:28,代码来源:SeekableSlider.cs

示例5: Foo_PointerWheelChanged

        private void Foo_PointerWheelChanged(object sender, FakeMouseWheelEventArgs e)
        {
            bool isFineTune = this.fineTuneLocation.IsChecked.Value;
            FrameworkElement source = (FrameworkElement)sender;
#if !NETFX_CORE
            var point = e.GetPosition(source);
            double MouseWheelDelta = e.Delta;
#else
            var vpoint = e.GetCurrentPoint(source);
            double MouseWheelDelta = vpoint.Properties.MouseWheelDelta;
            var point = vpoint.Position;
#endif
            if (this.wheelToggle.IsChecked.Value)
            {
                double multipler = MouseWheelDelta * 0.0005;
                if (isFineTune)
                {
                    multipler *= 0.1;
                }

                double newScale = Math.Exp(multipler);
                if (isFineTune)
                {
                    view.DeltaOffsetScale(newScale);
                }
                else
                {
                    view.AddScale(newScale, point.X - source.ActualWidth / 2, point.Y - source.ActualHeight / 2);
                }
            }
            else
            {
                double multipler = MouseWheelDelta / 10;
                if (isFineTune)
                {
                    multipler *= 0.1;
                }

                double newRot = multipler * 2 * Math.PI / 360;

                if (isFineTune)
                {
                    view.DeltaOffsetRot(newRot);
                }
                else
                {
                    view.AddBaseRotation(newRot, new Point(point.X - source.ActualWidth / 2, point.Y - source.ActualHeight / 2));
                }
            }

            e.Handled = true;
        }
开发者ID:jcookems,项目名称:freezing-ninja,代码行数:52,代码来源:MainPage.xaml.cs


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