protected override void NetworkChanged() { DrawOutputOnBitmap(); OutputControl.Refresh(); }
private void CreateOutputPage() { m_OutputPage = new Page("Output"); m_OutputPage.SuspendLayout(); m_OutputControl = new OutputControl() { Id = "Output" }; m_OutputPage.AddControl( m_OutputControl, true ); m_PictureBox = new PictureBox(); ((System.ComponentModel.ISupportInitialize)(m_PictureBox)).BeginInit(); m_PictureBox.Location = new System.Drawing.Point(0, 0); m_PictureBox.Margin = new System.Windows.Forms.Padding(0, 6, 0, 0); m_PictureBox.Size = new System.Drawing.Size(32, 32); m_PictureBox.TabStop = false; //m_PictureBox.Image = NoConsoleLib.Properties.Resources.circle_green; ((System.ComponentModel.ISupportInitialize)(m_PictureBox)).EndInit(); m_InfoTextBox = new InfoTextbox(); m_InfoTextBox.SetHeightRows( 2 ); m_KillButton = new Button(); m_KillButton.Image = NoConsoleLib.Properties.Resources.Skull; m_KillButton.Location = new System.Drawing.Point(0, 0); m_KillButton.Size = new System.Drawing.Size(26, 26); Lib.ToolTip.SetToolTip(m_KillButton, "Kill"); m_KillButton.UseVisualStyleBackColor = true; m_KillButton.Click += new System.EventHandler(this.OnKillClick); TableLayoutPanel tableLayoutPanel1 = new TableLayoutPanel(); tableLayoutPanel1.SuspendLayout(); tableLayoutPanel1.ColumnCount = 3; tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 32F + 12f)); tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 32F)); tableLayoutPanel1.RowCount = 1; tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); tableLayoutPanel1.Controls.Add(m_PictureBox, 0, 0); tableLayoutPanel1.Controls.Add(m_InfoTextBox, 1, 0); tableLayoutPanel1.Controls.Add(m_KillButton, 2, 0); tableLayoutPanel1.Location = new System.Drawing.Point(0, 0); tableLayoutPanel1.Margin = new System.Windows.Forms.Padding(0, 0, 0, 0); tableLayoutPanel1.Size = new System.Drawing.Size(300, 32 + 6); m_OutputPage.AddControl(tableLayoutPanel1); tableLayoutPanel1.ResumeLayout(false); m_OutputPage.ResumeLayout(); }
//returns true if it actually started something private bool StartNext() { if (OwnInProgressIDs.Count >= (int)(UDNumThreads.Value)) { return(false); } var Startables = GetStartables(); if (Startables.Count == 0) { EmptyStartables(); return(false); } //Startables.Sort((a, b) => CompareTuple( new Tuple<int, int>(a.id.WF + a.id.BF, -a.id.W - a.id.B), new Tuple<int, int>(b.id.WF + b.id.BF, -b.id.W - b.id.B))); //WuSec w = Startables[0]; WuSec w = ChooseRandom(Startables); FileStream lockfile = null; try { lockfile = File.Create(LockFileDir + '\\' + w.id.ToString() + "." + Mode.ToString() + "lock"); } catch (Exception) //majd meg kell nezni, hogy ez pontosan milyen exception { return(false); } lock (this) { OwnInProgressIDs.Add(w.id); } Process p = new Process(); p.StartInfo = new ProcessStartInfo( //Application.StartupPath + "\\..\\..\\..\\x64\\Release\\malom_megoldas", ExeToStart, w.id.W.ToString() + " " + w.id.B.ToString() + " " + w.id.WF.ToString() + " " + w.id.BF.ToString() + " -" + Mode.ToString()); p.StartInfo.WorkingDirectory = DataDir; p.StartInfo.UseShellExecute = false; //p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; //ez valahogy nem mukodik //p.StartInfo.WindowStyle = ProcessWindowStyle.Minimized; //ez se p.StartInfo.CreateNoWindow = true; p.StartInfo.RedirectStandardOutput = true; //p.StartInfo.RedirectStandardError = true; RunnerThread = new Thread(() => { p.Start(); ShowOutputControl OutputControl = null; this.Invoke(new Action(() => { //OutputForm = new ShowOutput(); //OutputForm.Text = w.id.ToString(); ////OutputForm.WindowState = FormWindowState.Minimized; //OutputForm.Show(); //OutputForm.StartReadOutput(p.StandardOutput); OutputControl = new ShowOutputControl(); OutputControl.Parent = flowLayoutPanel; OutputControl.StartReadOutput(p.StandardOutput); })); try { p.WaitForExit(); } catch (Win32Exception) { } //if it already exited try { this.Invoke(new Action(() => { OutputControl.DelayedClose(); })); } catch (InvalidOperationException) { } //form was closed if (p.ExitCode != 0) { this.Invoke(new Action(() => this.Activate())); MessageBox.Show("Nonzero exit code when running " + w.id.ToString() + " (code: " + p.ExitCode.ToString() + ")"); } lock (this) { OwnInProgressIDs.Remove(w.id); } lockfile.Close(); this.BeginInvoke(new Action(UpdateWuSecStatuses)); this.BeginInvoke(new Action(RepeatStartNext)); }); RunnerThread.IsBackground = true; //this.Text = (VerificationMode ? "Verifying " : "Solving ") + w.ToString(); RunnerThread.Start(); return(true); }