Methods


ShowRubberBandLine


This sample demonstrates the usage of the ShowRubberBandLine method, which allows for the display of a distance between two points specified by the StartPoint and EndPoint parameters. This distance is represented visually as a flexible rubber band line.

C#

using System;
using System.Windows.Forms;
using DXFReaderNET;
using DXFReaderNET.Entities;
namespace ShowRubberLine
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        internal enum FunctionsEnum
        {
            None,
            Line1,
            Line2,
        }

        private Vector2 p1 = Vector2.Zero;
        private Vector2 p2 = Vector2.Zero;
        private FunctionsEnum CurrentFunction = FunctionsEnum.None;

        private void button1_Click(object senderEventArgs e)
        {
            CurrentFunction = FunctionsEnum.Line1;
        }

        private void Form1_Load(object senderEventArgs e)
        {
            dxfReaderNETControl1.NewDrawing();
            dxfReaderNETControl1.CustomCursor = CustomCursorType.CrossHair;
        }

        private void dxfReaderNETControl1_MouseUp(object senderMouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                switch (CurrentFunction)
                {
                    case FunctionsEnum.Line2:
                        CurrentFunction = FunctionsEnum.None;

                        p2 = dxfReaderNETControl1.CurrentWCSpoint;

                        dxfReaderNETControl1.DrawEntity(dxfReaderNETControl1.AddLine(p1.ToVector3(), p2.ToVector3()));

                        break;
                    case FunctionsEnum.Line1:
                        CurrentFunction = FunctionsEnum.Line2;

                        p1 = dxfReaderNETControl1.CurrentWCSpoint;
                        break;
                }

            }
        }

        private void dxfReaderNETControl1_MouseMove(object senderMouseEventArgs e)
        {
            switch (CurrentFunction)
            {
                case FunctionsEnum.Line2:
                    dxfReaderNETControl1.ShowRubberBandLine(p1dxfReaderNETControl1.CurrentWCSpoint);
                    break;
            }
        }
        
    }
}

VB

Imports DXFReaderNET
Public Class Form1

    Friend Enum FunctionsEnum
        None
        Line1
        Line2
    End Enum

    Private p1 As Vector2 = Vector2.Zero
    Private p2 As Vector2 = Vector2.Zero
    Private CurrentFunction As FunctionsEnum = FunctionsEnum.None

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        DxfReaderNETControl1.NewDrawing()
        DxfReaderNETControl1.CustomCursor = CustomCursorType.CrossHair
    End Sub

    Private Sub button1_Click(sender As Object, e As EventArgs) Handles button1.Click
        CurrentFunction = FunctionsEnum.Line1
    End Sub

    Private Sub DxfReaderNETControl1_MouseUp(sender As Object, e As MouseEventArgs) Handles DxfReaderNETControl1.MouseUp
        If e.Button = MouseButtons.Left Then

            Select Case CurrentFunction
                Case FunctionsEnum.Line2
                    CurrentFunction = FunctionsEnum.None
                    p2 = DxfReaderNETControl1.CurrentWCSpoint
                    DxfReaderNETControl1.DrawEntity(DxfReaderNETControl1.AddLine(p1.ToVector3(), p2.ToVector3()))
                Case FunctionsEnum.Line1
                    CurrentFunction = FunctionsEnum.Line2
                    p1 = DxfReaderNETControl1.CurrentWCSpoint
            End Select
        End If
    End Sub

    Private Sub DxfReaderNETControl1_MouseMove(sender As Object, e As MouseEventArgs) Handles DxfReaderNETControl1.MouseMove
        Select Case CurrentFunction
            Case FunctionsEnum.Line2
                DxfReaderNETControl1.ShowRubberBandLine(p1, DxfReaderNETControl1.CurrentWCSpoint)
        End Select
    End Sub
End Class



Download C# code from GitHub

Download Visual Basic code from GitHub

 


Warning!
All samples, data, places and images in this section are only for tutorial scope. They are fictitious and may not correspond to real cases.

Any similarities to actual persons or places is merely coincidental.

To evaluate all code samples you need to download and install the DXFReader.NET Compoonent first.