/// <summary> /// Resize the job control. /// </summary> private void _resizeControl(CadKit.Threads.GUI.Job job) { if (null != job) { lock (this.Mutex) { // The value "26" keeps the horizontal scroll bar from // showing when the vertical one shows. job.Size = new System.Drawing.Size(_layout.Width - 26, job.Height); } } }
/// <summary> /// Get the mutex. /// </summary> private Job _findRow(CadKit.Threads.Jobs.Job job) { // Should be true. System.Diagnostics.Debug.Assert(false == this.InvokeRequired); ControlList controls = this.ControlsCopy; foreach (System.Windows.Forms.Control control in controls) { CadKit.Threads.GUI.Job row = control as CadKit.Threads.GUI.Job; if (null != row) { if (row.getJob() == job) { return(row); } } } return(null); }
/// <summary> /// Add the job. /// </summary> private void _add(CadKit.Threads.Jobs.Job job) { try { if (null == job) { return; } if (true == this.InvokeRequired) { this.BeginInvoke(new VoidReturnJobArgument(this._add), new object[] { job }); } else { // Should already be added to manager. System.Diagnostics.Debug.Assert(true == CadKit.Threads.Jobs.Manager.Instance.Contains(job)); // Make a new job row. CadKit.Threads.GUI.Job row = new CadKit.Threads.GUI.Job(job); // Add it to the control. lock (this.Mutex) { _layout.Controls.Add(row); } // Resize it to fit. this._resizeControl(row); // Repaint. lock (this.Mutex) { _layout.Invalidate(true); _layout.Update(); } } } catch (System.Exception e) { System.Console.WriteLine("Error 2946493990: {0}", e.Message); } }
/// <summary> /// Remove the job. /// </summary> private void _remove(CadKit.Threads.Jobs.Job job) { try { if (null == job) { return; } if (true == this.InvokeRequired) { this.BeginInvoke(new VoidReturnJobArgument(this._remove), new object[] { job }); } else { // Should already be removed from manager. System.Diagnostics.Debug.Assert(false == CadKit.Threads.Jobs.Manager.Instance.Contains(job)); // Find the row. CadKit.Threads.GUI.Job row = this._findRow(job); if (null != row) { lock (this.Mutex) { // Remove the job row. _layout.Controls.Remove(row); _layout.Invalidate(true); _layout.Update(); } } } } catch (System.Exception e) { System.Console.WriteLine("Error 2867827834: {0}", e.Message); } }