Sei sulla pagina 1di 8

using using using using using using using using

System; System.Collections.Generic; System.ComponentModel; System.Data; System.Drawing; System.Linq; System.Text; System.Windows.Forms;

namespace WindowsFormsApplication7 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { button1.Visible = true; button1.BackColor = Color.Red; button2.Visible = false; button2.BackColor = Color.Yellow; button3.Visible = false; button3.BackColor = Color.Green; }

private void timer1_Tick(object sender, EventArgs e) { button1.Visible = true; button2.Visible = false; button3.Visible = false; timer2.Enabled = true; timer1.Enabled = false; timer3.Enabled = false; } private void timer2_Tick(object sender, EventArgs e) { button2.Visible = true; button1.Visible = false; button3.Visible = false; timer3.Enabled = true; timer1.Enabled = false; timer2.Enabled = false; } private void timer3_Tick(object sender, EventArgs e) { button3.Visible = true; button1.Visible = false; button2.Visible = false; timer1.Enabled = true; timer3.Enabled = false; timer2.Enabled = false; } } }

using using using using using using

System; System.Collections; System.ComponentModel; System.Data; System.Drawing; System.IO;

using System.Linq; using System.Text; using System.Windows.Forms; namespace WindowsFormsApplication4 { public partial class Form1 : Form { string substringDirectory; String path = @"C:\\MATLAB7"; String path1 = @"D:\\TC\\"; string sourcepath, destpath; public Form1() { InitializeComponent(); treeView1.Nodes.Clear(); treeView2.Nodes.Clear(); }

public void PopulateTreeView(string directoryValue, TreeNode parentNode) { string[] directoryArray = Directory.GetDirectories(directoryValue); try {

if (directoryArray.Length != 0) { foreach (string directory in directoryArray) { substringDirectory = directory.Substring( directory.LastIndexOf('\\') + 1, directory.Length - directory.LastIndexOf('\\')

- 1);

TreeNode myNode = new TreeNode(substringDirectory); parentNode.Nodes.Add(myNode); } PopulateTreeView(directory, myNode);

} } catch (UnauthorizedAccessException) { parentNode.Nodes.Add("Access denied"); } // end catch } static void Main() { Application.Run(new Form1()); } private void button4_Click(object sender, EventArgs e)//copy { string filename, destfile; if (System.IO.Directory .Exists (sourcepath )) { string[] files = System.IO.Directory.GetFiles(sourcepath); foreach (string s in files) { filename = System.IO.Path.GetFileName(s); destfile = System.IO.Path.Combine(destpath,filename); System.IO.File.Copy(s, destfile, true); } label3.Text = "Copy Done."; } else { MessageBox .Show ("File doesnt exists"); }

Application.DoEvents();

private void button2_Click(object sender, EventArgs e) //CANCEL { Application.Exit(); } private void Form1_Load(object sender, EventArgs e) { treeView1.Nodes.Add(path); PopulateTreeView(path, treeView1.Nodes[0]); treeView2.Nodes.Add(path1); PopulateTreeView(path1, treeView2.Nodes[0]); } private string GetParentString(TreeNode node) { // if this is the root node (c:\) return the text if (node.Parent == null) { return node.Text; } else { // recurse up and get the path then // add this node and a slash // if this node is the leaf, don't add the slash return GetParentString(node.Parent) + "\\"+ node.Text + (node.Nodes.Count == 0 ? "" : "\\"); } } private void treeView1_AfterSelect(object sender, TreeViewEventArgs e) { sourcepath = GetParentString(e.Node); } private void treeView2_AfterSelect_1(object sender, TreeViewEventArgs e) { destpath = GetParentString(e.Node); textBox1.Text = destpath; } } }

Hand Drawn Windows Form using System; using System.Windows.Forms; namespace WindowsFormsApplication8 { public partial class HandDrawnClass : Form { private Label lblOutput; private Button btnCancel; public HandDrawnClass( ) { lblOutput = new Label ( ); btnCancel = new Button ( ); this.Text = "Hello World"; lblOutput.Location = new System.Drawing.Point (16, 24); lblOutput.Text = "Hello World!"; btnCancel.Location = new System.Drawing.Point (150,200); btnCancel.Text = "Cancel"; btnCancel.Click += new System.EventHandler (this.btnCancel_Click); this.Controls.Add (this.btnCancel); this.Controls.Add (this.lblOutput); } protected void btnCancel_Click (object sender, System.EventArgs e) { Application.Exit( ); } public static void Main( ) { Application.Run(new HandDrawnClass( )); } } }

Full Code using System; using System.Windows.Forms; namespace WindowsFormsApplication8 { public partial class HandDrawnClass : Form { private System.Windows.Forms.Label lblOutput; // a cancel button private System.Windows.Forms.Button btnCancel; public HandDrawnClass( ) { this.lblOutput = new System.Windows.Forms.Label ( ); this.btnCancel = new System.Windows.Forms.Button ( ); // set the form's title this.Text = "Hello World"; // set up the output label lblOutput.Location = new System.Drawing.Point (16, 24); lblOutput.Text = "Hello World!"; lblOutput.Size = new System.Drawing.Size (216, 24); // set up the cancel button btnCancel.Location = new System.Drawing.Point (150,200); btnCancel.Size = new System.Drawing.Size (112, 32); btnCancel.Text = "&Cancel"; // set up the event handler btnCancel.Click += new System.EventHandler (this.btnCancel_Click); // Add the controls and set the client area this.AutoScaleBaseSize = new System.Drawing.Size (5, 13); this.ClientSize = new System.Drawing.Size (300, 300); this.Controls.Add (this.btnCancel); this.Controls.Add (this.lblOutput); } // handle the cancel event protected void btnCancel_Click (object sender, System.EventArgs e) { Application.Exit( ); } // Run the app public static void Main( ) { Application.Run(new HandDrawnClass( )); } } }

Potrebbero piacerti anche