public MainForm(ref BinList newBinList) { InitializeComponent(); this.binList = newBinList; this.sizeSelect.SelectedIndex = (int)SizeSelection.SIZE_SELECT_MEDIUM; SetLogVisible(false); this.log.DataSource = Log.Instance; Log.Instance.ListChanged += LogListChanged; }
public static void Main() { BinList binList = new BinList(); MainForm mainForm = new MainForm(ref binList); mainForm.RefreshPanel(); Application.EnableVisualStyles(); Application.Run(mainForm); }
public static void Sort(ref BinList binList, Rectangle panelRectangle, out int unresolved) { Node startNode = new Node(); startNode.Rectangle = panelRectangle; unresolved = 0; int currentX = 0; int currentY = panelRectangle.Height; int currentHeight = 0; foreach (Bin bin in binList) { Node node = startNode.Insert(bin.Rectangle); if (node == null) { // since we cannot place the rectangle in a sorted position, place it // below the panel's view loosely fitted with the other unresolved // rectangles if (bin.Rectangle.Width + currentX > panelRectangle.Width) { currentX = 0; currentY += currentHeight; currentHeight = 0; } bin.Rectangle.X = currentX; currentX += bin.Rectangle.Width; bin.Rectangle.Y = currentY; if (bin.Rectangle.Height > currentHeight) { currentHeight = bin.Rectangle.Height; } unresolved++; continue; } bin.Rectangle = node.Rectangle; } }
public static void Sort(ref BinList binList, int panelWidth) { int binListCount = binList.Count; randomBinding = new Dictionary <Bin, int>(binListCount); foreach (Bin bin in binList) { randomBinding[bin] = randomGenerator.Next(); } binList.Sort(CompareBins); int currentHeight = 0; int currentX = 0; int currentY = 0; foreach (Bin bin in binList) { if (currentX + bin.Rectangle.Width > panelWidth) { currentX = 0; currentY += currentHeight; currentHeight = 0; } if (bin.Rectangle.Height > currentHeight) { currentHeight = bin.Rectangle.Height; } bin.Rectangle.X = currentX; bin.Rectangle.Y = currentY; currentX += bin.Rectangle.Width; } }