Exemple #1
0
        private void editGameDataToolStripMenuItem_Click(object sender, EventArgs e)
        {
            DataGridViewRow selectedRow   = GameGridView.SelectedRows[0];
            int             editGameIndex = selectedRow.Index;

            if (selectedRow != null)
            {
                //string selectedGameGuid = selectedRow.Cells[Database.Guid].Value.ToString();
                string selectedGameGuid = GameDataTable.Rows[selectedRow.Index][Database.Guid].ToString();

                GameItem selectedGameItem = Ap.Database.GameItems.GetGameByGuid(selectedGameGuid);
                if (selectedGameGuid != string.Empty && selectedGameItem != null)
                {
                    InfinityChess.GameData.frmGameData frmGameData = new InfinityChess.GameData.frmGameData(selectedGameItem.GameData, this.MainForm);
                    frmGameData.Game = this.Game;

                    if (frmGameData.ShowDialog(this) == DialogResult.OK)
                    {
                        int    selectedGameIndex = Ap.Database.GameItems.GetGameIndexByGuid(selectedGameGuid);
                        string updatedGameXml    = this.Game.GetGameXml(selectedGameItem.GameData);
                        Ap.Database.UpdateGame(updatedGameXml, selectedGameIndex);
                        Ap.Database.Save();
                        this.FocusOpenedDatabaseForm();
                        GameGridView.Rows[editGameIndex].Selected = true;
                    }
                }
            }
        }
        public void SaveGame(bool isSaveAs)
        {
            SaveFileDialog sfdSaveGame = new SaveFileDialog();

            sfdSaveGame.Filter           = "Databases icd(*" + Files.DatabaseExtension + ")|*" + Files.DatabaseExtension;
            sfdSaveGame.FileName         = "*" + Files.DatabaseExtension;
            sfdSaveGame.InitialDirectory = Ap.FolderDatabase;
            if (isSaveAs)
            {
                if (sfdSaveGame.ShowDialog() == DialogResult.OK)
                {
                    InfinityChess.GameData.frmGameData frmGameData = new InfinityChess.GameData.frmGameData(this);
                    frmGameData.Game = base.Game;
                    if (frmGameData.ShowDialog(this) == DialogResult.OK)
                    {
                        string fileName = sfdSaveGame.FileName;
                        if (!fileName.EndsWith(Files.DatabaseExtension))
                        {
                            fileName = fileName + Files.DatabaseExtension;
                        }
                        base.Game.GameData.Guid = string.Empty;
                        base.Game.SaveGame(fileName);
                        Ap.Databases.Add(fileName);
                        Ap.Options.CurrentGameGuid             = base.Game.GameData.Guid;
                        Ap.Options.CurrentGameDatabaseFilePath = fileName;
                        Ap.Options.Save();
                        //GameSelectedMode();
                        if (this.DatabaseForm != null)
                        {
                            this.DatabaseForm.FocusOpenedDatabaseForm();
                        }
                    }
                }
            }
            else
            {
                InfinityChess.GameData.frmGameData frmGameData = new InfinityChess.GameData.frmGameData(this);
                frmGameData.Game = base.Game;
                if (frmGameData.ShowDialog(this) == DialogResult.OK)
                {
                    base.Game.GameData.Guid = string.Empty;
                    base.Game.SaveGame(Ap.DefaultDatabaseFilePath);
                    Ap.Databases.Add(Ap.DefaultDatabaseFilePath);
                    Ap.Options.CurrentGameGuid             = base.Game.GameData.Guid;
                    Ap.Options.CurrentGameDatabaseFilePath = Ap.DefaultDatabaseFilePath;
                    Ap.Options.Save();
                }
            }
        }
Exemple #3
0
        public void SaveGameInCurrentGameDatabase()
        {
            InfinityChess.GameData.frmGameData frmGameData = new InfinityChess.GameData.frmGameData(this.MainForm);
            frmGameData.Game = this.Game;

            if (frmGameData.ShowDialog(this) == DialogResult.OK)
            {
                string fileName = Ap.Options.CurrentDatabaseFilePath;
                if (!fileName.EndsWith(Files.DatabaseExtension))
                {
                    fileName = fileName + Files.DatabaseExtension;
                }
                this.Game.GameData.Guid = string.Empty;
                this.Game.SaveGame(fileName);
                Ap.Databases.Add(fileName);
                Ap.Options.CurrentGameDatabaseFilePath = fileName;
                Ap.Options.CurrentGameGuid             = this.Game.GameData.Guid;
                Ap.Options.Save();
                MainForm.GameSelectedMode();
                this.FocusOpenedDatabaseForm();
            }
        }
Exemple #4
0
        public void ReplaceGameInCurrentGameDatabase()
        {
            InfinityChess.GameData.frmGameData frmGameData = new InfinityChess.GameData.frmGameData(this.MainForm);
            frmGameData.Game = this.Game;

            if (frmGameData.ShowDialog(this) == DialogResult.OK)
            {
                string fileName = string.Empty;

                if (Ap.Options.CurrentGameGuid == string.Empty)
                {
                    fileName = Ap.Options.DefaultGameDatabaseFilePath;
                    this.Game.GameData.Guid = string.Empty;
                    this.Game.SaveGame(fileName);
                    Ap.Databases.Add(fileName);
                    Ap.Options.CurrentGameDatabaseFilePath = fileName;
                    Ap.Options.CurrentGameGuid             = this.Game.GameData.Guid;
                    Ap.Options.Save();
                    MainForm.GameSelectedMode();
                    this.FocusOpenedDatabaseForm();
                }
                else
                {
                    fileName = Ap.Options.CurrentGameDatabaseFilePath;
                    Ap.LoadDatabase(fileName);
                    GameItem gameItem         = Ap.Database.GameItems.GetGameByGuid(Ap.Options.CurrentGameGuid);
                    int      currentGameIndex = Ap.Database.GameItems.GetCurrentGameIndex();
                    this.Game.GameData.Guid = Ap.Options.CurrentGameGuid;
                    string updatedGameXml = this.Game.GetGameXml();
                    Ap.Database.UpdateGame(updatedGameXml, currentGameIndex);
                    Ap.Database.Save();
                    MainForm.GameSelectedMode();
                    this.FocusOpenedDatabaseForm();
                }
            }
        }