Skip to content

Commit

Permalink
Add support casting System.Drawing.Color to Discord.Color
Browse files Browse the repository at this point in the history
commit fa33034
Author: Acid Chicken (硫酸鶏) <root@acid-chicken.com>
Date:   Sun Apr 29 13:50:56 2018 +0900

    Use built-in symbol

    refs: #1043 (comment)

commit 27ea826
Author: Acid Chicken (硫酸鶏) <root@acid-chicken.com>
Date:   Sun Apr 29 11:29:31 2018 +0900

    Add support casting System.Drawing.Color to Discord.Color

commit 1ab9de2
Merge: f5bb99c a4d1e2b
Author: Acid Chicken (硫酸鶏) <root@acid-chicken.com>
Date:   Sun Apr 29 10:16:46 2018 +0900

    Merge remote-tracking branch 'upstream/dev' into dev

commit f5bb99c
Merge: 3be8e40 b8b59d9
Author: Acid Chicken (硫酸鶏) <root@acid-chicken.com>
Date:   Tue Apr 10 11:07:36 2018 +0900

    Merge remote-tracking branch 'upstream/dev' into dev

commit 3be8e40
Merge: c692306 9d77a3c
Author: Acid Chicken (硫酸鶏) <root@acid-chicken.com>
Date:   Sun Jan 7 15:05:31 2018 +0900

    Merge remote-tracking branch 'upstream/dev' into dev

commit c692306
Author: Acid Chicken (硫酸鶏) <root@acid-chicken.com>
Date:   Sat Nov 11 10:49:00 2017 +0900

    Add target of the internal fields

commit 2d08f9a
Author: Acid Chicken (硫酸鶏) <root@acid-chicken.com>
Date:   Sat Nov 11 10:17:42 2017 +0900

    Add some more extension

commit 4f19b83
Author: Acid Chicken (硫酸鶏) <root@acid-chicken.com>
Date:   Sat Nov 11 01:19:11 2017 +0900

    Add naming rules

commit af756cd
Author: Acid Chicken (硫酸鶏) <root@acid-chicken.com>
Date:   Sat Nov 11 00:35:30 2017 +0900

    Add basic .NET style rules

commit 503ece5
Author: Acid Chicken (硫酸鶏) <root@acid-chicken.com>
Date:   Fri Nov 10 22:36:52 2017 +0900

    Add EditorConfig
  • Loading branch information
acid-chicken authored and foxbot committed May 24, 2018
1 parent 5023357 commit c275e57
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/Discord.Net.Core/Discord.Net.Core.csproj
Expand Up @@ -4,8 +4,8 @@
<AssemblyName>Discord.Net.Core</AssemblyName>
<RootNamespace>Discord</RootNamespace>
<Description>The core components for the Discord.Net library.</Description>
<TargetFrameworks Condition=" '$(OS)' == 'Windows_NT' ">net45;netstandard1.1;netstandard1.3</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' != 'Windows_NT' ">netstandard1.1;netstandard1.3</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' == 'Windows_NT' ">net45;netstandard1.1;netstandard1.3;netstandard2.0</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' != 'Windows_NT' ">netstandard1.1;netstandard1.3;netstandard2.0</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="10.0.2" />
Expand Down
12 changes: 11 additions & 1 deletion src/Discord.Net.Core/Entities/Roles/Color.cs
@@ -1,5 +1,8 @@
using System;
using System.Diagnostics;
#if NETSTANDARD2_0 || NET45
using StandardColor = System.Drawing.Color;
#endif

namespace Discord
{
Expand Down Expand Up @@ -96,7 +99,14 @@ public Color(float r, float g, float b)
((uint)(g * 255.0f) << 8) |
(uint)(b * 255.0f);
}


#if NETSTANDARD2_0 || NET45
public static implicit operator StandardColor(Color color) =>
StandardColor.FromArgb((int)color.RawValue);
public static explicit operator Color(StandardColor color) =>
new Color((uint)color.ToArgb() << 8 >> 8);
#endif

public override string ToString() =>
$"#{Convert.ToString(RawValue, 16)}";
private string DebuggerDisplay =>
Expand Down

0 comments on commit c275e57

Please sign in to comment.