Пример #1
0
        public SingleGameMenu()
        {
            InitializeComponent();
            ISingleMenuModel sm = new SingleMenuModel();

            smvm             = new SingleMenuViewModel(sm);
            this.DataContext = smvm;

            mazeInfo.btnStart.Click += delegate(Object sender, RoutedEventArgs e)
            {
                // writing task.
                //new Task(() =>
                //{
                SingleGameWindow sgw = new SingleGameWindow();
                sgw.Owner = this;
                // spw.Generate(name, rows, cols);
                int retVal = sgw.Generate(mazeInfo.txtMazeName.Text,
                                          mazeInfo.txtRows.Text,
                                          mazeInfo.txtCols.Text);
                if (retVal < 0)
                {
                    /*Application.Current.MainWindow.Show();
                     * //this.Close();//??
                     * this.Hide();*/
                }

                //}).Start();
                ///????????????????????????????????????????????????????????????????????
                //this.Close();
            };
        }
Пример #2
0
        /// <summary>
        /// Gets the command from menu.
        /// </summary>
        /// <returns></returns>
        private string GetCommandFromMenu()
        {
            try
            {
                // open multiplayer window
                SingleMenuModel model = new SingleMenuModel();
                SingleMenuVM    vm    = new SingleMenuVM(model);
                SingleMenu      mnu   = new SingleMenu(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);
            }
        }