[longomatch] Add a new Color class
- From: Andoni Morales Alastruey <amorales src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [longomatch] Add a new Color class
- Date: Mon, 7 Jul 2014 11:20:54 +0000 (UTC)
commit 6a2b04e8943640fba802d6390c5e775188792999
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date: Tue Apr 15 22:07:00 2014 +0200
Add a new Color class
LongoMatch.Core/Common/Color.cs | 47 ++++++++++++++++++++++-
LongoMatch.GUI/Gui/Component/ButtonTagger.cs | 1 +
LongoMatch.GUI/Gui/Component/DrawingToolBox.cs | 1 +
LongoMatch.GUI/Gui/Panel/NewProjectPanel.cs | 1 +
LongoMatch.GUI/Gui/TreeView/ListTreeViewBase.cs | 3 +-
Tests/Core/TestCategory.cs | 1 +
Tests/Core/TestColor.cs | 38 ++++++++++++++++++
Tests/Tests.mdp | 3 +-
8 files changed, 92 insertions(+), 3 deletions(-)
---
diff --git a/LongoMatch.Core/Common/Color.cs b/LongoMatch.Core/Common/Color.cs
index c7afabb..102556b 100644
--- a/LongoMatch.Core/Common/Color.cs
+++ b/LongoMatch.Core/Common/Color.cs
@@ -19,9 +19,54 @@ using System;
namespace LongoMatch.Common
{
- public class ColorHelper
+ public class Color
{
+ public Color (short r, short g, short b, short a)
+ {
+ R = r;
+ G = g;
+ B = b;
+ A = a;
+ }
+ public short R {
+ get;
+ set;
+ }
+
+ public short G {
+ get;
+ set;
+ }
+
+ public short B {
+ get;
+ set;
+ }
+
+ public short A {
+ get;
+ set;
+ }
+
+ public override bool Equals (object obj)
+ {
+ Color c = obj as Color;
+ if (c == null) {
+ return false;
+ }
+ return c.R == R && c.G == G && c.B == B && c.A == A;
+ }
+
+ public override int GetHashCode ()
+ {
+ return (Int32)R<<24 | (Int32)G<<16 | (Int32)B<<8 | (Int32)A;
+ }
+ }
+
+ public class ColorHelper
+ {
+
static public ushort ByteToShort (Byte val) {
var ret = (ushort) (((float)val) / byte.MaxValue * ushort.MaxValue);
return ret;
diff --git a/LongoMatch.GUI/Gui/Component/ButtonTagger.cs b/LongoMatch.GUI/Gui/Component/ButtonTagger.cs
index 09e9d07..ac0a41f 100644
--- a/LongoMatch.GUI/Gui/Component/ButtonTagger.cs
+++ b/LongoMatch.GUI/Gui/Component/ButtonTagger.cs
@@ -22,6 +22,7 @@ using Gdk;
using LongoMatch.Common;
using LongoMatch.Handlers;
using LongoMatch.Store;
+using Color = Gdk.Color;
namespace LongoMatch.Gui.Component
{
diff --git a/LongoMatch.GUI/Gui/Component/DrawingToolBox.cs b/LongoMatch.GUI/Gui/Component/DrawingToolBox.cs
index d080758..4d6a590 100644
--- a/LongoMatch.GUI/Gui/Component/DrawingToolBox.cs
+++ b/LongoMatch.GUI/Gui/Component/DrawingToolBox.cs
@@ -21,6 +21,7 @@ using Gtk;
using Gdk;
using LongoMatch.Handlers;
using LongoMatch.Common;
+using Color = Gdk.Color;
namespace LongoMatch.Gui.Component
{
diff --git a/LongoMatch.GUI/Gui/Panel/NewProjectPanel.cs b/LongoMatch.GUI/Gui/Panel/NewProjectPanel.cs
index 700d40c..744123d 100644
--- a/LongoMatch.GUI/Gui/Panel/NewProjectPanel.cs
+++ b/LongoMatch.GUI/Gui/Panel/NewProjectPanel.cs
@@ -36,6 +36,7 @@ using LongoMatch.Utils;
using LongoMatch.Interfaces.GUI;
using Device = LongoMatch.Common.Device;
+using Color = Gdk.Color;
namespace LongoMatch.Gui.Panel
{
diff --git a/LongoMatch.GUI/Gui/TreeView/ListTreeViewBase.cs b/LongoMatch.GUI/Gui/TreeView/ListTreeViewBase.cs
index f5a3866..9dac3f6 100644
--- a/LongoMatch.GUI/Gui/TreeView/ListTreeViewBase.cs
+++ b/LongoMatch.GUI/Gui/TreeView/ListTreeViewBase.cs
@@ -22,11 +22,12 @@ using Gdk;
using Gtk;
using Mono.Unix;
-using Image = LongoMatch.Common.Image;
using LongoMatch.Common;
using LongoMatch.Handlers;
using LongoMatch.Store;
using LongoMatch.Gui.Helpers;
+using Image = LongoMatch.Common.Image;
+using Color = Gdk.Color;
namespace LongoMatch.Gui.Component
{
diff --git a/Tests/Core/TestCategory.cs b/Tests/Core/TestCategory.cs
index dfdbdd9..5a5514d 100644
--- a/Tests/Core/TestCategory.cs
+++ b/Tests/Core/TestCategory.cs
@@ -23,6 +23,7 @@ using Newtonsoft.Json;
using LongoMatch.Common;
using LongoMatch.Store;
using System.IO;
+using Color = System.Drawing.Color;
namespace Tests.Core
{
diff --git a/Tests/Core/TestColor.cs b/Tests/Core/TestColor.cs
new file mode 100644
index 0000000..da822ca
--- /dev/null
+++ b/Tests/Core/TestColor.cs
@@ -0,0 +1,38 @@
+//
+// Copyright (C) 2014 Andoni Morales Alastruey
+//
+// 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 St, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+using System;
+using NUnit.Framework;
+using LongoMatch.Common;
+
+namespace Tests.Core
+{
+ [TestFixture()]
+ public class TestColor
+ {
+ [Test()]
+ public void TestSerialization ()
+ {
+ Color c = new Color (1, 2, 3, 4);
+
+ Utils.CheckSerialization (c);
+ Color c1 = Utils.SerializeDeserialize (c);
+ Assert.AreEqual (c, c1);
+ }
+ }
+}
+
diff --git a/Tests/Tests.mdp b/Tests/Tests.mdp
index c0cce63..9c449be 100644
--- a/Tests/Tests.mdp
+++ b/Tests/Tests.mdp
@@ -34,6 +34,7 @@
<File subtype="Directory" buildaction="Compile" name="Services" />
<File subtype="Code" buildaction="Compile" name="Services/TestDatabase.cs" />
<File subtype="Code" buildaction="Compile" name="Services/TestDatabasesManager.cs" />
+ <File subtype="Code" buildaction="Compile" name="Core/TestColor.cs" />
</Contents>
<References>
<ProjectReference type="Gac" localcopy="False" refto="nunit.core, Version=2.6.0.0, Culture=neutral,
PublicKeyToken=96d09a1eb7f44a77" />
@@ -45,4 +46,4 @@
<ProjectReference specificVersion="False" type="Gac" localcopy="False" refto="System.Core,
Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<ProjectReference type="Project" localcopy="True" refto="LongoMatch.Services" />
</References>
-</Project>
\ No newline at end of file
+</Project>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]