コード例 #1
0
ファイル: ProfileIO.cs プロジェクト: aj9251/pandorasbox3
		public ProfileIO( Profile p )
		{
			ProfileVersion = m_CurrentVersion;

			m_Profile = p;

			Name = p.Name;

			Commands = p.Commands;

			CustomDeco = p.Deco.ShowCustomDeco;

			CommandPrefix = p.General.CommandPrefix;
			Modifiers = p.General.Modifiers;
			ModifierWarnings = p.General.ModifiersWarnings;
			SpeechPresets = p.General.SpeechPresets;
			WebPresets = p.General.WebPresets;

			EnabledMaps = p.Travel.EnabledMaps;
			MapNames = p.Travel.MapNames;
			CustomMaps = p.Travel.CustomMaps;

			UseServer = p.Server.Enabled;
			Server = p.Server.Address;
			Port = p.Server.Port;
		}
コード例 #2
0
ファイル: ProfileWizard.cs プロジェクト: aj9251/pandorasbox3
		/// <summary>
		/// Creates a new Profile Wizard
		/// </summary>
		public ProfileWizard(Profile profile)
		{
			// This call is required by the Windows Form Designer.
			InitializeComponent();

			m_Profile = profile;
		}
コード例 #3
0
        /// <summary>
        /// Creates a new Profile Wizard
        /// </summary>
        public ProfileWizard(Profile profile)
        {
            // This call is required by the Windows Form Designer.
            InitializeComponent();

            m_Profile = profile;
        }
コード例 #4
0
ファイル: ProfileIO.cs プロジェクト: aj9251/pandorasbox3
		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;
		}
コード例 #5
0
ファイル: ProfileManager.cs プロジェクト: aj9251/pandorasbox3
        /// <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;
            }
            else
            {
                _profile = p;
            }

            bool 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)
            {
                System.Windows.Forms.MessageBox.Show("Profile imported correctly.");
            }

            if (!run)
            {
                _profile = null;
            }

            return run;
        }
コード例 #6
0
ファイル: ProfileManager.cs プロジェクト: aj9251/pandorasbox3
        /// <summary>
        /// Delete the current profile
        /// </summary>
        public void DeleteCurrentProfile()
        {
            // Have to be refactored when we have a more global GUI handling - Tarion
            // Temporarly deisabled
            //_context.MainForm = null;

            if (Pandora.BoxForm != null)
            {
                Pandora.BoxForm.Close();
                Pandora.BoxForm.Dispose();
            }


            Profile.DeleteProfile(_profile.Name);
            _profile = null;

            // Temporarly deisabled
            //_context.DoProfile();
        }
コード例 #7
0
ファイル: ProfileManager.cs プロジェクト: aj9251/pandorasbox3
 public void LoadProfile(string name)
 {
     _profile = Profile.Load(name);
 }
コード例 #8
0
ファイル: ProfileManager.cs プロジェクト: aj9251/pandorasbox3
        /// <summary>
        /// Closes Pandora's Box and creates a new profile
        /// </summary>
        public void CreateNewProfile(string language)
        {
            Profile profile = new Profile();
            profile.Language = language;
            // TODO: Display GUI to create a new profile. 
            ProfileWizard wiz = new ProfileWizard(profile);
            wiz.ShowDialog();
            profile = wiz.Profile;

            if (wiz.UseProfileAsDefault)
            {
                this.DefaultProfile = wiz.Profile.Name;
            }

            profile.Save();
            profile.CreateData();
            this._profile = profile;
        }
コード例 #9
0
        /// <summary>
        /// Loads a profile
        /// Should be part of the profile manager and need a return value
        /// </summary>
        /// <param name="name">The name of the profile</param>
        private void LoadProfile(string name)
        {
            _splash.SetStatusText("Loading profile");

            try
            {
                _profileManager.LoadProfile(name);
            }
            catch (Exception err)
            {
                Pandora.Log.WriteError(err, "Couldn't load profile {0}", name);

                if (name == _profileManager.DefaultProfile)
                {
                    _profileManager.DefaultProfile = "";
                }

                DoProfile();
                return;
            }

            if (_profileManager.Profile == null)
            {
                string msg = string.Format("The profile {0} is corrupt, therefore it can't be loaded. Would you like to attempt to restore it?", name);

                if (MessageBox.Show(null, msg, "Profile Error", MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    Profile p = new Profile();
                    p.Name = name;
                    p.Save();
                    LoadProfile(name);
                }
                else
                    DoProfile();
                return;
            }

            try
            {
                // To Test show the new form
                /* 
                // Should be handled through the LightCoreBuilder
                // Uncomment to get a first preview of the new form
                BoxForm newBoxForm = new BoxForm();
                Pandora.Localization.LocalizeControl(_newBoxForm);
                newBoxForm.Show();
                */

                IBoxForm boxForm = _container.Resolve<IBoxForm>();
                Pandora.BoxForm = boxForm;
                MainForm = boxForm as Form;
                MainForm.Show();
            }
            catch (Exception err)
            {
                Pandora.Log.WriteError(err, string.Format("Profile {0} failed.", name));
                // Issue 6:  	 Improve error management - Tarion
                // Application.Exit(); Did not worked correctly
                // We could use:  Environment.Exit(1);
                // But better forward the exception to the main function an cancel program there
                throw err;
                // End Issue 6
            }
        }