Imports System.Drawing
Imports System.Runtime.Serialization

Namespace CNC

    Partial Public MustInherit Class CNC

        Protected bStaticDataReaded As Boolean
        Protected _CncWindowProcess As Process

        Public Const R = False
        Public Const W = True

        Public Enum NcType
            DEMO = 0
            FANUC = 1
            OSAI = 2
            SIEMENS = 3
        End Enum

        Public Enum Memo
            MemBool = 1
            MemByte = 2
            MemWord = 3
            MemInt = 4
            MemDWord = 5
            MemDInt = 6
            MemSingle = 7
            MemDouble = 8
        End Enum

        Public Enum InfoType
            Descrizione
            Matricola
            Teste
            Magazzini
            ManineMagazzino
        End Enum

        Protected _Type As NcType
        Public ReadOnly Property Type() As NcType
            Get
                Return _Type
            End Get
        End Property


        Protected _Descrizione As String
        Public ReadOnly Property Descrizione() As String
            Get
                Return _Descrizione
            End Get
        End Property
        Protected _Matricola As Integer
        Public ReadOnly Property Matricola() As Integer
            Get
                If Not bStaticDataReaded Then Throw New System.Configuration.SettingsPropertyNotFoundException("Matricola not found")
                Return _Matricola
            End Get
        End Property
        Protected _Teste As Integer
        Public ReadOnly Property Teste() As Integer
            Get
                If Not bStaticDataReaded Then Throw New System.Configuration.SettingsPropertyNotFoundException("Teste not found")
                Return _Teste
            End Get
        End Property
        Protected _Magazzini As Integer
        Public ReadOnly Property Magazzini() As Integer
            Get
                If Not bStaticDataReaded Then Throw New System.Configuration.SettingsPropertyNotFoundException("Magazzini not found")
                Return _Magazzini
            End Get
        End Property
        Protected _ManineMagazzino() As Integer
        Public ReadOnly Property ManineMagazzino() As Integer()
            Get
                If Not bStaticDataReaded Then Throw New System.Configuration.SettingsPropertyNotFoundException("ManineMagazzino not found")
                Return _ManineMagazzino
            End Get
        End Property
        Protected _MagazziniConAttrezzaggioAutomatico As Integer
        Public ReadOnly Property MagazziniConAttrezzaggioAutomatico() As Integer
            Get
                If Not bStaticDataReaded Then Throw New System.Configuration.SettingsPropertyNotFoundException("MagazziniConAttrezzaggioAutomatico not found")
                Return _MagazziniConAttrezzaggioAutomatico
            End Get
        End Property
        Protected _MaxUtensiliGestibili As Integer
        Public ReadOnly Property MaxUtensiliGestibili() As Integer
            Get
                If Not bStaticDataReaded Then Throw New System.Configuration.SettingsPropertyNotFoundException("MaxUtensiliGestibili not found")
                Return _MaxUtensiliGestibili
            End Get
        End Property
        Protected _MaxIdUtensile As Integer
        Public ReadOnly Property MaxIdUtensile() As Integer
            Get
                If Not bStaticDataReaded Then Throw New System.Configuration.SettingsPropertyNotFoundException("MaxIdUtensile not found")
                Return _MaxIdUtensile
            End Get
        End Property
        Protected _ZoomSpeed As Integer
        Public ReadOnly Property ZoomSpeed() As Integer  '(aka: FattoreMoltSpeed)
            Get
                If Not bStaticDataReaded Then Throw New System.Configuration.SettingsPropertyNotFoundException("ZoomSpeed not found")
                Return _ZoomSpeed
            End Get
        End Property

        Protected _ScreenSize As Size
        Public Property ScreenSize() As Size
            Get
                Return _ScreenSize
            End Get
            Set(ByVal value As Size)
                _ScreenSize = value
            End Set
        End Property

        Protected _CncWindowSize As Size
        Public Property CncWindowSize() As Size
            Get
                Return _CncWindowSize
            End Get
            Set(ByVal value As Size)
                _CncWindowSize = value
            End Set
        End Property

        Protected _CncWindowPosition As Point
        Public Property CncWindowPosition() As Point
            Get
                Return _CncWindowPosition
            End Get
            Set(ByVal value As Point)
                _CncWindowPosition = value
            End Set
        End Property

        Protected _bConnected As Boolean
        Public Property Connected() As Boolean
            Get
                Return _bConnected
            End Get
            Private Set(ByVal value As Boolean)
                _bConnected = value
            End Set
        End Property

        Protected _Licenza As Integer
        Public Overridable Property Licenza() As Integer
            Get
                Return _Licenza
            End Get
            Set(ByVal value As Integer)
                _Licenza = value
            End Set
        End Property

        Protected _LicenzaScaduta As Boolean
        Public Overridable Property LicenzaScaduta() As Boolean
            Get
                Return _LicenzaScaduta
            End Get
            Set(ByVal value As Boolean)
                _LicenzaScaduta = value
            End Set
        End Property

        Public Sub New()

            'Definisco l'area della Cnc Window
            _CncWindowPosition = New System.Drawing.Point(0, 0)
            _CncWindowSize = New System.Drawing.Size(800, 600)

        End Sub

        Public Overridable Sub Initialize()
        End Sub

        Public Overridable Sub Connect(Optional ByRef szStatus As String = "")
        End Sub

        Public Overridable Sub Disconnect(Optional ByRef szStatus As String = "")
        End Sub

        Public Overridable Sub CncException(Optional ByRef szStatus As String = "")
            _bConnected = False
        End Sub

        ''' <summary>
        ''' Legge il valore del tempo di lavorazione totale del CN
        ''' </summary>
        Public Overridable Function GetDataMaintenance() As TimeSpan
        End Function

        ''' <summary>
        ''' Legge le memorie di configurazione dal cn
        ''' </summary>
        Public Overridable Sub GetStaticData()
        End Sub

        ''' <summary>
        ''' Chiude l'applicazione CNC
        ''' </summary>
        Public Overridable Sub CloseCnc()
        End Sub

        ''' <summary>
        ''' Riduce a icona la finestra CNC
        ''' </summary>
        Public Overridable Sub MinimizeCnc()
        End Sub

        ''' <summary>
        ''' Mostra a dimensioni normali la finestra CNC
        ''' </summary>
        Public Overridable Sub NormalizeCnc()
        End Sub

        ''' <summary>
        ''' Setta il focus sulla finestra CNC
        ''' </summary>
        Public Overridable Sub SetCncFocus()
        End Sub

        ''' <summary>
        ''' Setta il focus sulla finestra CNC
        ''' </summary>
        Public Overridable Sub MoveCnc()
        End Sub

    End Class






    Public Class CmsNcException
        Inherits System.ApplicationException
        Public Sub New()
            MyBase.New("CMS NC Exception")
        End Sub
        Public Sub New(ByVal new_message As String)
            MyBase.New(new_message)
        End Sub
        Public Sub New(ByVal new_message As String, ByVal inner_exception As Exception)
            MyBase.New(new_message, inner_exception)
        End Sub
        Public Sub New(ByVal info As SerializationInfo, ByVal context As StreamingContext)
            MyBase.New(info, context)
        End Sub
    End Class

    Public MustInherit Class CExceptionInfo
        Public Overrides Function ToString() As String
            ToString = ""
        End Function
    End Class

End Namespace