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.
In the Toolbox, find the MultiLayerViewer item and drag it to the form.
Edit the control properties, if needed, for example adjust its size and working area.
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
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); }
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
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); }
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
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:
Fig. 2. The resulting form design
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:
Fig. 3. Sample application