/// <summary> /// Indicates whether the current object is equal to another object of the same type. /// </summary> /// <returns> /// true if the current object is equal to the <paramref name="other"/> parameter; otherwise, false. /// </returns> /// <param name="other">An object to compare with this object.</param> public bool Equals(ColorCollection other) { bool result; result = other != null && other.Count == this.Count; if (result) { // check colors - by value though, as Color.Cornflowerblue != Color.FromArgb(255, 100, 149, 237) for (int i = 0; i < this.Count; i++) { Color expected; Color actual; expected = other[i]; actual = this[i]; if (expected.ToArgb() != actual.ToArgb()) { result = false; break; } } } return(result); }
/// <summary> /// Serializes the specified <see cref="ColorCollection" /> and writes the palette to a file using the specified <see cref="Stream"/>. /// </summary> /// <param name="fileName">The name of the file where the palette will be written to.</param> /// <param name="palette">The <see cref="ColorCollection" /> to serialize.</param> public void Serialize(string fileName, ColorCollection palette) { using (Stream stream = File.Create(fileName)) { this.Serialize(stream, palette); } }
/// <summary> /// Initializes a new instance of the <see cref="ColorCollection"/> class that contains elements copied from the specified collection. /// </summary> /// <param name="collection">The collection whose elements are copied to the new collection.</param> public ColorCollection(ColorCollection collection) : this() { for (int i = 0; i < collection.Count; i++) { this.Add(collection[i]); #if USENAMEHACK this.SetName(i, collection.GetName(i)); #endif } }
/// <summary> /// Serializes the specified <see cref="ColorCollection" /> and writes the palette to a file using the specified Stream. /// </summary> /// <param name="stream">The <see cref="Stream" /> used to write the palette.</param> /// <param name="palette">The <see cref="ColorCollection" /> to serialize.</param> void IPaletteSerializer.Serialize(Stream stream, ColorCollection palette) { this.Serialize(stream, palette); }
/// <summary> /// Serializes the specified <see cref="ColorCollection" /> and writes the palette to a file using the specified <see cref="Stream"/>. /// </summary> /// <param name="stream">The <see cref="Stream" /> used to write the palette.</param> /// <param name="palette">The <see cref="ColorCollection" /> to serialize.</param> public abstract void Serialize(Stream stream, ColorCollection palette);