devDept Eyeshot Documentation Send comments on this topic.
Quick Start
See Also
Getting Started > Quick Start

Glossary Item Box

This topic will give you a head start on creating great looking viewport for all of your Windows Forms applications.

 

Step 1 Creating a new Windows Application Project

  1. Launch Visual Studio
  2. From the File menu, select New, and then click Project
  3. In the New Project dialog box, click either Visual C# or Visual Basic from the Project types list
  4. From the Templates list, click Windows Forms Application
  5. In the Name field, replace the default project name with the name of your project

 

Step 2 Adding a viewport to Form1

Add a viewport to your Windows Form by either double-clicking on the ViewportProfessional toolbox icon (installed in the Eyeshot tab of the toolbox), or by clicking on the icon once then "drawing" the viewport onto the form using the left mouse button. 

The Eyeshot viewport control in design-time mode

Figure 1: The Eyeshot viewport control in design-time mode.

 

Step 3 Required using/Imports statements

Add the following using/Imports statements at the beginning of the Form1.cs file.

C# Copy Code
using devDept.Eyeshot;
using devDept.Eyeshot.Standard;
using devDept.Eyeshot.Geometry;
Visual Basic Copy Code
Imports devDept.Eyeshot
Imports devDept.Eyeshot.Standard
Imports devDept.Eyeshot.Geometry

 

Step 4 Customizing your viewport

Expand the Background property in the Properties window under the Viewport category and change the TopColor. A long list of viewport attributes is available, spend a couple of minutes on them.

Changing the viewport control background

Figure 2: Changing the viewport control background.

 

Step 5  Adding the Load event handler to Form1 

From the Form1 properties window switch to Events and double-click the Load event, the Form1_Load() method will be added to the Form1 class.

 

Step 6 Drawing a rectangular face

Add the following lines to the Form1_Load() method, then build and start your application.

C# Copy Code
private void Form1_Load(object sender, EventArgs e)
{

  
// creates a new Quad entity
  
Quad q = new Quad(
                  0,  0,  0,  
// first vertex
                
100,  0,  0,  // second vertex
                
100, 80, 80,  // third vertex
                  
0, 80, 80,  // fourth vertex
                
Color.DarkOrange);

  
// adds the entity to viewport's master entity collection
  
viewportProfessional1.Entities.Add(q);

  
// Sets edge color as entity color
  
viewportProfessional1.Edge.ColorMode = edgeColorType.EntityColor;

  
// Fits the model in the viewport
  
viewportProfessional1.ZoomFit();

}   
Visual Basic Copy Code
Private Sub Form1_Load( _
        ByVal sender As System.Object, _
        ByVal e As System.EventArgs) Handles MyBase.Load

   ' creates a new Quad entity
   Dim q As New Quad( _
                   0, 0, 0, _ ' first vertex
                 100, 0, 0, _ ' second vertex
                 100, 80, 80, _ ' third vertex
                   0, 80, 80, _ ' fourth vertex
                 Color.DarkOrange))

   ' adds the entity to viewport's master entity collection
   viewportProfessional1.Entities.Add(q);

   ' Sets edge color as entity color
   viewportProfessional1.Edge.ColorMode = edgeColorType.EntityColor

   ' Fits the model in the viewport
   viewportProfessional1.ZoomFit()

End Sub

You should now see something like this:

Your first 3D drawing with Eyeshot

Figure 3: Your first 3D drawing with Eyeshot.

Navigation quick commands:

  • Middle mouse button combined with Ctrl or Shift keys to Zoom/Pan/Rotate.
  • Mouse wheel to Zoom.
  • Ctrl+F to fit the model in the viewport

For your convenience you may want to rename viewportProfessional1 as viewport1.

 

Step 7 Now it's your turn

Try to add more entities like points, lines, circles, triangles, etc. You'll find them in the devDept.Eyeshot.Standard namespace.

See Also