public SearchDialog( ProcessModel model ) { InitializeComponent(); splitContainer1.IsSplitterFixed = true; _model = model; }
public void OnSave( ProcessModel model ) { this.FileName = model.FileName; this.Args = model.Args; this.ManualControl = model.ManualControl; this.WorkDir = model.WorkDir; }
public void OnLoad( ProcessModel model ) { model.FileName = this.FileName; model.Args = this.Args; model.ManualControl = this.ManualControl; model.WorkDir = this.WorkDir; }
public ProcessModel AddProcess(TabInfo tab) { var model = new ProcessModel( ); model.invoker = _invoker; tab.OnLoad(model); var obj = OnProcessCreate( model ); _modelByID.Add(obj, model); return model; }
// 命名规则: 与svc同目录下, svc.exe 对应的批处理是 svc_Build.bat void RunSvcShell(ProcessModel svcModel, bool startAfterDone) { if (!svcModel.Valid) return; // 还在跑的进程, 必须停下来 if (svcModel.Running) { svcModel.Stop(); } var buildcmd = Path.Combine(Path.GetDirectoryName(svcModel.FileName), Path.GetFileNameWithoutExtension(svcModel.FileName) + "_Build") + ".bat"; var shellModel = new ProcessModel(); shellModel.FileName = buildcmd; shellModel.invoker = this; shellModel.CanStop = false; shellModel.OnStart += (m) => { m.WriteLog(Color.Yellow, "启动Shell: " + buildcmd); }; Action<ProcessModel> stopProc = (m) => { m.WriteLog(Color.Yellow, "结束Shell: " + buildcmd); // 编译正常时, 启动进程 if (startAfterDone && shellModel.ExitCode == 0) { svcModel.Start(); } }; shellModel.OnStop += stopProc; shellModel.OnExit += stopProc; shellModel.OnLog += svcModel.OnLog; shellModel.OnError += svcModel.OnError; shellModel.Start(); RefreshButtonStatus(); }
void OnProcessStop(ProcessModel model) { tabMain.Refresh(); }
void OnProcessStart(ProcessModel model ) { model.WriteLog(Color.Yellow, "进程启动 "); RefreshButtonStatus(); tabMain.Refresh(); }
void OnProcessExit(ProcessModel model) { RefreshButtonStatus(); tabMain.Refresh(); model.WriteLog(Color.Yellow, string.Format("进程结束({0})", model.ExitCode) ); }
object OnProcessCreate(ProcessModel model) { var name = Path.GetFileNameWithoutExtension(model.FileName); var page = new TabPage(name); page.ContextMenuStrip = logMenu; var logview = new LogView(); page.ToolTipText = model.FileName; page.Controls.Add(logview); tabMain.TabPages.Add(page); model.Index = tabMain.TabPages.IndexOf(page); tabMain.SelectedTab = page; tabMain.MouseClick += (sender, e) => { if ( e.Button == System.Windows.Forms.MouseButtons.Right ) { tabMenu.Show(tabMain, e.Location); } }; Action<ProcessModel, Color, string> logProc = (m, c, data) => { logview.AddLog(c, data, model.AutoScroll); }; model.OnStart += OnProcessStart; model.OnStop += OnProcessStop; model.OnExit += OnProcessExit; model.OnLog += logProc; model.OnError += logProc; model.view = logview; model.OnClear += delegate() { logview.Items.Clear(); }; model.OnGetData += ( index ) => { return logview.Items[index] as LogData; }; model.OnGetDataCount += ( ) => { return logview.Items.Count; }; model.OnGetAllLog += delegate() { return logview.AllLogToString(); }; model.OnGetSelectedContent += delegate() { var logdata = logview.SelectedItem as LogData; if (logdata == null) return string.Empty; return logdata.Text; }; model.WriteLog(Color.Yellow, "就绪"); return page; }
object OnProcessCreate(ProcessModel model) { var name = Path.GetFileNameWithoutExtension(model.FileName); var page = new TabPage(name); page.ContextMenuStrip = logMenu; var logview = new LogView(); page.ToolTipText = model.FileName; page.Controls.Add(logview); tabMain.TabPages.Add(page); model.Index = tabMain.TabPages.IndexOf(page); tabMain.SelectedTab = page; tabMain.MouseClick += (sender, e) => { if (e.Button == System.Windows.Forms.MouseButtons.Right) { tabMenu.Show(tabMain, e.Location); } }; Action <ProcessModel, Color, string> logProc = (m, c, data) => { logview.AddLog(c, data, model.AutoScroll); }; model.OnStart += OnProcessStart; model.OnStop += OnProcessStop; model.OnExit += OnProcessExit; model.OnLog += logProc; model.OnError += logProc; model.view = logview; model.OnClear += delegate() { logview.Items.Clear(); }; model.OnGetData += (index) => { return(logview.Items[index] as LogData); }; model.OnGetDataCount += () => { return(logview.Items.Count); }; model.OnGetAllLog += delegate() { return(logview.AllLogToString()); }; model.OnGetSelectedContent += delegate() { var logdata = logview.SelectedItem as LogData; if (logdata == null) { return(string.Empty); } return(logdata.Text); }; model.WriteLog(Color.Yellow, "就绪"); return(page); }