Imports System.Drawing
Imports System.Windows.Forms
Imports Basics
Imports IMidRange
Imports MidRange
Public MustInherit Class VisorBase
Inherits BVGraphics
#Region "constantes"
Public Const XLabelsWidth = 60 '50
Public Const YLabelsHeight = 30
Public Const FrameBorders = 10
#End Region
#Region "Object"
Protected objGraphColorMode As GraphColorMode 'Almacena el Tipo de sistema de colores a utilizar
Protected BVArrayColor As BVSystemColors
'Protected ArrayLines As BVArrayList
Protected ArrayPoints() As PointF
Protected GUtil As GraphicUtilities
Protected Shared objMath As BVMathFunctions
Protected objStrMath As BVStrMath
Protected WithEvents objRender As System.Windows.Forms.Control
'Protected intGraph As Graphics
Protected PenAxis As Pen
'Protected PenValue As Pen
'Protected drawFont As System.Drawing.Font
'Protected drawBrush As System.Drawing.SolidBrush
'Protected BmpFrame As Bitmap
#End Region
Protected intEngineState As EEngineState
Protected DefaultPenWidth As Integer
Protected wasResized As Boolean 'el objeto fue redimensionado
Public Sub New(ByVal DrawingBmp As Bitmap)
MyBase.New(DrawingBmp)
DefaultPenWidth = 2
wasResized = True
End Sub
Public Sub New(ByVal RenderControl As Control)
MyBase.New(RenderControl)
DefaultPenWidth = 2
wasResized = True
End Sub
Public Property EngineState() As EEngineState
Get
Return intEngineState
End Get
Set(ByVal Value As EEngineState)
'se puede pasar de Ready a Idle, y viceversa
If Value = EEngineState.EExternalSetedToIdle Then
If intEngineState = EEngineState.EReady Then
intEngineState = Value
End If
ElseIf Value = EEngineState.EReady Then
If intEngineState = EEngineState.EExternalSetedToIdle Then
intEngineState = Value
End If
'raiseevent
End If
End Set
End Property
Public Property RenderControl() As Control
Get
Return Me.objRender
End Get
Set(ByVal Value As Control)
If Not Value Is Nothing Then
objRender = Value
End If
End Set
End Property
End Class
'Visor 2D de Multiples entradas
'sin terminar
Public Class Visor2DMultiGraph
Inherits VisorBase
'Implements IFrameEvents
Implements IZoomable
#Region "Atributs"
Protected InsertCiclyc As Boolean 'al insertar graficos comenzar de nuevo o quedarse en el ultimo
Protected HshTblIdGrp2IdFrm As BVHashTable 'IdGraph, IdFrame
Protected HshTblIDSto2IdFrm As BVHashTable 'IdGraph, IdFrame
Protected ArrFrames As BVHashTable 'almacena los objetos frame
Public Cursor1Position As PointF 'posicion del mouse o del cursor
Public Cursor2Position As PointF 'posicion del mouse o del cursor
Protected intGraphN As GraphOfVisor2D
Protected WithEvents intFrameN As IFrameOfVisor
Protected WithEvents intStorage2d As IStorage
Public Event SendMessage(ByVal sender As Object, ByVal S As MessageEventArgs) Implements IisComunicable.SendMessage
Public Event OnRenderControlMouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Implements IFrameEvents.OnRenderControlMouseDown
Public Event OnRenderControlMouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Implements IFrameEvents.OnRenderControlMouseMove
Public Event OnRenderControlMouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Implements IFrameEvents.OnRenderControlMouseUp
#End Region
#Region "Local Enums"
Public Enum FramePos
First
Current
Last
NewFrame
NextFrame 'no crea uno nuevo, se estanca en el ultimo
PreviousFrame
End Enum
Public Enum TypeofFrame
XY
ComplexPlain
SerialInput
End Enum
Public Enum TypeOfGraph
XY
ComplexPlain
SerialInput
End Enum
#End Region
#Region "Constructor"
Sub New(ByVal RenderDevice As Control)
Dim r As Rectangle
intEngineState = EEngineState.EInicializing
objRender = RenderDevice
objMath = New BVMathFunctions
objStrMath = New BVStrMath
BVArrayColor = New BVSystemColors(BVSisColorType.S2D)
objGraphColorMode = GraphColorMode.CPrinter
SetDefaultColors()
BmpFrame = New Bitmap(RenderDevice.Width, RenderDevice.Height)
PenAxis = New Pen(BVArrayColor.SisColor(BV2DColors.CAxis))
PenValue = New Pen(BVArrayColor.SisColor(BV2DColors.CFunc0))
drawFont = New System.Drawing.Font("Arial", 10)
drawBrush = New System.Drawing.SolidBrush(BVArrayColor.SisColor(BV2DColors.CAxis))
DefauldGrph = Graphics.FromImage(BmpFrame)
gutil = New GraphicUtilities(penvalue, DefauldGrph)
HshTblIdGrp2IdFrm = New BVHashTable
HshTblIDSto2IdFrm = New BVHashTable
ArrFrames = New BVHashTable
PenValue.Width = 2
PenAxis.DashStyle = Drawing2D.DashStyle.Dot
CreateNewFrame()
intEngineState = EEngineState.EWaitingForData
End Sub
Public Sub Dispose() Implements System.IDisposable.Dispose
intEngineState = EEngineState.EDisposing
intFrameN = Nothing
intGraphN = Nothing
intStorage2d = Nothing
objRender = Nothing
objMath = New BVMathFunctions
objStrMath = New BVStrMath
BVArrayColor = New BVSystemColors(BVSisColorType.S2D)
objGraphColorMode = GraphColorMode.CPrinter
SetDefaultColors()
BmpFrame.Dispose()
PenAxis.Dispose()
PenValue.Dispose()
drawFont.Dispose()
drawBrush.Dispose()
DefauldGrph.Dispose()
gutil = Nothing
HshTblIDSto2IdFrm.Clear()
HshTblIDSto2IdFrm = Nothing
ArrFrames.Clear()
ArrFrames = Nothing
End Sub
'Form reemplaza a Dispose para limpiar la lista de componentes.
Protected Sub Dispose(ByVal disposing As Boolean)
If disposing Then
End If
End Sub
#End Region
#Region "Properties"
#Region "Other"
Public ReadOnly Property FrameCount()
Get
Return intFrameN.Count
End Get
End Property
#End Region
#Region "Behaviour"
Public Property ResetScaleOnChange() As Boolean
Get
'Return intFrameN.blnResetOldScale
End Get
Set(ByVal Value As Boolean)
'intFrameN.blnResetOldScale = Value
End Set
End Property
#End Region
#Region "Stetic"
Public Property GraphColorMode() As GraphColorMode
Get
Return objGraphColorMode
End Get
Set(ByVal Value As GraphColorMode)
objGraphColorMode = Value
SetDefaultColors()
drawBrush.Color = BVArrayColor.SisColor(BV2DColors.CAxis)
PenValue.Color = BVArrayColor.SisColor(BV2DColors.CFunc0)
PenAxis.Color = BVArrayColor.SisColor(BV2DColors.CAxis)
End Set
End Property
Public Property SubGraphMode() As SubGraphType 'implements IVisor2DComplexU.InputStorag
Get
Return intGraphN.TypeOfSubGraph
End Get
Set(ByVal Value As SubGraphType)
intGraphN.TypeOfSubGraph = Value
' blnSubGraphTypeChanged = True
End Set
End Property
#End Region
#Region "Scale Section"
'solo para la variable Y
Public Property AutoScale() As Boolean
Get
Return Me.intFrameN.AutoScale
End Get
Set(ByVal Value As Boolean)
Me.intFrameN.AutoScale = Value
UpdatePointsArrays()
Redraw()
'Refresh()
End Set
End Property
Public Property Scale() As Single
Get
Return Me.intFrameN.Scale
End Get
Set(ByVal Value As Single)
Me.intFrameN.Scale = Value
UpdatePointsArrays()
Redraw()
'Refresh()
End Set
End Property
Public Property OrdOrigin() As Single
Get
Return Me.intFrameN.OrdOrigin
End Get
Set(ByVal Value As Single)
intFrameN.OrdOrigin = Value
UpdatePointsArrays()
Redraw()
'Refresh()
End Set
End Property
#End Region
#Region "Zoom Section"
Public Overloads Sub Zoom(ByVal factor As Single, ByVal Center As PointF) Implements IZoomable.Zoom
intFrameN.Zoom(factor, Center)
UpdatePointsArrays()
Redraw()
'Refresh()
End Sub
Public Overloads Sub Zoom(ByVal Corner1 As PointF, ByVal Corner2 As PointF) Implements IZoomable.Zoom
intFrameN.Zoom(Corner1, Corner2)
UpdatePointsArrays()
Redraw()
'Refresh()
End Sub
Public Overloads Sub Zoom(ByVal Rect As System.Drawing.RectangleF) Implements IZoomable.Zoom
intFrameN.Zoom(Rect)
UpdatePointsArrays()
Redraw()
'Refresh()
End Sub
Public Overloads Sub Zoom(ByVal Back As EZoomBack) Implements IZoomable.Zoom
intFrameN.Zoom(Back)
UpdatePointsArrays()
Redraw()
'Refresh()
End Sub
#End Region
#Region "Current GV and Frame"
'retorna el Id del grafico corriente
Public Property CurrentGraphId() As Integer
Get
Return intGraphN.Id
End Get
Set(ByVal Value As Integer)
Me.GetGraph(Value)
End Set
End Property
Public ReadOnly Property CurrentGraph() As GraphOfVisor2D
Get
Return GetFirstGraph(True)
End Get
End Property
Public ReadOnly Property CurrentFrame() As IFrameOfVisor
Get
If intFrameN Is Nothing Then
Return Me.GetFirstFrame(True)
Else
Return intFrameN
End If
End Get
End Property
#End Region
#Region "Axis Type"
Public Property XAxisType() As EAxisType
Get
If TypeOf intFrameN Is IFrameXY Then
Dim ifxy As IFrameXY = CType(intFrameN, IFrameXY)
Return ifxy.XAxisType
Else
Stop
End If
End Get
Set(ByVal Value As EAxisType)
If TypeOf intFrameN Is IFrameXY Then
Dim ifxy As IFrameXY = CType(intFrameN, IFrameXY)
If ifxy.FrameCalcX.AxisType <> Value Then
ifxy.XAxisType = Value
UpdatePointsArrays()
Redraw()
'Refresh()
End If
Else
Stop
End If
End Set
End Property
Public Property YAxisType() As EAxisType
Get
If TypeOf intFrameN Is IFrameXY Then
Dim ifxy As IFrameXY = CType(intFrameN, IFrameXY)
Return ifxy.YAxisType
Else
Stop
End If
End Get
Set(ByVal Value As EAxisType)
If TypeOf intFrameN Is IFrameXY Then
Dim ifxy As IFrameXY = CType(intFrameN, IFrameXY)
If ifxy.YAxisType <> Value Then
ifxy.YAxisType = Value
UpdatePointsArrays() 'actualizo el resto
Redraw()
'Refresh()
End If
Else
Stop
End If
End Set
End Property
#End Region
#End Region
#Region "Remove Sector"
'remueve el grafico de Id, retorna true si fue encontrado y removido
Public Function RemoveGraph(ByVal IdGraph As Integer) As Boolean
Dim igraph As GraphOfVisor2D
Stop 'totalmente desactualizado
igraph = intFrameN.ArrGraphs.GetValue(IdGraph)
If Not igraph Is Nothing Then
intStorage2d = igraph.ObjStorage
RemoveHandler intStorage2d.OnDataChanged, AddressOf StorageChanged
Return True
Else
Return False
End If
End Function
'remueve el Frame de Id, retorna true si fue encontrado y removido
Public Function RemoveFrame(ByVal IdFrame As Integer) As Boolean
Stop 'totalmente desactualizado
If ArrFrames.Count > 1 Then
If ArrFrames.Contains(IdFrame) Then
ClearFrame(IdFrame)
intFrameN.ArrGraphs.Remove(IdFrame)
Return True
Else
Return False
End If
Else
'el ultimo frame no se remueve, pero se quitan todos los graficos de el
ClearFrame(IdFrame)
Return False
End If
End Function
'limpia el Frame especificado
Public Sub ClearFrame(ByVal IdFrame As Integer)
Dim i As Integer
Dim g As GraphOfVisor2D
Stop 'totalmente desactualizado
For i = 0 To intFrameN.ArrGraphs.Count - 1
g = intFrameN.ArrGraphs(i)
If g.FrameId = IdFrame Then
intStorage2d = g.ObjStorage
RemoveHandler intStorage2d.OnDataChanged, AddressOf StorageChanged
intFrameN.ArrGraphs.Remove(i)
End If
Next
End Sub
#End Region
#Region "Get Frame and Graph Sector"
'cambia de frame a la funcion indicada en el Id, retorna true si encontro la
'funcion y el frame indicado, ademas de si fue realmente cambiado de frame
'(quizas se le indica el mismo destino que el frame original)
Public Function VerifieGraphFrame(ByVal graphId As Integer, ByVal FrameId As Integer) As Boolean
If HshTblIDSto2IdFrm.ContainsKey(graphId) Then
If ArrFrames.Contains(FrameId) Then
If HshTblIDSto2IdFrm(graphId) = FrameId Then
'frame target = Frame origin
Return True
Else
'eliminar el grafico del frame original, dejar disponible el deseado
intFrameN = ArrFrames.Item(HshTblIDSto2IdFrm.Item(graphId))
'remuevo y actualizo la tabla
intGraphN = intFrameN.ArrGraphs.GetValue(graphId)
HshTblIDSto2IdFrm.Remove(graphId)
'devuelvo el frame indicado
intFrameN = GetFrame(FrameId, True)
Return True
End If
Else
'frame inexistente
RaiseEvent SendMessage(Me, New MessageEventArgs("Unknown Frame", MessageEventArgs.EMessageType.Eerror))
Return False
End If
Else
'grafico inexistente
RaiseEvent SendMessage(Me, New MessageEventArgs("Unknown Graph", MessageEventArgs.EMessageType.Eerror))
Return False
End If
End Function
'devuelve el frame indicado, uno nuevo si se desea y se ha sobrepasado en 1
'la cantidad de frames, o el actual en otro caso
Protected Function GetFrame(ByVal FrameNumber As Integer, ByVal CreateIfNecesary As Boolean) As IFrameOfVisor
If FrameNumber <> intFrameN.Id Then
If FrameNumber < intFrameN.Count And FrameNumber >= 0 Then
'agregar a los frames existentes, recupero el frame
intFrameN = ArrFrames(FrameNumber)
ElseIf FrameNumber < intFrameN.Count + 1 Then
'agregar a un nuevo frame, hay que dividir el Panel en N partes
If CreateIfNecesary Then
CreateNewFrame()
Else
Return intFrameN
End If
Else
Stop
RaiseEvent SendMessage(Me, New MessageEventArgs("Frame number exceded o small than zero", MessageEventArgs.EMessageType.Eerror))
Return intFrameN
End If
Else
Return intFrameN
End If
End Function
'retorna el primero de los frames
Protected Function GetFirstFrame(ByVal CreateIfNecesary As Boolean) As IFrameOfVisor
If intFrameN.Count > 0 Then
Dim arr(intFrameN.Count - 1) As IFrameOfVisor
ArrFrames.Values.CopyTo(arr, 0)
intFrameN = arr(0)
Else
Stop
If CreateIfNecesary Then
Me.CreateNewFrame()
Else
Return Nothing
End If
End If
Return intFrameN
End Function
'devuelve el primer grafico encontrado
Protected Function GetFirstGraph(ByVal CreateIfNecesary As Boolean) As GraphOfVisor2D
If intGraphN Is Nothing Then
If intFrameN Is Nothing Then
GetFirstFrame(True)
End If
If intFrameN.ArrGraphs.Count > 0 Then
Dim arrg(intFrameN.ArrGraphs.Count - 1) As GraphOfVisor2D
intFrameN.ArrGraphs.Values.CopyTo(arrg, 0)
intGraphN = arrg(0)
End If
If intGraphN Is Nothing Then
If CreateIfNecesary Then
intGraphN = New GraphOfVisor2D(intFrameN.Id, PenValue, SubGraphType.TReal)
intGraphN.intPen = PenValue.Clone
'me.cre
End If
End If
End If
Return intGraphN
End Function
'devuelve en intGraphN el grafico indicado, retornando true si existe tal grafico
'en caso contrario devuelve false y deja intacto a la variable intGraphN
Protected Function GetGraph(ByVal GraphId As Integer) As Boolean
Dim FrN As IFrameOfVisor
If HshTblIdGrp2IdFrm.ContainsKey(GraphId) Then
FrN = ArrFrames.Item(HshTblIDSto2IdFrm.Item(GraphId))
'remuevo y actualizo la tabla
'intGraphN = FrN.ArrGraphs.GetValue(GraphId)
intGraphN = FrN.ArrGraphs.Item(GraphId)
'devuelvo el graph indicado
Return True
End If
End Function
#End Region
#Region "Input Object Sector"
'agrega el grafico indicado, devuelve true si fue ingresado exitosamente
Public Function Add(ByVal InputStorage As IStorage, ByVal Frame As FramePos, ByVal ReScale As Boolean) As Boolean
If InputStorage Is Nothing Then
Stop
Throw New Exception("No IStorage Input Compatible object was send")
Return False
End If
If HshTblIDSto2IdFrm.ContainsKey(InputStorage.Id) Then
'vuelvo, ya que los cambios del objeto se actualizan con eventos
Return False
End If
If Frame = FramePos.Current Then
If Not intGraphN Is Nothing Then
If Not intGraphN.ObjStorage Is Nothing Then
Me.CreateGraph()
End If
End If
Add(InputStorage, ReScale)
ElseIf Frame = FramePos.Last Then
Add(InputStorage, intFrameN.Count - 1, ReScale)
ElseIf Frame = FramePos.NewFrame Then
CreateNewFrame()
If Not intGraphN Is Nothing Then
If Not intGraphN.ObjStorage Is Nothing Then
Me.CreateGraph()
End If
End If
'Me.GetFrame(intFrameN.Count - 1, False)
Add(InputStorage, ReScale)
ElseIf Frame = FramePos.NextFrame Then
If intFrameN.Id = intFrameN.Count - 1 Then
If InsertCiclyc Then
Add(InputStorage, 0, ReScale)
Else
Add(InputStorage, intFrameN.Id, ReScale)
End If
End If
Else 'If Frame = FramePos.PreviousFrame Then
If intFrameN.Id = 0 Then
If InsertCiclyc Then
Add(InputStorage, intFrameN.Id, ReScale)
Else
Add(InputStorage, 0, ReScale)
End If
End If
End If
Return True
End Function
'agrega al grafico indicado por numero
Public Function Add(ByVal InputStorage As IStorage, ByVal FrameNumber As Integer, ByVal ReScale As Boolean) As Boolean
If InputStorage Is Nothing Then
Stop
Throw New Exception("No IStorage Input Compatible object was send")
Return False
End If
If HshTblIDSto2IdFrm.ContainsKey(InputStorage.Id) Then
'vuelvo, ya que los cambios del objeto se actualizan con eventos
Return False
End If
'si ya se esta utilizando el frame deseado sigo
Dim iId = CType(InputStorage, IIdentificable)
If Not iId Is Nothing Then
If Not VerifieGraphFrame(iId.Id, FrameNumber) Then
If ArrFrames.Count > 0 Then
Stop 'sin terminar
End If
Exit Function
End If
Else
Stop
RaiseEvent SendMessage(Me, New MessageEventArgs("IIdentificable object nedded", MessageEventArgs.EMessageType.Eerror))
'no se pueden utilizar objetos sin Id
End If
Return Add(InputStorage, ReScale)
End Function
'Agrega el Objeto storage al grafico actual, sea cual sea
Public Function Add(ByVal InputStorage As IStorage, ByVal ReScale As Boolean) As Boolean
If InputStorage Is Nothing Then
Stop
Throw New Exception("No IStorage Input Compatible object was send")
Return False
End If
If HshTblIDSto2IdFrm.ContainsKey(InputStorage.Id) Then
'vuelvo, ya que los cambios del objeto se actualizan con eventos
Return False
End If
If InputStorage.DataChanged Then
InputStorage.Storage()
End If
'Me.VerifieGraphFrame(InputStorage.Id, intFrameN.Id)
InputStorage.ScreenRect = intFrameN.DrawingRectangle
'agrego el objeto nuevo
If intGraphN Is Nothing Then
'para la primera funcion ingresada
intFrameN.UsedScaleR.Reset(InputStorage.ScaleR.Min, InputStorage.ScaleR.Max)
intFrameN.UsedScaleI.Reset(InputStorage.ScaleI.Min, InputStorage.ScaleI.Max)
If TypeOf intFrameN Is IFrameXY Then
Dim ifxy As IFrameXY = CType(intFrameN, IFrameXY)
ifxy.UsedScaleX.Reset(InputStorage.ScaleX.Min, InputStorage.ScaleX.Max)
ifxy.UsedScaleY.Reset(InputStorage.ScaleY.Min, InputStorage.ScaleY.Max)
Else
Stop
End If
PenValue.Color = BVArrayColor.SisColor(BV2DColors.CFunc0)
intGraphN = New GraphOfVisor2D(intFrameN.Id, PenValue, InputStorage.SubGraphMode)
intGraphN.intPen = PenValue.Clone
Else
'para el resto de las funciones ingresadas
PenValue = New Pen(BVArrayColor.SisColor(intFrameN.ArrGraphs.Count))
PenValue.Width = DefaultPenWidth
'intGraphN = New GraphOfVisor2D(intFrameN.Id, PenValue, InputStorage.SubGraphMode)
intGraphN.intPen = PenValue.Clone
FindGralFrameScaleValues(InputStorage, intFrameN.Id)
End If
If intGraphN.ObjStorage Is Nothing Then
'objeto nuevo
intGraphN.ObjStorage = InputStorage
AddHandler InputStorage.OnDataChanged, AddressOf StorageChanged
Else
If intGraphN.ObjStorage.Id <> InputStorage.Id Then
'cambio de objeto
RemoveHandler intGraphN.ObjStorage.OnDataChanged, AddressOf StorageChanged
intGraphN.ObjStorage = InputStorage
AddHandler InputStorage.OnDataChanged, AddressOf StorageChanged
End If
End If
'intGraphN.LineType = TypeOfVisorLine.SolidWithCalculatedPoints
'intFrameN.blnResetOldScale = InputStorage.ResetScaleOnChange
'intFrameN.AutoScale = True
If TypeOf InputStorage Is IStorageSing Then
If TypeOf intGraphN Is GraphOfVisor2DwSing Then
'agregar las singularidades al objeto Graph si corresponde
Dim Gtmp As GraphOfVisor2DwSing
Dim Stmp As IStorageSing
Gtmp = CType(Me.intGraphN, GraphOfVisor2DwSing)
Stmp = CType(InputStorage, IStorageSing)
Gtmp.Add(Stmp.Constelation.ReadConstelation)
End If
ElseIf TypeOf InputStorage Is IStorage2DUnd Then
End If
IfAutoShow()
If TypeOf intFrameN Is IFrameXY Then
Dim ifxy As IFrameXY = CType(intFrameN, IFrameXY)
If intGraphN.Show = GraphShow.Both Then
ifxy.SetRanges(ifxy.UsedScaleX.GetMin, ifxy.UsedScaleX.GetMax, ifxy.UsedScaleY.GetMin, ifxy.UsedScaleY.GetMax)
ElseIf intGraphN.Show = GraphShow.Real Then
ifxy.SetRanges(ifxy.UsedScaleX.GetMin, ifxy.UsedScaleX.GetMax, intFrameN.UsedScaleR.GetMin, intFrameN.UsedScaleR.GetMax)
ElseIf intGraphN.Show = GraphShow.Imaginary Then
ifxy.SetRanges(ifxy.UsedScaleX.GetMin, ifxy.UsedScaleX.GetMax, intFrameN.UsedScaleI.GetMin, intFrameN.UsedScaleI.GetMax)
Else
Stop
End If
End If
If TypeOf intFrameN Is Frame2DComplexPlain Then
Stop
End If
ConstructArrayPoints(intGraphN, InputStorage.ScaleX)
intFrameN.ArrGraphs.Add(InputStorage.Id, intGraphN)
HshTblIDSto2IdFrm.UpdateValue(InputStorage.Id, intFrameN.Id, True)
HshTblIdGrp2IdFrm.UpdateValue(intGraphN.Id, intFrameN.Id, True)
If ArrFrames.Count = 0 Then
'agrego
ArrFrames.Add(intFrameN.Id, intFrameN)
Else
'actualizo o agrego segun corresponda
ArrFrames.UpdateValue(intFrameN.Id, intFrameN, True)
End If
intEngineState = EEngineState.EReady
Return True
End Function
#End Region
#Region "Storage Event Handler"
'llamado por el delegado de Storage
'actualizar todos los datos que cambiaron y no se actualizan automaticamente
Protected Sub StorageChanged(ByVal sender As Object, ByVal e As EventArgs)
intStorage2d = CType(sender, IStorage)
'!!!TypeOf!!! PItm.FunctionForParse Is IParseFuncDelegateCalc
If Not intStorage2d Is Nothing Then
If intStorage2d.DataChanged Then
intStorage2d.Storage()
End If
If HshTblIDSto2IdFrm.ContainsKey(intStorage2d.Id) Then
'recupero y actualizo el objeto
Dim fid As Integer
fid = Me.HshTblIDSto2IdFrm(intStorage2d.Id) 'id del frame dode se halla el grafico
If fid <> intFrameN.Id Then
intFrameN = Me.ArrFrames(fid) 'recupero el frame donde se halla el grafico
End If
intGraphN = intFrameN.ArrGraphs.GetValue(intStorage2d.Id)
intGraphN.ArrayLines.Clear()
intGraphN.ArrayLinesI.Clear()
intGraphN.TypeOfSubGraph = intStorage2d.SubGraphMode
Else
Stop 'error
'no se saco el addhandler del objeto Storage que fue removido del hastable
End If
If intFrameN.AutoScale Then
If TypeOf intFrameN Is IFrameXY Then
Dim ifxy As IFrameXY = CType(intFrameN, IFrameXY)
ifxy.UsedScaleX.Reset(False)
ifxy.UsedScaleY.Reset(False)
Else
Stop
End If
intFrameN.UsedScaleR.Reset(False)
intFrameN.UsedScaleI.Reset(False)
End If
FindGralFrameScaleValues()
FindGralFrameScaleValues(intStorage2d, intFrameN.Id)
IfAutoShow()
intStorage2d.ScreenRect = intFrameN.DrawingRectangle
If TypeOf intFrameN Is IFrameXY Then
Dim ifxy As IFrameXY = CType(intFrameN, IFrameXY)
If intGraphN.Show = GraphShow.Both Then
ifxy.SetRanges(ifxy.UsedScaleX.GetMin, ifxy.UsedScaleX.GetMax, ifxy.UsedScaleY.GetMin, ifxy.UsedScaleY.GetMax)
ElseIf intGraphN.Show = GraphShow.Real Then
ifxy.SetRanges(ifxy.UsedScaleX.GetMin, ifxy.UsedScaleX.GetMax, ifxy.UsedScaleR.GetMin, ifxy.UsedScaleR.GetMax)
ElseIf intGraphN.Show = GraphShow.Imaginary Then
ifxy.SetRanges(ifxy.UsedScaleX.GetMin, ifxy.UsedScaleX.GetMax, ifxy.UsedScaleI.GetMin, ifxy.UsedScaleI.GetMax)
Else
Stop
End If
Else
Stop
End If
UpdatePointsArrays() 'actualizo el resto
ConstructArrayPoints(intGraphN, intStorage2d.ScaleX) 'construyo el nuevo
intFrameN.ArrGraphs.UpdateValue(intStorage2d.Id, intGraphN, True)
ArrFrames.UpdateValue(intGraphN.FrameId, intFrameN, True)
intEngineState = EEngineState.EReady
Redraw()
'Refresh()
Else
Stop
Throw New Exception("No IStorage Input Compatible object was send")
End If
End Sub
#End Region
#Region "Create Frame Methods"
'crea el graph por defecto
Protected Sub CreateGraph()
intGraphN = New GraphOfVisor2D(intFrameN.Id, PenValue, SubGraphType.TReal)
intGraphN.intPen = PenValue.Clone
End Sub
'crea un objeto graph
Public Sub CreateGraph(ByVal GraphType As TypeOfGraph)
If GraphType = TypeOfGraph.ComplexPlain Then
intGraphN = New GraphOfVisor2DwSing(intFrameN.Id, PenValue, SubGraphType.TReal)
intGraphN.intPen = PenValue.Clone
ElseIf GraphType = TypeOfGraph.SerialInput Then
intGraphN = New GraphOfVisor2DSerial(intFrameN.Id, PenValue, SubGraphType.TReal)
intGraphN.intPen = PenValue.Clone
Else
CreateGraph()
End If
End Sub
'crea y me deja en intFrameN un frame nuevo
'del tipo Deafult XY
Public Sub CreateNewFrame()
Dim r As Rectangle
'un rectangulo cualquiera, ya que resize actualiza todos los rectangulos
'r = New Rectangle(XLabelsWidth, FrameBorders, objRender.Width - FrameBorders - XLabelsWidth, objRender.Height)
r = New Rectangle(0, 0, objRender.Width, objRender.Height)
intFrameN = New Frame2DXY(r, Me.BmpFrame)
'intFrameN = New Frame2DXY(objRender)
AddHandler intFrameN.SendMessage, AddressOf RaiseMessage
AddHandler intFrameN.OnGraphChange, AddressOf OnInternalChange
ArrFrames.Add(intFrameN.Id, intFrameN)
Resize()
intGraphN = Nothing 'para que luego cree correctamente el frame
End Sub
'public Sub CreateNewFrame(ByVal frameType As IFrameOfVisor)
'End Sub
Public Sub CreateNewFrame(ByVal frameType As TypeofFrame)
If frameType = TypeofFrame.XY Then
CreateNewFrame()
Else
Dim r As Rectangle
'un rectangulo cualquiera, ya que resize actualiza todos los rectangulos
r = New Rectangle(0, 0, objRender.Width, objRender.Height)
If frameType = TypeofFrame.ComplexPlain Then
intFrameN = New Frame2DComplexPlain(r, Me.BmpFrame)
Else
intFrameN = New Frame2DXYSerial(r, Me.BmpFrame)
End If
AddHandler intFrameN.SendMessage, AddressOf RaiseMessage
ArrFrames.Add(intFrameN.Id, intFrameN)
Resize()
intGraphN = Nothing 'para que luego cree correctamente el frame
End If
End Sub
#End Region
#Region "Main Entry Point"
Public Sub Redraw()
Dim j As Integer
Dim Arrf() As IFrameOfVisor
intGraph.Clear(BVArrayColor.SisColor(BV2DColors.CImageBack))
ReDim Arrf(ArrFrames.Count - 1)
ArrFrames.Values.CopyTo(Arrf, 0)
For j = 0 To Arrf.GetUpperBound(0)
intFrameN = Arrf(j)
intFrameN.Redraw()
Next
Me.objRender.Refresh()
End Sub
Public Sub Refresh()
Dim j As Integer
Dim Arrf() As IFrameOfVisor
intGraph.Clear(BVArrayColor.SisColor(BV2DColors.CImageBack))
ReDim Arrf(ArrFrames.Count - 1)
ArrFrames.Values.CopyTo(Arrf, 0)
For j = 0 To Arrf.GetUpperBound(0)
intFrameN = Arrf(j)
'intFrameN.Refresh()
Me.intGraph.DrawImage(intFrameN.GetPreviewImage(), 0, 0)
Next
Me.objRender.Refresh()
End Sub
#End Region
#Region "Vector Methods"
Private Sub IfAutoShow()
If intGraphN.AutoShow Then
If intFrameN.UsedScaleR.GetDY <> 0 Or intFrameN.UsedScaleR.Offset <> 0 Then
intGraphN.Show = GraphShow.Real
End If
If intFrameN.UsedScaleI.GetDY <> 0 Or intFrameN.UsedScaleI.Offset <> 0 Then
If intGraphN.Show = GraphShow.Real Then
intGraphN.Show = GraphShow.Both
Else
intGraphN.Show = GraphShow.Imaginary
End If
End If
End If
If TypeOf intFrameN Is IFrameXY Then
Dim ifxy As IFrameXY = CType(intFrameN, IFrameXY)
If intGraphN.Show = GraphShow.Both Or intGraphN.Show = GraphShow.Real Then
ifxy.UsedScaleY.StorageMax(intFrameN.UsedScaleR.Min)
ifxy.UsedScaleY.StorageMax(intFrameN.UsedScaleR.Max)
End If
If intGraphN.Show = GraphShow.Both Or intGraphN.Show = GraphShow.Imaginary Then
ifxy.UsedScaleY.StorageMax(intFrameN.UsedScaleI.Max)
ifxy.UsedScaleY.StorageMax(intFrameN.UsedScaleI.Min)
End If
Else
Stop
End If
End Sub
'construye los arrays de puntos que seran graficas para un dado array de entrada
Protected Sub ConstructArrayPoints(ByVal graph As GraphOfVisor2D, ByVal CurrentScaleX As BVScaleDiscrete)
Dim i, j As Integer
Dim x, y As Single
Dim scrMax, scrmin As Single
Dim ArrPoints() As PointF
Dim Array2D() As ComplexUndefinied
Dim ArrayInd() As ComplexUndefinied
Dim oSt As IStorage2DUnd
If TypeOf intFrameN Is IFrameXY Then
Dim ifxy As IFrameXY = CType(intFrameN, IFrameXY)
scrMax = ifxy.FrameCalcY.ScreenMax - ifxy.FrameCalcY.ScreenDY * 3 '- 1
scrmin = ifxy.FrameCalcY.ScreenMin + ifxy.FrameCalcY.ScreenDY * 3 '+ 2
oSt = CType(graph.ObjStorage, IStorage2DUnd)
If Not oSt Is Nothing Then
Array2D = oSt.DataArray
'scrMax = oSt.ScaleY.ScreenMax - 1 'para que sirve???
ArrayInd = oSt.IndependientVarArray
Else
Stop
End If
If oSt.ScaleR.GetDY <> 0 Or oSt.ScaleR.Offset <> 0 Then
j = 0
For i = 0 To Array2D.GetUpperBound(0) '.ArrayLines.Count - 1
x = ifxy.FrameCalcX.Calc(ArrayInd(i).real)
y = ifxy.FrameCalcY.Calc(Array2D(i).real)
If y >= scrMax And y <= scrmin Then
ReDim Preserve ArrPoints(j)
ArrPoints(j) = New PointF(x, y)
j = j + 1
Else
If j > 0 Then
'seccionar el array en 2 arrays de puntos, de modo que los valores grandes
'tipo discontinuidad no aparezcan en la grafica
graph.ArrayLines.Add(ArrPoints)
j = 0
End If
End If
Next
If j <> 0 Then
graph.ArrayLines.Add(ArrPoints)
End If
Else
'si la grafica es una constante solo almacena 2 puntos, el inicio y el fin
ReDim ArrPoints(1)
'x = CurrentScaleX.GetIndependentVarScaled(0)
x = ifxy.FrameCalcX.Calc(ArrayInd(0).real)
y = ifxy.FrameCalcY.Calc(Array2D(0).real)
ArrPoints(0) = New PointF(x, y)
x = ifxy.FrameCalcX.Calc(ArrayInd(ArrayInd.GetUpperBound(0)).real)
ArrPoints(1) = New PointF(x, y)
graph.ArrayLines.Add(ArrPoints)
intGraphN.Show = GraphShow.Imaginary
End If
If oSt.ScaleI.GetDY <> 0 Or oSt.ScaleI.Offset <> 0 Then
j = 0
For i = 0 To Array2D.GetUpperBound(0)
x = ifxy.FrameCalcX.Calc(ArrayInd(i).real)
y = ifxy.FrameCalcY.Calc(Array2D(i).imaginario)
If y >= scrMax And y <= scrmin Then
ReDim Preserve ArrPoints(j)
ArrPoints(j) = New PointF(x, y)
j = j + 1
Else
If j > 0 Then
'seccionar el array en 2 arrays de puntos, de modo que los valores grandes
'tipo discontinuidad no aparezcan en la grafica
graph.ArrayLinesI.Add(ArrPoints)
j = 0
End If
End If
Next
If j <> 0 Then
graph.ArrayLinesI.Add(ArrPoints)
End If
Else
ReDim ArrPoints(1)
x = ifxy.FrameCalcX.Calc(ArrayInd(0).real)
y = ifxy.FrameCalcY.Calc(Array2D(0).imaginario)
ArrPoints(0) = New PointF(x, y)
x = ifxy.FrameCalcX.Calc(ArrayInd(ArrayInd.GetUpperBound(0)).real)
ArrPoints(1) = New PointF(x, y)
graph.ArrayLinesI.Add(ArrPoints)
End If
Else
Stop
End If
End Sub
'Actualiza los maximos y minimos generales de un Frame con los datos de un
'dado Storage Object
Public Sub FindGralFrameScaleValues(ByVal InputStorage As IStorage, ByVal FrameNumber As Integer)
Dim f As IFrameXY
f = ArrFrames.GetValue(FrameNumber)
If Not InputStorage Is Nothing Then
f.UsedScaleX.StorageMax(InputStorage.ScaleX.Max)
f.UsedScaleX.StorageMax(InputStorage.ScaleX.Min)
f.UsedScaleR.StorageMax(InputStorage.ScaleR.Max)
f.UsedScaleR.StorageMax(InputStorage.ScaleR.Min)
f.UsedScaleI.StorageMax(InputStorage.ScaleI.Max)
f.UsedScaleI.StorageMax(InputStorage.ScaleI.Min)
Else
Stop
End If
ArrFrames.Add(FrameNumber, f)
End Sub
'busca y almacena los maximos del Frame intFrameN entre
'todos los graficos almacenados
Public Sub FindGralFrameScaleValues()
Dim j As Integer
Dim g As GraphOfVisor2D
Dim s As IStorage
Dim si, sx, sr As BVScale
Dim Arr() As GraphOfVisor2D
If intFrameN.ArrGraphs.Count > 0 Then
sx = New BVScale
si = New BVScale
sr = New BVScale
ReDim Arr(intFrameN.ArrGraphs.Count - 1)
intFrameN.ArrGraphs.Values.CopyTo(Arr, 0)
For j = 0 To Arr.GetUpperBound(0)
g = Arr(j)
s = CType(g.ObjStorage, IStorage)
sx.StorageMax(s.ScaleX.Max)
sx.StorageMax(s.ScaleX.Min)
sr.StorageMax(s.ScaleR.Max)
sr.StorageMax(s.ScaleR.Min)
si.StorageMax(s.ScaleI.Max)
si.StorageMax(s.ScaleI.Min)
Next
If TypeOf intFrameN Is IFrameXY Then
Dim ifxy As IFrameXY = CType(intFrameN, IFrameXY)
ifxy.UsedScaleX.StorageMax(sx.Max)
ifxy.UsedScaleX.StorageMax(sx.Min)
Else
Stop
End If
intFrameN.UsedScaleI.StorageMax(si.Max)
intFrameN.UsedScaleI.StorageMax(si.Min)
intFrameN.UsedScaleR.StorageMax(sr.Max)
intFrameN.UsedScaleR.StorageMax(sr.Min)
ArrFrames.UpdateValue(intFrameN.Id, intFrameN)
End If
End Sub
#End Region
#Region "Resizing Methods"
'Actualiza los valores de los puntos para todos los arrays
'de puntos de un dado Frame "intFrameN"
Protected Sub UpdatePointsArrays()
Dim igraph As GraphOfVisor2D
Dim i, j As Integer
Dim Arrlines() As ComplexUndefinied
Dim St As IStorage
Dim Arr() As GraphOfVisor2D
If intFrameN.ArrGraphs.Count > 0 Then
ReDim Arr(intFrameN.ArrGraphs.Count - 1)
intFrameN.ArrGraphs.Values.CopyTo(Arr, 0)
For i = 0 To Arr.GetUpperBound(0)
igraph = Arr(i)
St = CType(igraph.ObjStorage, IStorage)
igraph.ArrayLines.Clear()
igraph.ArrayLinesI.Clear()
St.ScreenRect = intFrameN.DrawingRectangle
ConstructArrayPoints(igraph, St.ScaleX)
intFrameN.ArrGraphs.UpdateValue(St.Id, igraph)
Next
End If
End Sub
Protected Sub Resize()
Dim i As Integer
Dim r As Rectangle
Dim Arrf() As IFrameOfVisor
If wasResized Then
'hay que mejorarlo para no recrear el objeto intGraph
BmpFrame = New Bitmap(objRender.Width, objRender.Height)
intGraph = Graphics.FromImage(BmpFrame) 'objRender.CreateGraphics
'intGraph.SetClip(Value)
gutil = New GraphicUtilities(PenValue, intGraph)
End If
If ArrFrames.Count > 0 Then
If ArrFrames.Count > 1 Then
r = New Rectangle(0, 0, objRender.Width, objRender.Height / ArrFrames.Count)
ReDim Arrf(ArrFrames.Count - 1)
ArrFrames.Values.CopyTo(Arrf, 0)
For i = 0 To Arrf.GetUpperBound(0)
intFrameN = Arrf(i)
intFrameN.Resize(r, Me.BmpFrame)
UpdatePointsArrays()
ArrFrames.UpdateValue(intFrameN.Id, intFrameN)
r.Y = r.Y + r.Height
Next
Else '=1
r = New Rectangle(0, 0, objRender.Width, objRender.Height)
ReDim Arrf(0)
ArrFrames.Values.CopyTo(Arrf, 0)
intFrameN = Arrf(0)
intFrameN.Resize(r, BmpFrame)
UpdatePointsArrays()
ArrFrames.UpdateValue(intFrameN.Id, intFrameN, True)
End If
Else
r = New Rectangle(0, 0, objRender.Width, objRender.Height)
intFrameN.Resize(r, BmpFrame)
UpdatePointsArrays()
ArrFrames.UpdateValue(intFrameN.Id, intFrameN, True)
End If
wasResized = False
End Sub
#End Region
#Region "Miscelaneous Methods"
Protected Sub SetDefaultColors()
'colores de lde los graficos 3D
If objGraphColorMode = GraphColorMode.CScreen Then
BVArrayColor.SisColor(BV2DColors.CImageBack) = Color.Black
BVArrayColor.SisColor(BV2DColors.CAxis) = Color.White
BVArrayColor.SisColor(BV2DColors.CSubAxis) = Color.White
BVArrayColor.SisColor(BV2DColors.CFunc0) = Color.Orange
BVArrayColor.SisColor(BV2DColors.CFunc1) = Color.Yellow
BVArrayColor.SisColor(BV2DColors.CFunc2) = Color.Aquamarine
BVArrayColor.SisColor(BV2DColors.CFunc3) = Color.LightPink
BVArrayColor.SisColor(BV2DColors.CFunc4) = Color.Lavender
BVArrayColor.SisColor(BV2DColors.CFunc5) = Color.LemonChiffon
BVArrayColor.SisColor(BV2DColors.CFunc6) = Color.BurlyWood
BVArrayColor.SisColor(BV2DColors.CFunc7) = Color.Gold
BVArrayColor.SisColor(BV2DColors.CFunc8) = Color.LightCyan
BVArrayColor.SisColor(BV2DColors.CFunc9) = Color.AntiqueWhite
BVArrayColor.SisColor(BV2DColors.CStats) = Color.SeaShell
BVArrayColor.SisColor(BV2DColors.CFunctionName) = Color.SpringGreen
ElseIf objGraphColorMode = GraphColorMode.CPrinter Then
BVArrayColor.SisColor(BV2DColors.CImageBack) = Color.White
BVArrayColor.SisColor(BV2DColors.CAxis) = Color.Black
BVArrayColor.SisColor(BV2DColors.CSubAxis) = Color.Gray
BVArrayColor.SisColor(BV2DColors.CFunc0) = Color.Red
BVArrayColor.SisColor(BV2DColors.CFunc1) = Color.Green
BVArrayColor.SisColor(BV2DColors.CFunc2) = Color.Blue
BVArrayColor.SisColor(BV2DColors.CFunc3) = Color.Brown
BVArrayColor.SisColor(BV2DColors.CFunc4) = Color.Violet
BVArrayColor.SisColor(BV2DColors.CFunc5) = Color.Gold
BVArrayColor.SisColor(BV2DColors.CFunc6) = Color.HotPink
BVArrayColor.SisColor(BV2DColors.CFunc7) = Color.Orange
BVArrayColor.SisColor(BV2DColors.CFunc8) = Color.Lavender
BVArrayColor.SisColor(BV2DColors.CFunc9) = Color.LightSeaGreen
BVArrayColor.SisColor(BV2DColors.CStats) = Color.CadetBlue
BVArrayColor.SisColor(BV2DColors.CFunctionName) = Color.SteelBlue
ElseIf objGraphColorMode = GraphColorMode.CUser Then
BVArrayColor.SisColor(BV2DColors.CImageBack) = Color.LightYellow
BVArrayColor.SisColor(BV2DColors.CAxis) = Color.Black
BVArrayColor.SisColor(BV2DColors.CSubAxis) = Color.LightGray
BVArrayColor.SisColor(BV2DColors.CFunc0) = Color.Red
BVArrayColor.SisColor(BV2DColors.CFunc1) = Color.Green
BVArrayColor.SisColor(BV2DColors.CFunc2) = Color.Brown
BVArrayColor.SisColor(BV2DColors.CFunc3) = Color.LightPink
BVArrayColor.SisColor(BV2DColors.CFunc4) = Color.Lavender
BVArrayColor.SisColor(BV2DColors.CFunc5) = Color.LemonChiffon
BVArrayColor.SisColor(BV2DColors.CFunc6) = Color.BurlyWood
BVArrayColor.SisColor(BV2DColors.CFunc7) = Color.Gold
BVArrayColor.SisColor(BV2DColors.CFunc8) = Color.LightCyan
BVArrayColor.SisColor(BV2DColors.CFunc9) = Color.AntiqueWhite
BVArrayColor.SisColor(BV2DColors.CStats) = Color.Bisque
BVArrayColor.SisColor(BV2DColors.CFunctionName) = Color.Wheat
End If
If intEngineState = EEngineState.EReady Then
If ArrFrames.Count > 0 Then
Dim f(ArrFrames.Count - 1) As Frame2DBase
Dim i, j As Integer
Dim GV() As GraphOfVisor2D
Me.ArrFrames.Values.CopyTo(f, 0)
For i = 0 To ArrFrames.Count - 1
f(i).ArrayColor = Me.BVArrayColor
ReDim GV(f(i).ArrGraphs.Count - 1)
f(i).ArrGraphs.Values.CopyTo(GV, 0)
For j = 0 To GV.GetUpperBound(0)
GV(j).intPen.Color = BVArrayColor.SisColor(j)
Next
Next
End If
'Refresh()
Redraw()
End If
End Sub
Public Sub CopyToClippboard()
intFrameN.CopyToClippboard()
End Sub
Public Function GetImage(ByVal GraphId As Integer) As Image
Return intFrameN.GetPreviewImage(GraphId)
End Function
Public Function GetImage() As Image
'Return intFrameN.GetPreviewImage()
Return CType(intFrameN, Frame2DXY).GetImage()
End Function
Public Function GetImage(ByVal ImageSize As Size) As Image
Return intFrameN.GetPreviewImage(ImageSize)
End Function
#End Region
#Region "Event Managed"
#Region "Message Managed"
Protected Sub RaiseMessage(ByVal sender As Object, ByVal s As MessageEventArgs)
RaiseEvent SendMessage(Me, s)
End Sub
#End Region
#Region "Control Event Manage"
Protected Sub On_ControlRefresh(ByVal sender As Object, ByVal e As PaintEventArgs) Handles objRender.Paint
If intEngineState = EEngineState.EReady Then
If wasResized Then
Resize()
'Refresh()
Redraw()
End If
e.Graphics.DrawImage(BmpFrame, 0, 0)
'intFrameN.OnPaint(Me, e)
End If
End Sub
Protected Sub On_ControlResize(ByVal sender As Object, ByVal e As EventArgs) Handles objRender.Resize
If intEngineState = EEngineState.EReady Then
wasResized = True
End If
End Sub
#End Region
#Region "Mouse-Cursor Region"
Sub OnRenderControl_MouseMove(ByVal sender As Object, ByVal e As MouseEventArgs) Handles objRender.MouseMove
If TypeOf intFrameN Is IFrameXY Then
Dim ifxy As IFrameXY = CType(intFrameN, IFrameXY)
If e.Button = MouseButtons.Left Then
Cursor1Position.X = ifxy.FrameCalcX.CalcInv(e.X)
Cursor1Position.Y = ifxy.FrameCalcY.CalcInv(e.Y)
ElseIf e.Button = MouseButtons.Right Then
Cursor2Position.X = ifxy.FrameCalcX.CalcInv(e.X)
Cursor2Position.Y = ifxy.FrameCalcY.CalcInv(e.Y)
End If
RaiseEvent OnRenderControlMouseMove(Me, e)
Else
Stop
End If
End Sub
Sub OnRenderControl_MouseDown(ByVal sender As Object, ByVal e As MouseEventArgs) Handles objRender.MouseDown
If TypeOf intFrameN Is IFrameXY Then
Dim ifxy As IFrameXY = CType(intFrameN, IFrameXY)
If e.Button = MouseButtons.Left Then
Cursor1Position.X = ifxy.FrameCalcX.CalcInv(e.X)
Cursor1Position.Y = ifxy.FrameCalcY.CalcInv(e.Y)
RaiseEvent OnRenderControlMouseDown(Me, e)
ElseIf e.Button = MouseButtons.Right Then
Cursor2Position.X = ifxy.FrameCalcX.CalcInv(e.X)
Cursor2Position.Y = ifxy.FrameCalcY.CalcInv(e.Y)
RaiseEvent OnRenderControlMouseDown(Me, e)
End If
Else
Stop
End If
End Sub
Sub OnRenderControl_MouseUp(ByVal sender As Object, ByVal e As MouseEventArgs) Handles objRender.MouseUp
If TypeOf intFrameN Is IFrameXY Then
Dim ifxy As IFrameXY = CType(intFrameN, IFrameXY)
If e.Button = MouseButtons.Left Then
Cursor1Position.X = ifxy.FrameCalcX.CalcInv(e.X)
Cursor1Position.Y = ifxy.FrameCalcY.CalcInv(e.Y)
RaiseEvent OnRenderControlMouseUp(Me, e)
ElseIf e.Button = MouseButtons.Right Then
Cursor2Position.X = ifxy.FrameCalcX.CalcInv(e.X)
Cursor2Position.Y = ifxy.FrameCalcY.CalcInv(e.Y)
RaiseEvent OnRenderControlMouseUp(Me, e)
End If
Else
Stop
End If
End Sub
#End Region
Sub OnInternalChange(ByVal sender As Object, ByVal e As EventArgs)
'mejor una variable tipo !MustUpdate!, asi re calcula todo al refrescar!
UpdatePointsArrays()
End Sub
#End Region
End Class