public SearchDialog( ProcessModel model )
        {
            InitializeComponent();
            splitContainer1.IsSplitterFixed = true;

            _model = model;
        }
Exemple #2
0
 public void OnSave( ProcessModel model )
 {
     this.FileName = model.FileName;
     this.Args = model.Args;
     this.ManualControl = model.ManualControl;
     this.WorkDir = model.WorkDir;
 }
Exemple #3
0
 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;
        }
Exemple #5
0
        // 命名规则: 与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();
        }
Exemple #6
0
 void OnProcessStop(ProcessModel model)
 {
     tabMain.Refresh();
 }
Exemple #7
0
        void OnProcessStart(ProcessModel model )
        {
            model.WriteLog(Color.Yellow, "进程启动 ");

            RefreshButtonStatus();

            tabMain.Refresh();
        }
Exemple #8
0
        void OnProcessExit(ProcessModel model)
        {
            RefreshButtonStatus();

            tabMain.Refresh();

            model.WriteLog(Color.Yellow, string.Format("进程结束({0})", model.ExitCode) );
        }
Exemple #9
0
        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;
        }
 void OnProcessStop(ProcessModel model)
 {
     tabMain.Refresh();
 }
        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);
        }