public MineField(MineSweeperGame parentGame) { /* * I never realy asked but, init paramters in constructor vs in class. * Normaly i always init stuff in the constructor, to make it more readable but there is * a case to be made to create less repeating code by defining them in the class...? */ this.parentGame = parentGame; this.Neigbours = new ObservableDictionary <CardinalDirection, MineField>(8); this.c_isEnabled = base.IsEnabled; //setup Bindings MultiBinding multiBinding = new MultiBinding(); multiBinding.Converter = new MineFieldMultiConverter(); //First condition (SuspectedMine) Binding binding1 = new Binding(); binding1.Source = this; binding1.Path = new PropertyPath("SuspectedMine"); binding1.Mode = BindingMode.OneWay; //Second condition (ContainsMine) Binding binding2 = new Binding(); binding2.Source = this; binding2.Path = new PropertyPath("ContainsMine"); binding2.Mode = BindingMode.OneWay; //Third condition (IsEnabled) Binding binding3 = new Binding(); binding3.Source = this; binding3.Path = new PropertyPath("IsEnabled"); binding3.Mode = BindingMode.OneWay; //Fourth condition (no Of neigbour mines) Binding binding4 = new Binding(); binding4.Source = this; binding4.Path = new PropertyPath("Neigbours"); //This should in theory listen to add/delete... etc binding4.Mode = BindingMode.OneWay; //Listening to to the mineField inside the observable? //Finalise binding multiBinding.Bindings.Add(binding1); multiBinding.Bindings.Add(binding2); multiBinding.Bindings.Add(binding3); multiBinding.Bindings.Add(binding4); this.SetBinding(ContentProperty, multiBinding); }
private void BtnResetButton_Click(object sender, RoutedEventArgs e) { this.mineSweeperGame = new MineSweeperGame(10, 10, 10); this.ccGameArea.Content = mineSweeperGame; }
public MainWindow() { InitializeComponent(); this.mineSweeperGame = new MineSweeperGame(10, 10, 10); this.ccGameArea.Content = mineSweeperGame; }