Namespace GraphicsViewer ''' ''' A graphic ''' ''' ''' History: ''' ''' ''' Date and responsible ''' Description ''' ''' ''' 2007-04-11 Émilie Deschamps ''' Creation of the class. ''' 2008-12-15 Maxime Grondines Thériault ''' Modification of the class to avoid 3 call to get data... only one call at the right time is done now ''' ''' ''' ''' Public MustInherit Class Graphic #Region " FIELDS " ''' Graphic title Protected m_titre As String = String.Empty Protected m_chartText As Boolean = False Protected m_titleBottom As String = String.Empty Protected m_titleLeft As String = String.Empty Protected m_titleRight As String = String.Empty ''' Graphic's lengend margins Protected m_legendMargin As New LegendMargins() ''' Graphic 3D transformations Protected m_transform3D As New Transform3D(0, 0, 0, 0) ''' Graphic type Protected m_graphType As TypeGraph = TypeGraph.COLUMN ''' Graphic data Protected m_data As New DataTable Protected m_second_data As New DataTable ''' Visibility of axes labels Protected m_axes As New AxesLabels(True, True, True, False) ''' Visibility of the lengend Protected m_viewLegend As New Boolean ''' Graphic series way Protected m_serie As New Serie #End Region ' Fields #Region " PUBLIC PROPERTIES " ''' Get or set the graphic title Public Property Titre() As String Get Return m_titre End Get Set(ByVal Value As String) m_titre = Value End Set End Property ' Titre ''' Get or set the graphic title Public Property TitleBottom() As String Get Return m_titleBottom End Get Set(ByVal Value As String) m_titleBottom = Value End Set End Property ' Titre Public Property TitleLeft() As String Get Return m_titleLeft End Get Set(ByVal Value As String) m_titleLeft = Value End Set End Property ' Titre Public Property TitleRight() As String Get Return m_titleRight End Get Set(ByVal Value As String) m_titleRight = Value End Set End Property ' Titre Public Property Data() As DataTable Get Return m_data End Get Set(ByVal Value As DataTable) m_data = Value End Set End Property ' Titre Public Property Secondary_Data() As DataTable Get Return m_second_data End Get Set(ByVal Value As DataTable) m_second_data = Value End Set End Property ''' Get or set the graphic type Public Property GraphType() As TypeGraph Get Return m_graphType End Get Set(ByVal Value As TypeGraph) m_graphType = Value End Set End Property ' GraphType ''' Get or set the graphic's legend margins Public Property LegendMargin() As LegendMargins Get Return m_legendMargin End Get Set(ByVal Value As LegendMargins) m_legendMargin = Value End Set End Property ' LegendMargin ''' Get or set the axes labels visibility Public Property Axes() As AxesLabels Get Return m_axes End Get Set(ByVal Value As AxesLabels) m_axes = Value End Set End Property ' LegendMargin ''' Get or set the graphic's 3D transformations Public Property Trans3D() As Transform3D Get Return m_transform3D End Get Set(ByVal Value As Transform3D) m_transform3D = Value End Set End Property ' Trans3D ''' Get or set the visibility of the graphic's legend Public Property ViewLegend() As Boolean Get Return m_viewLegend End Get Set(ByVal Value As Boolean) m_viewLegend = Value End Set End Property ' ViewLegend ''' Get or set the graphic's series way Public Property Serie() As Serie Get Return m_serie End Get Set(ByVal Value As Serie) m_serie = Value End Set End Property ' Serie Public Property ChartText() As Boolean Get Return m_chartText End Get Set(ByVal value As Boolean) m_chartText = value End Set End Property #End Region ' Public Properties #Region " LIFE CYCLE " ''' The graphic title. ''' The graphic type. ''' The graphics series way. DEFAULT : Column ''' The visibility of the legend. DEFAULT : true Public Sub New(ByVal titre As String, ByVal type As TypeGraph, Optional ByVal serie As Serie = GraphsEnums.Serie.COLUMN, Optional ByVal viewLegend As Boolean = True, Optional ByVal titreBottom As String = "", Optional ByVal titreLeft As String = "", Optional ByVal titleRight As String = "", Optional ByVal charText As Boolean = False) Me.Titre = titre Me.GraphType = type Me.ViewLegend = viewLegend Me.Serie = serie 'Me.Data = Me.GetData() 'Me.Secondary_Data = Me.GetSecondaryData() Me.TitleBottom = titreBottom Me.TitleLeft = titreLeft Me.TitleRight = titleRight Me.ChartText = charText SetGraph() End Sub ' New (titre, type) #End Region ' Life Cycle #Region " PUBLIC METHODS - OVERRIDES " ''' Return the Graphic's title if "ToString" of the object is called. Public Overrides Function ToString() As String Return Me.Titre End Function #End Region ' Public Methods - Overrides #Region " PUBLIC METHODS - MUST OVERRIDES " ''' Get graphic's data from the database Public MustOverride Function GetData() As DataTable Public Overridable Function GetSecondaryData() As DataTable Return Nothing End Function Public Overridable Function GetThirdData() As DataTable Return Nothing End Function Public Overridable Function GetFourthData() As DataTable Return Nothing End Function Public Overridable Function GetInformations() As DataTable Return Nothing End Function ' A noter : dans le DataTable retourné, ce sont les noms des colonnes qui seront affichés dans la légende. #End Region ' Public Methods - Must Overrides #Region " PRIVATE METHODS - SETTINGS " ''' Set the graphic's settings according to it's type Private Sub SetGraph() Me.LegendMargin = New LegendMargins() Select Case Me.GraphType Case TypeGraph.AREA SetArea() Case TypeGraph.AREA3D SetArea3D() Case TypeGraph.COLUMN SetColumn() Case TypeGraph.COLUMN3D SetColumn3D() Case TypeGraph.LINES SetLines() Case TypeGraph.PIE SetPie() Case TypeGraph.PIE3D SetPie3D() Case TypeGraph.SPLINES SetSplines() End Select End Sub ' SetGraph ''' Settings for an "Area" graphic Private Sub SetArea() Me.Axes = New AxesLabels(True, True, False, False) End Sub ''' Settings for an "Area3D" graphic Private Sub SetArea3D() Me.Trans3D = New Transform3D(120, 15, 0, 0) Me.Axes = New AxesLabels(True, True, False, False) End Sub ''' Settings for a "Columns" graphic Private Sub SetColumn() Me.Axes = New AxesLabels(False, True, True, False) End Sub ''' Settings for a "Columns3D" graphic Private Sub SetColumn3D() Me.Trans3D = New Transform3D(125, 10, 0, 0) Me.Axes = New AxesLabels(True, True, False, False) End Sub ''' Settings for a "Lines" graphic Private Sub SetLines() Me.Axes = New AxesLabels(True, True, False, False) End Sub ''' Settings for a "Pie" graphic Private Sub SetPie() Me.Axes = New AxesLabels(False, False, False, False) End Sub ''' Settings for a "Pie3D" graphic Private Sub SetPie3D() Me.Trans3D = New Transform3D(220, 20, 0, 0) Me.Axes = New AxesLabels(False, False, False, False) End Sub ''' Settings for a "Splines" graphic Private Sub SetSplines() Me.Axes = New AxesLabels(True, True, False, False) End Sub Private Sub SetComlumnLine() Me.Axes = New AxesLabels(True, True, False, True) End Sub #End Region ' Private Methods - Settings #Region " SUB-CLASSES " ''' Graphic's legend margins. DEFAULT : 20(top), 20(bottom), 0(left), 20(right) Public Class LegendMargins #Region " FIELDS " Protected m_bottom As Int32 Protected m_top As Int32 Protected m_left As Int32 Protected m_right As Int32 #End Region ' Fields #Region " PUBLIC PROPERTIES " Public Property Bottom() As Int32 Get Return m_bottom End Get Set(ByVal Value As Int32) m_bottom = Value End Set End Property ' Bottom Public Property Top() As Int32 Get Return m_top End Get Set(ByVal Value As Int32) m_top = Value End Set End Property ' Top Public Property Left() As Int32 Get Return m_left End Get Set(ByVal Value As Int32) m_left = Value End Set End Property ' Left Public Property Right() As Int32 Get Return m_right End Get Set(ByVal Value As Int32) m_right = Value End Set End Property ' Right #End Region ' Public Properties #Region " LIFE CYCLE " Public Sub New() m_bottom = 20 m_top = 20 m_left = 0 m_right = 20 End Sub ' New #End Region ' Life Cycle End Class ' LegendMargins ''' Visibility of Graphic's axes labels. DEFAULT : true(x), true(y), false(z) Public Class AxesLabels #Region " FIELDS " Protected m_X As Boolean Protected m_Y As Boolean Protected m_Z As Boolean Protected m_Y2 As Boolean #End Region ' Fields #Region " PUBLIC PROPERTIES " Public Property X() As Boolean Get Return m_X End Get Set(ByVal Value As Boolean) m_X = Value End Set End Property ' X Public Property Y() As Boolean Get Return m_Y End Get Set(ByVal Value As Boolean) m_Y = Value End Set End Property ' Y Public Property Z() As Boolean Get Return m_Z End Get Set(ByVal Value As Boolean) m_Z = Value End Set End Property ' Z Public Property Y2() As Boolean Get Return m_Y2 End Get Set(ByVal value As Boolean) m_Y2 = value End Set End Property #End Region ' Public Properties #Region " LIFE CYCLE " Public Sub New() m_X = True m_Y = True m_Y2 = False m_Z = False End Sub ' New Public Sub New(ByVal x As Boolean, ByVal y As Boolean, ByVal z As Boolean, ByVal y2 As Boolean) m_X = x m_Y = y m_Z = z m_Y2 = y End Sub #End Region ' Life Cycle End Class ' AxesLabels ''' Graphic's 3D Transformations : axes angle and perspective percentage. Public Class Transform3D #Region " FIELDS " Protected m_XRotation As Int32 = 0 Protected m_YRotation As Int32 = 0 Protected m_ZRotation As Int32 = 0 Protected m_Perspective As Int32 = 0 #End Region ' Fields #Region " PUBLIC PROPERTIES " Public Property XRotation() As Int32 Get Return m_XRotation End Get Set(ByVal Value As Int32) If Value >= -180 And Value <= 360 Then m_XRotation = Value End If End Set End Property ' XRotation Public Property YRotation() As Int32 Get Return m_YRotation End Get Set(ByVal Value As Int32) If Value >= -180 And Value <= 360 Then m_YRotation = Value End If End Set End Property ' YRotation Public Property ZRotation() As Int32 Get Return m_ZRotation End Get Set(ByVal Value As Int32) If Value >= -180 And Value <= 360 Then m_ZRotation = Value End If End Set End Property ' ZRotation Public Property Perspective() As Int32 Get Return m_Perspective End Get Set(ByVal Value As Int32) If Value >= 0 And Value <= 100 Then m_Perspective = Value End If End Set End Property ' Perspective #End Region ' Public Properties #Region " LIFE CYCLE " Public Sub New() 'nada End Sub ' New Public Sub New(ByVal x As Int32, ByVal y As Int32, ByVal z As Int32, ByVal perspective As Int32) m_XRotation = x m_YRotation = y m_ZRotation = z m_Perspective = perspective End Sub ' New ( type ) #End Region ' Life Cycle End Class ' Transform3D #End Region ' Sub-Classes End Class ' Graphic End Namespace ' GraphicsViewer