Use dark or light GitHub logo automatically depending on how dark is theme background color

This commit is contained in:
Jaex 2019-09-25 17:48:21 +03:00
parent 4701eb7d0f
commit 251bbe2119
10 changed files with 518 additions and 535 deletions

View file

@ -381,7 +381,12 @@ public static Color VisibleColor(Color color)
public static Color VisibleColor(Color color, Color lightColor, Color darkColor)
{
return PerceivedBrightness(color) > 130 ? darkColor : lightColor;
return IsLightColor(color) ? darkColor : lightColor;
}
public static bool IsLightColor(Color color)
{
return PerceivedBrightness(color) > 130;
}
public static Color Lerp(Color from, Color to, float amount)

View file

@ -2283,7 +2283,7 @@ private void InitializeComponent()
// tsbGitHub
//
this.tsbGitHub.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
this.tsbGitHub.Image = global::ShareX.Properties.Resources.GitHub_32x32;
this.tsbGitHub.Image = global::ShareX.Properties.Resources.GitHub_Black_32x32;
resources.ApplyResources(this.tsbGitHub, "tsbGitHub");
this.tsbGitHub.Name = "tsbGitHub";
this.tsbGitHub.Click += new System.EventHandler(this.TsbGitHub_Click);

View file

@ -821,6 +821,15 @@ public void UpdateTheme()
btnCloseNews.FlatAppearance.BorderColor = ShareXResources.Theme.BorderColor;
btnCloseNews.ForeColor = ShareXResources.Theme.TextColor;
btnCloseNews.BackColor = ShareXResources.Theme.LightBackgroundColor;
if (ColorHelpers.IsLightColor(ShareXResources.Theme.BackgroundColor))
{
tsbGitHub.Image = Resources.GitHub_Black_32x32;
}
else
{
tsbGitHub.Image = Resources.GitHub_White_32x32;
}
}
else
{
@ -842,6 +851,7 @@ public void UpdateTheme()
btnCloseNews.FlatAppearance.BorderColor = SystemColors.ControlText;
btnCloseNews.ForeColor = SystemColors.ControlText;
btnCloseNews.BackColor = SystemColors.Window;
tsbGitHub.Image = Resources.GitHub_Black_32x32;
}
pbPreview.UpdateTheme();

File diff suppressed because it is too large Load diff

View file

@ -1308,9 +1308,19 @@ public static System.Drawing.Bitmap GitHub {
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
public static System.Drawing.Bitmap GitHub_32x32 {
public static System.Drawing.Bitmap GitHub_Black_32x32 {
get {
object obj = ResourceManager.GetObject("GitHub_32x32", resourceCulture);
object obj = ResourceManager.GetObject("GitHub_Black_32x32", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
public static System.Drawing.Bitmap GitHub_White_32x32 {
get {
object obj = ResourceManager.GetObject("GitHub_White_32x32", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}

View file

@ -1012,13 +1012,16 @@ Middle click to close</value>
<data name="Discord_32x32" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\Discord-32x32.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="GitHub_32x32" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\GitHub-32x32.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="Patreon_32x32" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\Patreon-32x32.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="Twitter_32x32" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\Twitter-32x32.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="GitHub_Black_32x32" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\GitHub-Black-32x32.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="GitHub_White_32x32" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\GitHub-White-32x32.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

View file

@ -1677,7 +1677,10 @@
<None Include="Resources\Bitcoin-32x32.png" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\GitHub-32x32.png" />
<None Include="Resources\GitHub-White-32x32.png" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\GitHub-Black-32x32.png" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>