コード例 #1
0
 private void click_joinRoom(object sender, RoutedEventArgs e)
 {
     if (room == "")
     {
         MessageBox.Show(this, "You have not selected a room");
     }
     else
     {
         if (sendJoinRoom())
         {
             int    i;
             byte[] rcv = new byte[2];
             cl._clientStream.Read(rcv, 0, 2);
             int questionNum = Int32.Parse(System.Text.Encoding.UTF8.GetString(rcv, 0, 2));
             cl._clientStream.Read(rcv, 0, 2);
             int questionTime = Int32.Parse(System.Text.Encoding.UTF8.GetString(rcv, 0, 2));
             for (i = 0; i < WPFclient.App.Current.Windows.Count; i++)
             {
                 if (WPFclient.App.Current.Windows[i].ToString() == "WPFclient.inRoom")
                 {
                     break;
                 }
             }
             if (i == WPFclient.App.Current.Windows.Count)                                                         //if there is mainMenu open already
             {
                 inRoom r = new inRoom(false, questionNum, questionTime, 0, room.Substring(11, room.Length - 11)); //else create one and open it
                 r.Show();
             }
             else
             {
                 WPFclient.App.Current.Windows[i].Show();
             }
             this.Close();
         }
     }
 }
コード例 #2
0
 private void click_inRoom(object sender, RoutedEventArgs e)
 {
     if (sendCreateRoom())
     {
         int i;
         for (i = 0; i < WPFclient.App.Current.Windows.Count; i++)
         {
             if (WPFclient.App.Current.Windows[i].ToString() == "WPFclient.inRoom")
             {
                 break;
             }
         }
         if (i == WPFclient.App.Current.Windows.Count)                                                                               //if there is mainMenu open already
         {
             inRoom m = new inRoom(true, Int32.Parse(questions.Text), Int32.Parse(time.Text), Int32.Parse(players.Text), name.Text); //else create one and open it
             m.Show();
         }
         else
         {
             WPFclient.App.Current.Windows[i].Show();
         }
         this.Close();
     }
 }