2012-03-03 20:42:42 -04:00
|
|
|
|
using System;
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
using System.Windows.Forms;
|
2012-03-29 19:17:06 -03:00
|
|
|
|
using ArdupilotMega.Controls.BackstageView;
|
2012-03-03 20:42:42 -04:00
|
|
|
|
using log4net;
|
|
|
|
|
|
|
|
|
|
namespace ArdupilotMega
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Helper class for the stylng 'theming' of forms and controls, and provides MessageBox
|
|
|
|
|
/// replacements which are also styled
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class ThemeManager
|
|
|
|
|
{
|
|
|
|
|
private static readonly ILog log =
|
|
|
|
|
LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
|
|
|
|
|
|
|
|
|
private static Themes _currentTheme = Themes.BurntKermit;
|
|
|
|
|
|
|
|
|
|
public enum Themes
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// no theme - standard Winforms appearance
|
|
|
|
|
/// </summary>
|
|
|
|
|
None,
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Standard Planner Charcoal & Green colours
|
|
|
|
|
/// </summary>
|
|
|
|
|
BurntKermit,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Change the current theme. Existing controls are not affected
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="theme"></param>
|
|
|
|
|
public static void SetTheme(Themes theme)
|
|
|
|
|
{
|
|
|
|
|
log.Debug("Theme set to " + Enum.GetName(typeof(Themes), theme));
|
|
|
|
|
_currentTheme = theme;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Will recursively apply the current theme to 'control'
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="control"></param>
|
|
|
|
|
public static void ApplyThemeTo(Control control)
|
|
|
|
|
{
|
|
|
|
|
switch (_currentTheme)
|
|
|
|
|
{
|
|
|
|
|
case Themes.BurntKermit: ApplyBurntKermitTheme(control, 0);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
// More themes go here
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static void ApplyBurntKermitTheme(Control temp, int level)
|
|
|
|
|
{
|
2012-03-06 06:27:43 -04:00
|
|
|
|
Color BGColor = Color.FromArgb(0x26, 0x27, 0x28); // background
|
|
|
|
|
Color ControlBGColor = Color.FromArgb(0x43, 0x44, 0x45); // editable bg color
|
|
|
|
|
Color TextColor = Color.White;
|
|
|
|
|
|
2012-03-03 20:42:42 -04:00
|
|
|
|
if (level == 0)
|
|
|
|
|
{
|
2012-03-06 06:27:43 -04:00
|
|
|
|
temp.BackColor = BGColor;
|
|
|
|
|
temp.ForeColor = TextColor;// Color.FromArgb(0xe6, 0xe8, 0xea);
|
2012-03-03 20:42:42 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//temp.Font = new Font("Lucida Console", 8.25f);
|
|
|
|
|
|
|
|
|
|
foreach (Control ctl in temp.Controls)
|
|
|
|
|
{
|
|
|
|
|
if (ctl.GetType() == typeof(Button))
|
|
|
|
|
{
|
|
|
|
|
ctl.ForeColor = Color.Black;
|
|
|
|
|
}
|
2012-03-06 06:27:43 -04:00
|
|
|
|
else if (ctl.GetType() == typeof(MyButton))
|
|
|
|
|
{
|
|
|
|
|
Color PrimeColor = Color.FromArgb(0x94, 0xc1, 0x1f);
|
|
|
|
|
|
|
|
|
|
MyButton but = (MyButton)ctl;
|
|
|
|
|
//but.BGGradTop = Color.FromArgb(PrimeColor.R, PrimeColor.G, PrimeColor.B);
|
|
|
|
|
//but.BGGradBot = Color.FromArgb(255 - (int)(PrimeColor.R * 0.27), 255 - (int)(PrimeColor.G * 0.14), 255 - (int)(PrimeColor.B * 0.79));
|
|
|
|
|
//but.ForeColor = Color.FromArgb(0x40, 0x57, 0x04); //Color.FromArgb(255 - (int)(PrimeColor.R * 0.7), 255 - (int)(PrimeColor.G * 0.8), 255 - (int)(PrimeColor.B * 0.1));
|
|
|
|
|
//but.Outline = ControlBGColor;
|
|
|
|
|
}
|
2012-03-03 20:42:42 -04:00
|
|
|
|
else if (ctl.GetType() == typeof(TextBox))
|
|
|
|
|
{
|
2012-03-06 06:27:43 -04:00
|
|
|
|
ctl.BackColor = ControlBGColor;
|
|
|
|
|
ctl.ForeColor = TextColor;// Color.FromArgb(0xe6, 0xe8, 0xea);
|
2012-03-03 20:42:42 -04:00
|
|
|
|
TextBox txt = (TextBox)ctl;
|
|
|
|
|
txt.BorderStyle = BorderStyle.None;
|
|
|
|
|
}
|
|
|
|
|
else if (ctl.GetType() == typeof(DomainUpDown))
|
|
|
|
|
{
|
2012-03-06 06:27:43 -04:00
|
|
|
|
ctl.BackColor = ControlBGColor;
|
|
|
|
|
ctl.ForeColor = TextColor;// Color.FromArgb(0xe6, 0xe8, 0xea);
|
2012-03-03 20:42:42 -04:00
|
|
|
|
DomainUpDown txt = (DomainUpDown)ctl;
|
|
|
|
|
txt.BorderStyle = BorderStyle.None;
|
|
|
|
|
}
|
|
|
|
|
else if (ctl.GetType() == typeof(GroupBox))
|
|
|
|
|
{
|
2012-03-06 06:27:43 -04:00
|
|
|
|
ctl.BackColor = BGColor;
|
|
|
|
|
ctl.ForeColor = TextColor;// Color.FromArgb(0xe6, 0xe8, 0xea);
|
2012-03-03 20:42:42 -04:00
|
|
|
|
}
|
|
|
|
|
else if (ctl.GetType() == typeof(ZedGraph.ZedGraphControl))
|
|
|
|
|
{
|
|
|
|
|
var zg1 = (ZedGraph.ZedGraphControl)ctl;
|
|
|
|
|
zg1.GraphPane.Chart.Fill = new ZedGraph.Fill(Color.FromArgb(0x1f, 0x1f, 0x20));
|
|
|
|
|
zg1.GraphPane.Fill = new ZedGraph.Fill(Color.FromArgb(0x37, 0x37, 0x38));
|
|
|
|
|
|
|
|
|
|
foreach (ZedGraph.LineItem li in zg1.GraphPane.CurveList)
|
|
|
|
|
li.Line.Width = 4;
|
|
|
|
|
|
2012-03-06 06:27:43 -04:00
|
|
|
|
zg1.GraphPane.Title.FontSpec.FontColor = TextColor;
|
2012-03-03 20:42:42 -04:00
|
|
|
|
|
|
|
|
|
zg1.GraphPane.XAxis.MajorTic.Color = Color.White;
|
|
|
|
|
zg1.GraphPane.XAxis.MinorTic.Color = Color.White;
|
|
|
|
|
zg1.GraphPane.YAxis.MajorTic.Color = Color.White;
|
|
|
|
|
zg1.GraphPane.YAxis.MinorTic.Color = Color.White;
|
2012-03-26 07:21:49 -03:00
|
|
|
|
zg1.GraphPane.Y2Axis.MajorTic.Color = Color.White;
|
|
|
|
|
zg1.GraphPane.Y2Axis.MinorTic.Color = Color.White;
|
2012-03-03 20:42:42 -04:00
|
|
|
|
|
|
|
|
|
zg1.GraphPane.XAxis.MajorGrid.Color = Color.White;
|
|
|
|
|
zg1.GraphPane.YAxis.MajorGrid.Color = Color.White;
|
2012-03-26 07:21:49 -03:00
|
|
|
|
zg1.GraphPane.Y2Axis.MajorGrid.Color = Color.White;
|
2012-03-03 20:42:42 -04:00
|
|
|
|
|
|
|
|
|
zg1.GraphPane.YAxis.Scale.FontSpec.FontColor = Color.White;
|
|
|
|
|
zg1.GraphPane.YAxis.Title.FontSpec.FontColor = Color.White;
|
2012-03-26 07:21:49 -03:00
|
|
|
|
zg1.GraphPane.Y2Axis.Title.FontSpec.FontColor = Color.White;
|
|
|
|
|
zg1.GraphPane.Y2Axis.Scale.FontSpec.FontColor = Color.White;
|
2012-03-03 20:42:42 -04:00
|
|
|
|
|
|
|
|
|
zg1.GraphPane.XAxis.Scale.FontSpec.FontColor = Color.White;
|
|
|
|
|
zg1.GraphPane.XAxis.Title.FontSpec.FontColor = Color.White;
|
|
|
|
|
|
|
|
|
|
zg1.GraphPane.Legend.Fill = new ZedGraph.Fill(Color.FromArgb(0x85, 0x84, 0x83));
|
2012-03-06 06:27:43 -04:00
|
|
|
|
zg1.GraphPane.Legend.FontSpec.FontColor = TextColor;
|
2012-03-03 20:42:42 -04:00
|
|
|
|
}
|
|
|
|
|
else if (ctl.GetType() == typeof(BSE.Windows.Forms.Panel) || ctl.GetType() == typeof(SplitterPanel))
|
|
|
|
|
{
|
2012-03-06 06:27:43 -04:00
|
|
|
|
ctl.BackColor = BGColor;
|
|
|
|
|
ctl.ForeColor = TextColor;// Color.FromArgb(0xe6, 0xe8, 0xea);
|
2012-03-03 20:42:42 -04:00
|
|
|
|
}
|
|
|
|
|
else if (ctl.GetType() == typeof(Form))
|
|
|
|
|
{
|
2012-03-06 06:27:43 -04:00
|
|
|
|
ctl.BackColor = BGColor;
|
|
|
|
|
ctl.ForeColor = TextColor;// Color.FromArgb(0xe6, 0xe8, 0xea);
|
2012-03-03 20:42:42 -04:00
|
|
|
|
}
|
|
|
|
|
else if (ctl.GetType() == typeof(RichTextBox))
|
|
|
|
|
{
|
2012-03-06 06:27:43 -04:00
|
|
|
|
ctl.BackColor = ControlBGColor;
|
|
|
|
|
ctl.ForeColor = TextColor;
|
2012-03-03 20:42:42 -04:00
|
|
|
|
RichTextBox txtr = (RichTextBox)ctl;
|
|
|
|
|
txtr.BorderStyle = BorderStyle.None;
|
|
|
|
|
}
|
|
|
|
|
else if (ctl.GetType() == typeof(CheckedListBox))
|
|
|
|
|
{
|
2012-03-06 06:27:43 -04:00
|
|
|
|
ctl.BackColor = ControlBGColor;
|
|
|
|
|
ctl.ForeColor = TextColor;
|
2012-03-03 20:42:42 -04:00
|
|
|
|
CheckedListBox txtr = (CheckedListBox)ctl;
|
|
|
|
|
txtr.BorderStyle = BorderStyle.None;
|
|
|
|
|
}
|
|
|
|
|
else if (ctl.GetType() == typeof(TabPage))
|
|
|
|
|
{
|
2012-03-06 06:27:43 -04:00
|
|
|
|
ctl.BackColor = BGColor; //ControlBGColor
|
|
|
|
|
ctl.ForeColor = TextColor;
|
2012-03-03 20:42:42 -04:00
|
|
|
|
TabPage txtr = (TabPage)ctl;
|
|
|
|
|
txtr.BorderStyle = BorderStyle.None;
|
|
|
|
|
}
|
|
|
|
|
else if (ctl.GetType() == typeof(TabControl))
|
|
|
|
|
{
|
2012-03-06 06:27:43 -04:00
|
|
|
|
ctl.BackColor = BGColor; //ControlBGColor
|
|
|
|
|
ctl.ForeColor = TextColor;
|
2012-03-03 20:42:42 -04:00
|
|
|
|
TabControl txtr = (TabControl)ctl;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else if (ctl.GetType() == typeof(DataGridView))
|
|
|
|
|
{
|
2012-03-06 06:27:43 -04:00
|
|
|
|
ctl.ForeColor = TextColor;
|
2012-03-03 20:42:42 -04:00
|
|
|
|
DataGridView dgv = (DataGridView)ctl;
|
|
|
|
|
dgv.EnableHeadersVisualStyles = false;
|
|
|
|
|
dgv.BorderStyle = BorderStyle.None;
|
2012-03-06 06:27:43 -04:00
|
|
|
|
dgv.BackgroundColor = BGColor;
|
2012-03-03 20:42:42 -04:00
|
|
|
|
DataGridViewCellStyle rs = new DataGridViewCellStyle();
|
2012-03-06 06:27:43 -04:00
|
|
|
|
rs.BackColor = ControlBGColor;
|
|
|
|
|
rs.ForeColor = TextColor;
|
2012-03-03 20:42:42 -04:00
|
|
|
|
dgv.RowsDefaultCellStyle = rs;
|
|
|
|
|
|
|
|
|
|
DataGridViewCellStyle hs = new DataGridViewCellStyle(dgv.ColumnHeadersDefaultCellStyle);
|
2012-03-06 06:27:43 -04:00
|
|
|
|
hs.BackColor = BGColor;
|
|
|
|
|
hs.ForeColor = TextColor;
|
2012-03-03 20:42:42 -04:00
|
|
|
|
|
|
|
|
|
dgv.ColumnHeadersDefaultCellStyle = hs;
|
|
|
|
|
dgv.RowHeadersDefaultCellStyle = hs;
|
|
|
|
|
}
|
|
|
|
|
else if (ctl.GetType() == typeof(ComboBox))
|
|
|
|
|
{
|
2012-03-06 06:27:43 -04:00
|
|
|
|
ctl.BackColor = ControlBGColor;
|
|
|
|
|
ctl.ForeColor = TextColor;
|
2012-03-03 20:42:42 -04:00
|
|
|
|
ComboBox CMB = (ComboBox)ctl;
|
|
|
|
|
CMB.FlatStyle = FlatStyle.Flat;
|
|
|
|
|
}
|
|
|
|
|
else if (ctl.GetType() == typeof(NumericUpDown))
|
|
|
|
|
{
|
2012-03-06 06:27:43 -04:00
|
|
|
|
ctl.BackColor = ControlBGColor;
|
|
|
|
|
ctl.ForeColor = TextColor;
|
2012-03-03 20:42:42 -04:00
|
|
|
|
}
|
|
|
|
|
else if (ctl.GetType() == typeof(TrackBar))
|
|
|
|
|
{
|
2012-03-06 06:27:43 -04:00
|
|
|
|
ctl.BackColor = BGColor;
|
|
|
|
|
ctl.ForeColor = TextColor;
|
2012-03-03 20:42:42 -04:00
|
|
|
|
}
|
|
|
|
|
else if (ctl.GetType() == typeof(LinkLabel))
|
|
|
|
|
{
|
2012-03-06 06:27:43 -04:00
|
|
|
|
ctl.BackColor = BGColor;
|
|
|
|
|
ctl.ForeColor = TextColor;
|
2012-03-03 20:42:42 -04:00
|
|
|
|
LinkLabel LNK = (LinkLabel)ctl;
|
2012-03-06 06:27:43 -04:00
|
|
|
|
LNK.ActiveLinkColor = TextColor;
|
|
|
|
|
LNK.LinkColor = TextColor;
|
|
|
|
|
LNK.VisitedLinkColor = TextColor;
|
2012-03-03 20:42:42 -04:00
|
|
|
|
|
|
|
|
|
}
|
2012-03-29 19:17:06 -03:00
|
|
|
|
else if (ctl.GetType() == typeof(BackstageView))
|
|
|
|
|
{
|
|
|
|
|
var bsv = ctl as BackstageView;
|
|
|
|
|
|
|
|
|
|
bsv.BackColor = BGColor;
|
|
|
|
|
bsv.ButtonsAreaBgColor = ControlBGColor;
|
|
|
|
|
bsv.HighlightColor2 = Color.FromArgb(0x94, 0xc1, 0x1f);
|
|
|
|
|
bsv.HighlightColor1 = Color.FromArgb(0x40, 0x57, 0x04);
|
|
|
|
|
bsv.SelectedTextColor = Color.White;
|
|
|
|
|
bsv.UnSelectedTextColor = Color.Gray;
|
|
|
|
|
bsv.ButtonsAreaPencilColor = Color.DarkGray;
|
|
|
|
|
}
|
2012-03-03 20:42:42 -04:00
|
|
|
|
else if (ctl.GetType() == typeof(HorizontalProgressBar2) || ctl.GetType() == typeof(VerticalProgressBar2))
|
|
|
|
|
{
|
2012-03-06 06:27:43 -04:00
|
|
|
|
((HorizontalProgressBar2)ctl).BackgroundColor = ControlBGColor;
|
2012-03-03 20:42:42 -04:00
|
|
|
|
((HorizontalProgressBar2)ctl).ValueColor = Color.FromArgb(148, 193, 31);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (ctl.Controls.Count > 0)
|
|
|
|
|
ApplyBurntKermitTheme(ctl, 1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|