Пример #1
0
        private void SetupSide(string name, StandardCursorType cursor, WindowEdge edge)
        {
            var ctl = this.FindControl <Control>(name);

            ctl.Cursor          = new Cursor(cursor);
            ctl.PointerPressed += (i, e) => PlatformImpl?.BeginResizeDrag(edge, e);
        }
Пример #2
0
        public IPlatformHandle GetCursor(StandardCursorType cursorType)
        {
            var handle = s_mapping.TryGetValue(cursorType, out var shape)
                ? _cursors[shape]
                : _cursors[CursorFontShape.XC_top_left_arrow];

            return(new PlatformHandle(handle, "XCURSOR"));
        }
Пример #3
0
 public static void SetCursorOnPointerPressed(this Control control, StandardCursorType cursor)
 {
     if (control != null)
     {
         control.PointerPressed += (s, e) =>
         {
             control.Cursor = new Cursor(cursor);
         };
     }
 }
Пример #4
0
        void SetupSide(string name, StandardCursorType cursor, WindowEdge edge, ref TemplateAppliedEventArgs e)
        {
            var ctl = e.NameScope.Get <Control>(name);

            ctl.Cursor          = new Cursor(cursor);
            ctl.PointerPressed += delegate
            {
                ((Window)this.GetVisualRoot()).PlatformImpl?.BeginResizeDrag(edge);
            };
        }
Пример #5
0
        private static IPlatformHandle GetCursor(StandardCursorType type)
        {
            var platform = AvaloniaGlobals.StandardCursorFactory;

            if (platform == null)
            {
                throw new Exception("Could not create Cursor: IStandardCursorFactory not registered.");
            }

            return(platform.GetCursor(type));
        }
Пример #6
0
        private static IPlatformHandle GetCursor(StandardCursorType type)
        {
            var platform = AvaloniaLocator.Current.GetService<IStandardCursorFactory>();

            if (platform == null)
            {
                throw new Exception("Could not create Cursor: IStandardCursorFactory not registered.");
            }

            return platform.GetCursor(type);
        }
Пример #7
0
        private static IPlatformHandle GetCursor(StandardCursorType type)
        {
            var platform = AvaloniaLocator.Current.GetService <IStandardCursorFactory>();

            if (platform == null)
            {
                throw new Exception("Could not create Cursor: IStandardCursorFactory not registered.");
            }

            return(platform.GetCursor(type));
        }
Пример #8
0
        public ICursorImpl GetCursor(StandardCursorType cursorType)
        {
            if (!Cache.TryGetValue(cursorType, out var rv))
            {
                rv = new CursorImpl(
                    UnmanagedMethods.LoadCursor(IntPtr.Zero, new IntPtr(CursorTypeMapping[cursorType])),
                    false);
                Cache.Add(cursorType, rv);
            }

            return(rv);
        }
Пример #9
0
        private static void LoadModuleCursor(StandardCursorType cursorType, string module, int id)
        {
            IntPtr mh = UnmanagedMethods.GetModuleHandle(module);

            if (mh != IntPtr.Zero)
            {
                IntPtr cursor = UnmanagedMethods.LoadCursor(mh, new IntPtr(id));
                if (cursor != IntPtr.Zero)
                {
                    Cache.Add(cursorType, new CursorImpl(cursor, false));
                }
            }
        }
Пример #10
0
        public IPlatformHandle GetCursor(StandardCursorType cursorType)
        {
            IPlatformHandle rv;
            if (!Cache.TryGetValue(cursorType, out rv))
            {
                Cache[cursorType] =
                    rv =
                        new PlatformHandle(
                            UnmanagedMethods.LoadCursor(IntPtr.Zero, new IntPtr(CursorTypeMapping[cursorType])),
                            PlatformConstants.CursorHandleType);
            }

            return rv;
        }
