|
| 1 | +// Copyright © 2022 The CefSharp Authors. All rights reserved. |
| 2 | +// |
| 3 | +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. |
| 4 | + |
| 5 | +using System; |
| 6 | +using System.Collections.Generic; |
| 7 | +using CefSharp.Enums; |
| 8 | + |
| 9 | +namespace CefSharp.Wpf.Internals |
| 10 | +{ |
| 11 | + // Workaround for upstream issue |
| 12 | + // It's possible resources Ids might change between versions, so this might need to be updated |
| 13 | + // for different builds, will need to test after upgrading |
| 14 | + // See #4021 |
| 15 | + public static class EmbeddedCursor |
| 16 | + { |
| 17 | + //const int IDC_ALIAS = 35610; |
| 18 | + //const int IDC_CELL = 35611; |
| 19 | + //const int IDC_COLRESIZE = 35612; |
| 20 | + //const int IDC_COPYCUR = 35613; |
| 21 | + //const int IDC_HAND_GRAB = 35614; |
| 22 | + //const int IDC_HAND_GRABBING = 35615; |
| 23 | + //const int IDC_PAN_EAST = 35616; |
| 24 | + //const int IDC_PAN_MIDDLE = 35617; |
| 25 | + //const int IDC_PAN_MIDDLE_HORIZONTAL = 35618; |
| 26 | + //const int IDC_PAN_MIDDLE_VERTICAL = 35619; |
| 27 | + //const int IDC_PAN_NORTH = 35620; |
| 28 | + //const int IDC_PAN_NORTH_EAST = 35621; |
| 29 | + //const int IDC_PAN_NORTH_WEST = 35622; |
| 30 | + //const int IDC_PAN_SOUTH = 35623; |
| 31 | + //const int IDC_PAN_SOUTH_EAST = 35624; |
| 32 | + //const int IDC_PAN_SOUTH_WEST = 35625; |
| 33 | + //const int IDC_PAN_WEST = 35626; |
| 34 | + //const int IDC_ROWRESIZE = 35627; |
| 35 | + //const int IDC_VERTICALTEXT = 35628; |
| 36 | + //const int IDC_ZOOMIN = 35629; |
| 37 | + //const int IDC_ZOOMOUT = 35630; |
| 38 | + |
| 39 | + private static Dictionary<CursorType, int> EmbeddedCursors = new Dictionary<CursorType, int> |
| 40 | + { |
| 41 | + { CursorType.Alias, 35610 }, |
| 42 | + { CursorType.Cell, 35611 }, |
| 43 | + { CursorType.ColumnResize, 35612 }, |
| 44 | + { CursorType.Copy, 35613 }, |
| 45 | + { CursorType.Grab, 35614 }, |
| 46 | + { CursorType.Grabbing, 35615 }, |
| 47 | + { CursorType.EastPanning, 35616 }, |
| 48 | + { CursorType.MiddlePanning, 35617 }, |
| 49 | + { CursorType.MiddlePanningHorizontal, 35618 }, |
| 50 | + { CursorType.MiddlePanningVertical, 35619 }, |
| 51 | + { CursorType.NorthPanning, 35620 }, |
| 52 | + { CursorType.NortheastPanning, 35621 }, |
| 53 | + { CursorType.NorthwestPanning, 35622 }, |
| 54 | + { CursorType.SouthPanning, 35623 }, |
| 55 | + { CursorType.SoutheastPanning, 35624 }, |
| 56 | + { CursorType.SouthwestPanning, 35625 }, |
| 57 | + { CursorType.WestPanning, 35626 }, |
| 58 | + { CursorType.RowResize, 35627 }, |
| 59 | + { CursorType.VerticalText, 35628 }, |
| 60 | + { CursorType.ZoomIn, 35629 }, |
| 61 | + { CursorType.ZoomOut, 35630 } |
| 62 | + }; |
| 63 | + |
| 64 | + public static bool TryLoadCursor(CursorType cursorType, out IntPtr cursor) |
| 65 | + { |
| 66 | + cursor = IntPtr.Zero; |
| 67 | + |
| 68 | + try |
| 69 | + { |
| 70 | + if (EmbeddedCursors.TryGetValue(cursorType, out int key)) |
| 71 | + { |
| 72 | + cursor = NativeMethodWrapper.LoadCursorFromLibCef(key); |
| 73 | + |
| 74 | + return cursor != IntPtr.Zero; |
| 75 | + } |
| 76 | + } |
| 77 | + catch (Exception) |
| 78 | + { |
| 79 | + |
| 80 | + } |
| 81 | + |
| 82 | + return false; |
| 83 | + } |
| 84 | + } |
| 85 | +} |
0 commit comments