Esempio n. 1
0
        public void LoadSession()
        {
            if (isDirty)
            {
                if (!Exit())
                {
                    return;
                }
            }
            OpenFileDialog load = new OpenFileDialog();

            if (startFolder != "")
            {
                load.InitialDirectory = startFolder;
            }

            load.Filter = "Session File (*.ssn)|*.ssn";
            DialogResult result = load.ShowDialog();

            FilePath = load.FileName;
            SessionDetail.FilePath = load.FileName;

            if (result == DialogResult.OK)
            {
                if (File.Exists(FilePath))
                {
                    saver = new BattleIO();
                    SessionDetail newParent = saver.LoadObject <SessionDetail>(FilePath);
                    if (newParent == null)
                    {
                        sendingForm.WriteToLog("Load failed. Invalid file loaded.");
                    }
                    else
                    {
                        sendingForm.ExtractFields(newParent);
                        if (newParent.combatants.Count > 0)
                        {
                            sendingForm.enableGlobalButtons(); sendingForm.enableTurnButtons();
                        }
                        else
                        {
                            sendingForm.ResetControls();
                        }

                        sendingForm.WriteToLog("===============  SESSION LOADED ON " + DateTime.Now + " ===============");
                        startFolder = Path.GetDirectoryName(FilePath);
                        Program.activeSessionName = Path.GetFileName(FilePath);
                        sendingForm.Text          = Program.ProgramName + " - " + Path.GetFileName(FilePath);

                        isDirty = false;
                    }
                }
            }
        }
Esempio n. 2
0
        public void LoadSettings(string path)
        {
            string settingsName = Path.GetDirectoryName(path) + @"\" + Path.GetFileNameWithoutExtension(path) + "_settings.xml";

            if (File.Exists(settingsName))
            {
                Settings newSettings = saver.LoadObject <Settings>(settingsName);
                if (newSettings == null)
                {
                    sendingForm.WriteToLog("No settings found for this session. Using defaults");
                }
                else
                {
                    settings = newSettings;
                }
            }
        }