Skip to content
This repository
tree: f52ddb96fe
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 144 lines (125 sloc) 6.752 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143
Imports System.IO
Imports EmberAPI

Public Class genericBoxee
    Implements Interfaces.EmberExternalModule

    Private fBoxee As frmBoxee
    Private _enabled As Boolean = False
    Private _name As String = "Boxee compatibility"

    Public Property Enabled() As Boolean Implements EmberAPI.Interfaces.EmberExternalModule.Enabled
        Get
            Return _enabled
        End Get
        Set(ByVal value As Boolean)
            If _enabled = value Then Return
            _enabled = value
            If _enabled Then
                'Enable()
            Else
                'Disable()
            End If
        End Set
    End Property

    Public Event GenericEvent(ByVal mType As EmberAPI.Enums.ModuleEventType, ByRef _params As System.Collections.Generic.List(Of Object)) Implements EmberAPI.Interfaces.EmberExternalModule.GenericEvent

    Public Sub Init(ByVal sAssemblyName As String) Implements EmberAPI.Interfaces.EmberExternalModule.Init

    End Sub
    Public Function InjectSetup() As EmberAPI.Containers.SettingsPanel Implements EmberAPI.Interfaces.EmberExternalModule.InjectSetup
        Dim SPanel As New Containers.SettingsPanel
        Me.fBoxee = New frmBoxee
        Me.fBoxee.chkEnabled.Checked = Me._enabled
        Me.fBoxee.chkBoxeeId.Checked = AdvancedSettings.GetBooleanSetting("BoxeeTVShowId", False)
        'chkYAMJnfoFields
        SPanel.Name = _name
        SPanel.Text = Master.eLang.GetString(1, "Boxee Compatibility")
        SPanel.Prefix = "Boxee_"
        SPanel.Type = Master.eLang.GetString(802, "Modules", True)
        SPanel.ImageIndex = If(Me._enabled, 9, 10)
        SPanel.Order = 100
        SPanel.Panel = Me.fBoxee.pnlSettings
        AddHandler Me.fBoxee.ModuleSettingsChanged, AddressOf Handle_ModuleSettingsChanged
        AddHandler fBoxee.ModuleEnabledChanged, AddressOf Handle_SetupChanged
        AddHandler fBoxee.GenericEvent, AddressOf DeploySyncSettings
        Return SPanel
        'Return Nothing
    End Function
    Private Sub Handle_ModuleSettingsChanged()
        RaiseEvent ModuleSettingsChanged()
    End Sub
    Private Sub Handle_SetupChanged(ByVal state As Boolean, ByVal difforder As Integer)
        RaiseEvent ModuleSetupChanged(Me._name, state, difforder)
    End Sub
    Public ReadOnly Property ModuleName() As String Implements EmberAPI.Interfaces.EmberExternalModule.ModuleName
        Get
            Return "Boxee Compatibility"
        End Get
    End Property

    Public Event ModuleSettingsChanged() Implements EmberAPI.Interfaces.EmberExternalModule.ModuleSettingsChanged

    Public Event ModuleSetupChanged(ByVal Name As String, ByVal State As Boolean, ByVal diffOrder As Integer) Implements EmberAPI.Interfaces.EmberExternalModule.ModuleSetupChanged

    Public ReadOnly Property ModuleType() As System.Collections.Generic.List(Of EmberAPI.Enums.ModuleEventType) Implements EmberAPI.Interfaces.EmberExternalModule.ModuleType
        Get
            Return New List(Of Enums.ModuleEventType)(New Enums.ModuleEventType() {Enums.ModuleEventType.Generic, Enums.ModuleEventType.OnTVShowNFORead, Enums.ModuleEventType.OnTVShowNFOSave})
        End Get
    End Property

    Public ReadOnly Property ModuleVersion() As String Implements EmberAPI.Interfaces.EmberExternalModule.ModuleVersion
        Get
            Return FileVersionInfo.GetVersionInfo(System.Reflection.Assembly.GetExecutingAssembly.Location).FileVersion.ToString
        End Get
    End Property

    Public Sub SaveSetup(ByVal DoDispose As Boolean) Implements EmberAPI.Interfaces.EmberExternalModule.SaveSetup
        Me.Enabled = Me.fBoxee.chkEnabled.Checked()
        AdvancedSettings.SetBooleanSetting("BoxeeTVShowId", Me.fBoxee.chkBoxeeId.Checked)
    End Sub

    Public Function RunGeneric(ByVal mType As EmberAPI.Enums.ModuleEventType, ByRef _params As System.Collections.Generic.List(Of Object), ByRef _refparam As Object) As EmberAPI.Interfaces.ModuleResult Implements EmberAPI.Interfaces.EmberExternalModule.RunGeneric
        Dim doContinue As Boolean
        Dim mTvShow As Structures.DBTV
        If Enabled Then
            Try
                Select Case mType
                    Case Enums.ModuleEventType.OnTVShowNFOSave
                        mTvShow = DirectCast(_params(0), Structures.DBTV)
                        doContinue = DirectCast(_refparam, Boolean)
                        If AdvancedSettings.GetBooleanSetting("BoxeeTVShowId", False) Then
                            Dim mTVDetails As MediaContainers.TVShow
                            mTVDetails = mTvShow.TVShow
                            If mTVDetails.IDSpecified() Then
                                mTVDetails.BoxeeTvDb = mTVDetails.ID
                                mTVDetails.BlankId()
                            End If
                        End If

                    Case Enums.ModuleEventType.OnTVShowNFORead
                        Dim mTVDetails As New MediaContainers.TVShow
                        mTVDetails = DirectCast(_params(0), MediaContainers.TVShow)
                        doContinue = DirectCast(_refparam, Boolean)
                        If AdvancedSettings.GetBooleanSetting("BoxeeTVShowId", False) Then
                            If mTVDetails.BoxeeIDSpecified() Then
                                mTVDetails.ID = mTVDetails.BoxeeTvDb
                                mTVDetails.BlankBoxeeId()
                            End If


                        End If
                End Select

                _refparam = doContinue
            Catch ex As Exception
                Master.eLog.WriteToErrorLog(ex.Message, ex.StackTrace, "Error")
            End Try
        End If
    End Function

    Protected Overrides Sub Finalize()
        RemoveHandler ModulesManager.Instance.GenericEvent, AddressOf SyncSettings
        MyBase.Finalize()
    End Sub
    Public Sub New()
        AddHandler ModulesManager.Instance.GenericEvent, AddressOf SyncSettings
    End Sub
    Sub SyncSettings(ByVal mType As Enums.ModuleEventType, ByRef _params As List(Of Object))
        If mType = Enums.ModuleEventType.SyncModuleSettings AndAlso Not IsNothing(Me.fBoxee) Then
            RemoveHandler fBoxee.GenericEvent, AddressOf DeploySyncSettings
            Me.fBoxee.chkBoxeeId.Checked = AdvancedSettings.GetBooleanSetting("BoxeeTVShowId", False)
            AddHandler fBoxee.GenericEvent, AddressOf DeploySyncSettings
        End If
    End Sub
    Sub DeploySyncSettings(ByVal mType As Enums.ModuleEventType, ByRef _params As List(Of Object))
        If Not IsNothing(Me.fBoxee) Then
            AdvancedSettings.SetBooleanSetting("BoxeeTVShowId", Me.fBoxee.chkBoxeeId.Checked)
            RaiseEvent GenericEvent(mType, _params)
        End If

    End Sub
End Class
Something went wrong with that request. Please try again.