Пример #1
0
        private void Load()
        {
            LoggingStation.Instance.Work();
            Updater.CheckAndNotice();
            Statistics.Do();
            ui.Progress = 0;
            //如果设置在启动时打开调试窗口
            if (Settings.Default.ShowDebuggingWindowNextLaunch)
            {
                //打开调试窗口
                App.Current.Dispatcher.Invoke(() =>
                {
                    new LogWindow().Show();
                });
            }
            logger.Info("");
            logger.Info("======================");
            logger.Info($"Run as " + (Self.HaveAdminPermission ? "Admin" : "Normal user"));
            logger.Info($"AutumnBox version: {Self.Version}");
            logger.Info($"SDK version: {BuildInfo.SDK_VERSION}");
            logger.Info($"Windows version {Environment.OSVersion.Version}");
            logger.Info("======================");
            logger.Info("===loading===");
#if DEBUG
            Basic.Util.Debugging.LoggingStation.Logging += (s, e) =>
            {
                LoggingStation.Instance.Log(e.Tag, e.Level.ToString(), e.Text);
            };
#endif
            ui.Progress   = 30;
            ui.LoadingTip = App.Current.Resources["ldmsgStartAdb"].ToString();

            try
            {
                logger.Info("trying starts adb server ");
                Adb.DefaultLoad();
                logger.Info("adb server starts successed");
            }
            catch (AdbCommandFailedException e)
            {
                logger.Info("adb server starts failed");
                logger.Warn(e);
                ui.Progress   = 60;
                ui.LoadingTip = App.Current.Resources["ldmsgAdbServerFailed"].ToString();
                Thread.Sleep(10000);
                App.Current.Shutdown(e.ExitCode);
            }
            ui.Progress   = 60;
            ui.LoadingTip = App.Current.Resources["ldmsgLoadingExtensions"].ToString();
            OpenFrameworkManager.Init();
            OpenFxObserver.Instance.OnLoaded();
            ConnectedDevicesListener.Instance.Work();
            ui.Progress   = 100;
            ui.LoadingTip = "Enjoy!";
            Thread.Sleep(1 * 1000);
            logger.Info("===loaded===");
            ui.Finish();
        }