public override bool Equals(object obj) { if (null == obj) { return(false); } if (!(obj is HlaeCommentedColor)) { return(false); } HlaeCommentedColor ccol = (HlaeCommentedColor)obj; return(Color.Equals(ccol.Color)); }
private bool GetRowColor(DataGridViewRow row, out HlaeCommentedColor src, out HlaeWeightedColor dst) { bool bOk = true; string[] colNames = { "Index", "R1", "G1", "B1", "A1", "Comment", "R2", "G2", "B2", "A2" }; int[] cols = { 1, 2, 3, 4, 6, 7, 8, 9 }; byte[] vals = { 255, 255, 255, 255, 255, 255, 255, 255 }; string comment; float weight; for (int i = 0; i < cols.Length && bOk; ++i) { bOk = bOk && null != row.Cells[cols[i]].Value; if (bOk) { bOk = bOk && byte.TryParse(row.Cells[cols[i]].Value.ToString(), out vals[i]); } if (!bOk) { RowColumnError(row.Index, colNames[cols[i]]); } } comment = null == row.Cells[5].Value ? "" : row.Cells[5].Value.ToString(); if (null == row.Cells[10].Value) { weight = 1.0f; } else if (!float.TryParse(row.Cells[10].Value.ToString(), out weight)) { RowColumnError(row.Index, "Weight"); } src = new HlaeCommentedColor(vals[0] / 255.0f, vals[1] / 255.0f, vals[2] / 255.0f, vals[3] / 255.0f, comment); dst = new HlaeWeightedColor(vals[4] / 255.0f, vals[5] / 255.0f, vals[6] / 255.0f, vals[7] / 255.0f, weight); return(bOk); }