void FlyingScoreUC_Loaded(object sender, RoutedEventArgs e) { if (_presenter == null) { _presenter = this.DataContext as GamePresenter; if (_presenter != null) { _presenter.CurrentGame.FlyingScores.CollectionChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler(FlyingScores_CollectionChanged); } } }
public TPillGame(GamePresenter _gp) { subInit(); tb.Visibility = Visibility.Collapsed; tb.LayoutUpdated += new EventHandler(TbChanged); RemainingPills++; fGp = _gp; fTskProvider = fGp.CurrentGame.taskBox.tskProvider; MouseEnter += new MouseEventHandler(TPill_MouseEnter); MouseLeftButtonDown += new MouseButtonEventHandler(TPill_MouseDown); MouseLeftButtonUp += new MouseButtonEventHandler(TPill_MouseUp); }
void PacmanUC_Loaded(object sender, RoutedEventArgs e) { if (System.ComponentModel.DesignerProperties.IsInDesignTool) { this.DataContext = new GamePresenter(); //HACK BUG VS Designer } GamePresenter gp = ((GamePresenter)this.DataContext); gp.Pills = Pills; //because FindName doesn't works inside viewbox, i should remap local fields Canvas cv = (Canvas)this.viewBox.Child; pacman.mouseTopPosition = FindName <LineSegment>(cv, "mouseTopPosition"); pacman.mouseBottomPosition = FindName <ArcSegment>(cv, "mouseBottomPosition"); this.ghost1 = FindName <GhostUC>(cv, "ghost1"); this.ghost2 = FindName <GhostUC>(cv, "ghost2"); this.ghost3 = FindName <GhostUC>(cv, "ghost3"); this.ghost4 = FindName <GhostUC>(cv, "ghost4"); gp.PacmanPresenter.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(PacmanPresenter_PropertyChanged); if (this.ghost1 != null) { ((GhostUCPresenter)this.ghost1.DataContext).GhostPresenter = gp.Ghost1; } if (this.ghost2 != null) { ((GhostUCPresenter)this.ghost2.DataContext).GhostPresenter = gp.Ghost2; } if (this.ghost3 != null) { ((GhostUCPresenter)this.ghost3.DataContext).GhostPresenter = gp.Ghost3; } if (this.ghost4 != null) { ((GhostUCPresenter)this.ghost4.DataContext).GhostPresenter = gp.Ghost4; } gp.CurrentGame.Audio = this; _gamepresenter = gp; soundPlay = new TSoundPlayer(soundElem); musicPlay = new TSoundPlayer(musicElem); pillPlay = new TSoundPlayer(pillElem); (this as IAudio).MusicMenu(); }