Skip to content

Commit

Permalink
ThemeManager: add missed controls
Browse files Browse the repository at this point in the history
  • Loading branch information
meee1 committed May 26, 2016
1 parent cc9b76d commit 2563c98
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 32 deletions.
11 changes: 9 additions & 2 deletions MainV2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using System.Collections;
using System.Runtime.InteropServices;
using System.Globalization;
using System.Linq;
using System.Threading;
using MissionPlanner.Utilities;
using IronPython.Hosting;
Expand Down Expand Up @@ -806,7 +807,7 @@ public MainV2()
this.Icon = Icon.FromHandle(((Bitmap)Program.IconFile).GetHicon());
}

if (Program.Logo != null && Program.vvvvz)
if (Program.Logo != null && Program.name == "VVVVZ")
{
MenuDonate.Click -= this.toolStripMenuItem1_Click;
MenuDonate.Text = "";
Expand All @@ -822,6 +823,12 @@ public MainV2()
MenuSimulation.Visible = false;
MenuTerminal.Visible = false;
}
else if (Program.Logo != null && Program.names.Contains(Program.name))
{
MenuDonate.Click -= this.toolStripMenuItem1_Click;
MenuDonate.Text = "";
MenuDonate.Image = Program.Logo;
}

Application.DoEvents();

Expand Down Expand Up @@ -2431,7 +2438,7 @@ protected override void OnLoad(EventArgs e)
log.Error(ex);
}

if (Program.Logo != null && Program.vvvvz)
if (Program.Logo != null && Program.name == "VVVVZ")
{
this.PerformLayout();
MenuFlightPlanner_Click(this, e);
Expand Down
73 changes: 43 additions & 30 deletions Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ public static class Program

public static DateTime starttime = DateTime.Now;

public static bool vvvvz = false;
public static string name { get; internal set; }

public static Image Logo = null;
public static Image IconFile = null;

Expand All @@ -32,7 +33,8 @@ public static class Program

public static string[] args = new string[] {};
public static Bitmap SplashBG = null;


public static string[] names = new string[] { "VVVVZ" };

/// <summary>
/// The main entry point for the application.
Expand Down Expand Up @@ -70,6 +72,45 @@ public static void Main(string[] args)
return;
}

name = "Mission Planner";

try
{
if (File.Exists(Application.StartupPath + Path.DirectorySeparatorChar + "logo.txt"))
name = File.ReadAllLines(Application.StartupPath + Path.DirectorySeparatorChar + "logo.txt",
Encoding.UTF8)[0];
}
catch
{
}

if (File.Exists(Application.StartupPath + Path.DirectorySeparatorChar + "logo.png"))
Logo = new Bitmap(Application.StartupPath + Path.DirectorySeparatorChar + "logo.png");

if (File.Exists(Application.StartupPath + Path.DirectorySeparatorChar + "icon.png")) // 128*128
IconFile = new Bitmap(Application.StartupPath + Path.DirectorySeparatorChar + "icon.png");

if (File.Exists(Application.StartupPath + Path.DirectorySeparatorChar + "splashbg.png")) // 600*375
SplashBG = new Bitmap(Application.StartupPath + Path.DirectorySeparatorChar + "splashbg.png");


Splash = new MissionPlanner.Splash();
if (SplashBG != null)
{
Splash.BackgroundImage = SplashBG;
Splash.pictureBox1.Visible = false;
}

if (IconFile != null)
Splash.Icon = Icon.FromHandle(((Bitmap)IconFile).GetHicon());

string strVersion = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();
Splash.Text = name + " " + Application.ProductVersion + " build " + strVersion;
Splash.Show();

Application.DoEvents();
Application.DoEvents();

// setup theme provider
CustomMessageBox.ApplyTheme += MissionPlanner.Utilities.ThemeManager.ApplyThemeTo;
Controls.MainSwitcher.ApplyTheme += MissionPlanner.Utilities.ThemeManager.ApplyThemeTo;
Expand All @@ -96,24 +137,8 @@ public static void Main(string[] args)
WebRequest.DefaultWebProxy = WebRequest.GetSystemWebProxy();
WebRequest.DefaultWebProxy.Credentials = CredentialCache.DefaultNetworkCredentials;

string name = "Mission Planner";

if (File.Exists(Application.StartupPath + Path.DirectorySeparatorChar + "logo.txt"))
name = File.ReadAllText(Application.StartupPath + Path.DirectorySeparatorChar + "logo.txt",
Encoding.UTF8);

if (File.Exists(Application.StartupPath + Path.DirectorySeparatorChar + "logo.png"))
Logo = new Bitmap(Application.StartupPath + Path.DirectorySeparatorChar + "logo.png");

if (File.Exists(Application.StartupPath + Path.DirectorySeparatorChar + "icon.png"))
IconFile = new Bitmap(Application.StartupPath + Path.DirectorySeparatorChar + "icon.png");

if (File.Exists(Application.StartupPath + Path.DirectorySeparatorChar + "splashbg.png"))
SplashBG = new Bitmap(Application.StartupPath + Path.DirectorySeparatorChar + "splashbg.png");

if (name == "VVVVZ")
{
vvvvz = true;
// set pw
Settings.Instance["password"] = "viDQSk/lmA2qEE8GA7SIHqu0RG2hpkH973MPpYO87CI=";
Settings.Instance["password_protect"] = "True";
Expand All @@ -127,18 +152,6 @@ public static void Main(string[] args)

Utilities.NGEN.doNGEN();

Splash = new MissionPlanner.Splash();
if (SplashBG != null)
Splash.BackgroundImage = SplashBG;
if (IconFile != null)
Splash.Icon = Icon.FromHandle(((Bitmap)IconFile).GetHicon());
string strVersion = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();
Splash.Text = name + " " + Application.ProductVersion + " build " + strVersion;
Splash.Show();

Application.DoEvents();
Application.DoEvents();

try
{
//System.Diagnostics.Process.GetCurrentProcess().PriorityClass = System.Diagnostics.ProcessPriorityClass.RealTime;
Expand Down
17 changes: 17 additions & 0 deletions Utilities/ThemeManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,18 @@ private static void ApplyCustomTheme(Control temp, int level)
ctl.BackColor = BGColor;
ctl.ForeColor = TextColor; // Color.FromArgb(0xe6, 0xe8, 0xea);
}
else if (ctl.GetType() == typeof(RadialGradientBG))
{
var rbg = ctl as RadialGradientBG;
rbg.CenterColor = ControlBGColor;
rbg.OutsideColor = ButBG;
}
else if (ctl.GetType() == typeof(GradientBG))
{
var rbg = ctl as GradientBG;
rbg.CenterColor = ControlBGColor;
rbg.OutsideColor = ButBG;
}
else if (ctl.GetType() == typeof (Form))
{
ctl.BackColor = BGColor;
Expand Down Expand Up @@ -669,6 +681,11 @@ private static void ApplyCustomTheme(Control temp, int level)
((HorizontalProgressBar2) ctl).BackgroundColor = ControlBGColor;
((HorizontalProgressBar2) ctl).ValueColor = Color.FromArgb(148, 193, 31);
}
else if (ctl.GetType() == typeof(MyProgressBar))
{
((MyProgressBar)ctl).BGGradBot = ControlBGColor;
((MyProgressBar)ctl).BGGradTop = BGColor;
}

if (ctl.Controls.Count > 0)
ApplyCustomTheme(ctl, 1);
Expand Down

0 comments on commit 2563c98

Please sign in to comment.