'form.show doesn't show all the content on the form like forms.showdialog
I am currently developing a GUI that helps users pick a test to run for a DUT. The program controls a bunch of lab equipment via visa com drivers and logs the data and determines the final result of the test. All of this works just fine.
The tests have multiple stages and I want the application to show in which stage the program is at a given point of time via a windows form. So I created the following form.
Each textbox represents a stage in a test and when the stage is done, the background turns green. I need to show this form and keep executing the program. So I used object.show(). It only shows partial form like this:
It shows the complete form if I use object.showdialog(). But the program won't run till I close the form. How can I fix this problem?
Code:
partial class TestUpdateFlowChart
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
public void InitializeComponent()
{
this.DCPower = new System.Windows.Forms.TextBox();
this.GridSim = new System.Windows.Forms.TextBox();
this.Startup = new System.Windows.Forms.TextBox();
this.ExportPower = new System.Windows.Forms.TextBox();
this.NoPower = new System.Windows.Forms.TextBox();
this.PowerOFF = new System.Windows.Forms.TextBox();
this.SuspendLayout();
//
// DCPower
//
this.DCPower.Location = new System.Drawing.Point(721, 53);
this.DCPower.Name = "DCPower";
this.DCPower.Size = new System.Drawing.Size(216, 22);
this.DCPower.TabIndex = 0;
this.DCPower.Text = "PV SImulator ON";
//
// GridSim
//
this.GridSim.Location = new System.Drawing.Point(721, 113);
this.GridSim.Name = "GridSim";
this.GridSim.Size = new System.Drawing.Size(216, 22);
this.GridSim.TabIndex = 1;
this.GridSim.Text = "Grid Active";
//
// Startup
//
this.Startup.Location = new System.Drawing.Point(721, 166);
this.Startup.Name = "Startup";
this.Startup.Size = new System.Drawing.Size(216, 22);
this.Startup.TabIndex = 2;
this.Startup.Text = "Waiting for micro to Export Power";
//
// ExportPower
//
this.ExportPower.Location = new System.Drawing.Point(851, 273);
this.ExportPower.Name = "ExportPower";
this.ExportPower.Size = new System.Drawing.Size(216, 22);
this.ExportPower.TabIndex = 3;
this.ExportPower.Text = "Exporting Power, Logging Data";
//
// NoPower
//
this.NoPower.Location = new System.Drawing.Point(578, 273);
this.NoPower.Name = "NoPower";
this.NoPower.Size = new System.Drawing.Size(216, 22);
this.NoPower.TabIndex = 4;
this.NoPower.Text = "No Power Exported";
//
// PowerOFF
//
this.PowerOFF.Location = new System.Drawing.Point(721, 361);
this.PowerOFF.Name = "PowerOFF";
this.PowerOFF.Size = new System.Drawing.Size(216, 22);
this.PowerOFF.TabIndex = 5;
this.PowerOFF.Text = "Power OFF Equipment";
//
// TestUpdateFlowChart
//
this.ClientSize = new System.Drawing.Size(1837, 927);
this.Controls.Add(this.PowerOFF);
this.Controls.Add(this.NoPower);
this.Controls.Add(this.ExportPower);
this.Controls.Add(this.Startup);
this.Controls.Add(this.GridSim);
this.Controls.Add(this.DCPower);
this.Name = "TestUpdateFlowChart";
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.TextBox DCPower;
private System.Windows.Forms.TextBox GridSim;
private System.Windows.Forms.TextBox Startup;
private System.Windows.Forms.TextBox ExportPower;
private System.Windows.Forms.TextBox NoPower;
private System.Windows.Forms.TextBox PowerOFF;
}
Call:
public class RGTests
{
public TestResult QualTest()
{
TestUpdateFlowChart fc = new TestUpdateFlowChart();
TestVector qualTest = new TestVector("NA", "Qual Test", 600000, 900000,"NA");
// configure test bench
fc.Show();
if (TestRunner.Startup(qualTest, fc))
{
TestRunner.LogData(qualTest);
TestRunner.CreateLogFile(qualTest);
return TestResult.Pass;
}
else
return TestResult.Fail;
}
TestManager:
public class TestManager
{
public TestPriority priority { get; set; }
public TestManager(TestPriority testPriority)
{
priority = testPriority;
}
public TestResult RunTest()
{
RGTests rt = new RGTests();
switch (priority)
{
case TestPriority.A:
{
TestResult QualTestResult = rt.QualTest();
TestResult StandbyPowerResult = rt.StandbyPowerTest();
break;
}
case TestPriority.B:
{
break;
}
case TestPriority.C:
{
break;
}
}
return TestResult.Pass;
}
}
TestRunner:
public class TestRunner
{
// Functions to run tests
public static bool Startup(TestVector tv, TestUpdateFlowChart fc)
{
Stopwatch sw = new Stopwatch();
double dcPow = 0;
sw.Start();
fc.UpdateTextboxColor(TestOperations.Startup);
while (dcPow < 100 && sw.ElapsedMilliseconds < tv.StartupTImeout) // wait for 10 minutes for the pwrmicro to start generating power
{
//dcPow = GetMeasurementFromDCPower(DCPowerCommands.measurePower);
}
sw.Stop();
Console.WriteLine("Time taken for Pwrmicro to start generating power in Seconds: {0}", sw.ElapsedMilliseconds / 1000);
if(dcPow > 100)
return true;
else
return false;
}
public static TestResult LogData(TestVector tv)
{
StringBuilder sb = new StringBuilder();
Stopwatch sw = new Stopwatch();
double dcPow = 0;
while (dcPow > 100 && sw.ElapsedMilliseconds < tv.ExecutionTime)
{
}
string filePath = @"C:\Logs\" + tv.Name.ToString() + ".csv";
if (File.Exists(filePath))
File.Delete(filePath);
File.WriteAllText(filePath, sb.ToString());
return TestResult.Fail;
}
public static TestResult ConfigureTestBench(DeviceManager dm)
{
return TestResult.Fail;
}
public static TestResult InitTestBench(DeviceManager dm)
{
return TestResult.Fail;
}
public static TestResult CreateLogFile(TestVector tv)
{
return TestResult.Fail;
}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|