コード例 #1
0
ファイル: Attached.cs プロジェクト: Daoting/dt
        /// <summary>
        /// 切换光标处理
        /// </summary>
        /// <param name="d"></param>
        /// <param name="e"></param>
        static void OnCursorChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            CoreCursorType oldCursor = (CoreCursorType)e.OldValue;
            CoreCursorType newCursor = (CoreCursorType)d.GetValue(CursorProperty);

            if (oldCursor == CoreCursorType.Arrow)
            {
                var handler = new CursorDisplayHandler();
                handler.Attach((UIElement)d);
                SetCursorDisplayHandler(d, handler);
            }
            else
            {
                var handler = GetCursorDisplayHandler(d);
                if (newCursor == CoreCursorType.Arrow)
                {
                    handler.Detach();
                    SetCursorDisplayHandler(d, null);
                }
                else
                {
                    handler.UpdateCursor();
                }
            }
        }
コード例 #2
0
        private Rectangle CreateHandle(
            HorizontalAlignment ha,
            VerticalAlignment va,
            Point allowedDelta,
            CoreCursorType cursorType)
        {
            Rectangle handle = new Rectangle()
            {
                Name                = "AdonerHandle",
                Stroke              = this.HandleColor,
                Fill                = this.HandleColor,
                StrokeThickness     = 1,
                Height              = c_handleHeight,
                Width               = c_handleHeight,
                HorizontalAlignment = ha,
                VerticalAlignment   = va,
                Tag = allowedDelta,
            };

            // Establish the event handlers for changing the size of this object
            handle.ManipulationMode       = ManipulationModes.TranslateX | ManipulationModes.TranslateY;
            handle.ManipulationStarted   += Handle_ManipulationStarted;
            handle.ManipulationCompleted += Handle_ManipulationCompleted;
            handle.ManipulationDelta     += Handle_ManipulationDelta;

            Microsoft.Toolkit.Uwp.UI.Extensions.Mouse.SetCursor(handle, cursorType);

            _handleList.Add(handle);

            _grid.Children.Add(handle);

            return(handle);
        }
コード例 #3
0
        internal void SetBuiltInCursor(CoreCursorType cursorType)
        {
#if UWP
            CoreWindow win = Windows.UI.Xaml.Window.Current.CoreWindow;
            win.PointerCursor = new CoreCursor(cursorType, 0);
#endif
        }
コード例 #4
0
        private void TrySetNewCursor(CoreCursorType type)
        {
            if (Window.Current.CoreWindow.PointerCursor.Type != type)
            {
                if (defaultPointerCursor is null)
                {
                    defaultPointerCursor = Window.Current.CoreWindow.PointerCursor;
                }

                Window.Current.CoreWindow.PointerCursor = new CoreCursor(type, 0);
            }
        }
コード例 #5
0
ファイル: CursorExtensions.cs プロジェクト: weitzhandler/Uno
        public static CoreCursor ToCoreCursor(this Cursor cursor)
        {
            CoreCursorType cursorType = CoreCursorType.Arrow;

            if (cursor == Cursors.Wait)
            {
                cursorType = CoreCursorType.Wait;
            }
            else if (cursor == Cursors.Hand)
            {
                cursorType = CoreCursorType.Hand;
            }
            else if (cursor == Cursors.Cross)
            {
                cursorType = CoreCursorType.Cross;
            }
            else if (cursor == Cursors.Help)
            {
                cursorType = CoreCursorType.Help;
            }
            else if (cursor == Cursors.IBeam)
            {
                cursorType = CoreCursorType.IBeam;
            }
            else if (cursor == Cursors.No)
            {
                cursorType = CoreCursorType.UniversalNo;
            }
            else if (cursor == Cursors.UpArrow)
            {
                cursorType = CoreCursorType.UpArrow;
            }
            else if (cursor == Cursors.SizeNESW)
            {
                cursorType = CoreCursorType.SizeNortheastSouthwest;
            }
            else if (cursor == Cursors.SizeNS)
            {
                cursorType = CoreCursorType.SizeNorthSouth;
            }
            else if (cursor == Cursors.SizeNWSE)
            {
                cursorType = CoreCursorType.SizeNorthwestSoutheast;
            }
            else if (cursor == Cursors.SizeWE)
            {
                cursorType = CoreCursorType.SizeWestEast;
            }
            return(new CoreCursor(cursorType, 0));
        }
