Ejemplo n.º 1
0
        public void click_mainMenu(object sender, RoutedEventArgs e)
        {
            mainMenu m = new mainMenu();

            m.Show();
            this.Close();
        }
Ejemplo n.º 2
0
        private void theWindow_Closed(object sender, System.EventArgs e)
        {//After closing this (as it is somewhat an information pop up and not the
         //body of the program, mainMenu will reopen instead
            mainMenu m = new mainMenu();

            m.Show();
            this.Close();
        }
Ejemplo n.º 3
0
        private void click_mainMenu(object sender, RoutedEventArgs e)
        {//move back to main menu
            int i;

            for (i = 0; i < WPFclient.App.Current.Windows.Count; i++)
            {
                if (WPFclient.App.Current.Windows[i].ToString() == "WPFclient.mainMenu")
                {
                    break;
                }
            }
            if (i == WPFclient.App.Current.Windows.Count) //if there is mainMenu open already
            {
                mainMenu m = new mainMenu();              //else create one and open it
                m.Show();
            }
            else
            {
                WPFclient.App.Current.Windows[i].Show();
            }
            this.Close();
        }
Ejemplo n.º 4
0
 void background_worker_ProgressChanged(object sender, ProgressChangedEventArgs e)
 {/* Same code as in connectedUser, but doesn't send for it, beacuse it is sent automatically when someone joins*/
     if (e.ProgressPercentage.CompareTo(108) == 0)
     {
         usersList.Items.Clear();
         byte[] rcv = new byte[1]; //0 if failed, otherwise number of users
         cl._clientStream.Read(rcv, 0, 1);
         if (System.Text.Encoding.UTF8.GetString(rcv) == "0")
         {
             ListBoxItem item = new ListBoxItem();
             item.Content = "There are no users, the room probably closed";
             usersList.Items.Add(item);
         }
         else
         {
             int userNum = Int32.Parse(System.Text.Encoding.UTF8.GetString(rcv));
             for (int i = 0; i < userNum; i++)
             {
                 ListBoxItem item = new ListBoxItem();
                 rcv = new byte[2];
                 cl._clientStream.Read(rcv, 0, 2);
                 int nameLen = Int32.Parse(System.Text.Encoding.UTF8.GetString(rcv));
                 rcv = new byte[nameLen];
                 cl._clientStream.Read(rcv, 0, nameLen);
                 item.Content += System.Text.Encoding.UTF8.GetString(rcv);
                 usersList.Items.Add(item);
             }
         }
     }
     else if (e.ProgressPercentage.CompareTo(116) == 0)
     {
         int i;
         for (i = 0; i < windows.Count; i++)
         {
             if (windows[i].ToString() == "WPFclient.mainMenu")
             {
                 break;
             }
         }
         if (i == windows.Count)          //if there is mainMenu open already
         {
             mainMenu m = new mainMenu(); //else create one and open it
             m.Show();
         }
         else
         {
             windows[i].Show();
         }
         this.Close();
         _inRoom = false;
     }
     else if (e.ProgressPercentage.CompareTo(118) == 0)
     {
         int i;
         for (i = 0; i < windows.Count; i++)
         {
             if (windows[i].ToString() == "WPFclient.game")
             {
                 break;
             }
         }
         if (i == windows.Count) //if there is mainMenu open already
         {
             int  timeParam     = Int32.Parse(time.Content.ToString().Substring(20, time.Content.ToString().Length - 20));
             int  questionParam = Int32.Parse(questionNum.Content.ToString().Substring(22, questionNum.Content.ToString().Length - 22));
             game g             = new game(timeParam, questionParam); //else create one and open it
             g.Show();
         }
         else
         {
             windows[i].Show();
         }
         this.Close();
         _inRoom = false;
     }
 }