PageRenderTime 18ms CodeModel.GetById 7ms app.highlight 8ms RepoModel.GetById 2ms app.codeStats 0ms

/NfoLibrary/TV/TvEpisode.Treeview.vb

#
Visual Basic | 104 lines | 83 code | 13 blank | 8 comment | 0 complexity | a3b9a6d5c30bd1fe4d1f8fae232f9f9a MD5 | raw file
  1Imports System.Windows.Forms
  2Imports Media_Companion
  3
  4Partial Public Class TvEpisode
  5    Public EpisodeNode As New TreeNode With {.SelectedImageKey = "blank", .ImageKey = "blank"}
  6
  7    Public Sub UpdateTreenode(Optional ByVal scraping As Boolean = False)
  8        Me.EpisodeNode.Tag = Me
  9
 10        Dim episode_count = 1
 11        If Me.SeasonObj IsNot Nothing Then
 12            If Me.SeasonObj.MaxEpisodeCount > 99 Then
 13                episode_count = 3
 14            ElseIf Me.SeasonObj.MaxEpisodeCount > 9 Then
 15                episode_count = 2
 16            End If
 17        End If
 18
 19        If scraping = True Then
 20            For Each EpisodeNode2 As TreeNode In Me.SeasonObj.SeasonNode.Nodes
 21                Try
 22                    Dim TempEpisodeNo As String = EpisodeNode2.Text.Substring(0, EpisodeNode2.Text.IndexOf("-") - 1)
 23                    Dim TempEpisodeTitle As String = EpisodeNode2.Text.Substring(TempEpisodeNo.Length + 2, EpisodeNode2.Text.Length - (TempEpisodeNo.Length + 2))
 24                    TempEpisodeTitle = TempEpisodeTitle.Trim
 25                    EpisodeNode2.Text = Utilities.PadNumber(TempEpisodeNo, episode_count) & " - " & TempEpisodeTitle
 26                Catch ex As Exception
 27
 28                End Try
 29            Next
 30        End If
 31
 32        If Me.Title.Value IsNot Nothing Then
 33            Me.EpisodeNode.Name = Me.NfoFilePath             ' save nfo path in this node
 34            If Me.Episode.Value IsNot Nothing Then
 35                If IsNumeric(Me.Episode.Value) Then
 36                    Dim seasonstring As String = Me.Episode.Value.ToString
 37                    Me.EpisodeNode.Text = Utilities.PadNumber(Me.Episode.Value, episode_count) & " - " & Me.Title.Value
 38                Else
 39                    Me.EpisodeNode.Text = Utilities.PadNumber(Me.Episode.Value, episode_count) & " - " & Me.Title.Value
 40                End If
 41            Else
 42                Me.EpisodeNode.Text = Me.Title.Value
 43            End If
 44        Else
 45            Me.EpisodeNode.Text = Me.NfoFilePath
 46        End If
 47
 48        If Me.IsMissing Then
 49            Dim ThisDate As Date = If(Media_Companion.Pref.TvMissingEpOffset, Now.AddDays(-1), Now)
 50            ' Phyonics - Fix for issue #208
 51            If String.IsNullOrEmpty(Aired.Value) Then
 52                ' Change the colour to gray
 53                EpisodeNode.ForeColor = Drawing.Color.Gray
 54            Else
 55                Try
 56                    ' Is the episode in the future?
 57                    If Convert.ToDateTime(Aired.Value) > ThisDate Then
 58                        ' Yes, so change its colour to Red
 59                        EpisodeNode.ForeColor = Drawing.Color.Red
 60                    Else
 61                        EpisodeNode.ForeColor = Drawing.Color.Blue
 62                    End If
 63                Catch ex As Exception
 64                    ' Set the colour to the missing colour
 65                    EpisodeNode.ForeColor = Drawing.Color.Blue
 66                End Try
 67            End If
 68        Else
 69            EpisodeNode.ForeColor = Drawing.Color.Black
 70        End If
 71
 72        If Me.FailedLoad Then
 73            EpisodeNode.ForeColor = Drawing.Color.Red
 74        End If
 75
 76        'If Me.IsAltered Then
 77        '    EpisodeNode.ImageKey = "edit"
 78        '    EpisodeNode.SelectedImageKey = "edit"
 79        If Me.PlayCount.Value <> "0" AndAlso Me.PlayCount.Value <> "" Then
 80            EpisodeNode.ImageKey = "watched"
 81            EpisodeNode.SelectedImageKey = "watched"
 82        Else
 83            EpisodeNode.ImageKey = "blank"
 84            EpisodeNode.SelectedImageKey = "blank"
 85        End If
 86
 87        If Me.EpisodeNode.TreeView Is Nothing Then
 88            If Me.SeasonObj IsNot Nothing Then
 89                Me.SeasonObj.SeasonNode.Nodes.Add(Me.EpisodeNode)
 90            End If
 91        End If
 92    End Sub
 93    Public Overrides Sub Load()
 94        MyBase.Load()
 95
 96        UpdateTreenode()
 97    End Sub
 98
 99    Public Overrides Sub Load(ByVal Path As String)
100        MyBase.Load(Path)
101
102        UpdateTreenode()
103    End Sub
104End Class