Click or drag to resize

DXFReaderNETControlShowRubberBandLine Method

Shows the distance specified by the StartPoint and EndPoint parameters as a rubber band line.

Namespace:  DXFReaderNET
Assembly:  DXFReaderNET (in DXFReaderNET.dll) Version: 20.10.54
Syntax
public void ShowRubberBandLine(
	Vector2 StartPoint,
	Vector2 EndPoint,
	Color? Color = null,
	RubberBandType RubberBandType = RubberBandType.Dashed,
	bool Keep = false
)

Parameters

StartPoint
Type: DXFReaderNETVector2
The start point of the line.
EndPoint
Type: DXFReaderNETVector2
The start point of the line.
Color (Optional)
Type: SystemNullableColor
The color of the rubber band if solid. If omitted the CurrentColor will be used.
RubberBandType (Optional)
Type: DXFReaderNETRubberBandType
The type of rubber band: solid or dashed.
Keep (Optional)
Type: SystemBoolean
True if the rubber line isn't deleted after mouse click.
Remarks
See also the code sample.
Examples
Sample code to draw a 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 sender, EventArgs e)
        {
            CurrentFunction = FunctionsEnum.Line1;
        }

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

        private void dxfReaderNETControl1_MouseUp(object sender, MouseEventArgs 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 sender, MouseEventArgs e)
        {
            switch (CurrentFunction)
            {
                case FunctionsEnum.Line2:
                    dxfReaderNETControl1.ShowRubberBandLine(p1, dxfReaderNETControl1.CurrentWCSpoint);
                    break;
            }
        }

    }
}
[Visual Basic]
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
See Also