public IntPtr?GetThemeBitmap(int partId, int stateId, int propertyId) { HResult hr = UxThemeExNativeMethods.UxGetThemeBitmap( themeFile, theme, partId, stateId, propertyId, GBF.GBF_DIRECT, out IntPtr value); return(hr.Succeeded() ? value : (IntPtr?)null); }
public LOGFONT GetThemeSysFont(int propertyId) { var value = new LOGFONT(); HResult hr = UxThemeExNativeMethods.GetThemeSysFont(theme, propertyId, value); return(Found(hr) ? value : null); }
public int?GetThemeSysInt(int propertyId) { HResult hr = UxThemeExNativeMethods.GetThemeSysInt( theme, propertyId, out int value); return(Found(hr) ? value : (int?)null); }
public int?GetThemeEnumValue(int partId, int stateId, int propertyId) { HResult hr = UxThemeExNativeMethods.UxGetThemeEnumValue( themeFile, theme, partId, stateId, propertyId, out int value); return(Found(hr) ? value : (int?)null); }
public bool?GetThemeBool(int partId, int stateId, int propertyId) { HResult hr = UxThemeExNativeMethods.UxGetThemeBool( themeFile, theme, partId, stateId, propertyId, out var value); return(Found(hr) ? value : (bool?)null); }
public Color?GetThemeColor(int partId, int stateId, int propertyId) { HResult hr = UxThemeExNativeMethods.UxGetThemeColor( themeFile, theme, partId, stateId, propertyId, out int value); return(Found(hr) ? ThemeExtensions.ColorFromArgb(value) : (Color?)null); }
public RECT?GetThemeRect(int partId, int stateId, int propertyId) { HResult hr = UxThemeExNativeMethods.UxGetThemeRect( themeFile, theme, partId, stateId, propertyId, out RECT value); return(Found(hr) ? value : (RECT?)null); }
public SIZE?GetThemePartSize(int partId, int stateId, ThemeSize themeSize) { HResult hr = UxThemeExNativeMethods.UxGetThemePartSize( themeFile, theme, IntPtr.Zero, partId, stateId, null, themeSize, out SIZE value); return(Found(hr) ? value : (SIZE?)null); }
public POINT?GetThemePosition(int partId, int stateId, int propertyId) { HResult hr = UxThemeExNativeMethods.UxGetThemePosition( themeFile, theme, partId, stateId, propertyId, out POINT value); return(Found(hr) ? value : (POINT?)null); }
public MARGINS?GetThemeMargins(int partId, int stateId, int propertyId) { HResult hr = UxThemeExNativeMethods.UxGetThemeMargins( themeFile, theme, IntPtr.Zero, partId, stateId, propertyId, null, out MARGINS value); return(Found(hr) ? value : (MARGINS?)null); }
public PropertyOrigin GetThemePropertyOrigin( int partId, int stateId, int propertyId) { HResult hr = UxThemeExNativeMethods.UxGetThemePropertyOrigin( themeFile, theme, partId, stateId, propertyId, out PropertyOrigin origin); return(hr.Succeeded() ? origin : PropertyOrigin.NotFound); }
public INTLIST GetThemeIntList(int partId, int stateId, int propertyId) { var value = new INTLIST(); HResult hr = UxThemeExNativeMethods.UxGetThemeIntList( themeFile, theme, partId, stateId, propertyId, value); return(Found(hr) ? value : null); }
public LOGFONT GetThemeFont(int partId, int stateId, int propertyId) { var value = new LOGFONT(); HResult hr = UxThemeExNativeMethods.UxGetThemeFont( themeFile, theme, IntPtr.Zero, partId, stateId, propertyId, value); return(Found(hr) ? value : null); }
public string GetThemeFilename(int partId, int stateId, int propertyId) { var filename = new StringBuilder(512); HResult hr = UxThemeExNativeMethods.UxGetThemeFilename( themeFile, theme, partId, stateId, propertyId, filename, filename.Capacity); return(Found(hr) ? filename.ToString() : null); }
public string GetThemeSysString(int propertyId) { var value = new StringBuilder(512); HResult hr = UxThemeExNativeMethods.GetThemeSysString( theme, propertyId, value, value.Capacity); return(Found(hr) ? value.ToString() : null); }
public static SafeThemeFileHandle LoadTheme( string path, UxThemeLoadParams loadParams = null) { UxThemeExNativeMethods.UxOpenThemeFileEx( path, loadParams?.IsHighContrast ?? false, loadParams?.CustomColors, out var themeFile).ThrowIfFailed(); return(themeFile); }
public async Task SetThemeAsync(string path, UxThemeLoadParams loadParams = null) { if (path != null) { SetNativeTheme(await Task.Run(() => LoadTheme(path, loadParams))); } else { SetNativeTheme(SafeThemeFileHandle.Zero); } CurrentOverride = path; UxThemeExNativeMethods.UxBroadcastThemeChange(); }
public async Task SetPresentationFrameworkTheme(Dispatcher dispatcher, Uri resourceUri) { await dispatcher.InvokeAsync(() => { if (resourceUri != null) { ThemeManager.SetPresentationFrameworkTheme(resourceUri); } else { ThemeManager.ClearPresentationFrameworkTheme(); } UxThemeExNativeMethods.UxBroadcastThemeChange(); }, DispatcherPriority.ContextIdle); }
private void SetNativeTheme(SafeThemeFileHandle newTheme) { var oldTheme = theme; if (newTheme != null && !newTheme.IsInvalid && !newTheme.IsClosed) { UxThemeExNativeMethods.UxOverrideTheme(newTheme).ThrowIfFailed(); UxThemeExNativeMethods.UxHook().ThrowIfFailed(); theme = newTheme; } else { theme = null; UxThemeExNativeMethods.UxUnhook().ThrowIfFailed(); UxThemeExNativeMethods.UxOverrideTheme(SafeThemeFileHandle.Zero).ThrowIfFailed(); } oldTheme?.Dispose(); }
public ThemeFile LoadTheme() { var themeFile = new ThemeFile(filePath, neutralModule, muiModule); themeFile.Version = GetVersion(); var classNames = ReadClassMap(); var vmap = ReadVariantMap(); var bcmap = ReadBaseClassMap(); themeFile.VariantMap = vmap; themeFile.ClassNames = classNames; UxThemeExNativeMethods.UxOpenThemeFile(filePath, isHighContrast, out var themeFileHandle).ThrowIfFailed(); themeFile.NativeThemeFile = themeFileHandle; ReadProperties(themeFile, "RMAP", "RMAP"); ReadProperties(themeFile, "VARIANT", vmap.Name); foreach (var @class in themeFile.Classes) { AddKnownPartsAndStates(@class); } var classMap = themeFile.Classes.ToDictionary(x => x.Name); var classNames2 = themeFile.ClassNames.Skip(4).ToList(); foreach (var entry in bcmap.Map) { var className = classNames2[entry.Key]; var baseClassName = classNames2[entry.Value]; if (classMap.TryGetValue(className, out ThemeClass @class) && classMap.TryGetValue(baseClassName, out ThemeClass baseClass)) { @class.BaseClass = baseClass; } } themeFile.Sort(); return(themeFile); }
public unsafe Stream GetThemeStream( int partId, int stateId, int propertyId, SafeModuleHandle instance) { HResult hr = UxThemeExNativeMethods.UxGetThemeStream( themeFile, theme, partId, stateId, propertyId, out IntPtr stream, out uint length, instance); if (!Found(hr) || stream == IntPtr.Zero) { return(null); } var buffer = new byte[length]; if (length > 0) { Marshal.Copy(stream, buffer, 0, buffer.Length); } return(new UnmanagedMemoryStream( (byte *)stream.ToPointer(), 0, length, FileAccess.Read)); }
protected override bool ReleaseHandle() { return(UxThemeExNativeMethods.UxCloseThemeFile(handle) >= 0); }
public HResult GetThemeTransitionDuration( int partId, int stateFrom, int stateTo, int propertyId, out uint duration) { return(UxThemeExNativeMethods.UxGetThemeTransitionDuration( themeFile, theme, partId, stateFrom, stateTo, propertyId, out duration)); }
public bool GetThemeSysBool(int propertyId) { return(UxThemeExNativeMethods.GetThemeSysBool(theme, propertyId)); }
public Color GetThemeSysColor(int propertyId) { int value = UxThemeExNativeMethods.GetThemeSysColor(theme, propertyId); return(ThemeExtensions.ColorFromArgb(value)); }
public static UxThemeExData Open( SafeThemeFileHandle themeFile, IntPtr hwnd, string classList) { return(new UxThemeExData( themeFile, UxThemeExNativeMethods.UxOpenThemeData(themeFile, hwnd, classList))); }