コード例 #1
0
ファイル: frmMain.cs プロジェクト: paarthenon/chummer5a
        public frmMain()
        {
            InitializeComponent();
            Version version           = Assembly.GetExecutingAssembly().GetName().Version;
            string  strCurrentVersion = string.Format("{0}.{1}.{2}", version.Major, version.Minor, version.Build);

            this.Text = string.Format("Chummer 5a - Version " + strCurrentVersion);

#if DEBUG
            Text += " DEBUG BUILD";
#endif

            LanguageManager.Instance.Load(GlobalOptions.Instance.Language, this);

            /** Dashboard **/
            //this.toolsMenu.DropDownItems.Add("GM Dashboard").Click += this.dashboardToolStripMenuItem_Click;
            /** End Dashboard **/

            // If Automatic Updates are enabled, check for updates immediately.

#if RELEASE
            if (Utils.GitUpdateAvailable() > 0)
            {
                if (GlobalOptions.Instance.AutomaticUpdate)
                {
                    frmUpdate frmAutoUpdate = new frmUpdate();
                    frmAutoUpdate.SilentMode = true;
                    frmAutoUpdate.Visible    = false;
                    frmAutoUpdate.ShowDialog(this);
                }
                else
                {
                    this.Text += String.Format(" - Update {0} now available!", Utils.GitVersion());
                }
            }
#endif

            GlobalOptions.Instance.MRUChanged += PopulateMRU;

            // Delete the old executable if it exists (created by the update process).
            if (File.Exists("Chummer.exe.old"))
            {
                try
                {
                    File.Delete("Chummer.exe.old");
                }
                catch
                {
                }
            }

            // Populate the MRU list.
            PopulateMRU();

            // Retrieve the arguments passed to the application. If more than 1 is passed, we're being given the name of a file to open.
            string[] strArgs = Environment.GetCommandLineArgs();
            if (strArgs.GetUpperBound(0) > 0)
            {
                if (strArgs[1] != "/debug")
                {
                    LoadCharacter(strArgs[1]);
                }
                if (strArgs.Length > 2)
                {
                    if (strArgs[2] == "/test")
                    {
                        frmTest frmTestData = new frmTest();
                        frmTestData.Show();
                    }
                }
            }

            GlobalOptions.Instance.MainForm = this;

            // Set the Tag for each ToolStrip item so it can be translated.
            foreach (ToolStripMenuItem objItem in menuStrip.Items.OfType <ToolStripMenuItem>())
            {
                if (objItem.Tag != null)
                {
                    objItem.Text = LanguageManager.Instance.GetString(objItem.Tag.ToString());
                }
            }

            // ToolStrip Items.
            foreach (ToolStrip objToolStrip in this.Controls.OfType <ToolStrip>())
            {
                foreach (ToolStripButton objButton in objToolStrip.Items.OfType <ToolStripButton>())
                {
                    if (objButton.Tag != null)
                    {
                        objButton.Text = LanguageManager.Instance.GetString(objButton.Tag.ToString());
                    }
                }
            }

            // Attempt to cache the XML files that are used the most.
            try
            {
                Timekeeper.Start("cache_load");
                XmlManager.Instance.Load("armor.xml");
                XmlManager.Instance.Load("bioware.xml");
                XmlManager.Instance.Load("books.xml");
                XmlManager.Instance.Load("cyberware.xml");
                XmlManager.Instance.Load("gear.xml");
                XmlManager.Instance.Load("lifestyles.xml");
                XmlManager.Instance.Load("metatypes.xml");
                XmlManager.Instance.Load("qualities.xml");
                XmlManager.Instance.Load("ranges.xml");
                XmlManager.Instance.Load("skills.xml");
                XmlManager.Instance.Load("vehicles.xml");
                XmlManager.Instance.Load("weapons.xml");
                Timekeeper.Finish("cache_load");
            }
            catch
            {
            }
        }