From: jpbruyere Date: Mon, 21 Mar 2016 06:39:28 +0000 (+0100) Subject: code clean X-Git-Tag: v0.4~70^2~5 X-Git-Url: https://git.osiis.dedyn.io/?a=commitdiff_plain;h=0490aefbd71436f575187602355cfcda48a92063;p=jp%2Fcrow.git code clean --- diff --git a/src/Colors.cs b/src/Colors.cs index 4cb8cd5c..269d7ae6 100644 --- a/src/Colors.cs +++ b/src/Colors.cs @@ -1028,6 +1028,25 @@ namespace Crow } #endregion + public override int GetHashCode () + { + unchecked // Overflow is fine, just wrap + { + int hash = 17; + // Suitable nullity checks etc, of course :) + hash = hash * 23 + A.GetHashCode(); + hash = hash * 23 + R.GetHashCode(); + hash = hash * 23 + G.GetHashCode(); + hash = hash * 23 + B.GetHashCode(); + return hash; + } + } + public override bool Equals (object obj) + { + return (obj == null || obj.GetType() != typeof(Color)) ? + false : + this == (Color)obj; + } public override string ToString() { if (!string.IsNullOrEmpty(Name)) diff --git a/src/GraphicObjects/GenericStack.cs b/src/GraphicObjects/GenericStack.cs index 6dec8453..362143fa 100644 --- a/src/GraphicObjects/GenericStack.cs +++ b/src/GraphicObjects/GenericStack.cs @@ -218,7 +218,6 @@ namespace Crow { base.OnChildLayoutChanges (sender, arg); - GraphicObject g = sender as GraphicObject; switch (arg.LayoutType) { case LayoutingType.Width: if (Orientation == Orientation.Horizontal) { diff --git a/src/GraphicObjects/GraphicObject.cs b/src/GraphicObjects/GraphicObject.cs index a6ed7807..81ec72a6 100644 --- a/src/GraphicObjects/GraphicObject.cs +++ b/src/GraphicObjects/GraphicObject.cs @@ -1225,7 +1225,6 @@ namespace Crow { if (!reader.HasAttributes) return; - Type thisType = this.GetType (); string stylePath = reader.GetAttribute ("Style"); diff --git a/src/GraphicObjects/PrivateContainer.cs b/src/GraphicObjects/PrivateContainer.cs index ddabc7e0..a399567c 100644 --- a/src/GraphicObjects/PrivateContainer.cs +++ b/src/GraphicObjects/PrivateContainer.cs @@ -138,7 +138,6 @@ namespace Crow } public virtual void OnChildLayoutChanges (object sender, LayoutingEventArgs arg) { - GraphicObject g = sender as GraphicObject; switch (arg.LayoutType) { case LayoutingType.X: break; diff --git a/src/GraphicObjects/TabView.cs b/src/GraphicObjects/TabView.cs index 2700043a..65657f38 100644 --- a/src/GraphicObjects/TabView.cs +++ b/src/GraphicObjects/TabView.cs @@ -116,7 +116,6 @@ namespace Crow } public override void RemoveChild (GraphicObject child) { - int idx = Children.IndexOf (child); base.RemoveChild (child); if (selectedTab > Children.Count - 1) SelectedTab--; diff --git a/src/Input/KeyboardKeyEventArgs.cs b/src/Input/KeyboardKeyEventArgs.cs index bfe0debb..f9307ffc 100644 --- a/src/Input/KeyboardKeyEventArgs.cs +++ b/src/Input/KeyboardKeyEventArgs.cs @@ -88,7 +88,6 @@ namespace Crow /// /// Gets the scancode which generated this event. /// - [CLSCompliant(false)] public uint ScanCode { get { return (uint)Key; } diff --git a/src/Rectangle.cs b/src/Rectangle.cs index ce1ed39c..e9445224 100644 --- a/src/Rectangle.cs +++ b/src/Rectangle.cs @@ -247,6 +247,24 @@ namespace Crow int.Parse(d[2]), int.Parse(d[3])); } + public override int GetHashCode () + { + unchecked // Overflow is fine, just wrap + { + int hash = 17; + // Suitable nullity checks etc, of course :) + hash = hash * 23 + _x.GetHashCode(); + hash = hash * 23 + _y.GetHashCode(); + hash = hash * 23 + _width.GetHashCode(); + hash = hash * 23 + _height.GetHashCode(); + return hash; + } + } + public override bool Equals (object obj) + { + return (obj == null || obj.GetType() != typeof(Rectangle)) ? + false : + this == (Rectangle)obj; + } } - } diff --git a/src/Size.cs b/src/Size.cs index c9d4427b..21ddb539 100644 --- a/src/Size.cs +++ b/src/Size.cs @@ -129,7 +129,24 @@ namespace Crow return new Size(s.Width + i, s.Height + i); } #endregion - + + public override int GetHashCode () + { + unchecked // Overflow is fine, just wrap + { + int hash = 17; + // Suitable nullity checks etc, of course :) + hash = hash * 23 + _width.GetHashCode(); + hash = hash * 23 + _height.GetHashCode(); + return hash; + } + } + public override bool Equals (object obj) + { + return (obj == null || obj.GetType() != typeof(Size)) ? + false : + this == (Size)obj; + } public override string ToString() { return string.Format("{0},{1}", Width, Height); diff --git a/src/SolidColor.cs b/src/SolidColor.cs index 7a1178cc..2b6f7e71 100644 --- a/src/SolidColor.cs +++ b/src/SolidColor.cs @@ -50,6 +50,10 @@ namespace Crow return left.color == right.color ? false : true; } + public override int GetHashCode () + { + return color.GetHashCode(); + } public override bool Equals (object obj) { if (obj is Crow.Color)