Imports System.Math
Imports System.Drawing
Imports System.Windows.Forms
Imports Basics
Imports GraphicsObjects
Public Class GraphicsDerivadeTool
Inherits GraphicsToolWVisor
Protected intEnableDer As Boolean
Private GMCls As GraphicMathCls
Private MathDeleg As BVMathDelegate
Private x, y As Single
Private P1, P2 As PointF
Dim pend As Single
#Region "Constructor"
Public Sub New(ByVal Visor2D As IVisorBase, ByVal CalcObj As Object)
MyBase.New(Visor2D)
'objVisor2D = Visor2D
GMCls = New GraphicMathCls(objVisor2D)
If TypeOf CalcObj Is ICalcS Then
MathDeleg = New BVMathDelegate(CType(CalcObj, ICalcS))
ElseIf TypeOf CalcObj Is ICalcSC Then
MathDeleg = New BVMathDelegate(CType(CalcObj, ICalcSC))
Else
Throw New Exception("Invalid CalcObject")
End If
'AddHandler objVisor2D.MouseDown, AddressOf OnRenderControl_MouseDown
'AddHandler objVisor2D.MouseUp, AddressOf OnRenderControl_MouseUp
'AddHandler objVisor2D.MouseMove, AddressOf OnRenderControl_MouseMove
End Sub
'Public Sub Dispose()
' RemoveHandler objVisor2D.MouseDown, AddressOf OnRenderControl_MouseDown
' RemoveHandler objVisor2D.MouseUp, AddressOf OnRenderControl_MouseUp
' RemoveHandler objVisor2D.MouseMove, AddressOf OnRenderControl_MouseMove
'End Sub
#End Region
#Region "Properties"
Public Property EnableDer() As Boolean
Get
Return intEnableDer
End Get
Set(ByVal Value As Boolean)
intEnableDer = Value
End Set
End Property
#End Region
#Region "Methods"
Protected Overrides Sub OnRenderControl_MouseDown(ByVal sender As Object, ByVal e As MouseEventArgs)
Draw(sender, e)
End Sub
Protected Overrides Sub OnRenderControl_MouseUp(ByVal sender As Object, ByVal e As MouseEventArgs) 'Handles objVisor2D.OnRenderControlMouseUp
Draw(sender, e)
End Sub
Protected Sub Draw(ByVal sender As Object, ByVal e As MouseEventArgs)
If EnableDer Then
If e.Button = MouseButtons.Left OrElse e.Button = MouseButtons.Right Then
pend = MathDeleg.DerivadeDelegate(objVisor2D.Cursor1Position.X, 0.0001)
y = MathDeleg.CalcDelegate(objVisor2D.Cursor1Position.X)
x = objVisor2D.Cursor1Position.X
Me.GMCls.GetTangentCoordinates(x, y, pend, P1, P2)
Me.objVisor2D.Refresh(Me)
'GMCls.DrawTangent(
End If
End If
End Sub
Protected Overrides Sub OnRenderControl_MouseMove(ByVal sender As Object, ByVal e As MouseEventArgs) 'Handles objVisor2D.OnRenderControlMouseMove
Draw(sender, e)
End Sub
#End Region
Public Overrides Sub Redraw(ByVal sender As Object, ByVal p As PaintEventArgs)
If intEnableDer Then
p.Graphics.DrawLine(Me.intGraphics.Pen, P1, P2)
'GMCls.DrawTangent(p.Graphics, x, y, pend, False)
End If
End Sub
End Class