Example #1
0
 public void Compute(FieldControl field)
 {
     grid.ItemsSource = (from row in field.Bubbles
                         group row by row.Color into g
                         select new GridRow
     {
         Color = g.Key,
         Count = g.Count()
     }).ToArray();
     //field
     //foreach (BubleColor color in labels.Keys)
     //{
     //    labels[color].Text = field.GetCount(color).ToString();
     //}
 }
Example #2
0
        private static void OnRowAttachedPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            var b = d as Bubble;

            if (b == null)
            {
                return;
            }



            var row = (int)e.NewValue;

            Canvas.SetTop(b, row * bubleSize + margin);

            var column = GetColumn(b);

            if (column < 0)
            {
                return;
            }

            FieldControl f = getField(d);

            if (f == null)
            {
                return;
            }


            if (f.bubbles[row, column] != null)
            {
                throw new OperationCanceledException("Try to move on not empty cell");
            }


            f.bubbles[row, column] = b;
            var oldRow = (int)e.OldValue;

            if (oldRow > -1)
            {
                f.bubbles[oldRow, column] = null;
            }
        }