
Исходный код диалоговой формы.
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
namespace CustomizedTaskManager
{
/// <summary>
/// Summary description for frmnewprcdetails.
/// </summary>
public class frmnewprcdetails : System.Windows.Forms.Form
{
private System.Windows.Forms.TextBox txtapplnpath;
private System.Windows.Forms.Button btnok;
private System.Windows.Forms.Button btncancel;
private System.Windows.Forms.Button btnbrowse;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.OpenFileDialog openFileDialog1;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
public frmnewprcdetails()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
public frmnewprcdetails(string mcname)
{
InitializeComponent();
label1.Text = mcname;
if(label1.Text.ToUpper() == "Enter Machine Name".ToUpper())
{
this.Height = 100;
this.Width = 400;
txtapplnpath.Left = 140;
label1.Width = 120;
txtapplnpath.Width = 250;
btnbrowse.Visible = false;
btnok.Left = btnok.Left+80;
btncancel.Left = btncancel.Left+90;
}
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
private void btncancel_Click(object sender, System.EventArgs e)
{
frmmain.newprocpathandparm = "";
frmmain.objnewprocess.Close();
this.DialogResult = DialogResult.Cancel;
}
private void btnbrowse_Click(object sender, System.EventArgs e)
{
try
{
openFileDialog1.CheckFileExists = false;
openFileDialog1.ShowDialog();
txtapplnpath.Text = openFileDialog1.FileName;
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void btnok_Click(object sender, System.EventArgs e)
{
if(label1.Text.ToUpper() == "Enter Machine Name".ToUpper())
{
if(txtapplnpath.Text.Trim() == "")
{
txtapplnpath.Text = ".";
}
frmmain.mcname = txtapplnpath.Text.Trim();
}
else
{
frmmain.newprocpathandparm = txtapplnpath.Text.Trim();
}
this.DialogResult = DialogResult.OK;
frmmain.objnewprocess.Close();
}
}
}