Пример #1
0
        public MainWindow(UpdateMonitor InUpdateMonitor, string InApiUrl, string InDataFolder, string InCacheFolder, bool bInRestoreStateOnLoad, string InOriginalExecutableFileName, bool bInUnstable, DetectProjectSettingsResult[] StartupProjects, LineBasedTextWriter InLog, UserSettings InSettings)
        {
            InitializeComponent();

            UpdateMonitor = InUpdateMonitor;
            MainThreadSynchronizationContext = SynchronizationContext.Current;
            ApiUrl                     = InApiUrl;
            DataFolder                 = InDataFolder;
            CacheFolder                = InCacheFolder;
            bRestoreStateOnLoad        = bInRestoreStateOnLoad;
            OriginalExecutableFileName = InOriginalExecutableFileName;
            bUnstable                  = bInUnstable;
            Log      = InLog;
            Settings = InSettings;

            // While creating tab controls during startup, we need to prevent layout calls resulting in the window handle being created too early. Disable layout calls here.
            SuspendLayout();
            TabPanel.SuspendLayout();

            TabControl.OnTabChanged  += TabControl_OnTabChanged;
            TabControl.OnNewTabClick += TabControl_OnNewTabClick;
            TabControl.OnTabClicked  += TabControl_OnTabClicked;
            TabControl.OnTabClosing  += TabControl_OnTabClosing;
            TabControl.OnTabClosed   += TabControl_OnTabClosed;
            TabControl.OnTabReorder  += TabControl_OnTabReorder;
            TabControl.OnButtonClick += TabControl_OnButtonClick;

            SetupDefaultControl();

            int SelectTabIdx = -1;

            foreach (DetectProjectSettingsResult StartupProject in StartupProjects)
            {
                int TabIdx = -1;
                if (StartupProject.bSucceeded)
                {
                    TabIdx = TryOpenProject(StartupProject.Task, -1, OpenProjectOptions.Quiet);
                }
                else if (StartupProject.ErrorMessage != null)
                {
                    CreateErrorPanel(-1, StartupProject.Task.SelectedProject, StartupProject.ErrorMessage);
                }

                if (TabIdx != -1 && Settings.LastProject != null && StartupProject.Task.SelectedProject.Equals(Settings.LastProject))
                {
                    SelectTabIdx = TabIdx;
                }
            }

            if (SelectTabIdx != -1)
            {
                TabControl.SelectTab(SelectTabIdx);
            }
            else if (TabControl.GetTabCount() > 0)
            {
                TabControl.SelectTab(0);
            }

            StartScheduleTimer();

            if (bUnstable)
            {
                Text += String.Format(" (UNSTABLE BUILD {0})", Assembly.GetExecutingAssembly().GetName().Version);
            }

            AutomationLog    = new TimestampLogWriter(new BoundedLogWriter(Path.Combine(DataFolder, "Automation.log")));
            AutomationServer = new AutomationServer(Request => { MainThreadSynchronizationContext.Post(Obj => PostAutomationRequest(Request), null); }, AutomationLog);

            // Allow creating controls from now on
            TabPanel.ResumeLayout(false);
            ResumeLayout(false);

            bAllowCreatingHandle = true;
        }