Пример #11
0
        public static Cursor Create(StandardCursorType cursorType)
        {
            Cursor cursor;

            lock (_StdCursors)
            {
                if (!_StdCursors.TryGetValue(cursorType, out cursor))
                {
                    cursor = new Cursor(cursorType);
                    _StdCursors[cursorType] = cursor;
                }
            }
            return(cursor);
        }
Пример #12
0
        public IPlatformHandle GetCursor(StandardCursorType cursorType)
        {
            IPlatformHandle rv;
            if (!Cache.TryGetValue(cursorType, out rv))
            {
                Cache[cursorType] =
                    rv =
                        new PlatformHandle(
                            GetCursor(CursorTypeMapping[cursorType]).Handle,
                            "GTKCURSOR");
            }

            return rv;
        }
Пример #13
0
        private static void LoadModuleCursor(StandardCursorType cursorType, string module, int id)
        {
            IntPtr mh = UnmanagedMethods.GetModuleHandle(module);

            if (mh != IntPtr.Zero)
            {
                IntPtr cursor = UnmanagedMethods.LoadCursor(mh, new IntPtr(id));
                if (cursor != IntPtr.Zero)
                {
                    PlatformHandle phCursor = new PlatformHandle(cursor, PlatformConstants.CursorHandleType);
                    Cache.Add(cursorType, phCursor);
                }
            }
        }
Пример #14
0
        public IPlatformHandle GetCursor(StandardCursorType cursorType)
        {
            IPlatformHandle rv;

            if (!Cache.TryGetValue(cursorType, out rv))
            {
                Cache[cursorType] =
                    rv            =
                        new PlatformHandle(
                            UnmanagedMethods.LoadCursor(IntPtr.Zero, new IntPtr(CursorTypeMapping[cursorType])),
                            PlatformConstants.CursorHandleType);
            }

            return(rv);
        }
Пример #15
0
        public IPlatformHandle GetCursor(StandardCursorType cursorType)
        {
            IPlatformHandle rv;

            if (!Cache.TryGetValue(cursorType, out rv))
            {
                Cache[cursorType] =
                    rv            =
                        new PlatformHandle(
                            GetCursor(CursorTypeMapping[cursorType]).Handle,
                            "GTKCURSOR");
            }

            return(rv);
        }
Пример #16
0
        public ICursorImpl GetCursor(StandardCursorType cursorType)
        {
            IntPtr handle;

            if (cursorType == StandardCursorType.None)
            {
                handle = _nullCursor;
            }
            else
            {
                handle = s_mapping.TryGetValue(cursorType, out var shape)
                ? _cursors[shape]
                : _cursors[CursorFontShape.XC_left_ptr];
            }
            return(new CursorImpl(handle));
        }
Пример #17
0
        public IPlatformHandle GetCursor(StandardCursorType cursorType)
        {
            IntPtr handle;

            if (cursorType == StandardCursorType.None)
            {
                handle = _nullCursor;
            }
            else
            {
                handle = s_mapping.TryGetValue(cursorType, out var shape)
                ? _cursors[shape]
                : _cursors[CursorFontShape.XC_top_left_arrow];
            }
            return(new PlatformHandle(handle, "XCURSOR"));
        }
Пример #18
0
        private void UpdateCursor(IInputRoot root, DragDropEffects effect)
        {
            if (_lastRoot != root)
            {
                if (_lastRoot is InputElement ieLast)
                {
                    if (_originalCursor == AvaloniaProperty.UnsetValue)
                    {
                        ieLast.ClearValue(InputElement.CursorProperty);
                    }
                    else
                    {
                        ieLast.Cursor = _originalCursor as Cursor;
                    }
                }

                if (root is InputElement ieNew)
                {
                    if (!ieNew.IsSet(InputElement.CursorProperty))
                    {
                        _originalCursor = AvaloniaProperty.UnsetValue;
                    }
                    else
                    {
                        _originalCursor = root.Cursor;
                    }
                }
                else
                {
                    _originalCursor = null;
                }

                _lastCursorType = StandardCursorType.Arrow;
                _lastRoot       = root;
            }

            if (root is InputElement ie)
            {
                var ct = GetCursorForDropEffect(effect);
                if (ct != _lastCursorType)
                {
                    _lastCursorType = ct;
                    ie.Cursor       = new Cursor(ct);
                }
            }
        }
