C# for non C# programmer

Hi, quick question, I would like to eliminate a button on form1 and when the form1 loads go directly to

private void button1_Click(object sender, System.EventArgs e)

How ?

Thanks
Matt


[code]using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.IO;
using System.Runtime.Serialization.Formatters.Soap;
using Integral.Client.Sources;
using System.Xml.Serialization;

namespace SimpleVideoOverlay
{
///
/// Summary description for Form1.
///
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.OpenFileDialog openFileDialog1;
private System.Windows.Forms.PictureBox picVideo;
private System.Windows.Forms.Button button1;

private string txtRecorder;
private string cmbSystem;
private string txtUserID;
private string txtPassword;


private IRecorder mRecorder;
private OverlayControlDialog osdDiag;
private IStreamRenderInfo mInfo;
private Button button1;

///
/// Required designer variable.
///
private System.ComponentModel.Container components = null;

public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
}

///
/// Clean up any resources being used.
///
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}

if (mRecorder != null)
{
mRecorder = null;
}
base.Dispose( disposing );
}

#region Windows Form Designer generated code
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///
private void InitializeComponent()
{
this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog();
this.picVideo = new System.Windows.Forms.PictureBox();
this.button1 = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.picVideo)).BeginInit();
this.SuspendLayout();
//
// openFileDialog1
//
this.openFileDialog1.Filter = "Integral Media Files (*.xpa,*.xpv)|*.xpa;*.xpv";
//
// picVideo
//
this.picVideo.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.picVideo.Location = new System.Drawing.Point(0, 123);
this.picVideo.Name = "picVideo";
this.picVideo.Size = new System.Drawing.Size(384, 355);
this.picVideo.TabIndex = 16;
this.picVideo.TabStop = false;
this.picVideo.Click += new System.EventHandler(this.picVideo_Click);
//
// button1
//
this.button1.Location = new System.Drawing.Point(96, 12);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(197, 66);
this.button1.TabIndex = 17;
this.button1.Text = "Play";
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(384, 478);
this.Controls.Add(this.button1);
this.Controls.Add(this.picVideo);
this.Name = "Form1";
this.Text = "Export Image";
this.Load += new System.EventHandler(this.Form1_Load);
((System.ComponentModel.ISupportInitialize)(this.picVideo)).EndInit();
this.ResumeLayout(false);

}
#endregion

///
/// The main entry point for the application.
///
[STAThread]
static void Main()
{
Application.Run(new Form1());
}


private void button1_Click(object sender, System.EventArgs e)
{

txtRecorder="10.10.2.3";
cmbSystem="10.10.2.3";
txtUserID="admin";
txtPassword="admin";


IDVRSystem system = SystemFactory.FindOrCreateSystem(cmbSystem, 18772, txtUserID, txtPassword);
system.Open();
if (system.ConnectionStatus == Integral.Client.Sources.ConnectionState.LoggedIn)
{

mRecorder = system.Recorders.FindByIPAddress(txtRecorder);
if (mRecorder != null)
{
// Sometimes a camera is not renderable because it is not 'detected.'
// we'll just keep rendering until we get a successful render.
foreach (IStream stream in mRecorder.Cameras)
{
mInfo = stream.Render(picVideo);
if (mInfo != null)
break;
}
}
}
}

private void Form1_Load(object sender, EventArgs e)
{

}

private void picVideo_Click(object sender, EventArgs e)
{

}

private void button1_Click(object sender, EventArgs e)
{

}
}
}
[/code]

Comments

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion