2013-11-06 06:58:22 +13:00
|
|
|
|
#region License Information (GPL v3)
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
ShareX - A program that allows you to take screenshots and share any file type
|
2019-01-02 20:43:52 +13:00
|
|
|
|
Copyright (c) 2007-2019 ShareX Team
|
2013-11-06 06:58:22 +13:00
|
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
|
modify it under the terms of the GNU General Public License
|
|
|
|
|
as published by the Free Software Foundation; either version 2
|
|
|
|
|
of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
|
|
|
|
|
|
Optionally you can also view the license at <http://www.gnu.org/licenses/>.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#endregion License Information (GPL v3)
|
|
|
|
|
|
2014-12-11 09:25:20 +13:00
|
|
|
|
using ShareX.HelpersLib.Properties;
|
2018-11-06 12:40:05 +13:00
|
|
|
|
using System;
|
2013-11-06 06:58:22 +13:00
|
|
|
|
using System.Drawing;
|
2018-11-06 12:40:05 +13:00
|
|
|
|
using System.Windows.Forms;
|
2013-11-06 06:58:22 +13:00
|
|
|
|
|
2014-12-11 09:25:20 +13:00
|
|
|
|
namespace ShareX.HelpersLib
|
2013-11-06 06:58:22 +13:00
|
|
|
|
{
|
|
|
|
|
public static class ShareXResources
|
|
|
|
|
{
|
2018-11-06 12:40:05 +13:00
|
|
|
|
public static string UserAgent
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
Version version = Version.Parse(Application.ProductVersion);
|
|
|
|
|
return $"ShareX/{version.Major}.{version.Minor}.{version.Build}";
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-03-12 09:54:42 +13:00
|
|
|
|
|
2019-05-16 11:51:40 +12:00
|
|
|
|
public static bool UseDarkTheme { get; set; }
|
2019-02-11 10:47:51 +13:00
|
|
|
|
public static bool UseWhiteIcon { get; set; }
|
2019-06-17 19:43:13 +12:00
|
|
|
|
public static bool ApplyTheme { get; set; } = true;
|
2019-02-11 10:47:51 +13:00
|
|
|
|
|
2019-06-01 09:19:37 +12:00
|
|
|
|
public static Icon Icon => UseWhiteIcon ? Resources.ShareX_Icon_White : Resources.ShareX_Icon;
|
2017-03-12 09:54:42 +13:00
|
|
|
|
|
|
|
|
|
public static Image Logo => Resources.ShareX_Logo;
|
|
|
|
|
public static Image LogoBlack => Resources.ShareX_Logo_Black;
|
2019-05-23 23:39:17 +12:00
|
|
|
|
|
2019-06-17 18:35:21 +12:00
|
|
|
|
public static Color BackgroundColor => UseDarkTheme ? DarkBackgroundColor : SystemColors.Window;
|
|
|
|
|
public static Color TextColor => UseDarkTheme ? DarkTextColor : SystemColors.ControlText;
|
2019-06-17 19:43:13 +12:00
|
|
|
|
public static Color BorderColor => UseDarkTheme ? DarkBorderColor : ProfessionalColors.SeparatorDark;
|
|
|
|
|
public static Color CheckerColor1 => UseDarkTheme ? DarkCheckerColor1 : SystemColors.ControlLightLight;
|
|
|
|
|
public static Color CheckerColor2 => UseDarkTheme ? DarkCheckerColor2 : SystemColors.ControlLight;
|
2019-06-17 18:35:21 +12:00
|
|
|
|
|
2019-05-23 23:39:17 +12:00
|
|
|
|
public static Color DarkBackgroundColor { get; } = Color.FromArgb(42, 47, 56);
|
|
|
|
|
public static Color DarkTextColor { get; } = Color.FromArgb(235, 235, 235);
|
|
|
|
|
public static Color DarkBorderColor { get; } = Color.FromArgb(28, 32, 38);
|
2019-06-17 19:43:13 +12:00
|
|
|
|
public static Color DarkCheckerColor1 { get; } = Color.FromArgb(60, 60, 60);
|
|
|
|
|
public static Color DarkCheckerColor2 { get; } = Color.FromArgb(50, 50, 50);
|
2019-06-01 09:19:37 +12:00
|
|
|
|
|
2019-06-03 07:45:15 +12:00
|
|
|
|
public static int CheckerSize { get; } = 15;
|
2019-06-17 18:35:21 +12:00
|
|
|
|
|
2019-06-17 19:43:13 +12:00
|
|
|
|
public static void ApplyThemeToForm(Form form)
|
|
|
|
|
{
|
|
|
|
|
form.Icon = Icon;
|
|
|
|
|
|
|
|
|
|
if (ApplyTheme)
|
|
|
|
|
{
|
|
|
|
|
ApplyThemeToControl(form);
|
2019-06-19 03:17:02 +12:00
|
|
|
|
|
2019-06-19 08:15:53 +12:00
|
|
|
|
if (form.IsHandleCreated)
|
|
|
|
|
{
|
|
|
|
|
NativeMethods.UseImmersiveDarkMode(form.Handle, UseDarkTheme);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
form.HandleCreated += (s, e) => NativeMethods.UseImmersiveDarkMode(form.Handle, UseDarkTheme);
|
|
|
|
|
}
|
2019-06-17 19:43:13 +12:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static void ApplyThemeToControl(Control control)
|
2019-06-17 18:35:21 +12:00
|
|
|
|
{
|
2019-06-23 23:26:53 +12:00
|
|
|
|
switch (control)
|
2019-06-17 18:35:21 +12:00
|
|
|
|
{
|
2019-06-23 23:26:53 +12:00
|
|
|
|
case Button btn:
|
|
|
|
|
// Button looks better with system colors
|
|
|
|
|
control.ForeColor = SystemColors.ControlText;
|
|
|
|
|
break;
|
|
|
|
|
case SplitContainer sc:
|
|
|
|
|
sc.Panel1.BackColor = BackgroundColor;
|
|
|
|
|
sc.Panel2.BackColor = BackgroundColor;
|
|
|
|
|
goto default;
|
|
|
|
|
default:
|
|
|
|
|
control.ForeColor = TextColor;
|
|
|
|
|
control.BackColor = BackgroundColor;
|
|
|
|
|
break;
|
2019-06-17 19:03:56 +12:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
foreach (Control child in control.Controls)
|
|
|
|
|
{
|
2019-06-17 19:43:13 +12:00
|
|
|
|
ApplyThemeToControl(child);
|
2019-06-17 18:35:21 +12:00
|
|
|
|
}
|
|
|
|
|
}
|
2013-11-06 06:58:22 +13:00
|
|
|
|
}
|
|
|
|
|
}
|