private int CompareByClusterColor(PaletteItem x, PaletteItem y) { if (this.clusters == null) { return(PaletteSortContext.CompareByTitle(x, y)); } ClusteringPoint px = this.colorBase; if (this.clusters.ContainsKey(x.Cluster)) { px = PaletteSortContext.ToPoint(this.clusters[x.Cluster].Colors); } ClusteringPoint py = this.colorBase; if (this.clusters.ContainsKey(y.Cluster)) { py = PaletteSortContext.ToPoint(this.clusters[y.Cluster].Colors); } double dx = this.colorBase.Distance(px); double dy = this.colorBase.Distance(py); int r = dx.CompareTo(dy); if (r == 0) { r = PaletteSortContext.CompareByTitle(x, y); } return(r); }
PaletteSortContext(Color baseColor, SortedDictionary <int, PaletteItem> clusters) { this.clusters = clusters; this.colorBase = PaletteSortContext.ToPoint(new Color[8] { Color.Black, Color.Black, Color.Black, Color.Black, Color.Black, Color.Black, Color.Black, Color.Black }); }
private static int CompareByClusterId(PaletteItem x, PaletteItem y) { int r = -x.Cluster.CompareTo(y.Cluster); if (r == 0) { r = PaletteSortContext.CompareByTitle(x, y); } return(r); }
private int CompareByPaletteColor(PaletteItem x, PaletteItem y) { ClusteringPoint px = PaletteSortContext.ToPoint(x.Colors); ClusteringPoint py = PaletteSortContext.ToPoint(y.Colors); double dx = this.colorBase.Distance(px); double dy = this.colorBase.Distance(py); int r = dx.CompareTo(dy); if (r == 0) { r = PaletteSortContext.CompareByTitle(x, y); } return(r); }
public static void Sort(List <PaletteItem> list, PaletteListSortMode mode, SortedDictionary <int, PaletteItem> clusters) { PaletteSortContext.Sort(list, mode, clusters); }