Changeset 1558
- Timestamp:
- 1/18/2010 5:53:45 AM (3 years ago)
- Location:
- branches/eraser6/CodeReview/Eraser.Util
- Files:
-
- 2 edited
- 1 moved
-
Eraser.Util.csproj (modified) (2 diffs)
-
NativeMethods/UxTheme.cs (modified) (1 diff)
-
Theming.cs (moved) (moved from branches/eraser6/CodeReview/Eraser.Util/UxThemeApi.cs) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eraser6/CodeReview/Eraser.Util/Eraser.Util.csproj
r1552 r1558 69 69 <Compile Include="KernelApi.cs" /> 70 70 <Compile Include="File.cs" /> 71 <Compile Include=" UxThemeApi.cs" />71 <Compile Include="Theming.cs" /> 72 72 <Compile Include="VolumeInfo.cs" /> 73 73 <Compile Include="NetApi.cs" /> … … 82 82 </ItemGroup> 83 83 <ItemGroup> 84 <Compile Include="NativeMethods\Gdi.cs" /> 84 85 <Compile Include="NativeMethods\Sfc.cs" /> 85 86 <Compile Include="Win32ErrorCodes.cs" /> -
branches/eraser6/CodeReview/Eraser.Util/NativeMethods/UxTheme.cs
r1555 r1558 164 164 TS_DRAW 165 165 } 166 167 public const int WM_THEMECHANGED = 0x031A; 168 public const int WM_DWMCOMPOSITIONCHANGED = 0x031E; 166 169 } 167 170 } -
branches/eraser6/CodeReview/Eraser.Util/Theming.cs
r1556 r1558 31 31 namespace Eraser.Util 32 32 { 33 public static class UXThemeApi33 public static class Theming 34 34 { 35 35 /// <summary> 36 36 /// Verifies whether themeing is active. 37 37 /// </summary> 38 public static bool ThemesActive38 public static bool Active 39 39 { 40 40 get … … 55 55 /// </summary> 56 56 /// <remarks>This function will also set the volume on all child controls.</remarks> 57 public static void UpdateControlTheme(Control control)57 public static void ApplyTheme(Control control) 58 58 { 59 59 if (control is ContainerControl) … … 64 64 65 65 if (control is ButtonBase) 66 UpdateControlTheme((ButtonBase)control);66 ApplyTheme((ButtonBase)control); 67 67 else if (control is ListView) 68 UpdateControlTheme((ListView)control);68 ApplyTheme((ListView)control); 69 69 else if (control is ToolStrip) 70 UpdateControlTheme((ToolStrip)control);70 ApplyTheme((ToolStrip)control); 71 71 72 72 if (control.ContextMenuStrip != null) 73 UpdateControlTheme(control.ContextMenuStrip);73 ApplyTheme(control.ContextMenuStrip); 74 74 75 75 foreach (Control child in control.Controls) 76 UpdateControlTheme(child);76 ApplyTheme(child); 77 77 } 78 78 … … 81 81 /// </summary> 82 82 /// <param name="button">The ButtonBase control to set the theme on.</param> 83 public static void UpdateControlTheme(ButtonBase button)83 public static void ApplyTheme(ButtonBase button) 84 84 { 85 85 if (button.FlatStyle == FlatStyle.Standard) … … 91 91 /// </summary> 92 92 /// <param name="lv">The List View control to set the theme on.</param> 93 public static void UpdateControlTheme(ListView lv)93 public static void ApplyTheme(ListView lv) 94 94 { 95 95 try … … 109 109 /// </summary> 110 110 /// <param name="menu">The tool strip control to set the theme on.</param> 111 public static void UpdateControlTheme(ToolStrip menu)111 public static void ApplyTheme(ToolStrip menu) 112 112 { 113 113 //Register for Theme changed messages … … 126 126 menu.Disposed += OnThemedMenuDisposed; 127 127 ThemedMenus.Add(menu, renderer); 128 if ( ThemesActive)128 if (Active) 129 129 menu.Renderer = renderer; 130 130 } … … 135 135 ToolStripMenuItem toolStripItem = item as ToolStripMenuItem; 136 136 if (toolStripItem != null) 137 UpdateControlTheme(toolStripItem);137 ApplyTheme(toolStripItem); 138 138 } 139 139 } … … 143 143 /// </summary> 144 144 /// <param name="menu">The List View control to set the theme on.</param> 145 public static void UpdateControlTheme(ToolStripDropDownItem menuItem)145 public static void ApplyTheme(ToolStripDropDownItem menuItem) 146 146 { 147 147 if (menuItem.Font != SystemFonts.MenuFont) 148 148 menuItem.Font = new Font(SystemFonts.MenuFont, menuItem.Font.Style); 149 149 150 UpdateControlTheme(menuItem.DropDown);150 ApplyTheme(menuItem.DropDown); 151 151 } 152 152 … … 157 157 private static void OnThemeChanged(object sender, EventArgs e) 158 158 { 159 bool themesActive = ThemesActive;159 bool themesActive = Active; 160 160 foreach (KeyValuePair<ToolStrip, UXThemeMenuRenderer> value in ThemedMenus) 161 161 { … … 197 197 198 198 Instance = this; 199 ThemesActive = UXThemeApi.ThemesActive;199 ThemesActive = Theming.Active; 200 200 Application.AddMessageFilter(this); 201 201 } … … 204 204 public bool PreFilterMessage(ref Message m) 205 205 { 206 if (m.Msg == WM_THEMECHANGED)207 { 208 ThemesActive = UXThemeApi.ThemesActive;206 if (m.Msg == NativeMethods.WM_THEMECHANGED) 207 { 208 ThemesActive = Theming.Active; 209 209 ThemeChanged(null, EventArgs.Empty); 210 210 } 211 else if (m.Msg == WM_DWMCOMPOSITIONCHANGED)212 { 213 if (ThemesActive != UXThemeApi.ThemesActive)211 else if (m.Msg == NativeMethods.WM_DWMCOMPOSITIONCHANGED) 212 { 213 if (ThemesActive != Theming.Active) 214 214 { 215 ThemesActive = UXThemeApi.ThemesActive;215 ThemesActive = Theming.Active; 216 216 ThemeChanged(null, EventArgs.Empty); 217 217 } … … 240 240 } 241 241 242 private const int WM_THEMECHANGED = 0x031A;243 private const int WM_DWMCOMPOSITIONCHANGED = 0x031E;244 242 private bool ThemesActive; 245 243 }
Note: See TracChangeset
for help on using the changeset viewer.
