Cabster/Extensions/WindowsApiExtensions.cs
/// <summary>
///     Corrige o cursor para o valor original do sistema operacional.
/// </summary>
/// <param name="cursor">Cursor.</param>
Corrige o cursor para o valor original do sistema operacional.
Corrige o cursor para o valor original do sistema operacional .
public static void FixesForTheOperatingSystemCursor(this Cursor cursor)
        {
            if (!CursorsMatchingValues.ContainsKey(cursor))
                throw new WrongArgumentException(
                    nameof(WindowsApiExtensions),
                    nameof(FixesForTheOperatingSystemCursor),
                    nameof(cursor));
            var cursorsType = typeof(Cursors);
            var cursorsProperty = cursorsType
                .GetProperties(BindingFlags.Static | BindingFlags.Public)
                .Single(a => a.GetValue(null).Equals(cursor));
            var cursorsFieldName = cursorsProperty.Name[0].ToString().ToLower() + cursorsProperty.Name.Substring(1);
            var cursorsField = cursorsType.GetField(cursorsFieldName, BindingFlags.Static | BindingFlags.NonPublic)
                               ?? throw new ThisWillNeverOccurException();
            var operatingSystemCursorName = CursorsMatchingValues[cursor];
            var operatingSystemCursorHandle = WindowsApi.LoadCursor(IntPtr.Zero, operatingSystemCursorName);
            var operatingSystemCursor = new Cursor(operatingSystemCursorHandle);
            cursorsField.SetValue(null, operatingSystemCursor);
        }
public static void FixesForTheOperatingSystemCursor ( this Cursor cursor ) { if ( ! CursorsMatchingValues . ContainsKey ( cursor ) ) throw new WrongArgumentException ( nameof ( WindowsApiExtensions ) , nameof ( FixesForTheOperatingSystemCursor ) , nameof ( cursor ) ) ; var cursorsType = typeof ( Cursors ) ; var cursorsProperty = cursorsType . GetProperties ( BindingFlags . Static | BindingFlags . Public ) . Single ( a => a . GetValue ( null ) . Equals ( cursor ) ) ; var cursorsFieldName = cursorsProperty . Name [ 0 ] . ToString ( ) . ToLower ( ) + cursorsProperty . Name . Substring ( 1 ) ; var cursorsField = cursorsType . GetField ( cursorsFieldName , BindingFlags . Static | BindingFlags . NonPublic ) ?? throw new ThisWillNeverOccurException ( ) ; var operatingSystemCursorName = CursorsMatchingValues [ cursor ] ; var operatingSystemCursorHandle = WindowsApi . LoadCursor ( IntPtr . Zero , operatingSystemCursorName ) ; var operatingSystemCursor = new Cursor ( operatingSystemCursorHandle ) ; cursorsField . SetValue ( null , operatingSystemCursor ) ; }
Corrige o cursor para o valor original do sistema operacional.
Corrige o cursor para o valor original do sistema operacional .
Cursor
this
cursor
None