private void Register_Button_Click(object sender, RoutedEventArgs e) { callback = new ClientCallback(); client = new MSServiceClient( new InstanceContext(callback)); RegisterWindow wind = new RegisterWindow(); wind.client = client; wind.callback = callback; wind.ShowDialog(); }
public BoardWindow(int mines, int size, Tuple <int, int>[] minesPositions, string username, string rival, MSServiceClient client, ClientCallback callback, bool flag) { InitializeComponent(); this.size = size; this.mines = mines; this.Username = username; this.Rival = rival; Title = username; this.Client = client; this.Callback = callback; this.flag = flag; for (int i = 0; i < size * size; ++i) { Button button = new Button() { Tag = i, }; button.Click += new RoutedEventHandler(Button_Click); button.MouseRightButtonDown += new MouseButtonEventHandler(Right_Button_Click); this.ButtonsGrid.Children.Add(button); this.ButtonsGrid.Columns = size; this.ButtonsGrid.Rows = size; } gameStarted = false; mineText = new Color[] { Colors.White /*first doesn't matter*/, Colors.Blue, Colors.DarkGreen, Colors.Red, Colors.DarkBlue, Colors.DarkViolet, Colors.DarkCyan, Colors.Brown, Colors.Black }; GameSetup(minesPositions); game = new MSClient.ServiceReference1.Games() { Winner = Rival, Loser = Username }; if (flag == true) { Client.GameConnect(game); } }
private void ConnectToServer() { callback = new ClientCallback(); try { client = new MSServiceClient( new InstanceContext(callback)); //checking if this user exists, if not, receives a message MSClient.ServiceReference1.Clients c = new ServiceReference1.Clients(); c.UserName = tbUsername.Text.Trim(); c.Password = tbPassword.Text.Trim(); bool value = client.SearchUsernamePasswordInDB(c); if (value == true) { username = tbUsername.Text.Trim(); client.ClientConnected(username); MenuWindow mainWindow = new MenuWindow(); mainWindow.Client = client; mainWindow.Callback = callback; mainWindow.Username = username; mainWindow.Title = username; this.Close(); mainWindow.Show(); } else { var res = MessageBox.Show("username or password wrong. please register", "error", MessageBoxButton.OK); } } catch (FaultException <UserExistsFault> ex) { MessageBox.Show(ex.Detail.Message); } catch (Exception ex) { MessageBox.Show(ex.Message); } }