Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
 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
     });
 }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
        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);
        }
Exemplo n.º 5
0
 public static void Sort(List <PaletteItem> list, PaletteListSortMode mode, SortedDictionary <int, PaletteItem> clusters)
 {
     PaletteSortContext.Sort(list, mode, clusters);
 }