Пример #19
0
        internal void SetUpBorder <T>(string name, StandardCursorType cursorType, WindowEdge edge) where T : Control
        {
            Control?ctl = this.Find <T>(name);

            if (ctl != null)
            {
                ctl.Cursor          = new Cursor(cursorType);
                ctl.PointerPressed += (s, e_) =>
                {
                    this.BeginResizeDrag(edge, e_);
                };
            }
            else
            {
#if DEBUG
                Debug.WriteLine("The referenced control does not exist");
#endif
            }
        }
Пример #20
0
 public IPlatformHandle GetCursor(StandardCursorType cursorType)
 {
     return(new PlatformHandle(IntPtr.Zero, "null"));
 }
Пример #21
0
 /// <summary>
 /// Create a cursor from png/svg and hotspot position
 /// </summary>
 public CssCursor(string url, PixelPoint hotSpot, StandardCursorType fallback)
 {
     Value = $"url('{url}') {hotSpot.X} {hotSpot.Y}, {ToKeyword(fallback)}";
 }
Пример #22
0
 /// <summary>
 /// Create a cursor from base64 image
 /// </summary>
 public CssCursor(string base64, string format, PixelPoint hotspot, StandardCursorType fallback)
 {
     Value = $"url(\"data:image/{format};base64,{base64}\") {hotspot.X} {hotspot.Y}, {ToKeyword(fallback)}";
 }
Пример #23
0
        public IPlatformHandle GetCursor(StandardCursorType cursorType)
        {
            var cursor = _native.GetCursor((AvnStandardCursorType)cursorType);

            return(new AvaloniaNativeCursor(cursor));
        }
Пример #24
0
 public Cursor(StandardCursorType cursorType)
     : this(
         ((IStandardCursorFactory)PerspexLocator.Current.GetService(typeof(IStandardCursorFactory))).GetCursor(
             cursorType))
 {
 }
Пример #25
0
 ICursorImpl ICursorFactory.GetCursor(StandardCursorType cursorType) => new CursorImplStub();
Пример #26
0
 public ICursorImpl GetCursor(StandardCursorType cursorType)
 {
     return(new MockCursorImpl());
 }
Пример #27
0
 public IPlatformHandle GetCursor(StandardCursorType cursorType)
     => new PlatformHandle(IntPtr.Zero, "ZeroCursor");
Пример #28
0
 public IPlatformHandle GetCursor(StandardCursorType cursorType)
 {
     return(new PlatformHandle(new IntPtr((int)cursorType), "STUB"));
 }
Пример #29
0
 public CssCursor(StandardCursorType type)
 {
     Value = ToKeyword(type);
 }
Пример #30
0
 public ICursorImpl GetCursor(StandardCursorType cursorType) => new CursorStub();
Пример #31
0
 /// <summary>
 /// Create a cursor from url to *.cur file.
 /// </summary>
 public CssCursor(string url, StandardCursorType fallback)
 {
     Value = $"url('{url}'), {ToKeyword(fallback)}";
 }
Пример #32
0
 public Cursor(StandardCursorType cursorType)
     : this(GetCursor(cursorType))
 {
 }
Пример #33
0
 private static string ToKeyword(StandardCursorType type) => type switch
 {
Пример #34
0
 public Cursor(StandardCursorType cursorType)
     : this(GetCursor(cursorType))
 {
 }
Пример #35
0
 public IPlatformHandle GetCursor(StandardCursorType cursorType)
 {
     return(new Cursor(_cache[cursorType]));
 }
Пример #36
0
 public IPlatformHandle GetCursor(StandardCursorType cursorType) => new PlatformHandle(IntPtr.Zero, "NULL");