Changeset 970


Ignore:
Timestamp:
05/02/09 11:33:14 (6 years ago)
Author:
lowjoel
Message:

-Separated the ToolBar? drop-down menus from the toolbar itself - I didn't want to use the same renderer because the renderer will have to implement menu item rendering too which is what UxThemeMenuRenderer? does. But that only works on Vista+
-Fixed all the overloads for menus in UpdateControlTheme?. Menus/toolbars all use the same interface now.

Location:
branches/eraser6
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/eraser6/Eraser/MainForm.Designer.cs

    r967 r970  
    6363            this.ToolBar = new Eraser.ToolBar(); 
    6464            this.tbScheduleDropDown = new System.Windows.Forms.ToolStripMenuItem(); 
    65             this.newTaskToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 
    6665            this.tbSettings = new System.Windows.Forms.ToolStripMenuItem(); 
    6766            this.tbHelp = new System.Windows.Forms.ToolStripMenuItem(); 
    6867            this.tbHelpDropDown = new System.Windows.Forms.ToolStripMenuItem(); 
     68            this.checkForUpdatesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 
     69            this.tbScheduleMenu = new System.Windows.Forms.ContextMenuStrip(this.components); 
     70            this.tbHelpMenu = new System.Windows.Forms.ContextMenuStrip(this.components); 
     71            this.newTaskToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 
    6972            this.checkForUpdatesToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); 
    7073            this.aboutEraserToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 
    71             this.checkForUpdatesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 
    7274            this.notificationMenu.SuspendLayout(); 
    7375            this.ToolBar.SuspendLayout(); 
     76            this.tbScheduleMenu.SuspendLayout(); 
     77            this.tbHelpMenu.SuspendLayout(); 
    7478            this.SuspendLayout(); 
    7579            //  
     
    148152            //  
    149153            this.tbScheduleDropDown.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; 
    150             this.tbScheduleDropDown.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { 
    151             this.newTaskToolStripMenuItem}); 
     154            this.tbScheduleDropDown.DropDown = this.tbScheduleMenu; 
    152155            this.tbScheduleDropDown.Image = global::Eraser.Properties.Resources.ToolbarArrow; 
    153156            resources.ApplyResources(this.tbScheduleDropDown, "tbScheduleDropDown"); 
     
    155158            this.tbScheduleDropDown.Padding = new System.Windows.Forms.Padding(0); 
    156159            //  
    157             // newTaskToolStripMenuItem 
    158             //  
    159             this.newTaskToolStripMenuItem.Name = "newTaskToolStripMenuItem"; 
    160             resources.ApplyResources(this.newTaskToolStripMenuItem, "newTaskToolStripMenuItem"); 
    161             this.newTaskToolStripMenuItem.Click += new System.EventHandler(this.newTaskToolStripMenuItem_Click); 
    162             //  
    163160            // tbSettings 
    164161            //  
     
    178175            //  
    179176            this.tbHelpDropDown.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; 
    180             this.tbHelpDropDown.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { 
    181             this.checkForUpdatesToolStripMenuItem1, 
    182             this.aboutEraserToolStripMenuItem}); 
     177            this.tbHelpDropDown.DropDown = this.tbHelpMenu; 
    183178            this.tbHelpDropDown.Image = global::Eraser.Properties.Resources.ToolbarArrow; 
    184179            resources.ApplyResources(this.tbHelpDropDown, "tbHelpDropDown"); 
     
    186181            this.tbHelpDropDown.Padding = new System.Windows.Forms.Padding(2, 0, 4, 0); 
    187182            //  
    188             // checkForUpdatesToolStripMenuItem1 
    189             //  
    190             this.checkForUpdatesToolStripMenuItem1.Name = "checkForUpdatesToolStripMenuItem1"; 
    191             resources.ApplyResources(this.checkForUpdatesToolStripMenuItem1, "checkForUpdatesToolStripMenuItem1"); 
    192             this.checkForUpdatesToolStripMenuItem1.Click += new System.EventHandler(this.checkForUpdatesToolStripMenuItem_Click); 
    193             //  
    194             // aboutEraserToolStripMenuItem 
    195             //  
    196             this.aboutEraserToolStripMenuItem.Name = "aboutEraserToolStripMenuItem"; 
    197             resources.ApplyResources(this.aboutEraserToolStripMenuItem, "aboutEraserToolStripMenuItem"); 
    198             this.aboutEraserToolStripMenuItem.Click += new System.EventHandler(this.aboutEraserToolStripMenuItem_Click); 
    199             //  
    200183            // checkForUpdatesToolStripMenuItem 
    201184            //  
     
    203186            resources.ApplyResources(this.checkForUpdatesToolStripMenuItem, "checkForUpdatesToolStripMenuItem"); 
    204187            this.checkForUpdatesToolStripMenuItem.Click += new System.EventHandler(this.checkForUpdatesToolStripMenuItem_Click); 
     188            //  
     189            // tbScheduleMenu 
     190            //  
     191            this.tbScheduleMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { 
     192            this.newTaskToolStripMenuItem}); 
     193            this.tbScheduleMenu.Name = "tbScheduleMenu"; 
     194            resources.ApplyResources(this.tbScheduleMenu, "tbScheduleMenu"); 
     195            //  
     196            // tbHelpMenu 
     197            //  
     198            this.tbHelpMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { 
     199            this.checkForUpdatesToolStripMenuItem1, 
     200            this.aboutEraserToolStripMenuItem}); 
     201            this.tbHelpMenu.Name = "tbHelpMenu"; 
     202            resources.ApplyResources(this.tbHelpMenu, "tbHelpMenu"); 
     203            //  
     204            // newTaskToolStripMenuItem 
     205            //  
     206            this.newTaskToolStripMenuItem.Name = "newTaskToolStripMenuItem"; 
     207            resources.ApplyResources(this.newTaskToolStripMenuItem, "newTaskToolStripMenuItem"); 
     208            //  
     209            // checkForUpdatesToolStripMenuItem1 
     210            //  
     211            this.checkForUpdatesToolStripMenuItem1.Name = "checkForUpdatesToolStripMenuItem1"; 
     212            resources.ApplyResources(this.checkForUpdatesToolStripMenuItem1, "checkForUpdatesToolStripMenuItem1"); 
     213            //  
     214            // aboutEraserToolStripMenuItem 
     215            //  
     216            this.aboutEraserToolStripMenuItem.Name = "aboutEraserToolStripMenuItem"; 
     217            resources.ApplyResources(this.aboutEraserToolStripMenuItem, "aboutEraserToolStripMenuItem"); 
    205218            //  
    206219            // MainForm 
     
    221234            this.ToolBar.ResumeLayout(false); 
    222235            this.ToolBar.PerformLayout(); 
     236            this.tbScheduleMenu.ResumeLayout(false); 
     237            this.tbHelpMenu.ResumeLayout(false); 
    223238            this.ResumeLayout(false); 
    224239            this.PerformLayout(); 
     
    243258        private System.Windows.Forms.ToolStripMenuItem tbScheduleDropDown; 
    244259        private System.Windows.Forms.ToolStripMenuItem tbHelpDropDown; 
     260        private System.Windows.Forms.ContextMenuStrip tbScheduleMenu; 
    245261        private System.Windows.Forms.ToolStripMenuItem newTaskToolStripMenuItem; 
     262        private System.Windows.Forms.ContextMenuStrip tbHelpMenu; 
    246263        private System.Windows.Forms.ToolStripMenuItem checkForUpdatesToolStripMenuItem1; 
    247264        private System.Windows.Forms.ToolStripMenuItem aboutEraserToolStripMenuItem; 
  • branches/eraser6/Eraser/MainForm.cs

    r966 r970  
    4343        { 
    4444            InitializeComponent(); 
     45            UxThemeAPI.UpdateControlTheme(tbScheduleDropDown); 
     46            UxThemeAPI.UpdateControlTheme(tbHelpDropDown); 
    4547            UxThemeAPI.UpdateControlTheme(notificationMenu); 
    4648            SettingsPage.CreateControl(); 
  • branches/eraser6/Eraser/MainForm.resx

    r967 r970  
    146146  </data> 
    147147  <data name="&gt;&gt;contentPanel.ZOrder" xml:space="preserve"> 
    148     <value>1</value> 
     148    <value>3</value> 
    149149  </data> 
    150150  <data name="tbSchedule.Size" type="System.Drawing.Size, System.Drawing"> 
     
    155155  </data> 
    156156  <metadata name="notificationIcon.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> 
    157     <value>110, 17</value> 
     157    <value>420, 17</value> 
    158158  </metadata> 
    159159  <metadata name="notificationMenu.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> 
    160     <value>413, 17</value> 
     160    <value>723, 17</value> 
    161161  </metadata> 
    162162  <data name="openEraserToolStripMenuItem.Font" type="System.Drawing.Font, System.Drawing"> 
     
    17601760  </data> 
    17611761  <metadata name="notificationIconTimer.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> 
    1762     <value>246, 17</value> 
     1762    <value>556, 17</value> 
    17631763  </metadata> 
    17641764  <metadata name="ToolBar.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> 
    1765     <value>14, 26</value> 
     1765    <value>17, 17</value> 
    17661766  </metadata> 
    17671767  <data name="ToolBar.Dock" type="System.Windows.Forms.DockStyle, System.Windows.Forms"> 
    17681768    <value>None</value> 
    17691769  </data> 
     1770  <metadata name="tbScheduleMenu.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> 
     1771    <value>110, 17</value> 
     1772  </metadata> 
    17701773  <data name="newTaskToolStripMenuItem.ShortcutKeys" type="System.Windows.Forms.Keys, System.Windows.Forms"> 
    17711774    <value>Ctrl+N</value> 
     
    17771780    <value>New Task</value> 
    17781781  </data> 
     1782  <data name="tbScheduleMenu.Size" type="System.Drawing.Size, System.Drawing"> 
     1783    <value>169, 26</value> 
     1784  </data> 
     1785  <data name="&gt;&gt;tbScheduleMenu.Name" xml:space="preserve"> 
     1786    <value>tbScheduleMenu</value> 
     1787  </data> 
     1788  <data name="&gt;&gt;tbScheduleMenu.Type" xml:space="preserve"> 
     1789    <value>System.Windows.Forms.ContextMenuStrip, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> 
     1790  </data> 
    17791791  <data name="tbScheduleDropDown.ImageAlign" type="System.Drawing.ContentAlignment, System.Drawing"> 
    17801792    <value>BottomLeft</value> 
     
    18011813    <value>Help</value> 
    18021814  </data> 
     1815  <metadata name="tbHelpMenu.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> 
     1816    <value>265, 17</value> 
     1817  </metadata> 
    18031818  <data name="checkForUpdatesToolStripMenuItem1.Size" type="System.Drawing.Size, System.Drawing"> 
    18041819    <value>171, 22</value> 
     
    18131828    <value>About Eraser</value> 
    18141829  </data> 
     1830  <data name="tbHelpMenu.Size" type="System.Drawing.Size, System.Drawing"> 
     1831    <value>172, 70</value> 
     1832  </data> 
     1833  <data name="&gt;&gt;tbHelpMenu.Name" xml:space="preserve"> 
     1834    <value>tbHelpMenu</value> 
     1835  </data> 
     1836  <data name="&gt;&gt;tbHelpMenu.Type" xml:space="preserve"> 
     1837    <value>System.Windows.Forms.ContextMenuStrip, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> 
     1838  </data> 
    18151839  <data name="tbHelpDropDown.ImageAlign" type="System.Drawing.ContentAlignment, System.Drawing"> 
    18161840    <value>BottomLeft</value> 
     
    18291853  </data> 
    18301854  <data name="ToolBar.Size" type="System.Drawing.Size, System.Drawing"> 
    1831     <value>404, 32</value> 
     1855    <value>312, 32</value> 
    18321856  </data> 
    18331857  <data name="ToolBar.TabIndex" type="System.Int32, mscorlib"> 
     
    18471871  </data> 
    18481872  <data name="&gt;&gt;ToolBar.ZOrder" xml:space="preserve"> 
    1849     <value>2</value> 
     1873    <value>4</value> 
    18501874  </data> 
    18511875  <data name="checkForUpdatesToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing"> 
     
    34813505    <value>System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> 
    34823506  </data> 
     3507  <data name="&gt;&gt;tbSettings.Name" xml:space="preserve"> 
     3508    <value>tbSettings</value> 
     3509  </data> 
     3510  <data name="&gt;&gt;tbSettings.Type" xml:space="preserve"> 
     3511    <value>System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> 
     3512  </data> 
     3513  <data name="&gt;&gt;tbHelp.Name" xml:space="preserve"> 
     3514    <value>tbHelp</value> 
     3515  </data> 
     3516  <data name="&gt;&gt;tbHelp.Type" xml:space="preserve"> 
     3517    <value>System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> 
     3518  </data> 
     3519  <data name="&gt;&gt;tbHelpDropDown.Name" xml:space="preserve"> 
     3520    <value>tbHelpDropDown</value> 
     3521  </data> 
     3522  <data name="&gt;&gt;tbHelpDropDown.Type" xml:space="preserve"> 
     3523    <value>System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> 
     3524  </data> 
     3525  <data name="&gt;&gt;checkForUpdatesToolStripMenuItem.Name" xml:space="preserve"> 
     3526    <value>checkForUpdatesToolStripMenuItem</value> 
     3527  </data> 
     3528  <data name="&gt;&gt;checkForUpdatesToolStripMenuItem.Type" xml:space="preserve"> 
     3529    <value>System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> 
     3530  </data> 
    34833531  <data name="&gt;&gt;newTaskToolStripMenuItem.Name" xml:space="preserve"> 
    34843532    <value>newTaskToolStripMenuItem</value> 
     
    34873535    <value>System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> 
    34883536  </data> 
    3489   <data name="&gt;&gt;tbSettings.Name" xml:space="preserve"> 
    3490     <value>tbSettings</value> 
    3491   </data> 
    3492   <data name="&gt;&gt;tbSettings.Type" xml:space="preserve"> 
    3493     <value>System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> 
    3494   </data> 
    3495   <data name="&gt;&gt;tbHelp.Name" xml:space="preserve"> 
    3496     <value>tbHelp</value> 
    3497   </data> 
    3498   <data name="&gt;&gt;tbHelp.Type" xml:space="preserve"> 
    3499     <value>System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> 
    3500   </data> 
    3501   <data name="&gt;&gt;tbHelpDropDown.Name" xml:space="preserve"> 
    3502     <value>tbHelpDropDown</value> 
    3503   </data> 
    3504   <data name="&gt;&gt;tbHelpDropDown.Type" xml:space="preserve"> 
    3505     <value>System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> 
    3506   </data> 
    35073537  <data name="&gt;&gt;checkForUpdatesToolStripMenuItem1.Name" xml:space="preserve"> 
    35083538    <value>checkForUpdatesToolStripMenuItem1</value> 
     
    35173547    <value>System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> 
    35183548  </data> 
    3519   <data name="&gt;&gt;checkForUpdatesToolStripMenuItem.Name" xml:space="preserve"> 
    3520     <value>checkForUpdatesToolStripMenuItem</value> 
    3521   </data> 
    3522   <data name="&gt;&gt;checkForUpdatesToolStripMenuItem.Type" xml:space="preserve"> 
    3523     <value>System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> 
    3524   </data> 
    35253549  <data name="&gt;&gt;$this.Name" xml:space="preserve"> 
    35263550    <value>MainForm</value> 
  • branches/eraser6/Eraser/ToolBar.cs

    r968 r970  
    4242        } 
    4343 
    44         private class EraserToolStripRenderer : UxThemeMenuRenderer 
     44        private class EraserToolStripRenderer : ToolStripRenderer 
    4545        { 
    4646            protected override void Initialize(ToolStrip toolStrip) 
     
    5050            } 
    5151 
     52            protected override void InitializeItem(ToolStripItem item) 
     53            { 
     54                base.InitializeItem(item); 
     55            } 
     56 
    5257            protected override void OnRenderToolStripBackground(ToolStripRenderEventArgs e) 
    5358            { 
    54                 if (e.ToolStrip == owner) 
    55                     //Draw the parent background image. This is not portable in that it will render 
    56                     //this code unreusable, but for the lack of anything better this will have to suffice! 
    57                     e.Graphics.DrawImage(Properties.Resources.BackgroundGradient, 
    58                         new Point(-owner.Left, -owner.Top)); 
    59                 else 
    60                     base.OnRenderToolStripBackground(e); 
    61             } 
    62  
    63             protected override void OnRenderMenuItemBackground(ToolStripItemRenderEventArgs e) 
    64             { 
    65                 if (e.ToolStrip != owner) 
    66                     base.OnRenderMenuItemBackground(e); 
     59                //Draw the parent background image. This is not portable in that it will render 
     60                //this code unreusable, but for the lack of anything better this will have to suffice! 
     61                e.Graphics.DrawImage(Properties.Resources.BackgroundGradient, 
     62                    new Point(-owner.Left, -owner.Top)); 
    6763            } 
    6864 
    6965            protected override void OnRenderItemText(ToolStripItemTextRenderEventArgs e) 
    7066            { 
    71                 if (e.ToolStrip != owner) 
    72                 { 
    73                     base.OnRenderItemText(e); 
    74                     return; 
    75                 } 
    76  
    7767                Graphics g = e.Graphics; 
    7868 
     
    111101            private readonly Color TextColour = Color.White; 
    112102 
     103            /// <summary> 
     104            /// The toolstrip using this renderer. 
     105            /// </summary> 
    113106            private ToolStrip owner; 
    114107        } 
  • branches/eraser6/Util/UxThemeAPI.cs

    r969 r970  
    3939            if (control is ListView) 
    4040                UpdateControlTheme((ListView)control); 
    41             else if (control is ContextMenuStrip) 
    42                 UpdateControlTheme((ContextMenuStrip)control); 
    43             else if (control is MenuStrip) 
    44                 UpdateControlTheme((MenuStrip)control); 
     41            else if (control is ToolStrip) 
     42                UpdateControlTheme((ToolStrip)control); 
    4543 
    4644            if (control.ContextMenuStrip != null) 
     
    7270        /// </summary> 
    7371        /// <param name="lv">The List View control to set the theme on.</param> 
    74         public static void UpdateControlTheme(ContextMenuStrip menu) 
     72        public static void UpdateControlTheme(ToolStrip menu) 
    7573        { 
    7674            if (Environment.OSVersion.Version.Major >= 6) 
    7775                if (!(menu.Renderer is UxThemeMenuRenderer)) 
    7876                    menu.Renderer = new UxThemeMenuRenderer(); 
    79         } 
    80  
    81         /// <summary> 
    82         /// Updates the control's theme to fit in with the latest Windows visuals. 
    83         /// </summary> 
    84         /// <param name="lv">The List View control to set the theme on.</param> 
    85         public static void UpdateControlTheme(MenuStrip menu) 
    86         { 
    87             foreach (ToolStripMenuItem item in menu.Items) 
    88                 UpdateControlTheme(item); 
     77 
     78            foreach (ToolStripItem item in menu.Items) 
     79                if (item is ToolStripMenuItem) 
     80                    UpdateControlTheme((ToolStripMenuItem)item); 
    8981        } 
    9082 
Note: See TracChangeset for help on using the changeset viewer.