//predicate for sorting the widths in descending order //public static int CompareWidthDesc(Block arg1, Block arg2) //{ // return arg2.Width.CompareTo(arg1.Width); //} public static int CompareWidthThenCol(Block arg1, Block arg2) { int compI = 0; compI = arg1.Width - arg2.Width; if (compI != 0) return compI; else compI = arg1._color.ToArgb() - arg2._color.ToArgb(); return compI; }
public static int CompareWidth(Block arg1, Block arg2) { return arg1.Width.CompareTo(arg2.Width); }
public static bool LongEnough(Block arg) { return arg.Width > 100; }
//predicates public static bool BrightEnough(Block arg) { return arg._color.GetBrightness() > 0.5; }
private void btnPopulate_Click(object sender, EventArgs e) { blocksList.Clear(); int blockArea = 0; while (blockArea < Block.Canvas.ScaledWidth * Block.Canvas.ScaledHeight * 0.8) { Block tBlock = new Block(); if (!blocksList.Equals(tBlock)) { blocksList.Add(tBlock); blockArea += tBlock.Width * Block.Height; } } UpdateTrackBar(); ShowBlocks(); }