📄 form1.cs
字号:
this.label1.Location = new System.Drawing.Point(16, 58);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(89, 16);
this.label1.TabIndex = 0;
this.label1.Text = "Packets per Xfer";
this.label1.TextAlign = System.Drawing.ContentAlignment.BottomLeft;
//
// label2
//
this.label2.Location = new System.Drawing.Point(16, 97);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(89, 17);
this.label2.TabIndex = 1;
this.label2.Text = "Xfers to Queue";
this.label2.TextAlign = System.Drawing.ContentAlignment.BottomLeft;
//
// label3
//
this.label3.Location = new System.Drawing.Point(215, 58);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(64, 17);
this.label3.TabIndex = 2;
this.label3.Text = "Successes";
this.label3.TextAlign = System.Drawing.ContentAlignment.BottomLeft;
//
// label4
//
this.label4.Location = new System.Drawing.Point(215, 99);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(64, 16);
this.label4.TabIndex = 3;
this.label4.Text = "Failures";
this.label4.TextAlign = System.Drawing.ContentAlignment.BottomLeft;
//
// PpxBox
//
this.PpxBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.PpxBox.Items.AddRange(new object[] {
"1",
"2",
"4",
"8",
"16",
"32",
"64",
"128"});
this.PpxBox.Location = new System.Drawing.Point(111, 58);
this.PpxBox.SelectedIndex = 0;
this.PpxBox.Name = "PpxBox";
this.PpxBox.Size = new System.Drawing.Size(64, 21);
this.PpxBox.TabIndex = 1;
this.PpxBox.SelectedIndexChanged += new System.EventHandler(this.PpxBox_SelectedIndexChanged);
//
// QueueBox
//
this.QueueBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.QueueBox.Items.AddRange(new object[] {
"1",
"2",
"4",
"8",
"16",
"32",
"64",
"128"});
this.QueueBox.Location = new System.Drawing.Point(111, 97);
this.QueueBox.SelectedIndex = 0;
this.QueueBox.Name = "QueueBox";
this.QueueBox.Size = new System.Drawing.Size(64, 21);
this.QueueBox.TabIndex = 2;
//
// SuccessBox
//
this.SuccessBox.Location = new System.Drawing.Point(279, 58);
this.SuccessBox.Name = "SuccessBox";
this.SuccessBox.Size = new System.Drawing.Size(72, 20);
this.SuccessBox.TabIndex = 6;
this.SuccessBox.TabStop = false;
this.SuccessBox.Text = "0";
this.SuccessBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
//
// FailuresBox
//
this.FailuresBox.Location = new System.Drawing.Point(279, 98);
this.FailuresBox.Name = "FailuresBox";
this.FailuresBox.Size = new System.Drawing.Size(72, 20);
this.FailuresBox.TabIndex = 7;
this.FailuresBox.TabStop = false;
this.FailuresBox.Text = "0";
this.FailuresBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
//
// groupBox1
//
this.groupBox1.Controls.Add(this.ThroughputLabel);
this.groupBox1.Controls.Add(this.ProgressBar);
this.groupBox1.Location = new System.Drawing.Point(19, 172);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(330, 60);
this.groupBox1.TabIndex = 8;
this.groupBox1.TabStop = false;
this.groupBox1.Text = " Throughput (KB/s) ";
//
// ThroughputLabel
//
this.ThroughputLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.ThroughputLabel.Location = new System.Drawing.Point(114, 38);
this.ThroughputLabel.Name = "ThroughputLabel";
this.ThroughputLabel.Size = new System.Drawing.Size(100, 16);
this.ThroughputLabel.TabIndex = 1;
this.ThroughputLabel.Text = "0";
this.ThroughputLabel.TextAlign = System.Drawing.ContentAlignment.BottomCenter;
//
// ProgressBar
//
this.ProgressBar.ForeColor = System.Drawing.SystemColors.HotTrack;
this.ProgressBar.Location = new System.Drawing.Point(16, 25);
this.ProgressBar.Maximum = 40000;
this.ProgressBar.Name = "ProgressBar";
this.ProgressBar.Size = new System.Drawing.Size(294, 10);
this.ProgressBar.TabIndex = 0;
//
// StartBtn
//
this.StartBtn.BackColor = System.Drawing.Color.Aquamarine;
this.StartBtn.Location = new System.Drawing.Point(223, 136);
this.StartBtn.Name = "StartBtn";
this.StartBtn.Size = new System.Drawing.Size(128, 20);
this.StartBtn.TabIndex = 3;
this.StartBtn.Text = "Start";
this.StartBtn.UseVisualStyleBackColor = false;
this.StartBtn.Click += new System.EventHandler(this.StartBtn_Click);
//
// EndPointsComboBox
//
this.EndPointsComboBox.DropDownHeight = 120;
this.EndPointsComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.EndPointsComboBox.FormattingEnabled = true;
this.EndPointsComboBox.IntegralHeight = false;
this.EndPointsComboBox.Location = new System.Drawing.Point(111, 15);
this.EndPointsComboBox.Name = "EndPointsComboBox";
this.EndPointsComboBox.Size = new System.Drawing.Size(240, 21);
this.EndPointsComboBox.TabIndex = 0;
this.EndPointsComboBox.SelectedIndexChanged += new System.EventHandler(this.EndPointsComboBox_SelectedIndexChanged);
//
// label5
//
this.label5.AutoSize = true;
this.label5.Location = new System.Drawing.Point(16, 18);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(94, 13);
this.label5.TabIndex = 11;
this.label5.Text = "Endpoint . . . . . . . ";
//
// CPULoadBox
//
this.CPULoadBox.Controls.Add(this.CpuLabel);
this.CPULoadBox.Controls.Add(this.CpuBar);
this.CPULoadBox.Location = new System.Drawing.Point(19, 247);
this.CPULoadBox.Name = "CPULoadBox";
this.CPULoadBox.Size = new System.Drawing.Size(330, 60);
this.CPULoadBox.TabIndex = 12;
this.CPULoadBox.TabStop = false;
this.CPULoadBox.Text = " CPU Load ";
//
// CpuLabel
//
this.CpuLabel.AutoSize = true;
this.CpuLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.CpuLabel.Location = new System.Drawing.Point(150, 41);
this.CpuLabel.Name = "CpuLabel";
this.CpuLabel.Size = new System.Drawing.Size(27, 13);
this.CpuLabel.TabIndex = 1;
this.CpuLabel.Text = "0 %";
this.CpuLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// CpuBar
//
this.CpuBar.ForeColor = System.Drawing.Color.ForestGreen;
this.CpuBar.Location = new System.Drawing.Point(16, 28);
this.CpuBar.Name = "CpuBar";
this.CpuBar.Size = new System.Drawing.Size(294, 10);
this.CpuBar.Step = 1;
this.CpuBar.TabIndex = 0;
//
// PerfTimer
//
this.PerfTimer.Enabled = true;
this.PerfTimer.Interval = 500;
this.PerfTimer.Tick += new System.EventHandler(this.PerfTimer_Tick);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(374, 329);
this.Controls.Add(this.CPULoadBox);
this.Controls.Add(this.label5);
this.Controls.Add(this.EndPointsComboBox);
this.Controls.Add(this.StartBtn);
this.Controls.Add(this.groupBox1);
this.Controls.Add(this.FailuresBox);
this.Controls.Add(this.SuccessBox);
this.Controls.Add(this.QueueBox);
this.Controls.Add(this.PpxBox);
this.Controls.Add(this.label4);
this.Controls.Add(this.label3);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.Menu = this.mainMenu;
this.Name = "Form1";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "C# USB Data Streamer";
this.Load += new System.EventHandler(this.Form1_Load);
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Form1_FormClosing);
this.groupBox1.ResumeLayout(false);
this.CPULoadBox.ResumeLayout(false);
this.CPULoadBox.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
/*Summary
The main entry point for the application.
*/
[STAThread]
static void Main()
{
try
{
Application.Run(new Form1());
}
catch (Exception e)
{
MessageBox.Show(e.StackTrace, "Exception '" + e.Message + "' thrown by " + e.Source);
}
}
/*Summary
Executes on clicking Help->about
*/
private void AboutItem_Click(object sender, System.EventArgs e)
{
string assemblyList = Util.Assemblies;
MessageBox.Show(assemblyList, Text);
}
/*Summary
Executes on clicking File->Exit
*/
private void ExitItem_Click(object sender, System.EventArgs e)
{
Close();
}
private void Form1_Load(object sender, System.EventArgs e)
{
if (EndPointsComboBox.Items.Count > 0)
EndPointsComboBox.SelectedIndex = 0;
}
/*Summary
Executes on clicking close button
*/
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
if (usbDevices != null)
usbDevices.Dispose();
}
/*Summary
This is the System event handler.
Enforces valid values for PPX(Packet per transfer)
*/
private void PpxBox_SelectedIndexChanged(object sender, EventArgs e)
{
if (EndPoint == null) return;
int ppx = Convert.ToUInt16(PpxBox.Text);
int len = EndPoint.MaxPktSize * ppx;
int maxLen = 0x10000; // 64K
if (len > maxLen)
{
ppx = maxLen / EndPoint.MaxPktSize / 8 * 8;
PpxBox.Text = ppx.ToString();
MessageBox.Show("Maximum of 64KB per transfer. Packets reduced.", "Invalid Packets per Xfer.");
}
if (MyDevice.bHighSpeed && (EndPoint.Attributes == 1) && (ppx < 8))
{
PpxBox.Text = "8";
MessageBox.Show("Minimum of 8 Packets per Xfer required for HS Isoc.", "Invalid Packets per Xfer.");
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -