public UIManagerImpl(GameTablePanel gameTablePanel) { myGameTablePanel = gameTablePanel; Application.Current.RootVisual.Effect = myBackgroundBlur = new BlurEffect {Radius = 0}; myCurrentBackgroundState = new BackgroundState(0, 1); Application.Current.RootVisual.MouseLeftButtonDown += delegate(object sender, MouseButtonEventArgs e) { if (myPopupData.Popup.IsOpen) { ClosePopup(myPopupData, myPopupData.Element, false); e.Handled = true; } }; Application.Current.RootVisual.KeyDown += delegate(object sender, KeyEventArgs e) { if (e.Key == Key.Escape && myPopupData.Popup.IsOpen) { ClosePopup(myPopupData, myPopupData.Element, false); e.Handled = true; } }; }
private void Application_Startup(object sender, StartupEventArgs e) { var rootVisual = new UserControl(); RootVisual = rootVisual; var gameTablePanel = new GameTablePanel(); rootVisual.Content = gameTablePanel; new UIManagerImpl(gameTablePanel); gameTablePanel.SetGame(CreateSampleGame()); gameTablePanel.Update(); /* mainPage.StatusBar.Text = "Связываемся с сервером..."; var serverCommunicator = new ServerCommunicator(); serverCommunicator.Login("valentin", "Egypt", delegate(bool success, string errorMessage) { if (success) { var playerInfo1 = new PlayerInfo {Namek__BackingField = "Player 1", Colork__BackingField = PlayerColor.Blue, Sexk__BackingField = Sex.Man}; var playerInfo2 = new PlayerInfo {Namek__BackingField = "Player 2", Colork__BackingField = PlayerColor.Red, Sexk__BackingField = Sex.Woman}; const string gameName = "TestGame"; const string gamePassword = "******"; serverCommunicator.CreateNewGame(gameName, gamePassword, new[]{playerInfo1, playerInfo2}, delegate(bool success1, string errorMessage1) { if (success1) mainPage.StatusBar.Text = errorMessage1; string activePlayerName = success1 ? "Player 1" : "Player 2"; ServerCommunicator.EnterGameCompletedHandler handler = delegate(bool success2, string errorMessage2, ICollection<PlayerInfo> players) { if (success) { mainPage.StatusBar.Text = "ОК"; IGame game = CreateGame(players, activePlayerName); mainPage.SetGame(game); mainPage.Update(); serverCommunicator.GameEventsApplied += mainPage.Update; serverCommunicator.Game = game; } else { mainPage.StatusBar.Text = errorMessage2; } }; serverCommunicator.EnterGame(gameName, activePlayerName, gamePassword, handler, () => StartGame(serverCommunicator)); }); } else { mainPage.StatusBar.Text = errorMessage; } } ); */ }