private void StartFlash() { var args = new MiFlasherArgs() { DevBasicInfo = new DeviceBasicInfo() { State = DeviceState.Fastboot, Serial = ShowInfo.Serial, }, BatFileName = ((BatInfo)CBFlashType.SelectedItem).FullPath }; _currentMiFlasher = new MiFlasher(); _currentMiFlasher.Init(args); _currentMiFlasher.OutputReceived += (s, _e) => { this.Dispatcher.Invoke(() => { TBOutput.AppendText(_e.Text + "\n"); TBOutput.ScrollToEnd(); }); }; _currentMiFlasher.Finished += (s, _e) => { this.Dispatcher.Invoke(() => { ChangeState(_e.Result.ResultType == Basic.FlowFramework.ResultType.Successful ? State.Successful : State.Fail); }); }; _currentMiFlasher.RunAsync(); ChangeState(State.Flashing); }
public PullingWindow(IFcuntionFlowBase _flow) { InitializeComponent(); flow = _flow; flow.OutputReceived += (s, e) => { this.Dispatcher.Invoke(() => { TBOutput.AppendText(e.Text); TBOutput.ScrollToEnd(); }); }; flow.NoArgFinished += (s, e) => { this.Dispatcher.Invoke(() => { Close(); }); }; if (flow.IsClosed) { throw new Exception("do not run flow!"); } flow.MustTiggerAnyFinishedEvent = true; }
public void Write(string txt) { if (NextIsLineBeginning) { Data.Text += DateTime.Now.ToString("[dd.MM.yyyy - HH:mm:ss] "); this.NextIsLineBeginning = false; } Data.Text += txt; TBOutput.Dispatcher.Invoke(new Action(() => { TBOutput.ScrollToEnd(); TBOutput.ScrollToEnd(); })); this.NextIsLineBeginning = txt.EndsWith("\n"); /* * string[] lines = txt.Split('\n'); * * * * string s = txt; * Data.Text += s; * TBOutput.Dispatcher.Invoke(new Action(()=>{ * TBOutput.ScrollToEnd(); * TBOutput.ScrollToEnd(); * })); */ }
public RunningWindow() { InitializeComponent(); ViewModel = new VMRunningWindow(this); DataContext = ViewModel; TBOutput.TextChanged += (s, e) => { TBOutput.ScrollToEnd(); }; }
public ApkInstallingWindow(ApkInstaller installer, List <FileInfo> files) { InitializeComponent(); this.installer = installer; _apkFilesCount = files.Count; Owner = App.Current.MainWindow; TBCountOfInstalled.Text = $"{_alreadyInstalledCount}/{_apkFilesCount}"; this.installer.Finished += (s, e) => { this.Dispatcher.Invoke(() => { Close(); new FlowResultWindow(e.Result).ShowDialog(); }); }; this.installer.OutputReceived += (s, e) => { this.Dispatcher.Invoke(() => { var bytes = Encoding.Default.GetBytes(e.Text); TBOutput.AppendText(Encoding.UTF8.GetString(bytes) + "\n"); TBOutput.ScrollToEnd(); }); }; this.installer.AApkIstanlltionCompleted += (s, e) => { this.Dispatcher.Invoke(() => { ProgressAdd(); if (!e.IsSuccess) //如果这次安装是失败的 { //询问用户是否在安装失败的情况下继续 //TODO } }); return(true); }; }
private void TBOutput_TextChanged(object sender, TextChangedEventArgs e) { TBOutput.ScrollToEnd(); }