コード例 #1
0
 public NativeThemeInfo(
     string name, FileVersionInfo version, FileInfo path,
     UxThemeLoadParams loadParams = null)
 {
     BaseName   = name;
     Name       = name + " (" + version.GetWindowsName() + ")";
     Version    = version;
     Path       = path;
     LoadParams = loadParams ?? new UxThemeLoadParams();
 }
コード例 #2
0
        public static SafeThemeFileHandle LoadTheme(
            string path, UxThemeLoadParams loadParams = null)
        {
            UxThemeExNativeMethods.UxOpenThemeFileEx(
                path,
                loadParams?.IsHighContrast ?? false,
                loadParams?.CustomColors,
                out var themeFile).ThrowIfFailed();

            return(themeFile);
        }
コード例 #3
0
        public static NativeThemeInfo FromPath(string themePath, UxThemeLoadParams loadParams = null)
        {
            string name    = System.IO.Path.GetFileName(themePath);
            var    version = FileVersionInfo.GetVersionInfo(themePath);
            var    path    = new FileInfo(themePath);

            if (!path.Exists)
            {
                throw new ArgumentException();
            }
            return(new NativeThemeInfo(name, version, path, loadParams));
        }
コード例 #4
0
        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();
        }
コード例 #5
0
 public bool Matches(string themePath, UxThemeLoadParams loadParams)
 {
     return
         (string.Equals(Path.FullName, themePath, StringComparison.OrdinalIgnoreCase) &&
          LoadParams == loadParams);
 }