WorldWind Series 3: Simple Function Analysis-screenshot function and "About" form Analysis

Source: Internet
Author: User

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 );
}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.