private bool VoteCounter(out bool[] result) { var rowsCount = App.OptiuniVot.Count / 2 + App.OptiuniVot.Count % 2; LeftBoxes.Clear(); RightBoxes.Clear(); Rectangle l = new Rectangle(), r = new Rectangle(); for (int i = 0; i < rowsCount; i++) { int yadd = (i % 4 == 0) ? 1 : 0; if (i == 0) { l = new Rectangle(RectLeft.Left + 6, RectLeft.Top + 3 + i * (RectLeft.Height / rowsCount), RectLeft.Width - 9, RectLeft.Height / rowsCount - 5); r = new Rectangle(RectRight.Left + 6, RectRight.Top + 3 + i * (RectRight.Height / rowsCount), RectRight.Width - 9, RectRight.Height / rowsCount - 5); } else { l = new Rectangle(l.X, l.Y + l.Height + 5 + yadd, l.Width, l.Height); r = new Rectangle(r.X, r.Y + r.Height + 5 + yadd, r.Width, r.Height); } LeftBoxes.Add(l); RightBoxes.Add(r); } Dictionary <int, bool> votes = new Dictionary <int, bool>(); using (var g = Graphics.FromImage(_bitmap)) using (Pen pen = new Pen(Color.Yellow, 2)) { int index = 0; Stopwatch sw = new Stopwatch(); sw.Start(); for (var i = 0; i < LeftBoxes.Count; i++) { var vote = PaintBox(g, pen, LeftBoxes[i]); votes[index++] = vote; } for (var i = 0; i < RightBoxes.Count; i++) { var vote = PaintBox(g, pen, RightBoxes[i]); votes[index++] = vote; } sw.Stop(); Console.WriteLine(String.Format("Took {0} ms to compute votes.", sw.ElapsedMilliseconds)); } SetVotes(votes); result = Votes.OrderBy(v => v.NrCrt).Select(p => p.Optiune).ToArray(); return(true); }