📄 form1.cs
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Runtime.InteropServices;
namespace onoff
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Button button2;
private System.ComponentModel.IContainer components;
public int control = 890, data = 888, delay;
private System.Windows.Forms.Timer timer1;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.Button button4;
private System.Windows.Forms.Button button5;
private System.Windows.Forms.Button button3;
private int [] ar=new int[]{1,2,4};
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Button button6;
private System.Windows.Forms.Timer timer2;
private System.Windows.Forms.Label label2;
int index=0;
public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after 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 Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.button1 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
this.button3 = new System.Windows.Forms.Button();
this.timer1 = new System.Windows.Forms.Timer(this.components);
this.textBox1 = new System.Windows.Forms.TextBox();
this.button4 = new System.Windows.Forms.Button();
this.button5 = new System.Windows.Forms.Button();
this.label1 = new System.Windows.Forms.Label();
this.button6 = new System.Windows.Forms.Button();
this.timer2 = new System.Windows.Forms.Timer(this.components);
this.label2 = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// button1
//
this.button1.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(224)), ((System.Byte)(224)), ((System.Byte)(224)));
this.button1.Font = new System.Drawing.Font("OzHandicraft BT", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.button1.Location = new System.Drawing.Point(40, 56);
this.button1.Name = "button1";
this.button1.TabIndex = 0;
this.button1.Text = "Camera1";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// button2
//
this.button2.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(224)), ((System.Byte)(224)), ((System.Byte)(224)));
this.button2.Font = new System.Drawing.Font("OzHandicraft BT", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.button2.Location = new System.Drawing.Point(128, 56);
this.button2.Name = "button2";
this.button2.TabIndex = 1;
this.button2.Text = "Camera2";
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// button3
//
this.button3.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(224)), ((System.Byte)(224)), ((System.Byte)(224)));
this.button3.Font = new System.Drawing.Font("OzHandicraft BT", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.button3.Location = new System.Drawing.Point(216, 56);
this.button3.Name = "button3";
this.button3.TabIndex = 2;
this.button3.Text = "Camera3";
this.button3.Click += new System.EventHandler(this.button3_Click);
//
// timer1
//
this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(56, 120);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(104, 20);
this.textBox1.TabIndex = 3;
this.textBox1.Text = "";
//
// button4
//
this.button4.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(224)), ((System.Byte)(224)), ((System.Byte)(224)));
this.button4.Font = new System.Drawing.Font("OzHandicraft BT", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.button4.Location = new System.Drawing.Point(176, 120);
this.button4.Name = "button4";
this.button4.TabIndex = 4;
this.button4.Text = "TIMER";
this.button4.Click += new System.EventHandler(this.button4_Click);
//
// button5
//
this.button5.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(224)), ((System.Byte)(224)), ((System.Byte)(224)));
this.button5.Font = new System.Drawing.Font("OzHandicraft BT", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.button5.Location = new System.Drawing.Point(64, 160);
this.button5.Name = "button5";
this.button5.Size = new System.Drawing.Size(176, 23);
this.button5.TabIndex = 5;
this.button5.Text = "STOP TIMER MODE";
this.button5.Click += new System.EventHandler(this.button5_Click);
//
// label1
//
this.label1.Location = new System.Drawing.Point(264, 120);
this.label1.Name = "label1";
this.label1.TabIndex = 6;
this.label1.Text = "label1";
//
// button6
//
this.button6.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(224)), ((System.Byte)(224)), ((System.Byte)(224)));
this.button6.Font = new System.Drawing.Font("OzHandicraft BT", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.button6.Location = new System.Drawing.Point(104, 200);
this.button6.Name = "button6";
this.button6.TabIndex = 7;
this.button6.Text = "TV";
this.button6.Click += new System.EventHandler(this.button6_Click);
//
// timer2
//
this.timer2.Enabled = true;
this.timer2.Tick += new System.EventHandler(this.timer2_Tick);
//
// label2
//
this.label2.Font = new System.Drawing.Font("Monotype Corsiva", 9.75F, (System.Drawing.FontStyle.Bold | System.Drawing.FontStyle.Italic), System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.label2.ImageAlign = System.Drawing.ContentAlignment.BottomCenter;
this.label2.Location = new System.Drawing.Point(8, 304);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(448, 23);
this.label2.TabIndex = 8;
this.label2.Text = "Integrated Ideas and Orbit Electronics";
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(255)), ((System.Byte)(255)), ((System.Byte)(192)));
this.ClientSize = new System.Drawing.Size(464, 334);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.label2,
this.button6,
this.label1,
this.button5,
this.button4,
this.textBox1,
this.button3,
this.button2,
this.button1});
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void button1_Click(object sender, System.EventArgs e)
{
PortAccess.Output(data,1);
label1.Text="1";
}
private void button2_Click(object sender, System.EventArgs e)
{
PortAccess.Output(data,2);
label1.Text="2";
}
private void button3_Click(object sender, System.EventArgs e)
{
PortAccess.Output(data,4);
label1.Text="3";
}
private void button4_Click(object sender, System.EventArgs e)
{
timer1.Interval=1000*int.Parse(textBox1.Text);
timer1.Enabled=true;
}
private void timer1_Tick(object sender, System.EventArgs e)
{
PortAccess.Output(data,ar[index]);
label1.Text=ar[index].ToString();
index++;
if(index==3)
index=0;
}
private void button5_Click(object sender, System.EventArgs e)
{
timer1.Enabled=false;
}
private void button6_Click(object sender, System.EventArgs e)
{
System.Diagnostics.Process.Start("C:\\TV Capture Card\\HDTVPCI.EXE");
}
private void timer2_Tick(object sender, System.EventArgs e)
{
label2.Left=label2.Left+5;
if(label2.Left>430)
label2.Left=0;
}
}
public class PortAccess
{
/* For sending to the ports */
[DllImport("d:\\yogi\\inpout32.dll", EntryPoint="Out32")]
public static extern void Output(int adress, int value);
/* For receiving from the ports */
[DllImport("d:\\yogi\\inpout32.dll", EntryPoint="Inp32")]
public static extern int Input(int adress);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -