private void RegisterEvent()
 {
     DevicesPanel.SelectionChanged += (s, e) =>
     {
         if (this.DevicesPanel.CurrentSelectDevice.State == DeviceState.None)//如果没选择
         {
             Reset();
         }
         else
         {
             Refresh(this.DevicesPanel.CurrentSelectDevice);
         }
     };
     FunctionFlowBase.AnyFinished    += FlowFinished;
     AdbHelper.AdbServerStartsFailed += (s, e) =>
     {
         DevicesMonitor.Stop();
         bool _continue = true;
         Dispatcher.Invoke(() =>
         {
             _continue = BoxHelper.ShowChoiceDialog("msgWarning",
                                                    "msgStartAdbServerFail",
                                                    "btnExit", "btnIHaveCloseOtherPhoneHelper")
                         .ToBool();
         });
         if (!_continue)
         {
             Close();
         }
         else
         {
             Task.Run(() =>
             {
                 Thread.Sleep(3000);
                 App.Current.Dispatcher.Invoke(DevicesMonitor.Begin);
             });
         }
     };
 }
Exemple #2
0
        public void Load()
        {
#if PAID_VERSION
            App.Current.Dispatcher.Invoke(() =>
            {
                loadingWindowApi.SetProgress(10);
                loadingWindowApi.SetTip(App.Current.Resources["ldmsgLoginAccount"].ToString());
            });
            if (Login() == false)
            {
                App.Current.Dispatcher.Invoke(() => App.Current.Shutdown(1));
            }
#endif
            //如果设置在启动时打开调试窗口
            if (Settings.Default.ShowDebuggingWindowNextLaunch)
            {
                //打开调试窗口
                App.Current.Dispatcher.Invoke(() =>
                {
                    new DebugWindow().Show();
                });
            }
            PrintInfo();
            //启动ADB服务
            App.Current.Dispatcher.Invoke(() =>
            {
                loadingWindowApi.SetProgress(30);
                loadingWindowApi.SetTip(App.Current.Resources["ldmsgStartAdb"].ToString());
            });

            bool success  = false;
            bool tryAgain = true;
            while (!success)
            {
                Logger.Info(this, "Try to start adb server ");
                success = AdbHelper.StartServer();
                Logger.Info(this, success ? "adb server starts success" : "adb server starts failed...");
                if (!success)
                {
                    App.Current.Dispatcher.Invoke(() =>
                    {
                        tryAgain = BoxHelper.ShowChoiceDialog(
                            "msgWarning",
                            "msgStartAdbServerFail",
                            "btnExit", "btnIHaveCloseOtherPhoneHelper").ToBool();
                    });
                }
                if (tryAgain)
                {
                    Thread.Sleep(2000);
                }
                else
                {
                    App.Current.Dispatcher.Invoke(() =>
                    {
                        App.Current.Shutdown(App.HAVE_OTHER_PROCESS);
                    });
                }
            }
            App.Current.Dispatcher.Invoke(() =>
            {
                //初始化主窗口
                App.Current.MainWindow = new MainWindow();
                //初始化拓展模块及其API框架
                loadingWindowApi.SetProgress(60);
                loadingWindowApi.SetTip(App.Current.Resources["ldmsgLoadingExtensions"].ToString());
            });
            OpenFrameworkManager.LoadApi();
            App.Current.OpenFrameworkManager.ReloadAllScript();
            App.Current.OpenFrameworkManager.LoadAllExtension();

            //启动设备拔插监听器
            App.Current.Dispatcher.Invoke(() =>
            {
                loadingWindowApi.SetProgress(80);
                loadingWindowApi.SetTip(App.Current.Resources["ldmsgStartDeviceMonitor"].ToString());
            });
            DevicesMonitor.Begin();

            //加载完成,启动主界面
            App.Current.Dispatcher.Invoke(() =>
            {
                loadingWindowApi.SetProgress(100);
                loadingWindowApi.Finish();
                App.Current.MainWindow.Show();
            });
        }
Exemple #3
0
 public TestUSBForm()
 {
     InitializeComponent();
     lblMessage.Text = MSG_ATTACH;
     _devicesMonitor = new DevicesMonitor();
 }
 private ConnectedDevicesListener()
 {
     monitor = new DevicesMonitor();
     monitor.DevicesChanged += ConnectedDevicesListener_DevicesChanged;
 }