Esempio n. 1
0
        private void SaveMapping()
        {
            GameMapping gm = new GameMapping()
            {
                GameTitle   = txtGameTitle.Text,
                FileName    = txtFilename.Text,
                KeyMappings = Keymappings
            };

            if (cboMachineMode.SelectedIndex > -1)
            {
                gm.Modle = (GameMapping.MachineModel)(int) cboMachineMode.SelectedItem;
            }

            string validationErrors = string.Empty;

            if (!gm.Validate(ref validationErrors))
            {
                MessageBox.Show(validationErrors, "Validation Errors", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
            }
            else
            {
                saveDialog.FileName = string.Concat(gm.GameTitle, ".zxk");

                if (saveDialog.ShowDialog() != DialogResult.Cancel)
                {
                    File.WriteAllText(saveDialog.FileName, gm.ToString());
                    this.Close();
                    this.Dispose();
                }
            }
        }
Esempio n. 2
0
        private void SaveMapping()
        {
            GameMapping gm = new GameMapping()
            {
                GameTitle = txtGameTitle.Text,
                FileName = txtFilename.Text,
                KeyMappings = Keymappings
            };
            if (cboMachineMode.SelectedIndex > -1)
            {
                gm.Modle = (GameMapping.MachineModel)(int)cboMachineMode.SelectedItem;
            }

            string validationErrors = string.Empty;
            if(!gm.Validate(ref validationErrors))
            {
                MessageBox.Show(validationErrors, "Validation Errors", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
            }
            else
            {
                saveDialog.FileName = string.Concat(gm.GameTitle, ".zxk");

                if (saveDialog.ShowDialog() != DialogResult.Cancel)
                {
                    File.WriteAllText(saveDialog.FileName, gm.ToString());
                    this.Close();
                    this.Dispose();
                }
            }
        }