예제 #1
0
			/// <summary>
			/// Initializes a new instance of <see cref="Htheme"/>.
			/// </summary>
			public Htheme(ThemeRenderer theme)
			{
				// update current application name
				bool hasCustomAppName = (theme.Value >> ApplicationShift) != 0;
				if (hasCustomAppName)
				{
					string appName = theme.ApplicationName;
					if (appName != CurrentApplicationName)
					{
						ThemeInternal.UxTheme.SetWindowTheme(ThemeControl.Handle, CurrentApplicationName = appName, null);
					}
				}
				
				if (!hasCustomAppName)
				{
					int themeID = (theme.Value >> ClassShift) & ClassMask;
					if (themeID > 0 && themeID <= HthemeCache.Length)
					{
						themeID--;
						Htheme cached = HthemeCache[themeID];
						
						if (cached._Handle == IntPtr.Zero)
						{
							cached._Handle = ThemeInternal.UxTheme.OpenThemeData(CachedThemeControl.Handle, theme.ClassName);
							HthemeCache[themeID] = cached;
						}
						
						this._Handle = cached._Handle;
						this._CachedHandle = true;
						
						return;
					}
				}
				
				// default to non-cached
				this._Handle = ThemeInternal.UxTheme.OpenThemeData(ThemeControl.Handle, theme.ClassName);
				this._CachedHandle = false;
			}