示例#1
0
        /// <summary>
        /// Exports a Pandora's Box profile
        /// </summary>
        /// <param name="p">The profile to export</param>
        public void ExportProfile()
        {
            System.Windows.Forms.SaveFileDialog dlg = new SaveFileDialog();
            dlg.Filter = "Pandora's Box Profile (*.pbp)|*.pbp";

            if (dlg.ShowDialog() == DialogResult.OK)
            {
                ProfileIO pio = new ProfileIO(_profile);
                pio.Save(dlg.FileName);
            }

            dlg.Dispose();
        }
示例#2
0
        public static Profile Load(string filename)
        {
            // Uncompress first of all
            FileStream fs = new FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.Read);

            byte[] data = new byte[fs.Length];
            fs.Read(data, 0, data.Length);
            fs.Close();

            byte[] uncompressed = TheBox.Common.BoxZLib.Decompress(data);

            string temp = Path.Combine(Pandora.Folder, "temp.dll");

            fs = new FileStream(temp, FileMode.Create, FileAccess.Write, FileShare.Read);
            fs.Write(uncompressed, 0, uncompressed.Length);
            fs.Close();

            if (!File.Exists(temp))
            {
                return(null);
            }

            Assembly asm = Assembly.LoadFile(temp);

            // Get ProfileIO object
            ProfileIO prof = Utility.GetEmbeddedObject(typeof(ProfileIO), "ProfileIO.xml", asm) as ProfileIO;

            if (prof == null)
            {
                return(null);
            }

            if (prof.ProfileVersion > m_CurrentVersion)
            {
                if (Pandora.Localization.TextProvider != null)
                {
                    System.Windows.Forms.MessageBox.Show(Pandora.Localization.TextProvider["Misc.ProfileIOErr"]);
                }
                else
                {
                    System.Windows.Forms.MessageBox.Show("Please upgrade your version of Pandora's Box.\n\nThe profile you are importing has been created with a more recent version of this software.");
                }
            }

            prof.Generate(asm);

            Profile p = new Profile();

            p.Name = prof.Name;
            p.General.CommandPrefix     = prof.CommandPrefix;
            p.Deco.ShowCustomDeco       = prof.CustomDeco;
            p.Travel.EnabledMaps        = prof.EnabledMaps;
            p.Travel.MapNames           = prof.MapNames;
            p.Travel.CustomMaps         = prof.CustomMaps;
            p.General.Modifiers         = prof.Modifiers;
            p.General.ModifiersWarnings = prof.ModifierWarnings;
            p.General.SpeechPresets     = prof.SpeechPresets;
            p.General.WebPresets        = prof.WebPresets;
            p.Server.Enabled            = prof.UseServer;
            p.Server.Address            = prof.Server;
            p.Server.Port = prof.Port;
            p.Commands    = prof.Commands;

            p.Save();

            return(p);
        }