/* Title : NetworkSelect
* Author : J�rgen Van Gorp
* Version : 1.0 - September 2004
* Purpose : Perform Network access using c#
* Copyright: (C) J�rgen Van Gorp - TIData BVBA IT Consultancy - Belgium - Jurgen.Van.Gorp@tidata.com
*/
using System;
using System.IO;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using TIData.NetworkSelect;
namespace NetSelect
{
/// <summary>
/// NetworkSelect finds network domains and computers.
/// It lets you browse the network and pick a computer and
/// share.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
#region Form buttons, fields, ...
private System.Windows.Forms.Button btnBrowseNetwork;
private System.Windows.Forms.Button btnQuit;
private TIData.NetworkSelect.NetworkSelect networkSelect1;
private System.Windows.Forms.Button btnResult;
private System.Windows.Forms.Button btnGetDomain;
private System.Windows.Forms.Button btnGetComputer;
private System.Windows.Forms.Button btnGetDirectory;
private System.Windows.Forms.Button btnGetFile;
private System.Windows.Forms.CheckBox chkHiddenShares;
private System.Windows.Forms.CheckBox chkShowShares;
private System.Windows.Forms.CheckBox chkShowCheckboxes;
private System.Windows.Forms.CheckBox chkShowFiles;
private System.Windows.Forms.CheckBox chkShowDirectories;
private System.Windows.Forms.Button btnGetFullPath;
private System.Windows.Forms.Button btnCheckedItems;
#endregion
public Form1()
{
InitializeComponent();
}
protected override void Dispose( bool disposing )
{
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.btnBrowseNetwork = new System.Windows.Forms.Button();
this.btnQuit = new System.Windows.Forms.Button();
this.networkSelect1 = new TIData.NetworkSelect.NetworkSelect();
this.btnResult = new System.Windows.Forms.Button();
this.btnGetDomain = new System.Windows.Forms.Button();
this.btnGetComputer = new System.Windows.Forms.Button();
this.btnGetDirectory = new System.Windows.Forms.Button();
this.btnGetFile = new System.Windows.Forms.Button();
this.chkShowCheckboxes = new System.Windows.Forms.CheckBox();
this.chkShowFiles = new System.Windows.Forms.CheckBox();
this.chkShowDirectories = new System.Windows.Forms.CheckBox();
this.chkHiddenShares = new System.Windows.Forms.CheckBox();
this.chkShowShares = new System.Windows.Forms.CheckBox();
this.btnGetFullPath = new System.Windows.Forms.Button();
this.btnCheckedItems = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// btnBrowseNetwork
//
this.btnBrowseNetwork.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.btnBrowseNetwork.Location = new System.Drawing.Point(8, 372);
this.btnBrowseNetwork.Name = "btnBrowseNetwork";
this.btnBrowseNetwork.Size = new System.Drawing.Size(136, 24);
this.btnBrowseNetwork.TabIndex = 0;
this.btnBrowseNetwork.Text = "Browse Network";
this.btnBrowseNetwork.Click += new System.EventHandler(this.btnBrowseNetwork_Click);
//
// btnQuit
//
this.btnQuit.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.btnQuit.Location = new System.Drawing.Point(416, 464);
this.btnQuit.Name = "btnQuit";
this.btnQuit.Size = new System.Drawing.Size(144, 24);
this.btnQuit.TabIndex = 1;
this.btnQuit.Text = "Quit";
this.btnQuit.Click += new System.EventHandler(this.btnQuit_Click);
//
// networkSelect1
//
this.networkSelect1.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.networkSelect1.Location = new System.Drawing.Point(0, 0);
this.networkSelect1.Name = "networkSelect1";
this.networkSelect1.Size = new System.Drawing.Size(568, 368);
this.networkSelect1.TabIndex = 2;
//
// btnResult
//
this.btnResult.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.btnResult.Location = new System.Drawing.Point(208, 420);
this.btnResult.Name = "btnResult";
this.btnResult.Size = new System.Drawing.Size(136, 24);
this.btnResult.TabIndex = 3;
this.btnResult.Text = "Get Share";
this.btnResult.Click += new System.EventHandler(this.btnResult_Click);
//
// btnGetDomain
//
this.btnGetDomain.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.btnGetDomain.Location = new System.Drawing.Point(208, 372);
this.btnGetDomain.Name = "btnGetDomain";
this.btnGetDomain.Size = new System.Drawing.Size(136, 24);
this.btnGetDomain.TabIndex = 4;
this.btnGetDomain.Text = "Get Domain";
this.btnGetDomain.Click += new System.EventHandler(this.btnGetDomain_Click);
//
// btnGetComputer
//
this.btnGetComputer.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.btnGetComputer.Location = new System.Drawing.Point(208, 396);
this.btnGetComputer.Name = "btnGetComputer";
this.btnGetComputer.Size = new System.Drawing.Size(136, 24);
this.btnGetComputer.TabIndex = 5;
this.btnGetComputer.Text = "Get Computer";
this.btnGetComputer.Click += new System.EventHandler(this.btnGetComputer_Click);
//
// btnGetDirectory
//
this.btnGetDirectory.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.btnGetDirectory.Location = new System.Drawing.Point(208, 444);
this.btnGetDirectory.Name = "btnGetDirectory";
this.btnGetDirectory.Size = new System.Drawing.Size(136, 24);
this.btnGetDirectory.TabIndex = 6;
this.btnGetDirectory.Text = "Get Directory";
this.btnGetDirectory.Click += new System.EventHandler(this.btnGetDirectory_Click);
//
// btnGetFile
//
this.btnGetFile.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.btnGetFile.Location = new System.Drawing.Point(208, 468);
this.btnGetFile.Name = "btnGetFile";
this.btnGetFile.Size = new System.Drawing.Size(136, 24);
this.btnGetFile.TabIndex = 7;
this.btnGetFile.Text = "Get File";
this.btnGetFile.Click += new System.EventHandler(this.btnGetFile_Click);
//
// chkShowCheckboxes
//
this.chkShowCheckboxes.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.chkShowCheckboxes.Location = new System.Drawing.Point(8, 400);
this.chkShowCheckboxes.Name = "chkShowCheckboxes";
this.chkShowCheckboxes.Size = new System.Drawing.Size(168, 16);
this.chkShowCheckboxes.TabIndex = 8;
this.chkShowCheckboxes.Text = "Show Check Boxes";
//
// chkShowFiles
//
this.chkShowFiles.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.chkShowFiles.Checked = true;
this.chkShowFiles.CheckState = System.Windows.Forms.CheckState.Checked;
this.chkShowFiles.Location = new System.Drawing.Point(8, 464);
this.chkShowFiles.Name = "chkShowFiles";
this.chkShowFiles.Size = new System.Drawing.Size(168, 16);
this.chkShowFiles.TabIndex = 9;
this.chkShowFiles.Text = "Show Files";
//
// chkShowDirectories
//
this.chkShowDirectories.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.chkShowDirectories.Checked = true;
this.chkShowDirectories.CheckState = System.Windows.Forms.CheckState.Checked;
this.chkShowDirectories.Location = new System.Drawing.Point(8, 448);
this.chkShowDirectories.Name = "chkShowDirectories";
this.chkShowDirectories.Size = new System.Drawing.Size(168, 16);
this.chkShowDirectories.TabIndex = 10;
this.chkShowDirectories.Text = "Show Directories";
//
// chkHiddenShares
//
this.chkHiddenShares.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.chkHiddenShares.Location = new System.Drawing.Point(8, 432);
this.chkHiddenShares.Name = "chkHiddenShares";
this.chkHiddenShares.Size = new System.Drawing.Size(168, 16);
this.chkHiddenShares.TabIndex = 11;
this.chkHiddenShares.Text = "Show Hidden Shares";
//
// chkShowShares
//
this.chkShowShares.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.chkShowShares.Checked = true;
this.chkShowShares.CheckState = System.Windows.Forms.CheckState.Checked;
this.chkShowShares.Location = new System.Drawing.Point(8, 416);
this.chkShowShares.Name = "chkShowShares";
this.chkShowShares.Size = new System.Drawing.Size(168, 16);
this.chkShowShares.TabIndex = 12;
this.chkShowShares.Text = "Show Computer Shares";
//
// btnGetFullPath
//
this.btnGetFullPath.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.btnGetFullPath.Location = new System.Drawing.Point(416, 376);
this.btnGetFullPath.Name = "btnGetFullPath";
this.btnGetFullPath.Size = new System.Drawing.Size(144, 24);
this.btnGetFullPath.TabIndex = 13;
this.btnGetFullPath.Text = "Get Full Path";
this.btnGetFullPath.Click += new System.EventHandler(this.btnGetFullPath_Click);
//
// btnCheckedItems
//
this.btnCheckedItems.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.btnCheckedItems.Location = new System.Drawing.Point(416, 400);
this.btnCheckedItems.Name = "btnCheckedItems";
this.btnCheckedItems.Size = new System.Drawing.Size(144, 24);
this.btnCheckedItems.TabIndex = 14;
this.btnCheckedItems.Text = "Get Checked Items";
this.btnCheckedItems.Click += new System.EventHandler(this.btnCheckedItems_Click);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(572, 493);
this.Controls.Add(this.btnCheckedItems);
this.Controls.Add(this.btnGetFullPath);
this.Controls.Add(this.chkShowShares);
this.Controls.Add(this.chkHiddenShares);
this.Controls.Add(this.chkShowDirectories);
this.Controls.Add(this.chkShowFiles);
this.Controls.Add(this.chkShowCheckboxes);
this.Controls.Add(this.btnGetFile);
this.Controls.Add(this.btnGetDirectory);
this.Controls.Add(this.btnGetComputer);
this.Controls.Add(this.btnGetDomain);
this.Controls.Add(this.btnResult);
this.Controls.Add(this.networkSelect1);
this.Controls.Add(this.btnQuit);
this.Controls.Add(this.btnBrowseNetwork);
this.MinimumSize = new System.Drawing.Size(580, 520);
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayout(false);
}
#endregion
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void btnQuit_Click(object sender, System.EventArgs e)
{
this.Close();
}
private void btnBrowseNetwork_Click(object sender, System.EventArgs e)
{
networkSelect1.SeekThroughDomains(
this.chkShowCheckboxes.Checked,
this.chkShowShares.Checked,
this.chkHiddenShares.Checked,
this.chkShowDirectories.Checked,
this.chkShowFiles.Checked );
}
private void btnResult_Click(object sender, System.EventArgs e)
{
GiveUserResponse("Share", networkSelect1.GetCurrentShare());
}
private void btnGetDomain_Click(object sender, System.EventArgs e)
{
GiveUserResponse("Domain", networkSelect1.GetCurrentDomain());
}
private void btnGetComputer_Click(object sender, System.EventArgs e)
{
GiveUserResponse("Computer or Server", networkSelect1.GetCurrentComputer());
}
private void btnGetDirectory_Click(object sender, System.EventArgs e)
{
GiveUserResponse("Directory", networkSelect1.GetCurrentDirectory());
}
private void btnGetFile_Click(object sender, System.EventArgs e)
{
GiveUserResponse("File", networkSelect1.GetCurrentFile());
}
private void GiveUserResponse(string whatAbout, string theValue)
{
MessageBox.Show("The " + whatAbout + " that you've selected is:\n\n" +
theValue,"You've asked for it...",
System.Windows.Forms.MessageBoxButtons.OK,
System.Windows.Forms.MessageBoxIcon.Information);
}
private void btnGetFullPath_Click(object sender, System.EventArgs e)
{
MessageBox.Show("The full path of that you've selected is:\n\n" +
networkSelect1.GetFullName(),"You've asked for it...",
System.Windows.Forms.MessageBoxButtons.OK,
System.Windows.Forms.MessageBoxIcon.Information);
}
private void btnCheckedItems_Click(object sender, System.EventArgs e)
{
MessageBox.Show ("Sorry, not yet implemented. Send me an email if you want this too: Jurgen@tidata.com");
}
}
}