It will have the following feature
-Drag and Drop, very friendly and easy to use.
- Some misc feature.
-Some picture boxes
-And a menu stripe.
I am aware that my tutorial about unpacking and packing .net assembly is not done. I lost the sample i had in mind using and will wait until i find a new fresh sample.
Now we add a Menu Stripe and add one label we change it text to 'About'. If the user click it the idea is that it should popup a second form with some information.
The Form should ate this moment look like something like this, next we will add code for the green one double click the green picture box and add the following.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void OpenFile_Click(object sender, EventArgs e) | |
{ | |
//Create and use OpenFileDialog | |
OpenFileDialog opDialog = new OpenFileDialog(); //inheriate new openfiledialog | |
if (opDialog.ShowDialog() == DialogResult.OK) | |
{ | |
//szFilePath equal to OpenFileDialog FileName | |
szFilePath = opDialog.FileName; | |
} | |
} |
Drag and Drop
Even is some thing that tricked under a special condition. We need to add two event doing that by
selecting the other picture box and right click properties click the yellow lighting icon and scroll down to DragDrop and DragEnter, in the empty text field double click. Now Do that for both DragEnter and DragDrop. Once inside "MainForm" viewing the code scroll to
public FromName(){
InitializeComponent();
}
Inside that we add the following, this make the form allow drop and event handler for drag and drop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public Form1() | |
{ | |
InitializeComponent(); | |
this.AllowDrop = true; | |
this.DragEnter += new DragEventHandler(DragFile_DragEnter); | |
this.DragDrop += new DragEventHandler(DragFile_DragDrop); | |
} |
Now add the following code, this will handle the drag and drop it self.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void DragFile_DragDrop(object sender, DragEventArgs e) | |
{ | |
try | |
{ | |
Array szFile = (Array)e.Data.GetData(DataFormats.FileDrop); | |
if (szFile.GetValue(0).ToString().EndsWith(".exe")) szFilePath = szFile.GetValue(0).ToString(); | |
} | |
catch { } | |
} | |
private void DragFile_DragEnter(object sender, DragEventArgs e) | |
{ | |
if (e.Data.GetDataPresent(DataFormats.FileDrop)) e.Effect = DragDropEffects.Copy; | |
} |
Misc notice i most off the time use iconspedia for icon's and below are links to the icon i use.
Make sure you download them as '.png'.
http://www.iconspedia.com/icon/inbox-green-icon-34984.html
http://www.iconspedia.com/icon/inbox-blue-icon-34983.html
And thanks to doublejdesign.co.uk for the icon's :).
Inga kommentarer:
Skicka en kommentar