Ejemplo n.º 1
0
        /// <summary>
        ///     Imports a new profile
        /// </summary>
        /// <param name="filename">The filename to the .pbp file</param>
        /// <returns>True if the profile has been imported and loaded successfully</returns>
        public bool ImportProfile(string filename)
        {
            Pandora.Log.WriteEntry("Importing Profile...");
            _splash.SetStatusText("Importing profile");

            Profile p = null;

            try
            {
                p = ProfileIO.Load(filename);
            }
            catch (Exception err)
            {
                MessageBox.Show(err.ToString());
            }

            if (p == null)
            {
                return(false);
            }
            _profile = p;

            var run = false;

            if (Pandora.ExistingInstance != null)
            {
                // Already running: Close?

                if (MessageBox.Show(
                        null,
                        "Another instance of Pandora's Box is currently running. Would you like to close it and load the profile you have just imported?",
                        "Profile import succesful",
                        MessageBoxButtons.YesNo,
                        MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    if (Pandora.ExistingInstance != null)
                    {
                        Pandora.ExistingInstance.Close();
                    }

                    run = true;
                }
            }
            else
            {
                run = true;
            }

            if (run)
            {
                MessageBox.Show("Profile imported correctly.");
            }

            if (!run)
            {
                _profile = null;
            }

            return(run);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Imports a profile from a PBP file
        /// </summary>
        /// <returns>The Profile object imported</returns>
        public Profile ImportProfile()
        {
            System.Windows.Forms.OpenFileDialog dlg = new OpenFileDialog();
            dlg.Filter = "Pandora's Box Profile (*.pbp)|*.pbp";
            Profile p = null;

            if (dlg.ShowDialog() == DialogResult.OK)
            {
                p = ProfileIO.Load(dlg.FileName);
            }

            dlg.Dispose();

            return(p);
        }