internal Simulator(SimulatorController _simulator) { InitializeComponent(); controller = _simulator; KeyDown += controller.KeyPressed; KeyUp += controller.KeyUnPressed; GamePanel.MouseDown += new Forms.MouseEventHandler(controller.MouseButtonDown); GamePanel.MouseUp += new Forms.MouseEventHandler(controller.MouseButtonUp); GamePanel.MouseEnter += new EventHandler(GamePanel_MouseEnter); GamePanel.MouseLeave -= new EventHandler(GamePanel_MouseExit); GamePanel.MouseWheel += new Forms.MouseEventHandler(controller.RouletteSouris); GamePanel.MouseMove += new Forms.MouseEventHandler(controller.MouseMove); /// Resize on resize only Application.Current.MainWindow.SizeChanged += new SizeChangedEventHandler(ResizeGamePanel); settings = (new ConfigPanelData()).LoadSettings(); profiles = (new ConfigPanelData()).LoadProfiles(); var defaultProfile = profiles.Where(x => settings != null && x.CompareTo(settings.DefaultProfile) == 0); if (defaultProfile.Count() > 0) { selectedProfile = defaultProfile.First(); controller.ChangeProfile(selectedProfile); } else { selectedProfile = profiles[0]; controller.ChangeProfile(selectedProfile); } }
private void LoadSimulator(object sender, EventArgs e) { var model = new Engine(); var controller = new SimulatorController(model); actualPage = new Simulator(controller); model.subscribe((Observer)actualPage); ((Simulator)actualPage).LoadMainMenu += LoadMainMenu; content.Navigate(actualPage); }