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


C# Visual.PointFromScreen方法代码示例

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


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

示例1: GetPosition

        /// <summary>
        /// Uses Win32 API to return mouse pointer position relative to a specific Visual. This
        /// function is provided because WPF's mouse API becomes unreliable under certain circumstances,
        /// like during drag-drop operations.
        /// </summary>
        /// <param name="relativeTo">Visual against which mouse position is reported</param>
        /// <returns>Mouse pointer location relative to passed in Visual</returns>
        public static Point GetPosition(Visual relativeTo)
        {
            Win32.Point w32Mouse = new Win32.Point();

            Win32.GetCursorPos( ref w32Mouse );

            return relativeTo.PointFromScreen( new Point( w32Mouse.X, w32Mouse.Y ) );
        }
开发者ID:dxm007,项目名称:Droppy,代码行数:15,代码来源:MouseEx.cs

示例2: GetMousePosition

        /// <summary>
        /// Returns the mouse cursor location.  This method is necessary during 
        /// a drag-drop operation because the WPF mechanisms for retrieving the
        /// cursor coordinates are unreliable.
        /// </summary>
        /// <param name="relativeTo">The Visual to which the mouse coordinates will be relative.</param>
        public static Point GetMousePosition(Visual relativeTo)
        {
            Win32Point mouse = new Win32Point();
            GetCursorPos(ref mouse);

            // Using PointFromScreen instead of Dan Crevier's code (commented out below)
            // is a bug fix created by William J. Roberts.  Read his comments about the fix
            // here: http://www.codeproject.com/useritems/ListViewDragDropManager.asp?msg=1911611#xx1911611xx
            return relativeTo.PointFromScreen(new Point((double)mouse.X, (double)mouse.Y));
        }
开发者ID:nydehi,项目名称:onesync,代码行数:16,代码来源:MouseUtilities.cs

示例3: GetMousePosition

        /// <summary>
        /// Returns the mouse cursor location.  This method is necessary during 
        /// a drag-drop operation because the WPF mechanisms for retrieving the
        /// cursor coordinates are unreliable.
        /// </summary>
        /// <param name="relativeTo">The Visual to which the mouse coordinates will be relative.</param>
        public static Point GetMousePosition( Visual relativeTo )
        {
            Win32Point mouse = new Win32Point();
            GetCursorPos( ref mouse );

            // Using PointFromScreen instead of Dan Crevier's code (commented out below)
            // is a bug fix created by William J. Roberts.  Read his comments about the fix
            // here: http://www.codeproject.com/useritems/ListViewDragDropManager.asp?msg=1911611#xx1911611xx
            return relativeTo.PointFromScreen( new Point( (double)mouse.X, (double)mouse.Y ) );

            #region Commented Out
            //System.Windows.Interop.HwndSource presentationSource =
            //    (System.Windows.Interop.HwndSource)PresentationSource.FromVisual( relativeTo );
            //ScreenToClient( presentationSource.Handle, ref mouse );
            //GeneralTransform transform = relativeTo.TransformToAncestor( presentationSource.RootVisual );
            //Point offset = transform.Transform( new Point( 0, 0 ) );
            //return new Point( mouse.X - offset.X, mouse.Y - offset.Y );
            #endregion // Commented Out
        }
开发者ID:iarray,项目名称:LoveMusic,代码行数:25,代码来源:MouseUtilities.cs

示例4: CloneUsingXaml

        /* NOTE: CloneUsingXaml is temporarily removed.
           The method is currently not used. To avoid any confusions in the API documentation it is
           commented out because it would be listed as extension method for every other type.
     
        /// <summary>
        /// Clones an object using XAML serialization rules.
        /// </summary>
        /// <param name="obj">The <see cref="Object"/> to be cloned.</param>
        /// <returns>
        /// A clone of <paramref name="obj"/> where all public fields are cloned (deep copy). Fields or
        /// events are not copied and have their default values.
        /// </returns>
        public static Object CloneUsingXaml(this object obj)
        {
            // NOTE: This helper method is based on the tip provided by Mike Hillberg.
            // See http://blogs.msdn.com/mikehillberg/archive/2007/05/01/CloneWithXamlWriterXamlReader.aspx

            string xaml = XamlWriter.Save(obj);
            return XamlReader.Load(new XmlTextReader(new StringReader(xaml)));
        }
        */


        /// <summary>
        /// Gets location of the mouse cursor relative to the specified <see cref="Visual"/>.
        /// </summary>
        /// <param name="visual">The <see cref="Visual"/>.</param>
        /// <returns>The mouse position relative to <paramref name="visual"/>.</returns>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="visual"/> is <see langword="null"/>.
        /// </exception>
        public static Point GetMousePosition(Visual visual)
        {
            if (visual == null)
                throw new ArgumentNullException(nameof(visual));

            POINT pointNative = new POINT();
            Win32.GetCursorPos(ref pointNative);
            Point point = new Point(pointNative.X, pointNative.Y);

            // Convert mouse position from screen coordinates into local coordinates of visual.
            return visual.PointFromScreen(point);
        }