コード例 #6
0
        /// <summary>
        /// Causes the pointer icon to appear when the user hovers over this UI element
        /// </summary>
        /// <param name="element"></param>
        public static void CursorOnHover(this UIElement element, CoreCursorType cursor = Windows.UI.Core.CoreCursorType.Hand)
        {
            element.PointerEntered += (sender, args) =>
            {
                if (element.IsHitTestVisible)
                {
                    Window.Current.CoreWindow.PointerCursor = new Windows.UI.Core.CoreCursor(cursor, 0);
                }
            };

            element.PointerExited += (sender, args) =>
            {
                Window.Current.CoreWindow.PointerCursor = new Windows.UI.Core.CoreCursor(Windows.UI.Core.CoreCursorType.Arrow, 0);
            };
        }
コード例 #7
0
        /// <summary>
        /// Handles changes to the SystemCursor property.
        /// </summary>
        /// <param name="d">
        /// The <see cref="DependencyObject"/> on which
        /// the property has changed value.
        /// </param>
        /// <param name="e">
        /// Event data that is issued by any event that
        /// tracks changes to the effective value of this property.
        /// </param>
        private static void OnSystemCursorChanged(
            DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            CoreCursorType oldSystemCursor = (CoreCursorType)e.OldValue;
            CoreCursorType newSystemCursor = (CoreCursorType)d.GetValue(SystemCursorProperty);

            //if (newSystemCursor.HasValue)
            {
                SetCursor(d, new CoreCursor(newSystemCursor, 1));
            }
            //else
            //{
            //    SetCursor(d, null);
            //}
        }
コード例 #8
0
ファイル: ModelDrawCursor.cs プロジェクト: davetz/ModelGraph3
        private void TrySetNewCursor(CoreCursorType cursorType, int id = 0)
        {
            if (_currentCusorType != cursorType || _currentCursorId != id)
            {
                _currentCursorId  = id;
                _currentCusorType = cursorType;

                if (cursorType == CoreCursorType.Custom && _customCursor.TryGetValue(id, out CoreCursor customCursor))
                {
                    Window.Current.CoreWindow.PointerCursor = customCursor;
                }
                else if (_standardCursors.TryGetValue(cursorType, out CoreCursor standardCursor))
                {
                    Window.Current.CoreWindow.PointerCursor = standardCursor;
                }
                else if (_standardCursors.TryGetValue(CoreCursorType.Arrow, out CoreCursor arrowCursor))
                {
                    Window.Current.CoreWindow.PointerCursor = arrowCursor;
                }
            }
        }
コード例 #9
0
        public DrawStar(Map map, CoreCursorType cursor)
        {

            Name = "DrawStar";
            Map = map;

            Stroke = new SolidColorBrush(Colors.Red);
            StrokeThickness = 2;
            Fill = new SolidColorBrush(Colors.Red);
            FillRule = FillRule.Nonzero;
            Opacity = 1;


        }
コード例 #10
0
 /// <summary>
 /// Sets the SystemCursor property. This dependency property 
 /// indicates the system CoreCursorType to use for the control's mouse cursor.
 /// </summary>
 public static void SetSystemCursor(DependencyObject d, CoreCursorType value)
 {
     d.SetValue(SystemCursorProperty, value);
 }
コード例 #11
0
 public static void SetCursor(DependencyObject element, CoreCursorType value)
 {
     element.SetValue(CursorProperty, value);
 }
コード例 #12
0
ファイル: ColHeaderCell.cs プロジェクト: Daoting/dt
 void SetCursor(CoreCursorType p_cursor)
 {
     CoreWindow.GetForCurrentThread().PointerCursor = new CoreCursor(p_cursor, 0);
 }
コード例 #13
0
ファイル: Attached.cs プロジェクト: Daoting/dt
 /// <summary>
 /// 设置光标附加属性
 /// </summary>
 public static void SetCursor(this DependencyObject d, CoreCursorType value)
 {
     d.SetValue(CursorProperty, value);
 }
コード例 #14
0
        /// <summary>
        /// Sets the Cursor for the Pointer
        /// </summary>
        /// <param name="cursor"></param>
        /// <param name="headerCell"></param>
        /// <remarks></remarks>
#if !WPF
        internal void SetPointerCursor(CoreCursorType cursorType)
