|
using System;
namespace QTools
{
/// <summary>
/// Summary description for ConfigControl.
/// </summary>
public class ConfigControl : System.Windows.Forms.UserControl
{
protected System.Windows.Forms.Label lblLogging;
protected System.Windows.Forms.ComboBox cboLogging;
protected System.Windows.Forms.TextBox txtSimultaneous;
protected System.Windows.Forms.TextBox txtIterations;
protected System.Windows.Forms.ComboBox cboUsers;
protected System.Windows.Forms.Label lblSimulatenous;
protected System.Windows.Forms.Label lblIterations;
protected System.Windows.Forms.Label lblUserType;
protected System.Windows.Forms.Label lblDelay;
protected System.Windows.Forms.ComboBox cboDelay;
protected System.Windows.Forms.TextBox txtDelay;
protected System.Windows.Forms.Label lblURL;
protected System.Windows.Forms.TextBox txtURL;
protected System.Windows.Forms.Label lblStartDelay;
protected System.Windows.Forms.TextBox txtStartDelay;
protected System.Windows.Forms.ComboBox cboSimultaneousConnections;
/// <summary>
/// Required designer variable.
/// </summary>
protected System.ComponentModel.Container components = null;
public ConfigControl()
{
// This call is required by the Windows.Forms Form Designer.
InitializeComponent();
// TODO: Add any initialization after the InitializeComponent call
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
protected void InitializeComponent()
{
this.lblLogging = new System.Windows.Forms.Label();
this.cboLogging = new System.Windows.Forms.ComboBox();
this.txtSimultaneous = new System.Windows.Forms.TextBox();
this.txtIterations = new System.Windows.Forms.TextBox();
this.cboUsers = new System.Windows.Forms.ComboBox();
this.lblSimulatenous = new System.Windows.Forms.Label();
this.lblIterations = new System.Windows.Forms.Label();
this.lblUserType = new System.Windows.Forms.Label();
this.lblDelay = new System.Windows.Forms.Label();
this.cboDelay = new System.Windows.Forms.ComboBox();
this.txtDelay = new System.Windows.Forms.TextBox();
this.lblURL = new System.Windows.Forms.Label();
this.txtURL = new System.Windows.Forms.TextBox();
this.txtStartDelay = new System.Windows.Forms.TextBox();
this.lblStartDelay = new System.Windows.Forms.Label();
this.cboSimultaneousConnections = new System.Windows.Forms.ComboBox();
this.SuspendLayout();
//
// lblLogging
//
this.lblLogging.AutoSize = true;
this.lblLogging.Location = new System.Drawing.Point(0, 10);
this.lblLogging.Name = "lblLogging";
this.lblLogging.Size = new System.Drawing.Size(75, 16);
this.lblLogging.TabIndex = 0;
this.lblLogging.Text = "Logging Level";
//
// cboLogging
//
this.cboLogging.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cboLogging.Items.AddRange(new object[] {
"Individual Request"});
this.cboLogging.Location = new System.Drawing.Point(152, 8);
this.cboLogging.Name = "cboLogging";
this.cboLogging.Size = new System.Drawing.Size(152, 21);
this.cboLogging.TabIndex = 0;
//
// txtSimultaneous
//
this.txtSimultaneous.Location = new System.Drawing.Point(312, 40);
this.txtSimultaneous.Name = "txtSimultaneous";
this.txtSimultaneous.Size = new System.Drawing.Size(96, 20);
this.txtSimultaneous.TabIndex = 2;
this.txtSimultaneous.Text = "1";
this.txtSimultaneous.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
//
// txtIterations
//
this.txtIterations.Location = new System.Drawing.Point(152, 72);
this.txtIterations.Name = "txtIterations";
this.txtIterations.Size = new System.Drawing.Size(152, 20);
this.txtIterations.TabIndex = 3;
this.txtIterations.Text = "10";
this.txtIterations.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
//
// cboUsers
//
this.cboUsers.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cboUsers.Items.AddRange(new object[] {
"Default"});
this.cboUsers.Location = new System.Drawing.Point(152, 104);
this.cboUsers.Name = "cboUsers";
this.cboUsers.Size = new System.Drawing.Size(152, 21);
this.cboUsers.TabIndex = 4;
//
// lblSimulatenous
//
this.lblSimulatenous.AutoSize = true;
this.lblSimulatenous.Location = new System.Drawing.Point(0, 42);
this.lblSimulatenous.Name = "lblSimulatenous";
this.lblSimulatenous.Size = new System.Drawing.Size(139, 16);
this.lblSimulatenous.TabIndex = 5;
this.lblSimulatenous.Text = "Simulatenous Connections";
//
// lblIterations
//
this.lblIterations.AutoSize = true;
this.lblIterations.Location = new System.Drawing.Point(0, 74);
this.lblIterations.Name = "lblIterations";
this.lblIterations.Size = new System.Drawing.Size(156, 16);
this.lblIterations.TabIndex = 6;
this.lblIterations.Text = "Number of Iterations (per thrd)";
//
// lblUserType
//
this.lblUserType.AutoSize = true;
this.lblUserType.Location = new System.Drawing.Point(0, 106);
this.lblUserType.Name = "lblUserType";
this.lblUserType.Size = new System.Drawing.Size(56, 16);
this.lblUserType.TabIndex = 7;
this.lblUserType.Text = "User Type";
//
// lblDelay
//
this.lblDelay.AutoSize = true;
this.lblDelay.Location = new System.Drawing.Point(0, 136);
this.lblDelay.Name = "lblDelay";
this.lblDelay.Size = new System.Drawing.Size(78, 16);
this.lblDelay.TabIndex = 9;
this.lblDelay.Text = "Request Delay";
//
// cboDelay
//
this.cboDelay.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cboDelay.Items.AddRange(new object[] {
"Default",
"Time in Milliseconds"});
this.cboDelay.Location = new System.Drawing.Point(152, 136);
this.cboDelay.Name = "cboDelay";
this.cboDelay.Size = new System.Drawing.Size(152, 21);
this.cboDelay.TabIndex = 5;
this.cboDelay.SelectedIndexChanged += new System.EventHandler(this.cboDelay_SelectedIndexChanged);
//
// txtDelay
//
this.txtDelay.Location = new System.Drawing.Point(312, 136);
this.txtDelay.Name = "txtDelay";
this.txtDelay.Size = new System.Drawing.Size(96, 20);
this.txtDelay.TabIndex = 6;
this.txtDelay.Text = "2000";
this.txtDelay.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
this.txtDelay.Visible = false;
//
// lblURL
//
this.lblURL.AutoSize = true;
this.lblURL.Location = new System.Drawing.Point(0, 200);
this.lblURL.Name = "lblURL";
this.lblURL.Size = new System.Drawing.Size(56, 16);
this.lblURL.TabIndex = 11;
this.lblURL.Text = "Base URL";
//
// txtURL
//
this.txtURL.Location = new System.Drawing.Point(152, 200);
this.txtURL.Name = "txtURL";
this.txtURL.Size = new System.Drawing.Size(256, 20);
this.txtURL.TabIndex = 8;
this.txtURL.Text = "DEFAULT";
//
// txtStartDelay
//
this.txtStartDelay.Location = new System.Drawing.Point(152, 168);
this.txtStartDelay.Name = "txtStartDelay";
this.txtStartDelay.Size = new System.Drawing.Size(96, 20);
this.txtStartDelay.TabIndex = 7;
this.txtStartDelay.Text = "250";
this.txtStartDelay.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
//
// lblStartDelay
//
this.lblStartDelay.AutoSize = true;
this.lblStartDelay.Location = new System.Drawing.Point(0, 168);
this.lblStartDelay.Name = "lblStartDelay";
this.lblStartDelay.Size = new System.Drawing.Size(133, 16);
this.lblStartDelay.TabIndex = 13;
this.lblStartDelay.Text = "Start Delay (milliseconds)";
//
// cboSimultaneousConnections
//
this.cboSimultaneousConnections.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cboSimultaneousConnections.Items.AddRange(new object[] {
"Fixed",
"Increasing to Maximum"});
this.cboSimultaneousConnections.Location = new System.Drawing.Point(152, 40);
this.cboSimultaneousConnections.Name = "cboSimultaneousConnections";
this.cboSimultaneousConnections.Size = new System.Drawing.Size(152, 21);
this.cboSimultaneousConnections.TabIndex = 1;
//
// ConfigControl
//
this.Controls.Add(this.cboSimultaneousConnections);
this.Controls.Add(this.txtStartDelay);
this.Controls.Add(this.lblStartDelay);
this.Controls.Add(this.txtURL);
this.Controls.Add(this.lblURL);
this.Controls.Add(this.txtDelay);
this.Controls.Add(this.lblDelay);
this.Controls.Add(this.cboDelay);
this.Controls.Add(this.lblUserType);
this.Controls.Add(this.lblSimulatenous);
this.Controls.Add(this.cboUsers);
this.Controls.Add(this.txtIterations);
this.Controls.Add(this.txtSimultaneous);
this.Controls.Add(this.cboLogging);
this.Controls.Add(this.lblLogging);
this.Controls.Add(this.lblIterations);
this.Name = "ConfigControl";
this.Size = new System.Drawing.Size(416, 224);
this.ResumeLayout(false);
}
#endregion
public void LoadSettings(QTools.Setting settings)
{
if (settings == null)
{
settings = new Setting();
}
txtIterations.Text = settings.NumberOfIterations.ToString();
txtSimultaneous.Text = settings.NumberOfSimulatenousConnections.ToString();
txtURL.Text = settings.baseURL;
txtStartDelay.Text = settings.StartDelayMilliSeconds.ToString();
switch (settings.LoggingLevel)
{
case LoggingLevels.IndividualRequests:
cboLogging.SelectedIndex = 0;
break;
case LoggingLevels.EntireTestInstance:
cboLogging.SelectedIndex = 1;
break;
case LoggingLevels.None:
cboLogging.SelectedIndex = 2;
break;
}
switch (settings.SimultaneousConnections)
{
case SimultaneousConnections.Fixed:
cboSimultaneousConnections.SelectedIndex = 0;
break;
case SimultaneousConnections.Increasing:
cboSimultaneousConnections.SelectedIndex = 1;
break;
}
switch (settings.DelayType)
{
case DelayType.Default:
cboDelay.SelectedIndex = 0;
break;
case DelayType.Milliseconds:
cboDelay.SelectedIndex = 1;
txtDelay.Text = settings.DelayMilliSeconds.ToString();
break;
}
switch (settings.UserType)
{
case UserType.Default:
cboUsers.SelectedIndex = 0;
break;
case UserType.Custom:
cboUsers.SelectedIndex = 1;
break;
}
}
public QTools.Setting SaveSettings()
{
Setting settings = new Setting();
settings.NumberOfIterations = int.Parse(txtIterations.Text);
settings.NumberOfSimulatenousConnections = int.Parse(txtSimultaneous.Text);
settings.baseURL = txtURL.Text;
settings.StartDelayMilliSeconds = int.Parse(txtStartDelay.Text);
switch (cboLogging.SelectedIndex)
{
case 0:
settings.LoggingLevel = LoggingLevels.IndividualRequests;
break;
case 1:
settings.LoggingLevel = LoggingLevels.EntireTestInstance;
break;
case 2:
settings.LoggingLevel = LoggingLevels.None;
break;
}
switch (cboSimultaneousConnections.SelectedIndex)
{
case 0:
settings.SimultaneousConnections = SimultaneousConnections.Fixed;
break;
case 1:
settings.SimultaneousConnections = SimultaneousConnections.Increasing;
break;
}
switch (cboDelay.SelectedIndex)
{
case 0:
settings.DelayType = DelayType.Default;
break;
case 1:
settings.DelayType = DelayType.Milliseconds;
settings.DelayMilliSeconds = int.Parse(txtDelay.Text);
break;
}
switch (cboUsers.SelectedIndex)
{
case 0:
settings.UserType = UserType.Default;
break;
case 1:
settings.UserType = UserType.Custom;
break;
}
return settings;
}
protected void cboDelay_SelectedIndexChanged(object sender, System.EventArgs e)
{
txtDelay.Visible = (cboDelay.SelectedIndex != 0);
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.