ShareX/ShareX.HelpersLib/ShareXTheme.cs

211 lines
7.4 KiB
C#
Raw Normal View History

#region License Information (GPL v3)
/*
ShareX - A program that allows you to take screenshots and share any file type
2020-02-05 20:19:48 +13:00
Copyright (c) 2007-2020 ShareX Team
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)
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Design;
namespace ShareX.HelpersLib
{
public class ShareXTheme
{
2019-09-06 23:48:57 +12:00
public string Name { get; set; }
private Color backgroundColor;
[Editor(typeof(MyColorEditor), typeof(UITypeEditor)), TypeConverter(typeof(MyColorConverter))]
public Color BackgroundColor
{
get
{
return backgroundColor;
}
set
{
2020-09-30 10:52:20 +13:00
if (!value.IsTransparent()) backgroundColor = value;
}
}
private Color lightBackgroundColor;
[Editor(typeof(MyColorEditor), typeof(UITypeEditor)), TypeConverter(typeof(MyColorConverter))]
public Color LightBackgroundColor
{
get
{
return lightBackgroundColor;
}
set
{
2020-09-30 10:52:20 +13:00
if (!value.IsTransparent()) lightBackgroundColor = value;
}
}
private Color darkBackgroundColor;
[Editor(typeof(MyColorEditor), typeof(UITypeEditor)), TypeConverter(typeof(MyColorConverter))]
public Color DarkBackgroundColor
{
get
{
return darkBackgroundColor;
}
set
{
2020-09-30 10:52:20 +13:00
if (!value.IsTransparent()) darkBackgroundColor = value;
}
}
private Color textColor;
[Editor(typeof(MyColorEditor), typeof(UITypeEditor)), TypeConverter(typeof(MyColorConverter))]
public Color TextColor
{
get
{
return textColor;
}
set
{
2020-09-30 10:52:20 +13:00
if (!value.IsTransparent()) textColor = value;
}
}
private Color borderColor;
[Editor(typeof(MyColorEditor), typeof(UITypeEditor)), TypeConverter(typeof(MyColorConverter))]
public Color BorderColor
{
get
{
return borderColor;
}
set
{
2020-09-30 10:52:20 +13:00
if (!value.IsTransparent()) borderColor = value;
}
}
[Editor(typeof(MyColorEditor), typeof(UITypeEditor)), TypeConverter(typeof(MyColorConverter))]
public Color CheckerColor { get; set; }
[Editor(typeof(MyColorEditor), typeof(UITypeEditor)), TypeConverter(typeof(MyColorConverter))]
public Color CheckerColor2 { get; set; }
public int CheckerSize { get; set; } = 15;
[Editor(typeof(MyColorEditor), typeof(UITypeEditor)), TypeConverter(typeof(MyColorConverter))]
public Color LinkColor { get; set; }
2019-09-11 07:35:40 +12:00
[Editor(typeof(MyColorEditor), typeof(UITypeEditor)), TypeConverter(typeof(MyColorConverter))]
public Color MenuHighlightColor { get; set; }
[Editor(typeof(MyColorEditor), typeof(UITypeEditor)), TypeConverter(typeof(MyColorConverter))]
public Color MenuHighlightBorderColor { get; set; }
[Editor(typeof(MyColorEditor), typeof(UITypeEditor)), TypeConverter(typeof(MyColorConverter))]
public Color MenuBorderColor { get; set; }
[Editor(typeof(MyColorEditor), typeof(UITypeEditor)), TypeConverter(typeof(MyColorConverter))]
public Color MenuCheckBackgroundColor { get; set; }
public Font ContextMenuFont { get; set; } = new Font("Segoe UI", 10);
2019-12-23 00:50:06 +13:00
public int ContextMenuOpacity { get; set; } = 100;
[Browsable(false)]
public double ContextMenuOpacityDouble => ContextMenuOpacity.Clamp(10, 100) / 100d;
2019-12-23 00:50:06 +13:00
2019-09-11 07:35:40 +12:00
[Editor(typeof(MyColorEditor), typeof(UITypeEditor)), TypeConverter(typeof(MyColorConverter))]
public Color SeparatorLightColor { get; set; }
2019-09-11 07:35:40 +12:00
[Editor(typeof(MyColorEditor), typeof(UITypeEditor)), TypeConverter(typeof(MyColorConverter))]
public Color SeparatorDarkColor { get; set; }
2019-09-11 07:35:40 +12:00
[Browsable(false)]
public bool IsDarkTheme => ColorHelpers.IsDarkColor(BackgroundColor);
2019-09-06 23:48:57 +12:00
public ShareXTheme()
{
2020-09-30 10:52:20 +13:00
SetDarkTheme();
2019-09-06 23:48:57 +12:00
}
2020-09-30 10:52:20 +13:00
public void SetDarkTheme()
{
2020-09-30 10:52:20 +13:00
Name = "Dark";
BackgroundColor = Color.FromArgb(42, 47, 56);
LightBackgroundColor = Color.FromArgb(52, 57, 65);
DarkBackgroundColor = Color.FromArgb(28, 32, 38);
TextColor = Color.FromArgb(235, 235, 235);
BorderColor = Color.FromArgb(28, 32, 38);
CheckerColor = Color.FromArgb(60, 60, 60);
CheckerColor2 = Color.FromArgb(50, 50, 50);
CheckerSize = 15;
LinkColor = Color.FromArgb(166, 212, 255);
MenuHighlightColor = Color.FromArgb(30, 34, 40);
MenuHighlightBorderColor = Color.FromArgb(116, 129, 152);
MenuBorderColor = Color.FromArgb(22, 26, 31);
MenuCheckBackgroundColor = Color.FromArgb(56, 64, 75);
ContextMenuOpacity = 100;
SeparatorLightColor = Color.FromArgb(56, 64, 75);
SeparatorDarkColor = Color.FromArgb(22, 26, 31);
}
2020-09-30 10:52:20 +13:00
public void SetLightTheme()
{
2020-09-30 10:52:20 +13:00
Name = "Light";
BackgroundColor = Color.FromArgb(242, 242, 242);
LightBackgroundColor = Color.FromArgb(247, 247, 247);
DarkBackgroundColor = Color.FromArgb(235, 235, 235);
TextColor = Color.FromArgb(69, 69, 69);
BorderColor = Color.FromArgb(201, 201, 201);
CheckerColor = Color.FromArgb(247, 247, 247);
CheckerColor2 = Color.FromArgb(235, 235, 235);
CheckerSize = 15;
LinkColor = Color.FromArgb(166, 212, 255);
MenuHighlightColor = Color.FromArgb(247, 247, 247);
MenuHighlightBorderColor = Color.FromArgb(96, 143, 226);
MenuBorderColor = Color.FromArgb(201, 201, 201);
MenuCheckBackgroundColor = Color.FromArgb(225, 233, 244);
ContextMenuOpacity = 100;
SeparatorLightColor = Color.FromArgb(253, 253, 253);
SeparatorDarkColor = Color.FromArgb(189, 189, 189);
}
public static List<ShareXTheme> GetPresets()
{
2020-09-30 10:52:20 +13:00
ShareXTheme darkTheme = new ShareXTheme();
ShareXTheme lightTheme = new ShareXTheme();
lightTheme.SetLightTheme();
return new List<ShareXTheme>() { darkTheme, lightTheme };
}
2019-09-07 22:41:38 +12:00
public override string ToString()
{
return Name;
}
}
}