예제 #1
0
파일: MainForm.cs 프로젝트: sonygod/dotahit
        public MainForm(bool smoothWakeUp)
        {
            Current.mainForm = this;

            this.SuspendLayout();

            hlForm = new HeroListForm();
            ilForm = new ItemListForm();
            cbForm = new ControlBarForm();

            splashScreen = new SplashScreen();
            splashScreen.Show();
            splashScreen.ShowText("Initializing...");

            DHRC.pfStartCount();
            Control.CheckForIllegalCrossThreadCalls = false;

            FloatingForms.AddRange(new FloatingListForm[] { hlForm, ilForm });

            splashScreen.ProgressAdd(30);

            InitializeComponent(); splashScreen.ProgressAdd(30);
            this.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.Opaque | ControlStyles.OptimizedDoubleBuffer, true);

            this.Icon = Properties.Resources.Icon;

            this.CenterToScreen();
            this.Top = this.Top + (hlForm.Height / 2);

            GatherAbilitySlots(); splashScreen.ProgressAdd(10);

            heroInfoPanel.Visible = false;
            heroSkillsPanel.Visible = false;

            hlForm.SetParent(this);

            ilForm.SetParent(this);
            ilForm.ItemActivate += new ItemListForm.ItemActivateEvent(ilForm_ItemActivate);

            cbForm.SetParent(this, FloatingForms);

            splashScreen.ProgressAdd(30);

            splashScreen.Close();

            DisplayUnit();

            cbForm.ApplyConfig();

            int hlX = hlForm.Left;
            hlForm.Left = -this.Width; // hide it to avoid flickering

            int ilX = ilForm.Left;
            ilForm.Left = -this.Width;

            hlForm.Display();
            ilForm.Display();

            hlForm.Minimize(true);
            ilForm.Minimize(true);

            hlForm.Left = hlX;
            ilForm.Left = ilX;

            mapNameLabel.Text = "";
            statusTS.Renderer = UIRenderers.NoBorderRenderer;

            saveFileDialog.InitialDirectory = Application.StartupPath;

            ApplyConfig();

            this.themeToolStripMenuItem.Enabled = false;

            this.ResumeLayout(false);

            if (!File.Exists(DHCFG.FileName))
            {
                this.Show();

                List<string> fileTypes = new List<string>(new string[] { ".dhb" });
                DHCFG.Items["Settings"]["FileTypes"] = fileTypes;
                DHFILE.AssociateFileTypes(fileTypes);

                MessageBox.Show("Hi. Configuration file (dotahit.cfg) was not found so you're probably running this program for the first time." +
                    "\nTo start working you need to open a DotA map file (like 'Dota Allstars 6.43b.w3x') by using the 'DotA map'->'Open...' option." +
                    "\nAlternatively you can just drag a map file onto the main window and it will be opened automatically.", "Introduction");
            }

            Theme theme = (Theme)DHCFG.Items["UI"].GetIntValue("Theme", (int)Theme.None);
            if (IsThemeAvailableOnDisk(theme))
                SetUITheme(theme);

            if (smoothWakeUp)
            {
                wakeupTimer = new System.Windows.Forms.Timer();
                wakeupTimer.Interval = 100;
                wakeupTimer.Tick += new EventHandler(wakeupTimer_Tick);
                wakeupTimer.Start();
            }
            else
                wakeUpThreadProcedure();

            //DHRC.timeCounter = 0;
            GC.Collect();
            DHRC.pfEndCount();
            DHRC.pfPrintCount("Initialization");
            DHRC.pfResetCount();
        }