Exemplo n.º 1
0
        private void FieldPropertyChanged(Field oldValue, Field newValue)
        {
            if (oldValue != null)
            {
                oldValue.Evaluated -= Field_Evaluated;
            }

            if (viewField != null)
            {
                foreach (var cell in viewField)
                {
                    cell.MouseLeftButtonUp -= View_MouseLeftButtonUp;
                }
            }

            viewField = null;

            grid.Children.Clear();
            grid.ColumnDefinitions.Clear();
            grid.RowDefinitions.Clear();

            if (newValue != null)
            {
                newValue.Evaluated += Field_Evaluated;
                team1L.Content      = newValue.Score1;
                team2L.Content      = newValue.Score2;

                for (int i = 0; newValue.Width > i; i++)
                {
                    grid.ColumnDefinitions.Add(new ColumnDefinition());
                }
                for (int i = 0; newValue.Height > i; i++)
                {
                    grid.RowDefinitions.Add(new RowDefinition());
                }

                var field = newValue.Map;

                var h = field.GetLength(0);
                var w = field.GetLength(1);
                viewField = new CellView[h, w];

                for (int y = 0; h > y; y++)
                {
                    for (int x = 0; w > x; x++)
                    {
                        CellView view = new CellView();
                        view.MouseLeftButtonUp += View_MouseLeftButtonUp;
                        view.Margin             = new Thickness(5);
                        view.Cell         = field[y, x];
                        view.CellFontSize = 20;

                        viewField[y, x] = view;

                        Grid.SetRow(view, y);
                        Grid.SetColumn(view, x);
                        grid.Children.Add(view);
                    }
                }
            }

            UpdateCellColors();
        }
Exemplo n.º 2
0
 public CellClickedEventArgs(CellView view, Core.Point position)
 {
     View     = view;
     Position = position;
 }