示例#1
0
 private void SetWindowStyle(object sender, Style style)
 {
     if (this.InvokeRequired)
     {
         StyleChangeDelegate d = new StyleChangeDelegate(SetWindowStyle);
         this.Invoke(d, new object[] { sender, style });
     }
     else
     {
         //Set the style
         this.style = style;
         //Set the foreground and background colors
         this.BackColor = ColorTranslator.FromHtml(style.trackerBackground);
         this.ForeColor = ColorTranslator.FromHtml(style.trackerForeground);
         //Create a custom color table for the menu and set the colors
         CustomMenuColorTable colorTable = new CustomMenuColorTable(style);
         menuStrip1.Renderer  = new ToolStripProfessionalRenderer(colorTable);
         menuStrip1.BackColor = ColorTranslator.FromHtml(style.menuStripBackground);
         menuStrip1.ForeColor = ColorTranslator.FromHtml(style.menuStripForeground);
         //Set the colors of items in the menu strip
         foreach (ToolStripMenuItem item in menuStrip1.Items)
         {
             foreach (ToolStripItem dropdownItem in item.DropDownItems)
             {
                 dropdownItem.ForeColor = ColorTranslator.FromHtml(style.menuStripForeground);
             }
             item.ForeColor = ColorTranslator.FromHtml(style.menuStripForeground);
         }
         //Recolor the table rows
         RecolorTableRows();
         //Set the time tracker UI style
         timeTrackerUI1.SetStyle(style);
     }
 }
 public void SetWindowStyle(object sender, Style style)
 {
     if (this.InvokeRequired)
     {
         StyleChangeDelegate d = new StyleChangeDelegate(SetWindowStyle);
         this.Invoke(d, new object[] { sender, style });
     }
     else
     {
         //Set the foreground and background colors
         this.currentStyle = style;
         this.BackColor    = ColorTranslator.FromHtml(style.trackerBackground);
         this.ForeColor    = ColorTranslator.FromHtml(style.trackerForeground);
         if (settingsController.GetTimeTrackerTimerEnabled())
         {
             labelTimer.ForeColor = ColorTranslator.FromHtml(style.timerForeground);
         }
         else
         {
             labelTimer.ForeColor = ColorTranslator.FromHtml(style.timerPausedForeground);
         }
     }
 }