コード例 #15
0
ファイル: Mouse.cs プロジェクト: vipadm/Unigram
 /// <summary>
 /// Set the target <see cref="CoreCursorType"/>.
 /// </summary>
 /// <param name="element">Object where the selector cursor type should be shown.</param>
 /// <param name="value">Target cursor type value.</param>
 public static void SetCursor(FrameworkElement element, CoreCursorType value)
 {
     element.SetValue(CursorProperty, value);
 }
コード例 #16
0
 public static void SetCursor(DependencyObject element, CoreCursorType value)
 {
     element.SetValue(CursorProperty, value);
 }
コード例 #17
0
        internal static string ToCssCursor(this CoreCursorType coreCursorType)
        {
            //best matches between
            // https://docs.microsoft.com/id-id/uwp/api/windows.ui.core.corecursortype
            //and
            //https://developer.mozilla.org/fr/docs/Web/CSS/cursor
            // no support for Custom Cursor for now

            switch (coreCursorType)
            {
            case CoreCursorType.Custom:
                coreCursorType.Log().Warn("Cursor type 'Custom' not supported yet. Default cursor is used instead.");
                return("auto");

            case CoreCursorType.Arrow:
                return("auto");

            case CoreCursorType.Cross:
                return("crosshair");

            case CoreCursorType.Hand:
                return("pointer");

            case CoreCursorType.Help:
                return("help");

            case CoreCursorType.IBeam:
                return("text");

            case CoreCursorType.SizeAll:
                return("move");

            case CoreCursorType.SizeNortheastSouthwest:
                return("nesw-resize");

            case CoreCursorType.SizeNorthSouth:
                return("ns-resize");

            case CoreCursorType.SizeNorthwestSoutheast:
                return("nwse-resize");

            case CoreCursorType.SizeWestEast:
                return("ew-resize");

            case CoreCursorType.UniversalNo:
                return("not-allowed");

            case CoreCursorType.UpArrow:
                return("n-resize");

            case CoreCursorType.Wait:
                return("wait");

            case CoreCursorType.Pin:
            case CoreCursorType.Person:
                return("pointer");

            default:
                return("auto");
            }
        }
コード例 #18
0
ファイル: MainPage.xaml.cs プロジェクト: biac/blogcode
 private void SetPointerCursor(CoreCursorType cursorType, uint resourceId = 0)
 => Window.Current.CoreWindow.PointerCursor = new CoreCursor(cursorType, resourceId);
コード例 #19
0
ファイル: Mouse.cs プロジェクト: vipadm/Unigram
        private static void Element_PointerEntered(object sender, PointerRoutedEventArgs e)
        {
            CoreCursorType cursor = GetCursor((FrameworkElement)sender);

            Window.Current.CoreWindow.PointerCursor = _cursors[cursor];
        }
コード例 #20
0
 /// <summary>Sets the system cursor.</summary>
 /// <param name="dependencyObject">The dependency object.</param>
 /// <param name="value">The value.</param>
 public static void SetSystemCursor(this DependencyObject dependencyObject, CoreCursorType value)
 {
     if (dependencyObject == null)
         throw new ArgumentNullException(nameof(dependencyObject));
     dependencyObject.SetValue(SystemCursorProperty, value);
 }
コード例 #21
0
ファイル: CoreCursor.cs プロジェクト: Robert-Louis/Uno
 public CoreCursor(CoreCursorType type, uint id)
 {
     Type = type;
     Id   = id;
 }
コード例 #22
0
ファイル: Attached.cs プロジェクト: Daoting/dt
 /// <summary>
 /// 获取光标实例
 /// </summary>
 /// <param name="p_curType"></param>
 /// <returns></returns>
 public static CoreCursor GetCursor(CoreCursorType p_curType)
 {
     return(_cursors[p_curType]);
 }
コード例 #23
0
 /// <summary>
 /// Sets the SystemCursor property. This dependency property
 /// indicates the system CoreCursorType to use for the control's mouse cursor.
 /// </summary>
 public static void SetSystemCursor(DependencyObject d, CoreCursorType value)
 {
     d.SetValue(SystemCursorProperty, value);
 }
コード例 #24
0
        /// <summary>
        /// Returns the VisibleLine on the pointer hitting point
        /// </summary>
        /// <param name="point"></param>
        /// <param name="cursor"></param>
        /// <returns></returns>
        /// <remarks></remarks>
#if !WPF
        internal VisibleLineInfo HitTest(Point point, out CoreCursorType cursor)