开发者ID:Zolniu,项目名称:DigitalRune,代码行数:43,代码来源:WindowsHelper.Desktop.cs

示例5: GetBoundsInLocalCoordinates

 private static Rect GetBoundsInLocalCoordinates(Visual visual, Rect boundsInScreenCoordinates)
 {
     var localBoundsUpperLeft = visual.PointFromScreen(new Point(boundsInScreenCoordinates.X, boundsInScreenCoordinates.Y));
     var localBoundsLowerRight = visual.PointFromScreen(new Point(
                                                     boundsInScreenCoordinates.X + boundsInScreenCoordinates.Width,
                                                     boundsInScreenCoordinates.Y + boundsInScreenCoordinates.Height));
     return new Rect(localBoundsUpperLeft, localBoundsLowerRight);
 }
开发者ID:osin-vladimir,项目名称:EyeX,代码行数:8,代码来源:WpfCrawler.cs

示例6: GetCursorPos

 public static Point GetCursorPos(Visual relativeTo)
 {
     Win32Point pt = new Win32Point();
     GetCursorPos(ref pt);
     return relativeTo.PointFromScreen(new Point((double)pt.X, (double)pt.Y));
 }
开发者ID:QuocHuy7a10,项目名称:Arianrhod,代码行数:6,代码来源:MouseHelper.cs

示例7: GetMousePosition

 /// <summary>
 /// Returns the mouse cursor location.  This method is necessary during
 /// a drag-drop operation because the WPF mechanisms for retrieving the
 /// cursor coordinates are unreliable.
 /// </summary>
 /// <param name="relativeTo">The Visual to which the mouse coordinates will be relative.</param>
 public static Point GetMousePosition(Visual relativeTo)
 {
     Win32Point mouse = new Win32Point();
     GetCursorPos(ref mouse);
     return relativeTo.PointFromScreen(new Point((double)mouse.X, (double)mouse.Y));
 }
开发者ID:networkelements,项目名称:Outopos,代码行数:12,代码来源:Extensions.cs

示例8: GetPosition

 public static Point GetPosition(Visual relativeTo)
 {
     return relativeTo.PointFromScreen(GetPosition());
 }
开发者ID:NGenesis,项目名称:VrPlayer.Trackers.OSVRTracker,代码行数:4,代码来源:MouseUtilities.cs

示例9: CorrectGetPosition

 public static Point CorrectGetPosition(Visual relativeTo)
 {
     var w32Mouse = new NativeMethods.Win32Point();
     NativeMethods.GetCursorPos(ref w32Mouse);
     return relativeTo.PointFromScreen(new Point(w32Mouse.X, w32Mouse.Y));
 }
开发者ID:OronDF343,项目名称:Sky-Jukebox,代码行数:6,代码来源:MouseUtils.cs

示例10: GetPosition

 internal static Point GetPosition(Visual relativeTo)
 {
     var w32Mouse = new User32.POINT();
     GetCursorPos(ref w32Mouse);
     return relativeTo.PointFromScreen(new Point(w32Mouse.X, w32Mouse.Y));
 }
开发者ID:sbambach,项目名称:ATF,代码行数:6,代码来源:Win32Calls.cs

示例11: GetPixelSnappingOffset

 private static Point GetPixelSnappingOffset(Visual visual, Visual rootVisual)
 {
     var point = new Point();
     if (rootVisual != null)
     {
         var transform = visual.TransformToAncestor(rootVisual) as Transform;
         if ((transform != null) && transform.Value.HasInverse)
         {
             point = visual.PointFromScreen(visual.PointToScreen(point));
         }
     }
     
     return point;
 }
开发者ID:sbambach,项目名称:ATF,代码行数:14,代码来源:Icon.cs

示例12: GetCorrectPosition

 private static Point GetCorrectPosition(Visual relativeTo)
 {
     UnsafeNativeMethods.Win32Point w32Mouse;
     UnsafeNativeMethods.GetCursorPos(out w32Mouse);
     return relativeTo.PointFromScreen(new Point(w32Mouse.X, w32Mouse.Y));
 }
开发者ID:D-Key,项目名称:LordJZ,代码行数:6,代码来源:BaseWindow.cs


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