コード例 #1
0
        public MultiGameMenu()
        {
            InitializeComponent();
            mgw = new MultiGameWindow();

            IMultiMenuModel mm = new MultiMenuModel();

            mmvm                     = new MultiMenuViewModel(mm);
            this.DataContext         = mmvm;
            mazeInfo.btnStart.Click += delegate(Object sender, RoutedEventArgs e)
            {
                mgw.Owner = this;
                int retVal = mgw.Start(mazeInfo.txtMazeName.Text,
                                       mazeInfo.txtRows.Text,
                                       mazeInfo.txtCols.Text);
                if (retVal < 0)
                {
                    /*Application.Current.MainWindow.Show();
                     * //this.Close();//??
                     * this.Hide();*/
                }
                //this.Close();
                //Thread.Sleep(1000);
            };

            games.ItemsSource = gamesList;

            string gamesLst = mmvm.List();

            if (!gamesLst.Equals("[]"))
            {
                gamesLst = gamesLst.Replace("\r\n", "");
                gamesLst = gamesLst.Replace("[", "");
                gamesLst = gamesLst.Replace("]", "");
                gamesLst = gamesLst.Replace(" ", "");
                gamesLst = gamesLst.Replace("\"", "");
                string[] gamesArr = gamesLst.Split(',');

                for (int i = 0; i < gamesArr.Length; i++)
                {
                    //gamesArr[i] = gamesArr[i].Replace("\"", "");

                    gamesList.Add(gamesArr[i]);
                }
            }
        }
コード例 #2
0
ファイル: MultiManager.cs プロジェクト: haim6678/Maze-game
        /// <summary>
        /// Gets the command from menu.
        /// </summary>
        /// <returns></returns>
        private string GetCommandFromMenu()
        {
            try
            {
                // open multiplayer window
                MultiMenuModel model = new MultiMenuModel();
                MultiMenuVM    vm    = new MultiMenuVM(model);
                MultiMenu      mnu   = new MultiMenu(vm);

                string cmd;
                mnu.ShowDialog(out cmd);
                return(cmd);
            }
            catch (Exception e)
            {
                MessageBox.Show("Error connecting to the server!", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                return(null);
            }
        }