This documentation is for the old version. Go to the latest Graphics Mill docs

Quick Start in Vector Objects

This topic describes how to get started with the Vector Objects module when creating a Windows application. As an example, a simple Windows Forms application will be created in this topic. It will allow the user to add rectangles and text and remove all objects from the viewer area.

Step 1: Create a Form

  1. Create a new Windows Forms application in Visual Studio: on the File menu choose New and click Project.
  2. Add the MultiLayerViewer control to the toolbox:
    1. Right-click the component toolbox and click Choose Items. This will open the Choose Toolbox Items dialog:
      Choose Toolbox Items dialog
      Fig. 1. Choose Toolbox Items dialog
    2. Find the MultiLayerViewer component on the .NET Framework Components tab. If, for some reason, you cannot find this component, click the Browse button and select the Aurigma.GraphicsMill.WinControls.dll assembly. Then, choose the MultiLayerViewer component as described above.

Step 2: Edit the Form

Add the MultiLayerViewer Control

In the Toolbox, find the MultiLayerViewer iconMultiLayerViewer item and drag it to the form.

Edit the control properties, if needed, for example adjust its size and working area.

Add Buttons

  1. Drag the standard Button control to the form. Edit button properties, changing its text to "Rectangle". This button will add a rectangle to the drawing.
  2. Add the following click event handler for the button:
    Visual Basic
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
        Handles Button1.Click
        'Create a rectangle object
        Dim rectangle As New Aurigma.GraphicsMill.WinControls.RectangleVObject(0.0F, _
            0.0F, MultiLayerViewer1.WorkspaceWidth, MultiLayerViewer1.WorkspaceHeight)
    
        'Modify stroke and fill parameters
        rectangle.Pen = New System.Drawing.Pen(System.Drawing.Color.BlanchedAlmond, _
            10.0F)
        rectangle.Brush = New System.Drawing.SolidBrush(System.Drawing.Color.Wheat)
    
        'Add the rectangle to a layer
        MultiLayerViewer1.Layers.Item(0).VObjects.Add(rectangle)
    End Sub
    
    C#
    private void button1_Click(object sender, System.EventArgs e)
    {
        //Create a rectangle object
        Aurigma.GraphicsMill.WinControls.RectangleVObject rectangle = new
            Aurigma.GraphicsMill.WinControls.RectangleVObject(0F, 0F,
            multiLayerViewer1.WorkspaceWidth, multiLayerViewer1.WorkspaceHeight);
        
        //Modify stroke and fill parameters
        rectangle.Pen = new System.Drawing.Pen(System.Drawing.Color.BlanchedAlmond, 10F);
        rectangle.Brush = new System.Drawing.SolidBrush(System.Drawing.Color.Wheat);
    
        //Add the rectangle to a layer
        multiLayerViewer1.Layers[0].VObjects.Add(rectangle);
    }
    
  3. Drag the standard Button control to the form. Edit button properties, changing its text to "Text". This button will add a text string to the drawing.
  4. Add the following click event handler for the button:
    Visual Basic
    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
        Handles Button2.Click
        'Create a text object
        Dim text As New Aurigma.GraphicsMill.WinControls.TextVObject
    
        'Set text
        text.Text = "Sample text"
    
        'Add the text to the layer
        MultiLayerViewer1.Layers.Item(0).VObjects.Add(text)
    End Sub
    
    C#
    private void button2_Click(object sender, System.EventArgs e)
    {
        //Create a text object
        Aurigma.GraphicsMill.WinControls.TextVObject text = new
            Aurigma.GraphicsMill.WinControls.TextVObject();
    
        //Set text
        text.Text = "Sample text";
    
        //Add the text to the layer
        multiLayerViewer1.Layers[0].VObjects.Add(text);
    }
    
  5. Drag the standard Button control to the form. Edit button properties, changing its text to "Clear all". This button will clear the drawing.
  6. Add the following click event handler for the button:
    Visual Basic
    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
        Handles Button3.Click
        'Remove all objects from the layer
        MultiLayerViewer1.Layers.Item(0).VObjects.Clear()
    End Sub
    
    C#
    private void button3_Click(object sender, System.EventArgs e)
    {
        //Remove all objects from the layer
        multiLayerViewer1.Layers[0].VObjects.Clear();
    }
    

The resulting form should look as follows:

Visual Studio Form Designer
Fig. 2. The resulting form design

Step 3: Test the Application

To test your application, run it either from the Debug menu (Debug -> Start Without Debugging), or by pressing Ctrl+F5.

After your application is loaded, add objects to the drawing area by clicking form buttons. Try to move or modify the objects you have added.

After that, your application will look like on this screenshot:

Sample application
Fig. 3. Sample application

See Also

Reference

Manual