DXFReaderNETControlShowRubberBandLine Method |
Namespace: DXFReaderNET
public void ShowRubberBandLine( Vector2 StartPoint, Vector2 EndPoint, Color? Color = null, RubberBandType RubberBandType = RubberBandType.Dashed, bool Keep = false )
[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