public override int GetHashCode() { unchecked { var hashCode = (ScreenInfo != null ? ScreenInfo.GetHashCode() : 0); hashCode = (hashCode * 397) ^ Color.GetHashCode(); return(hashCode); } }
public override int GetHashCode() { return(m_color.GetHashCode()); }
Pen GetPen(Color color, int width, bool dashed) { int hash = color.GetHashCode() ^ width.GetHashCode() ^ dashed.GetHashCode(); int debug1 = color.GetHashCode(); int debug2 = width.GetHashCode(); int debug3 = dashed.GetHashCode(); Pen pen; if (!PenCache.TryGetValue(hash, out pen)) { pen = new Pen(color, width); if (dashed) pen.DashPattern = new float[] { 3, 6 }; PenCache[hash] = pen; } return pen; }
/// <summary> /// /// </summary> /// <param name="clr"></param> /// <returns></returns> public int FindClosestEntry(Color clr) { // If not sure of consistency with palette, clear the hash table if (m_fClearHash) m_htbl.Clear(); // Is this mapping available already? int key = clr.GetHashCode(); if (m_htbl.ContainsKey(key)) return (int)m_htbl[key]; // Find the entry, the long way int nLowest = 256 * 256 * 3; int iLowest = 0; int nR = clr.R; int nG = clr.G; int nB = clr.B; for (int iclr = 0; iclr < m_aclr.Length; iclr++) { Color clrPal = m_aclr[iclr]; int dR = clrPal.R - nR; int dG = clrPal.G - nG; int dB = clrPal.B - nB; int nD = dR * dR + dG * dG + dB * dB; if (nD < nLowest) { nLowest = nD; iLowest = iclr; } } // Add it to the hash table and return it m_htbl.Add(key, iLowest); return iLowest; }