Screenshot Function Analysis in WorldWind. CS:
Private void menuitemsavescreenshot_click (Object sender, system. eventargs E) for processing screenshot menu commands,
The savefiledialog dialog is displayed to set the storage format and path selection.
This. worldwindow. savescreenshot (DLG. filename); // call the savescreenshot () method in worldwindow. CS to save the complete path set. This. savescreenshotfilepath = filepath; this is not implemented here.
The real screenshot function of worldwindow. CS is implemented by calling the render () and savescreenshot () Methods of the overload onpaint (painteventargs e) method.
If (savescreenshotfilepath! = NULL)
Savescreenshot ();
Screenshot output code
Protected Void Savescreenshot ()
{
Try
{
Using (Surface backbuffer = M_device3d.getbackbuffer ( 0 , 0 , Backbuffertype. Mono ))
Surfaceloader. Save (savescreenshotfilepath, savescreenshotimagefileformat, backbuffer );
Savescreenshotfilepath = Null ;
}
Catch (Invalidcallexception caught)
{
MessageBox. Show (caught. Message, " Screenshot save failed. " , Messageboxbuttons. OK, messageboxicon. Error );
}
}
Implementation key:
Add in worldwindow. CS
Using Microsoft. DirectX. direct3d;
Using Microsoft. DirectX;
HereCall the getbackbuffer method of the direct3d device class (instance: m_device3d) and call the surfaceloader. Save static method of the direct3d namespace to save.
You can learn from this screenshot method.
"About the form": aboutdialog. CS Analysis
1. load images from files
This. picturebox. Image = splash. getstartupimage ();
Public static image getstartupimage ()
{
ReturnImage. fromfile (path. getdirectoryname (application. executablepath) + "\ data \ icons \ interface \ splash.png ");
}
2. Obtain the parent form of the pop-up form, and then you can call the attributes and methods of the parent form.
Private Void Picturebox_click ( Object Sender, system. eventargs E)
{
Mainapplication mainapp = (Mainapplication) This . Owner; // Obtain the parent form of the pop-up form
String URL = Mainapplication. websiteurl;
Mainapp. browseto (URL ); // Method for calling the parent form
// Mainapplication. browseto (mainapplication. websiteurl );
}
3. Jump to the webpage address through the process, instead of simply calling IE to execute the webpage address,Advantage: prevent Internet Explorer from being used in customers' computers
How to open the URL
Public Void Browseto ( String URL)
{
Processstartinfo PSI = New Processstartinfo ();
PSI. filename = URL;
PSI. verb = " Open " ;
PSI. useshellexecute = True ;
PSI. createnowindow= True;
Process. Start (PSI );
}
SimplyUse IE to open the network address: process. Start ("iexplore.exe", "http://www.163.com ");
4. The onkeyup function of the Form keyevent event is reloadedThe form accepts the keyboard response.
Protected override void onkeyup (system. Windows. Forms. keyeventargs E)
{
Switch (E. keycode)
{
Case keys. Escape:
Close ();
E. Handled = true;
Break;
Case keys. F4:
If (E. modifiers = keys. Control)// Modifiers is the keyup or keydown modifier, which indicates that the key combination of Ctrl, ALT, and shift is pressed.
{
Close ();
E. Handled = true; // indicates that the event has been responded.
}
Break;
}
Base. onkeyup (E );
}