PageRenderTime 146ms CodeModel.GetById 34ms RepoModel.GetById 1ms app.codeStats 2ms

/Forms/Form1/Form1.vb

#
Visual Basic | 10353 lines | 9774 code | 456 blank | 123 comment | 15 complexity | 40a1bfda00cc6a098c9293f61b2d26d8 MD5 | raw file
Possible License(s): GPL-2.0
  1. Option Explicit On
  2. Imports System.Net
  3. Imports System.IO
  4. Imports System.Text
  5. Imports System.Text.RegularExpressions
  6. Imports System.Threading
  7. Imports System.Runtime.InteropServices
  8. Imports System.Globalization
  9. Imports Microsoft.Win32
  10. Imports Media_Companion.Pref
  11. Imports System.Xml
  12. Imports System.Reflection
  13. Imports System.Windows.Forms
  14. Imports System.ComponentModel
  15. Imports System.Linq
  16. Imports XBMC.JsonRpc
  17. #Const SilentErrorScream = False
  18. #Const Refocus = False
  19. Public Class Form1
  20. Const HOME_PAGE = "http://mediacompanion.codeplex.com"
  21. Const TMDB_SITE = "www.themoviedb.org/"
  22. Const TMDB_SET_URL = TMDB_SITE & "collection/"
  23. Const TMDB_MOVIE_URL = TMDB_SITE & "movie/"
  24. Const NFO_INDEX As Integer = 7
  25. Public Const XBMC_Controller_full_log_file As String = "XBMC-Controller-full-log-file.txt"
  26. Public Const XBMC_Controller_brief_log_file As String = "XBMC-Controller-brief-log-file.txt"
  27. Public Const MCToolsCommands As Integer = 5 ' increment when adding MC functions to ToolsToolStripMenuItem
  28. Public Dim WithEvents BckWrkScnMovies As BackgroundWorker = New BackgroundWorker
  29. Public Dim WithEvents BckWrkCheckNewVersion As BackgroundWorker = New BackgroundWorker
  30. Public Dim WithEvents BckWrkXbmcController As BackgroundWorker = New BackgroundWorker
  31. Public Dim WithEvents Bw As BackgroundWorker = New BackgroundWorker
  32. Public Dim WithEvents ImgBw As BackgroundWorker = New BackgroundWorker
  33. Property BWs As New List(Of BackgroundWorker)
  34. Property NumActiveThreads As Integer
  35. Shared Public XbmcControllerQ As PriorityQueue = New PriorityQueue
  36. Shared Public XbmcControllerBufferQ As PriorityQueue = New PriorityQueue
  37. Shared Public Property MC_Only_Movies As List(Of ComboList)
  38. Public Shared Property MaxXbmcMovies As List(Of MaxXbmcMovie)
  39. Shared Public MyCulture As New System.Globalization.CultureInfo("en-US")
  40. Private Declare Function GetActiveWindow Lib "user32" Alias "GetActiveWindow" () As IntPtr
  41. Public Property XBMC_Controller_LogLastShownDt As Date = Now
  42. Private XBMC_Link_ErrorLog_Timer As Timers.Timer = New Timers.Timer()
  43. Private XBMC_Link_Idle_Timer As Timers.Timer = New Timers.Timer()
  44. Private XBMC_Link_Check_Timer As Timers.Timer = New Timers.Timer()
  45. Declare Function AttachConsole Lib "kernel32.dll" (ByVal dwProcessId As Int32) As Boolean
  46. Private WithEvents Tmr As New Windows.Forms.Timer With {.Interval = 200}
  47. Private fb As New FolderBrowserDialog
  48. Private Const WM_USER As Integer = &H400
  49. Private Const BFFM_SETEXPANDED As Integer = WM_USER + 106
  50. <DllImport("user32.dll", EntryPoint:="SendMessageW")> _
  51. Private Shared Function SendMessageW(ByVal hWnd As IntPtr, ByVal msg As UInteger, ByVal wParam As Integer, <MarshalAs(UnmanagedType.LPWStr)> ByVal lParam As String) As IntPtr
  52. End Function
  53. <DllImport("user32.dll", EntryPoint:="FindWindowW")> _
  54. Private Shared Function FindWindowW(<MarshalAs(UnmanagedType.LPWStr)> ByVal lpClassName As String, <MarshalAs(UnmanagedType.LPWStr)> ByVal lpWindowName As String) As IntPtr
  55. End Function
  56. Shared ReadOnly Property Link_TotalQCount
  57. Get
  58. Return XbmcControllerQ.Count + XbmcControllerBufferQ.Count
  59. End Get
  60. End Property
  61. Shared ReadOnly Property MC_Only_Movies_Nfos As List(Of String)
  62. Get
  63. If IsNothing(MC_Only_Movies) Then Return New List(Of String)
  64. Return (From M In MC_Only_Movies Select M.fullpathandfilename).ToList
  65. End Get
  66. End Property
  67. ReadOnly Shared Property NumOfScreens As Integer
  68. Get
  69. Return System.Windows.Forms.Screen.AllScreens.GetUpperBound(0)
  70. End Get
  71. End Property
  72. ReadOnly Shared Property CurrentScreen As Integer
  73. Get
  74. Try
  75. Dim display As String = System.Windows.Forms.Screen.FromControl(Form1).DeviceName
  76. Dim m As String = Regex.Match(display, "DISPLAY[0-9]").Value
  77. Return ToInt(m.Substring(m.Length - 1)) - 1
  78. Catch
  79. Return 0
  80. End Try
  81. End Get
  82. End Property
  83. Property frmXBMC_Progress As frmXBMC_Progress = New frmXBMC_Progress
  84. #Region "Movie scraping related objects"
  85. Public WithEvents oMovies As New Movies
  86. Public filteredList As New List(Of ComboList)
  87. Public rescrapeList As New RescrapeList
  88. Public workingMovieDetails As FullMovieDetails
  89. Public _rescrapeList As New RescrapeSpecificParams
  90. Public ChangeMovieId = ""
  91. Public droppedItems As New List(Of String)
  92. Public ControlsToDisableDuringMovieScrape As IEnumerable(Of Control)
  93. Public Shared blnAbortFileDownload As Boolean
  94. Public Shared ReadOnly countLock = New Object
  95. Public ScraperErrorDetected As Boolean
  96. #End Region 'Movie scraping objects
  97. Enum ProgramState
  98. ResettingFilters
  99. UpdatingFilteredList
  100. ResizingSplitterPanel
  101. MovieControlsDisabled
  102. Other
  103. End Enum
  104. Shared Public ProgState As ProgramState=ProgramState.Other
  105. Public StateBefore As ProgramState=ProgramState.Other
  106. Public DataDirty As Boolean
  107. Public _yield As Boolean
  108. Public LastMovieDisplayed As String=""
  109. Public MainFormLoadedStatus As Boolean = False
  110. Public tvRefreshNeeded As Boolean = True
  111. Public messbox As New frmMessageBox("blank", "", "")
  112. Public startup As Boolean = True
  113. Public SeriesXmlPath As String
  114. Public scraperFunction2 As New ScraperFunctions
  115. Public globalThreadStop As Boolean = False
  116. Public nfoFunction As New WorkingWithNfoFiles
  117. Public mediaInfoExp As New MediaInfoExport
  118. Shared Public langarray(300, 3) As String
  119. Public screen As Screen
  120. Public Shared genrelist As New List(Of String)
  121. Public Data_GridViewMovie As Data_GridViewMovie
  122. Public DataGridViewBindingSource As New BindingSource
  123. Public homemovielist As New List(Of str_BasicHomeMovie)
  124. Public WorkingHomeMovie As New HomeMovieDetails
  125. Public workingMovie As New ComboList
  126. Public tvBatchList As New str_TvShowBatchWizard(SetDefaults)
  127. Public moviefolderschanged As Boolean = False
  128. Public tvfolderschanged As Boolean = False
  129. Public hmfolderschanged As Boolean = False
  130. Public customTvfolderschanged As Boolean = False
  131. Public scraperLog As String = ""
  132. Public NewTagList As New List(Of String)
  133. Public MovieSearchEngine As String = "imdb"
  134. Dim mov_TableColumnName As String = ""
  135. Dim mov_TableRowNum As Integer = -1
  136. Dim MovFanartToggle As Boolean = False
  137. Dim MovPosterToggle As Boolean = False
  138. Private keypresstimer As Timers.Timer = New Timers.Timer()
  139. Private statusstripclear As Timers.Timer = New Timers.Timer()
  140. Private MovieKeyPress As String = ""
  141. Public cropMode As String = "movieposter"
  142. Dim WithEvents bigPictureBox As PictureBox
  143. Dim WithEvents fanartBoxes As PictureBox
  144. Dim WithEvents fanartCheckBoxes As RadioButton
  145. Dim WithEvents posterPicBoxes As PictureBox
  146. Dim WithEvents posterCheckBoxes As RadioButton
  147. Dim WithEvents posterLabels As Label
  148. Dim WithEvents resLabel As Label
  149. Dim WithEvents tvFanartBoxes As PictureBox
  150. Dim WithEvents tvFanartCheckBoxes As RadioButton
  151. Dim WithEvents resolutionLabels As Label
  152. Dim newTvFolders As New List(Of String)
  153. Dim tvprogresstxt As String = ""
  154. Dim maximised As Boolean = False
  155. Dim tootip5 As New ToolTip
  156. Dim MovpictureList As New List(Of PictureBox)
  157. Dim tvpictureList As New List(Of PictureBox)
  158. Dim screenshotTab As TabPage
  159. Dim filterOverride As Boolean = False
  160. Dim bigPanel As Panel
  161. Dim realTvPaths As New List(Of String)
  162. Public Shared profileStruct As New Profiles
  163. Dim frmSplash As New frmSplashscreen
  164. Dim frmSplash2 As New frmProgressScreen
  165. Public Shared multimonitor As Boolean = False
  166. Dim progressmode As Boolean
  167. Dim scrapeAndQuit As Boolean = False
  168. Dim refreshAndQuit As Boolean = False
  169. Dim sandq As Integer = 0
  170. Dim mouseDelta As Integer = 0
  171. Dim resLabels As Label
  172. Dim votelabels As Label
  173. Dim fanartArray As New List(Of McImage)
  174. Dim cropString As String
  175. Dim thumbedItsMade As Boolean = False
  176. Dim posterArray As New List(Of McImage)
  177. Dim pageCount As Integer = 0
  178. Dim currentPage As Integer = 0
  179. Dim actorflag As Boolean = False
  180. Dim listOfTvFanarts As New List(Of str_FanartList)
  181. Dim tableSets As New List(Of str_TableItems)
  182. Dim relativeFolderList As New List(Of str_RelativeFileList)
  183. Dim templanguage As String
  184. Dim WithEvents tvposterpicboxes As PictureBox
  185. Dim WithEvents tvpostercheckboxes As RadioButton
  186. Dim WithEvents tvposterlabels As Label
  187. Dim WithEvents tvreslabel As Label
  188. Dim tvposterpage As Integer = 1
  189. Public Shared WallPicWidth As Integer = 165
  190. Public Shared WallPicHeight As Integer = Math.Floor((WallPicWidth/3)*4)
  191. Dim MovMaxWallCount As Integer = 0
  192. Dim tvMaxWallCount As Integer = 0
  193. Dim moviecount_bak As Integer = 0
  194. Dim tvCount_bak As Integer = 0
  195. Dim lastSort As String = ""
  196. Dim lastinvert As String = ""
  197. Public displayRuntimeScraper As Boolean = True
  198. Dim tv_IMDbID_detected As Boolean = False
  199. Dim tv_IMDbID_warned As Boolean = False
  200. Dim tv_IMDbID_detectedMsg As String = String.Format("Media Companion has detected one or more TV Shows has an incorrect ID.{0}", vbCrLf) & _
  201. String.Format("To rectify, please select the following:{0}", vbCrLf) & _
  202. String.Format(" 1. TV Preferences -> Fix NFO id during cache refresh{0}", vbCrLf) & _
  203. String.Format(" 2. TV Shows -> Refresh Shows{0}", vbCrLf) & _
  204. String.Format("(This will only be reported once per session)", vbCrLf)
  205. Dim TVSearchALL As Boolean = False
  206. Private ClickedControl As String
  207. Private tvCurrentTabIndex As Integer = 0
  208. Private currentTabIndex As Integer = 0
  209. Private homeTabIndex As Integer = 0
  210. Private CustTvIndex As Integer = 0
  211. Public totalfilesize As Long = 0
  212. Public listoffilestomove As New List(Of String)
  213. Dim currenttitle As String
  214. Public singleshow As Boolean = False
  215. Public showslist As Object
  216. Public DGVMoviesColName As String = ""
  217. Dim CloseMC As Boolean = False
  218. Public Imageloading As Boolean = False
  219. Dim MoviesFiltersResizeCalled As Boolean = False
  220. Private tb_tagtxt_changed As Boolean = False
  221. 'TODO: (Form1_Load) Need to refactor
  222. #Region "Form1 Events"
  223. Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  224. PictureBoxAssignedMoviePoster.AllowDrop = True
  225. Try
  226. Pref.movie_filters.FilterPanel = SplitContainer5.Panel2
  227. Label73.Text = ""
  228. BckWrkScnMovies.WorkerReportsProgress = True
  229. BckWrkScnMovies.WorkerSupportsCancellation = True
  230. ImgBw.WorkerReportsProgress = True
  231. ImgBw.WorkerSupportsCancellation = True
  232. oMovies.Bw = BckWrkScnMovies
  233. For I = 0 To 20
  234. Common.Tasks.Add(New Tasks.BlankTask())
  235. Next
  236. Pref.applicationPath = Application.StartupPath
  237. Utilities.applicationPath = Application.StartupPath
  238. SeriesXmlPath = IO.Path.Combine(Utilities.applicationPath, "SeriesXml\")
  239. Utilities.EnsureFolderExists(Utilities.PosterCachePath)
  240. Utilities.EnsureFolderExists(Utilities.MissingPath)
  241. Utilities.EnsureFolderExists(Utilities.CacheFolderPath)
  242. If Not Utilities.GetFrameworkVersions().IndexOf("4.0") Then
  243. Dim RequiredNetURL As String = "http://www.microsoft.com/download/en/details.aspx?id=17718"
  244. If MsgBox("The Client version is available through Windows Updates." & vbCrLf & _
  245. "The Full version, while not required, is available from:" & vbCrLf & _
  246. RequiredNetURL & vbCrLf & vbCrLf & _
  247. "Do you wish to download the Full version?", _
  248. MsgBoxStyle.YesNo, "MC Requires .Net 4.0.") = MsgBoxResult.Yes Then
  249. OpenUrl(RequiredNetURL)
  250. End
  251. End If
  252. End If
  253. ForegroundWorkTimer.Interval = 500
  254. #If Not Debug Then
  255. AddHandler ForegroundWorkTimer.Tick, AddressOf ForegroundWorkPumper
  256. #End If
  257. Dim asm As Assembly = Assembly.GetExecutingAssembly
  258. Dim InternalResourceNames() As String = asm.GetManifestResourceNames
  259. For Each Temp In InternalResourceNames
  260. Dim Temp1 As ManifestResourceInfo = asm.GetManifestResourceInfo(Temp)
  261. Next
  262. TvTreeview.Sort()
  263. For Each arg As String In Environment.GetCommandLineArgs().Skip(1)
  264. Select Case arg.ToLower
  265. Case "sq"
  266. scrapeAndQuit = True
  267. sandq = 3
  268. Case "st"
  269. scrapeAndQuit = True
  270. sandq = 1
  271. Case "sm"
  272. scrapeAndQuit = True
  273. sandq = 2
  274. Case "r"
  275. refreshAndQuit = True
  276. Case "?"
  277. AttachConsole(-1)
  278. Console.WriteLine("")
  279. Console.WriteLine("")
  280. Console.WriteLine("Commandline options")
  281. Console.WriteLine("-------------------")
  282. Console.WriteLine("sq - Search for & scrape new movies & tv shows")
  283. Console.WriteLine("st - Search for & scrape newtv shows")
  284. Console.WriteLine("sm - Search for & scrape new movies")
  285. Console.WriteLine("r - Refresh movie & tv caches")
  286. Console.WriteLine("? - Show this page")
  287. Console.WriteLine("")
  288. Environment.Exit(1)
  289. 'Me.Close()
  290. Case Else
  291. AttachConsole(-1)
  292. Console.WriteLine("")
  293. Console.WriteLine("")
  294. Console.WriteLine("Unrecognised commandline option : [" & arg & "]. Type ? for help")
  295. Console.WriteLine("")
  296. Environment.Exit(1)
  297. 'Me.Close()
  298. End Select
  299. Next
  300. If scrapeAndQuit Or refreshAndQuit Then
  301. Me.WindowState = FormWindowState.Minimized
  302. Else
  303. Dim scrn As Integer = splashscreenread()
  304. If multimonitor Then
  305. frmSplash.Bounds = screen.AllScreens(scrn).Bounds
  306. frmSplash.StartPosition = FormStartPosition.Manual
  307. Dim x As Integer = screen.AllScreens(scrn).Bounds.X
  308. frmSplash.Location = New Point(x + 250, 250)
  309. frmSplash.TopMost = True
  310. End If
  311. frmSplash.Show()
  312. frmSplash.Label3.Text = "Status :- Initialising Program"
  313. frmSplash.Label3.Refresh()
  314. End If
  315. Me.Visible = False
  316. Me.Refresh()
  317. Application.DoEvents()
  318. Dim tempstring As String
  319. tempstring = applicationPath & "\enablemultiple.set"
  320. If Not File.Exists(tempstring) Then
  321. Dim tej As Integer = 0
  322. Dim processes() As Process
  323. Dim instance As Process
  324. Dim process As New Process()
  325. processes = process.GetProcesses
  326. For Each instance In processes
  327. If instance.ProcessName = "Media Companion" Then
  328. tej = tej + 1
  329. If tej >= 2 Then
  330. MsgBox("Media Companion is already running")
  331. End 'Close MC since another version of the program is running.
  332. End If
  333. End If
  334. Next
  335. End If
  336. CheckForIllegalCrossThreadCalls = False
  337. Pref.maximised = False
  338. Pref.SetUpPreferences() 'Set defaults to all userpreferences. We then load the preferences from config.xml this way any missing ones have a default already set
  339. GenreMasterLoad()
  340. tempstring = applicationPath & "\Settings\" 'read in the config.xml to set the stored preferences (if it exists)
  341. Dim hg As New IO.DirectoryInfo(tempstring)
  342. If hg.Exists Then
  343. Pref.configpath = tempstring & "config.xml"
  344. If Not IO.File.Exists(Pref.configpath) Then Pref.ConfigSave()
  345. Else
  346. IO.Directory.CreateDirectory(tempstring)
  347. workingProfile.Config = applicationPath & "\Settings\config.xml"
  348. Pref.ConfigSave()
  349. End If
  350. If Not IO.File.Exists(applicationPath & "\Settings\profile.xml") Then
  351. profileStruct.WorkingProfileName = "Default"
  352. profileStruct.DefaultProfile = "Default"
  353. profileStruct.StartupProfile = "Default"
  354. Dim currentprofile As New ListOfProfiles
  355. tempstring = applicationPath & "\Settings\"
  356. currentprofile.ActorCache = tempstring & "actorcache.xml"
  357. currentprofile.DirectorCache = tempstring & "directorcache.xml"
  358. currentprofile.Config = tempstring & "config.xml"
  359. currentprofile.RegExList = tempstring & "regex.xml"
  360. currentprofile.TvCache = tempstring & "tvcache.xml"
  361. currentprofile.MusicVideoCache = tempstring & "musicvideocache.xml"
  362. currentprofile.Genres = tempstring & "genres.txt"
  363. currentprofile.MovieCache = tempstring & "moviecache.xml"
  364. currentprofile.MovieSetCache = tempstring & "moviesetcache.xml"
  365. currentprofile.CustomTvCache = tempstring & "customtvcache.xml"
  366. currentprofile.ProfileName = "Default"
  367. profileStruct.ProfileList.Add(currentprofile)
  368. profileStruct.WorkingProfileName = "Default"
  369. Call util_ProfileSave()
  370. End If
  371. 'hide debug xml view tabs - unhiden (i.e. added) via debug tab
  372. TabLevel1.TabPages.Remove(Me.TabConfigXML)
  373. TabLevel1.TabPages.Remove(Me.TabMovieCacheXML)
  374. TabLevel1.TabPages.Remove(Me.TabTVCacheXML)
  375. TabLevel1.TabPages.Remove(Me.TabProfile)
  376. TabLevel1.TabPages.Remove(Me.TabActorCache)
  377. TabLevel1.TabPages.Remove(Me.TabRegex)
  378. TabLevel1.TabPages.Remove(Me.TabCustTv) 'Hide customtv tab while Work-In-Progress
  379. 'TabControl2.TabPages.Remove(Me.tpMovSets)
  380. TabControl2.TabPages.Remove(Me.tpMovTags)
  381. Call util_ProfilesLoad()
  382. For Each prof In profileStruct.ProfileList
  383. If prof.ProfileName = profileStruct.StartupProfile Then
  384. workingProfile.ActorCache = prof.ActorCache
  385. workingProfile.DirectorCache = prof.DirectorCache
  386. workingProfile.Config = prof.Config
  387. workingProfile.MovieCache = prof.MovieCache
  388. workingProfile.ProfileName = prof.ProfileName
  389. workingProfile.RegExList = prof.RegExList
  390. workingProfile.Genres = prof.Genres
  391. workingProfile.TvCache = prof.TvCache
  392. workingProfile.CustomTvCache = prof.CustomTvCache
  393. workingProfile.ProfileName = prof.ProfileName
  394. workingProfile.MusicVideoCache = prof.MusicVideoCache
  395. workingProfile.MovieSetCache = prof.MovieSetCache
  396. For Each item In ProfilesToolStripMenuItem.DropDownItems
  397. If item.text = workingProfile.ProfileName Then
  398. With item
  399. item.checked = True
  400. End With
  401. Else
  402. item.checked = False
  403. End If
  404. Next
  405. End If
  406. Next
  407. 'add musicvideocache to profile if it doesnt exist
  408. Dim counter As Int16 = 0
  409. tempstring = applicationPath & "\Settings\"
  410. For Each prof In profileStruct.ProfileList
  411. If counter = 0 Then
  412. If prof.MusicVideoCache = "" Then
  413. prof.MusicVideoCache = tempstring & "musicvideocache.xml"
  414. If prof.ProfileName = workingProfile.ProfileName Then
  415. workingProfile.MusicVideoCache = tempstring & "musicvideocache.xml"
  416. End If
  417. End If
  418. If prof.MovieSetCache = "" Then
  419. prof.MovieSetCache = tempstring & "moviesetcache.xml"
  420. If prof.ProfileName = workingProfile.ProfileName Then
  421. workingProfile.MovieSetCache = tempstring & "moviesetcache.xml"
  422. End If
  423. End If
  424. If prof.CustomTvCache = "" Then
  425. prof.CustomTvCache = tempstring & "customtvcache.xml"
  426. If prof.ProfileName = workingProfile.ProfileName Then
  427. workingProfile.CustomTvCache = tempstring & "customtvcache.xml"
  428. End If
  429. End If
  430. Else
  431. If prof.MusicVideoCache = "" Then
  432. prof.MusicVideoCache = tempstring & "musicvideocache" & counter.ToString & ".xml"
  433. End If
  434. If prof.ProfileName = workingProfile.ProfileName Then
  435. workingProfile.MusicVideoCache = tempstring & "musicvideocache" & counter.ToString & ".xml"
  436. End If
  437. If prof.MovieSetCache = "" Then
  438. prof.MovieSetCache = tempstring & "moviesetcache" & counter.ToString & ".xml"
  439. End If
  440. If prof.ProfileName = workingProfile.ProfileName Then
  441. workingProfile.MovieSetCache = tempstring & "moviesetcache" & counter.ToString & ".xml"
  442. End If
  443. If prof.CustomTvCache = "" Then
  444. prof.CustomTvCache = tempstring & "customtvcache" & counter.ToString & ".xml"
  445. End If
  446. If prof.ProfileName = workingProfile.ProfileName Then
  447. workingProfile.CustomTvCache = tempstring & "customtvcache" & counter.ToString & ".xml"
  448. End If
  449. End If
  450. counter += 1
  451. Next
  452. If workingProfile.HomeMovieCache = "" Then workingProfile.HomeMovieCache = tempstring & "homemoviecache.xml"
  453. 'Update Main Form Window Title to show Currrent Version - displays current profile so has to be done after profile is loaded
  454. util_MainFormTitleUpdate()
  455. Dim g As New IO.DirectoryInfo(Utilities.PosterCachePath)
  456. If Not g.Exists Then
  457. Try
  458. Directory.CreateDirectory(Utilities.PosterCachePath)
  459. Catch ex As Exception
  460. MsgBox(ex.Message.ToString)
  461. End
  462. End Try
  463. End If
  464. CheckForIllegalCrossThreadCalls = False
  465. Try
  466. If IO.File.Exists(IO.Path.Combine(applicationPath, "\error.log")) Then IO.File.Delete(IO.Path.Combine(applicationPath, "\error.log"))
  467. Catch ex As Exception
  468. #If SilentErrorScream Then
  469. Throw ex
  470. #End If
  471. End Try
  472. tempstring = applicationDatapath & "error.log"
  473. If IO.File.Exists(tempstring) = True Then IO.File.Delete(tempstring)
  474. Call util_RegexLoad()
  475. Call util_PrefsLoad()
  476. Statusstrip_Enable(False)
  477. 'These lines fixed the associated panel so that they don't automove when the Form1 is resized
  478. SplitContainer1.FixedPanel = System.Windows.Forms.FixedPanel.Panel1 'Left Panel on Movie tab - Movie Listing
  479. SplitContainer5.FixedPanel = System.Windows.Forms.FixedPanel.Panel2 'Bottom Left Panel on Movie Tab - Filters
  480. SplitContainer3.FixedPanel = System.Windows.Forms.FixedPanel.Panel1 'Left Panel on TV Tab
  481. Movies.SpinUpDrives()
  482. If Not (scrapeAndQuit Or refreshAndQuit) Then
  483. Me.Visible = True
  484. Dim intX As Integer
  485. Dim intY As Integer
  486. If Pref.MultiMonitoEnabled Then
  487. Dim scrn As Integer = If(NumOfScreens > 0, Pref.preferredscreen, 0)
  488. intX = screen.AllScreens(scrn).Bounds.X ' + screen.AllScreens(scrn).Bounds.Width
  489. intY = screen.AllScreens(scrn).Bounds.Height
  490. Else
  491. intX = Screen.PrimaryScreen.Bounds.Width
  492. intY = Screen.PrimaryScreen.Bounds.Height
  493. End If
  494. SplitContainer1.IsSplitterFixed = True
  495. SplitContainer2.IsSplitterFixed = True
  496. SplitContainer3.IsSplitterFixed = True
  497. SplitContainer4.IsSplitterFixed = True
  498. SplitContainer5.IsSplitterFixed = True
  499. If intX >= 0 Then 'First check if screen is Centre or to the right of main screen.
  500. If Pref.locx < 0 Then Pref.locx = 0
  501. If Pref.locy < 0 Then Pref.locy = 0
  502. If Pref.formheight > intY Then Pref.formheight = intY
  503. If Pref.formwidth > intX Then Pref.formwidth = intX
  504. If Pref.locx >= intX Then Pref.locx = intX - Pref.formwidth
  505. If Pref.locy >= intY Then Pref.locy = intY - Pref.formheight
  506. Else 'Else screen could be to the left of Centre/Main screen so intX is a negative number.
  507. 'If Pref.locx < 0 Then Pref.locx = 0
  508. If Pref.locy < 0 Then Pref.locy = 0
  509. If Pref.formheight > intY Then Pref.formheight = intY
  510. If Pref.formwidth > Math.Abs(intX) Then Pref.formwidth = intX
  511. If Pref.locx <= intX Then Pref.locx = intX ' - Pref.formwidth
  512. If Pref.locy >= intY Then Pref.locy = intY - Pref.formheight
  513. End If
  514. If Pref.formheight <> 0 And Pref.formwidth <> 0 Then
  515. Me.Width = Pref.formwidth
  516. Me.Height = Pref.formheight
  517. Me.Location = New Point(Pref.locx, Pref.locy)
  518. End If
  519. If Pref.maximised Then Me.WindowState = FormWindowState.Maximized
  520. Dim dpi As Graphics = Me.CreateGraphics
  521. 'MessageBox.Show(String.Format("X={0}, Y={1}", dpi.DpiX, dpi.DpiY),
  522. '"DPI Settings", MessageBoxButtons.OK, MessageBoxIcon.Information)
  523. DebugSytemDPITextBox.Text = dpi.DpiX
  524. Me.Refresh()
  525. Application.DoEvents()
  526. Me.Refresh()
  527. Application.DoEvents()
  528. Application.DoEvents()
  529. screenshotTab = TabControl3.TabPages(1)
  530. TabControl3.TabPages.RemoveAt(1)
  531. If Pref.splt5 = 0 Then
  532. Dim tempint As Integer = SplitContainer1.Height
  533. tempint = tempint / 4
  534. tempint = tempint * 3
  535. If tempint > 275 Then
  536. Pref.splt5 = tempint
  537. Else
  538. Pref.splt5 = 275
  539. End If
  540. End If
  541. SplitContainer1.SplitterDistance = Pref.splt1
  542. SplitContainer2.SplitterDistance = Pref.splt2
  543. SplitContainer5.SplitterDistance = Pref.splt5
  544. SplitContainer3.SplitterDistance = Pref.splt3
  545. SplitContainer4.SplitterDistance = Pref.splt4
  546. TabLevel1.SelectedIndex = Pref.startuptab
  547. If Pref.startuptab = 0 Then
  548. If Not MoviesFiltersResizeCalled Then
  549. MoviesFiltersResizeCalled = True
  550. Pref.movie_filters.RemoveInvalidMovieFilters
  551. Pref.movie_filters.SetMovieFiltersVisibility
  552. UpdateMovieFiltersPanel
  553. End If
  554. End If
  555. btn_MPDB_posters.Enabled = False 'Disable MoviePoster button on Movie Poster Tab as now not available to us.
  556. SplitContainer1.IsSplitterFixed = False
  557. SplitContainer2.IsSplitterFixed = False
  558. SplitContainer3.IsSplitterFixed = False
  559. SplitContainer4.IsSplitterFixed = False
  560. SplitContainer5.IsSplitterFixed = False
  561. End If
  562. If scrapeAndQuit Or refreshAndQuit Then
  563. Do_ScrapeAndQuit()
  564. Me.Close()
  565. Else
  566. Try
  567. If cbMovieDisplay_MovieSet.Items.Count <> Pref.moviesets.Count Then
  568. cbMovieDisplay_MovieSet.Items.Clear()
  569. For Each mset In Pref.moviesets
  570. cbMovieDisplay_MovieSet.Items.Add(If(Pref.MovSetTitleIgnArticle, Pref.RemoveIgnoredArticles(mset), mset))
  571. Next
  572. End If
  573. If Not IsNothing(workingMovieDetails) AndAlso workingMovieDetails.fullmoviebody.MovieSet.MovieSetName <> "-None-" Then
  574. For Each mset In Pref.moviesets
  575. cbMovieDisplay_MovieSet.Items.Add(If(Pref.MovSetTitleIgnArticle, Pref.RemoveIgnoredArticles(mset), mset))
  576. Next
  577. For te = 0 To cbMovieDisplay_MovieSet.Items.Count - 1
  578. If cbMovieDisplay_MovieSet.Items(te) = workingMovieDetails.fullmoviebody.MovieSet.MovieSetDisplayName Then
  579. cbMovieDisplay_MovieSet.SelectedIndex = te
  580. Exit For
  581. End If
  582. Next
  583. End If
  584. Catch ex As Exception
  585. #If SilentErrorScream Then
  586. Throw ex
  587. #End If
  588. End Try
  589. mov_VideoSourcePopulate()
  590. ep_VideoSourcePopulate()
  591. Call util_FontSetup()
  592. Call langarrsetup()
  593. Dim mediaDropdown As New SortedList(Of String, String)
  594. mediaInfoExp.addTemplates(mediaDropdown)
  595. For Each item In mediaDropdown
  596. If item.Value = MediaInfoExport.mediaType.Movie Then
  597. ExportMovieListInfoToolStripMenuItem.DropDownItems.Add(item.Key)
  598. ElseIf item.Value = MediaInfoExport.mediaType.TV Then
  599. ExportTVShowInfoToolStripMenuItem.DropDownItems.Add(item.Key)
  600. End If
  601. Next
  602. Call util_CommandListLoad()
  603. startup = False
  604. frmSplash.Label3.Text = "Status :- Cleaning Cache folder."
  605. frmSplash.Label3.Refresh()
  606. frmSplash.Close()
  607. mov_SplitContainerAutoPosition()
  608. tv_ShowSelectedCurrently(TvTreeview)
  609. tv_SplitContainerAutoPosition()
  610. End If
  611. 'Parameters to display the movie grid at startup
  612. Select Case Pref.moviedefaultlist
  613. Case 0
  614. rbTitleAndYear.Checked = True
  615. Case 1
  616. rbFileName.Checked = True
  617. Case 2
  618. rbFolder.Checked = True
  619. End Select
  620. Try
  621. cbSort.SelectedIndex = Pref.moviesortorder
  622. Catch
  623. cbSort.SelectedIndex = 0
  624. End Try
  625. btnreverse.Checked = Pref.movieinvertorder
  626. If btnreverse.Checked Then
  627. Mc.clsGridViewMovie.GridSort = "Desc"
  628. Else
  629. Mc.clsGridViewMovie.GridSort = "Asc"
  630. End If
  631. Read_XBMC_TMDB_Scraper_Config()
  632. Read_XBMC_TVDB_Scraper_Config()
  633. MainFormLoadedStatus = True
  634. UcFanartTv1.Form1MainFormLoadedStatus = True
  635. UcFanartTvTv1.Form1MainFormLoadedStatus = True
  636. ReloadMovieCacheToolStripMenuItem.Visible = False
  637. ToolStripSeparator9.Visible = False
  638. ResetFilters()
  639. UpdateFilteredList()
  640. If Not IsNothing(Pref.MovFiltLastSize) Then ResizeBottomLHSPanel(Pref.MovFiltLastSize, MovieFiltersPanelMaxHeight)
  641. Common.Tasks.StartTaskEngine()
  642. ForegroundWorkTimer.Start()
  643. BckWrkXbmcController.WorkerReportsProgress = True
  644. ' BckWrkXbmcController.WorkerSupportsCancellation = true
  645. oMovies.Bw = BckWrkScnMovies
  646. AddHandler XBMC_Link_ErrorLog_Timer.Elapsed, AddressOf XBMC_Controller_Log_TO_Timer_Elapsed
  647. Ini_Timer(XBMC_Link_ErrorLog_Timer, 3000)
  648. AddHandler XBMC_Link_Idle_Timer.Elapsed, AddressOf XBMC_Link_Idle_Timer_Elapsed
  649. Ini_Timer(XBMC_Link_Idle_Timer, 3000)
  650. AddHandler XBMC_Link_Check_Timer.Elapsed, AddressOf XBMC_Link_Check_Timer_Elapsed
  651. Ini_Timer(XBMC_Link_Check_Timer, 2000, True)
  652. 'XBMC_Link_Check_Timer.Start
  653. AddHandler keypresstimer.Elapsed, AddressOf keypresstimer_Elapsed
  654. Ini_Timer(keypresstimer, 1000)
  655. AddHandler statusstripclear.Elapsed, AddressOf statusstripclear_Elapsed
  656. Ini_Timer(statusstripclear, 2000)
  657. AddHandler BckWrkXbmcController.ProgressChanged, AddressOf BckWrkXbmcController_ReportProgress
  658. AddHandler BckWrkXbmcController.DoWork, AddressOf BckWrkXbmcController_DoWork
  659. BckWrkXbmcController.RunWorkerAsync(Me)
  660. For each pb As Control In TableLayoutPanel6.Controls
  661. If pb.Name.Contains("pbEpScrSht") Then
  662. AddHandler pb.Click, AddressOf pbepscrsht_click
  663. End If
  664. Next
  665. For each pb As Control In TableLayoutPanel27.Controls
  666. If pb.Name.Contains("pbHmScrSht") Then
  667. AddHandler pb.Click, AddressOf pbHmScrSht_click
  668. End If
  669. Next
  670. Catch ex As Exception
  671. ExceptionHandler.LogError(ex)
  672. End Try
  673. End Sub
  674. #If Refocus Then
  675. Private Sub Form1_Activated(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Activated
  676. Try
  677. If messbox.Visible = True Then
  678. messbox.Activate()
  679. messbox.BringToFront()
  680. messbox.Focus()
  681. End If
  682. Catch ex As Exception
  683. ExceptionHandler.LogError(ex)
  684. End Try
  685. End Sub
  686. #End If
  687. Private Sub Form1_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles MyBase.FormClosed
  688. Try
  689. Me.Dispose()
  690. Me.Finalize()
  691. CleanCacheFolder(, cbClearCache.Checked) 'Limit cachefolder to max 300 files. Cleaned on startup and shutdown.
  692. 'If cbClearCache checked then completely empty
  693. If cbClearMissingFolder.Checked = True Then ClearMissingFolder() ' delete missing folder if option selected.
  694. End
  695. Catch ex As Exception
  696. ExceptionHandler.LogError(ex)
  697. End Try
  698. End Sub
  699. Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles MyBase.FormClosing
  700. BckWrkScnMovies_Cancel()
  701. While BckWrkScnMovies.IsBusy
  702. Application.DoEvents()
  703. End While
  704. Try
  705. oMovies.SaveCaches()
  706. If Tv_CacheSave() Then
  707. e.Cancel = True
  708. Exit Sub
  709. End If
  710. Call HomeMovieCacheSave()
  711. Call UcMusicVideo1.MVCacheSave()
  712. 'if we say cancel to save nfo's & exit then we don't want to exit MC if e.cancel= true we abort the closing....
  713. 'Todo: Code a better way to serialize the data
  714. Pref.splt1 = SplitContainer1.SplitterDistance
  715. Pref.splt2 = SplitContainer2.SplitterDistance
  716. Pref.splt3 = SplitContainer3.SplitterDistance
  717. Pref.splt4 = SplitContainer4.SplitterDistance
  718. Pref.splt5 = SplitContainer5.SplitterDistance
  719. Pref.splt6 = _tv_SplitContainer.SplitterDistance
  720. Pref.tvbannersplit = Math.Round(_tv_SplitContainer.SplitterDistance / _tv_SplitContainer.Height, 2)
  721. Pref.MovFiltLastSize = SplitContainer5.Height - SplitContainer5.SplitterDistance
  722. Pref.preferredscreen = CurrentScreen
  723. If Me.WindowState = FormWindowState.Minimized Then
  724. Me.WindowState = FormWindowState.Normal
  725. Pref.formwidth = Me.Width
  726. Pref.formheight = Me.Height
  727. Pref.locx = Me.Location.X
  728. Pref.locy = Me.Location.Y
  729. Pref.maximised = False
  730. End If
  731. If Me.WindowState = FormWindowState.Normal Then
  732. Pref.formwidth = Me.Width
  733. Pref.formheight = Me.Height
  734. Pref.locx = Me.Location.X
  735. Pref.locy = Me.Location.Y
  736. Pref.maximised = False
  737. End If
  738. If Me.WindowState = FormWindowState.Maximized Then
  739. Me.WindowState = FormWindowState.Normal
  740. Pref.maximised = True
  741. End If
  742. If DataGridView1.Columns.Count > 0 Then
  743. Pref.tableview.Clear()
  744. For Each column In DataGridView1.Columns
  745. Dim tempstring As String = String.Format("{0}|{1}|{2}|{3}", column.name, column.width, column.displayindex, column.visible)
  746. Pref.tableview.Add(tempstring)
  747. Next
  748. End If
  749. Pref.startuptab = TabLevel1.SelectedIndex
  750. Pref.ConfigSave()
  751. SplashscreenWrite()
  752. Call util_ProfileSave()
  753. Dim errpath As String = IO.Path.Combine(applicationPath, "tvrefresh.log")
  754. Catch ex As Exception
  755. MessageBox.Show(ex.ToString, "Exception")
  756. Environment.Exit(1)
  757. 'ExceptionHandler.LogError(ex)
  758. End Try
  759. End Sub
  760. Private Sub Form1_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.GotFocus
  761. Try
  762. If messbox.Visible = True Then
  763. messbox.Activate()
  764. End If
  765. Catch ex As Exception
  766. ExceptionHandler.LogError(ex)
  767. End Try
  768. End Sub
  769. Private Sub Form1_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Resize
  770. Try
  771. If Me.WindowState = FormWindowState.Maximized Then
  772. mov_SplitContainerAutoPosition()
  773. tv_SplitContainerAutoPosition()
  774. End If
  775. If Not Me.WindowState = FormWindowState.Minimized Then
  776. tv_SplitContainerAutoPosition()
  777. End If
  778. If startup = False Then
  779. Pref.locx = Me.Location.X
  780. Pref.locy = Me.Location.Y
  781. End If
  782. If MainFormLoadedStatus = True Then
  783. doResizeRefresh()
  784. End If
  785. Catch ex As Exception
  786. Dim paramInfo As String = ""
  787. Try
  788. paramInfo = "PbMovieFanArt.Width:" & PbMovieFanArt.Width.ToString & " PbMovieFanArt.Height: " & PbMovieFanArt.Height.ToString & " Rating:" & ratingtxt.Text
  789. Catch ex2 As Exception
  790. ExceptionHandler.LogError(ex2)
  791. End Try
  792. ExceptionHandler.LogError(ex, paramInfo)
  793. End Try
  794. End Sub
  795. Private Sub Form1_ResizeEnd(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.ResizeEnd
  796. Try
  797. If Pref.formwidth <> Me.Width Or Pref.formheight <> Me.Height Then
  798. Pref.formwidth = Me.Width
  799. Pref.formheight = Me.Height
  800. End If
  801. mov_SplitContainerAutoPosition()
  802. tv_SplitContainerAutoPosition()
  803. Catch ex As Exception
  804. ExceptionHandler.LogError(ex)
  805. End Try
  806. End Sub
  807. Private Sub Form1_KeyDown(sender As System.Object, e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown
  808. If e.KeyCode = Keys.Escape Then bckgrndcancel()
  809. If e.KeyCode = Keys.F5 Then doRefresh()
  810. If e.KeyCode = Keys.F3 Then doSearchNew()
  811. If e.Control And e.KeyCode = Keys.C Then AbortFileDownload()
  812. End Sub
  813. #End Region
  814. Sub Ini_Timer(t As Timers.Timer, Optional Interval As Integer = 1000, Optional Repeating As Boolean = False)
  815. t.Stop()
  816. t.Interval = Interval
  817. t.AutoReset = Repeating
  818. End Sub
  819. #Region "XBMC Link"
  820. Private Sub BckWrkXbmcController_DoWork(ByVal sender As Object, ByVal e As DoWorkEventArgs)
  821. Dim bw As BackgroundWorker = CType(sender, BackgroundWorker)
  822. Dim sm As New XbmcController(e.Argument, bw)
  823. sm.Go()
  824. End Sub
  825. Private Sub XBMC_Controller_Log_TO_Timer_Elapsed()
  826. If Not BckWrkScnMovies.IsBusy And XbmcControllerBufferQ.Count = 0 Then
  827. If DateDiff(DateInterval.Second, XBMC_Controller_LogLastShownDt, Now) > 30 Then
  828. Pref.OpenFileInAppPath(Form1.XBMC_Controller_full_log_file)
  829. Pref.OpenFileInAppPath(Form1.XBMC_Controller_brief_log_file)
  830. frmXBMC_Progress.Reset()
  831. Dim ce As New BaseEvent(XbmcController.E.ResetErrorCount, New BaseEventArgs())
  832. XbmcControllerQ.Write(ce)
  833. End If
  834. XBMC_Controller_LogLastShownDt = Now
  835. XBMC_Link_ErrorLog_Timer.Stop()
  836. End If
  837. End Sub
  838. Private Sub XBMC_Link_Idle_Timer_Elapsed()
  839. If Not BckWrkScnMovies.IsBusy And XbmcControllerBufferQ.Count = 0 Then
  840. frmXBMC_Progress.Visible = False
  841. XBMC_Link_ErrorLog_Timer.Stop()
  842. End If
  843. End Sub
  844. Sub Restart(tmr As Timers.Timer)
  845. tmr.Stop()
  846. tmr.Start()
  847. End Sub
  848. Private Sub BckWrkXbmcController_ReportProgress(ByVal sender As Object, ByVal e As ProgressChangedEventArgs)
  849. Dim oProgress As XBMC_Controller_Progress = CType(e.UserState, XBMC_Controller_Progress)
  850. If XBMC_Link_ErrorLog_Timer.Enabled Then
  851. Restart(XBMC_Link_ErrorLog_Timer)
  852. End If
  853. Restart(XBMC_Link_Idle_Timer)
  854. Restart(XBMC_Link_Check_Timer)
  855. frmXBMC_Progress.Visible = True
  856. If HandleEvents(oProgress) Then Return
  857. If oProgress.ErrorCount > 0 Then
  858. If Pref.ShowLogOnError Then
  859. XBMC_Link_ErrorLog_Timer.Start()
  860. End If
  861. End If
  862. frmXBMC_Progress.UpdateDetails(oProgress)
  863. End Sub
  864. Function HandleEvents(oProgress As XBMC_Controller_Progress) As Boolean
  865. Select Case oProgress.Evt
  866. Case XbmcController.E.MC_Only_Movies
  867. MC_Only_Movies = CType(oProgress.Args, ComboList_EventArgs).XbmcMovies
  868. Assign_FilterGeneral()
  869. Return True
  870. Case XbmcController.E.MC_XbmcMcMovies
  871. oMovies.XbmcMcMovies = CType(oProgress.Args, XBMC_MC_Movies_EventArgs).XbmcMcMovies
  872. Assign_FilterGeneral()
  873. Return True
  874. Case XbmcController.E.MC_XbmcOnlyMovies
  875. oMovies.XbmcOnlyMovies = CType(oProgress.Args, XBMC_Only_Movies_EventArgs).XbmcOnlyMovies
  876. Return True
  877. Case XbmcController.E.MC_XbmcQuit
  878. SetcbBtnLink()
  879. Return True
  880. End Select
  881. Return False
  882. End Function
  883. Const MaxConseqFailures As Integer = 3
  884. Dim ConnectSent As Boolean
  885. Dim XbmcLastLinkState As Boolean
  886. Dim ConseqFailures As Integer = 0
  887. Sub SetcbBtnLink(Optional sender As Object = Nothing)
  888. XBMC_Link_Check_Timer.Stop()
  889. 'Only check when link is idle
  890. If Not BckWrkScnMovies.IsBusy And XbmcControllerBufferQ.Count = 0 Then
  891. Dim passed As Boolean = XBMC_TestsPassed
  892. '
  893. ' Sometimes the link test fails. Don't know why yet, maybe XBMC is busy...but anyway this should reduce the number of phantom
  894. ' link disablings...
  895. '
  896. If Not IsNothing(sender) Then
  897. If cbBtnLink.Enabled And Not passed Then
  898. ConseqFailures += 1
  899. Else
  900. ConseqFailures = 0
  901. End If
  902. Else
  903. ConseqFailures = 0
  904. End If
  905. If IsNothing(sender) Or ConseqFailures <= MaxConseqFailures Then
  906. cbBtnLink.Enabled = passed
  907. If cbBtnLink.Enabled Then
  908. cbBtnLink.BackColor = IIf(cbBtnLink.Checked, Color.LightGreen, Color.Transparent)
  909. If Pref.XBMC_Link <> cbBtnLink.Checked Then
  910. Pref.XBMC_Link = cbBtnLink.Checked
  911. If Pref.XbmcLinkReady Then
  912. XbmcControllerQ.Write(XbmcController.E.ConnectReq, PriorityQueue.Priorities.low)
  913. End If
  914. Pref.ConfigSave()
  915. End If
  916. Else
  917. cbBtnLink.Checked = False
  918. cbBtnLink.BackColor = Color.Transparent
  919. End If
  920. tsmiMov_SyncToXBMC.Enabled = cbBtnLink.Enabled And cbBtnLink.Checked
  921. End If
  922. End If
  923. XBMC_Link_Check_Timer.Start()
  924. End Sub
  925. Private Sub XBMC_Link_Check_Timer_Elapsed()
  926. If ProgState = ProgramState.MovieControlsDisabled Then Return
  927. SetcbBtnLink(XBMC_Link_Check_Timer)
  928. End Sub
  929. Private Sub keypresstimer_Elapsed()
  930. MovieKeyPress = ""
  931. End Sub
  932. Private Sub statusstripclear_Elapsed()
  933. ToolStripStatusLabel2.Visible = False
  934. Statusstrip_Enable(False)
  935. ToolStripStatusLabel2.Text = "TV Show Episode Scan In Progress"
  936. End Sub
  937. Sub XbmcLink_UpdateArtwork()
  938. If Pref.XBMC_Delete_Cached_Images AndAlso Pref.XbmcLinkReady Then
  939. Dim m As Movie = oMovies.LoadMovie(workingMovieDetails.fileinfo.fullpathandfilename)
  940. m.SaveNFO()
  941. End If
  942. End Sub
  943. #End Region
  944. Private Sub BlinkTaskBar()
  945. If GetActiveWindow <> Me.Handle Then
  946. Dim res = WindowsApi.FlashWindow(Process.GetCurrentProcess().MainWindowHandle, True, True, 5)
  947. End If
  948. End Sub
  949. Private Function splashscreenread() As Integer
  950. Dim scrn As Integer = 0
  951. Dim checkpath As String = Pref.applicationPath & "\Settings\screen.xml"
  952. If File.Exists(checkpath) Then
  953. Try
  954. Dim document As XDocument = XDocument.Load(checkpath)
  955. Dim sc = From t In document.Descendants("screen") Select t.Value
  956. Dim mten = From t In document.Descendants("MultiEnabled") Select t.Value
  957. multimonitor = Convert.ToBoolean(mten.First())
  958. scrn = sc.First().ToInt
  959. If scrn > NumOfScreens Then scrn = 0
  960. Catch
  961. scrn = 0
  962. multimonitor = False
  963. End Try
  964. End If
  965. Return scrn
  966. End Function
  967. Private Sub SplashscreenWrite()
  968. Dim doc As New XmlDocument
  969. Dim thispref As XmlNode = Nothing
  970. Dim xmlproc As XmlDeclaration
  971. Dim root As XmlElement = Nothing
  972. Dim child As XmlElement = Nothing
  973. xmlproc = doc.CreateXmlDeclaration("1.0", "UTF-8", "yes")
  974. doc.AppendChild(xmlproc)
  975. root = doc.CreateElement("root")
  976. child = doc.CreateElement("MultiEnabled")
  977. child.InnerXml = Pref.MultiMonitoEnabled
  978. root.AppendChild(child)
  979. child = doc.CreateElement("screen")
  980. child.InnerText = CurrentScreen.ToString
  981. root.AppendChild(child)
  982. doc.AppendChild(root)
  983. Dim screenpath As String = Pref.applicationPath & "\Settings\screen.xml"
  984. Try
  985. Dim output As New XmlTextWriter(screenpath, System.Text.Encoding.UTF8)
  986. output.Formatting = Formatting.Indented
  987. doc.WriteTo(output)
  988. output.Close()
  989. Catch
  990. End Try
  991. End Sub
  992. Private Sub Batch_Rewritenfo()
  993. rescrapeList.ResetFields()
  994. rescrapeList.rebuildnfo = True
  995. _rescrapeList.FullPathAndFilenames.Clear()
  996. For Each movie As ComboList In oMovies.MovieCache
  997. _rescrapeList.FullPathAndFilenames.Add(movie.fullpathandfilename)
  998. Next
  999. RunBackgroundMovieScrape("BatchRescrape")
  1000. End Sub
  1001. Sub CleanCacheFolder(Optional ByVal All As Boolean = False, Optional ByVal Total As Boolean = False)
  1002. Dim cachefolder As String = applicationPath & "\cache\"
  1003. If IO.Directory.Exists(cacheFolder) Then
  1004. Dim Files As New IO.DirectoryInfo(cachefolder)
  1005. Dim FileList() = Files.GetFiles().OrderByDescending(Function(f) f.LastWriteTime).ToArray
  1006. Dim limit As Integer = If(Total, 0, 299)
  1007. Dim i As Integer = FileList.Count
  1008. Try
  1009. If i > limit Then
  1010. Do Until i = limit
  1011. i-=1
  1012. Dim filepath As String = FileList(i).FullName
  1013. Utilities.SafeDeleteFile(filepath)
  1014. Loop
  1015. End If
  1016. Catch
  1017. End Try
  1018. End If
  1019. If All Then
  1020. ClearSeriesFolder()
  1021. ClearPosterFolder()
  1022. End If
  1023. End Sub
  1024. Sub ClearSeriesFolder()
  1025. If IO.Directory.Exists(SeriesXmlPath) Then
  1026. Dim Files As New IO.DirectoryInfo(SeriesXmlPath)
  1027. Dim Filelist() = Files.GetFiles()
  1028. For Each f In Filelist
  1029. Utilities.SafeDeleteFile(f.FullName)
  1030. Next
  1031. End If
  1032. End Sub
  1033. Sub ClearMissingFolder()
  1034. Try
  1035. If IO.Directory.Exists(Utilities.MissingPath)
  1036. Dim Files As New IO.DirectoryInfo(Utilities.MissingPath)
  1037. Dim Filelist() = Files.GetFiles()
  1038. For Each f In Filelist
  1039. Utilities.SafeDeleteFile(f.FullName)
  1040. Next
  1041. End If
  1042. Catch ex As Exception
  1043. End Try
  1044. End Sub
  1045. Sub ClearPosterFolder()
  1046. If IO.Directory.Exists(Utilities.PosterCachePath) Then
  1047. Dim Files As New IO.DirectoryInfo(Utilities.PosterCachePath)
  1048. Dim Filelist() = Files.GetFiles()
  1049. For Each f In Filelist
  1050. Utilities.SafeDeleteFile(f.FullName)
  1051. Next
  1052. End If
  1053. End Sub
  1054. Sub util_MainFormTitleUpdate()
  1055. 'Update Main Form Window Title to show Currrent Version
  1056. Dim sAssemblyVersion As String = Trim(System.Reflection.Assembly.GetExecutingAssembly.FullName.Split(",")(1))
  1057. sAssemblyVersion = Microsoft.VisualBasic.Right(sAssemblyVersion, 7) 'Cuts Version=3.4.0.2 down to just 3.4.0.2
  1058. Dim codebase As String = If(Environment.Is64BitProcess, "64Bit", "32Bit")
  1059. If workingProfile.profilename.ToLower = "default" Then
  1060. Me.Text = "Media Companion - V" & sAssemblyVersion & " - " & codebase
  1061. Else
  1062. Me.Text = "Media Companion - V" & sAssemblyVersion & " - " & codebase & " - " & workingProfile.profilename
  1063. End If
  1064. End Sub
  1065. Sub mov_SplitContainerAutoPosition()
  1066. 'Set Movie Splitter Auto Position
  1067. Dim pic1ratio As Decimal
  1068. Dim pic2ratio As Decimal
  1069. Try
  1070. If Not IsNothing(PbMovieFanArt.Image) Then
  1071. Dim pic1ImSzW = PbMovieFanArt.Image.Size.Width 'original picture sizes
  1072. Dim pic1ImszH = PbMovieFanArt.Image.Size.Height
  1073. Dim pic2ImSzW = PbMoviePoster.Image.Size.Width
  1074. Dim pic2ImszH = PbMoviePoster.Image.Size.Height
  1075. pic1ratio = pic1ImSzW / pic1ImszH
  1076. pic2ratio = pic2ImSzW / pic2ImszH
  1077. Dim width As Integer = SplitContainer2.Size.Width
  1078. ' MsgBox(from & " = " & width & ":" & Int(SplitContainer2.Size.Width * (pic1ratio / (pic1ratio + pic2ratio))) - 5 & " - " & pic1ImSzW & "x" & pic1ImszH & " " & pic2ImszH & "x" & pic2ImSzW)
  1079. Else
  1080. pic1ratio = 2
  1081. pic2ratio = 1
  1082. End If
  1083. Catch ex As Exception
  1084. pic1ratio = 2
  1085. pic2ratio = 1
  1086. 'MsgBox("Movie Splitter Exception")
  1087. End Try
  1088. SplitContainer2.SplitterDistance = (SplitContainer2.Size.Width - 8) * (pic1ratio / (pic1ratio + pic2ratio))
  1089. End Sub
  1090. Sub tv_SplitContainerAutoPosition()
  1091. 'Set TVShow Splitter Auto Position
  1092. Dim pic3ratio As Decimal
  1093. Dim pic4ratio As Decimal
  1094. Dim HorizontalSplit As Decimal
  1095. Try
  1096. If (tv_PictureBoxLeft.Image IsNot Nothing AndAlso tv_PictureBoxRight.Image IsNot Nothing) Then
  1097. Dim pic3ImSzW = tv_PictureBoxLeft.Image.Size.Width
  1098. Dim pic3ImszH = tv_PictureBoxLeft.Image.Size.Height
  1099. Dim pic4ImSzW = tv_PictureBoxRight.Image.Size.Width
  1100. Dim pic4ImszH = tv_PictureBoxRight.Image.Size.Height
  1101. pic3ratio = pic3ImSzW / pic3ImszH
  1102. pic4ratio = pic4ImSzW / pic4ImszH
  1103. HorizontalSplit = ((SplitContainer4.Size.Width - 8) * (pic3ratio / (pic3ratio + pic4ratio)) / pic3ratio)
  1104. Else
  1105. pic3ratio = 2
  1106. pic4ratio = 1
  1107. HorizontalSplit = 235
  1108. End If
  1109. Catch ex As Exception
  1110. pic3ratio = 2
  1111. pic4ratio = 1
  1112. HorizontalSplit = 235
  1113. End Try
  1114. SplitContainer4.SplitterDistance = (SplitContainer4.Size.Width - 8) * (pic3ratio / (pic3ratio + pic4ratio))
  1115. Try 'Try Catch for minimize of MC when Full-screen
  1116. If _tv_SplitContainer.Height > 100 Then
  1117. If Pref.tvbannersplit = 0 Then
  1118. _tv_SplitContainer.SplitterDistance = HorizontalSplit
  1119. Else
  1120. _tv_SplitContainer.SplitterDistance = _tv_SplitContainer.Height * Pref.tvbannersplit
  1121. End If
  1122. End If
  1123. Catch
  1124. End Try
  1125. End Sub
  1126. Public Sub mov_CacheLoad()
  1127. mov_PreferencesDisplay
  1128. oMovies.LoadCaches
  1129. If oMovies.MovieCache.Count = 0 Then
  1130. mov_RebuildMovieCaches
  1131. Return
  1132. End If
  1133. filteredList.Clear
  1134. filteredList.AddRange(oMovies.MovieCache)
  1135. Mc.clsGridViewMovie.mov_FiltersAndSortApply(Me)
  1136. If DataGridViewMovies.Rows.Count > 0 then
  1137. DataGridViewMovies.Rows(0).Selected = True
  1138. End If
  1139. mov_FormPopulate
  1140. End Sub
  1141. Public Sub util_RegexLoad()
  1142. Dim tempstring As String
  1143. tempstring = workingProfile.regexlist
  1144. Pref.tv_RegexScraper.Clear()
  1145. Pref.tv_RegexRename.Clear()
  1146. Dim path As String = tempstring
  1147. Dim createDefaultRegexScrape As Boolean = True
  1148. Dim createDefaultRegexRename As Boolean = True
  1149. If File.Exists(path) Then
  1150. Try
  1151. Dim regexList As New XmlDocument
  1152. regexList.Load(path)
  1153. If regexList.DocumentElement.Name = "regexlist" Then
  1154. For Each result As XmlElement In regexList("regexlist")
  1155. Select Case result.Name
  1156. Case "tvregex" 'This is the old tag before custom renamer was introduced,
  1157. Pref.tv_RegexScraper.Add(result.InnerText) 'so add it to the scraper regex list in case there are custom regexs.
  1158. createDefaultRegexScrape = False 'The rename regex will not be flagged so regex.xml will be created as new format.
  1159. Case "tvregexscrape"
  1160. Pref.tv_RegexScraper.Add(result.InnerText)
  1161. createDefaultRegexScrape = False
  1162. Case "tvregexrename"
  1163. Pref.tv_RegexRename.Add(result.InnerText)
  1164. createDefaultRegexRename = False
  1165. End Select
  1166. Next
  1167. End If
  1168. Catch ex As Exception
  1169. Call util_RegexSave(True, True)
  1170. #If SilentErrorScream Then
  1171. Throw ex
  1172. #End If
  1173. End Try
  1174. End If
  1175. If createDefaultRegexScrape Or createDefaultRegexRename Then
  1176. Call util_RegexSave(createDefaultRegexScrape, createDefaultRegexRename) 'Valid regex XML doc not available, so create default one.
  1177. End If
  1178. End Sub
  1179. Public Sub util_RegexSave(Optional ByVal setScraperDefault As Boolean = False, Optional ByVal setRenameDefault As Boolean = False)
  1180. Dim path As String = workingProfile.regexlist
  1181. Dim doc As New XmlDocument
  1182. Dim xmlProc As XmlDeclaration = doc.CreateXmlDeclaration("1.0", "UTF-8", "yes")
  1183. Dim root As XmlElement
  1184. Dim child As XmlElement
  1185. If setScraperDefault = True Then Pref.util_RegexSetDefaultScraper()
  1186. If setRenameDefault = True Then Pref.util_RegexSetDefaultRename()
  1187. doc.AppendChild(xmlProc)
  1188. root = doc.CreateElement("regexlist")
  1189. For Each Regex In Pref.tv_RegexScraper
  1190. child = doc.CreateElement("tvregexscrape")
  1191. child.InnerText = Regex
  1192. root.AppendChild(child)
  1193. Next
  1194. For Each Regex In Pref.tv_RegexRename
  1195. child = doc.CreateElement("tvregexrename")
  1196. child.InnerText = Regex
  1197. root.AppendChild(child)
  1198. Next
  1199. doc.AppendChild(root)
  1200. Try
  1201. Using output As New XmlTextWriter(path, System.Text.Encoding.UTF8) With {.Formatting = Formatting.Indented}
  1202. '"D:\Dados de Utilizador\Freddy Krueger\Ambiente de Trabalho\MediaCompanion-EVRSOEIRANAS\Settings\regex.xml"
  1203. doc.WriteTo(output)
  1204. output.Close()
  1205. End Using
  1206. Catch ex As Exception
  1207. #If SilentErrorScream Then
  1208. Throw ex
  1209. #End If
  1210. End Try
  1211. End Sub
  1212. Private Sub GenreMasterLoad()
  1213. genrelist.Clear()
  1214. genrelist = Utilities.loadGenre
  1215. End Sub
  1216. Private Sub util_GenreLoad()
  1217. If Not File.Exists(workingProfile.Genres) Then Exit Sub
  1218. Dim line As String = String.Empty
  1219. Dim listof As New List(Of String)
  1220. listof.Clear()
  1221. genrelist.Sort()
  1222. Try
  1223. Dim userConfig As StreamReader = File.OpenText(workingProfile.Genres)
  1224. Do
  1225. Try
  1226. line = userConfig.ReadLine
  1227. If line = Nothing Then Continue Do
  1228. Dim regexMatch As Match
  1229. regexMatch = Regex.Match(line, "<([\d]{2,3})>")
  1230. If regexMatch.Success = False AndAlso (genrelist.FindIndex(Function(x) x.Equals(line.trim, StringComparison.OrdinalIgnoreCase) ) = -1) Then
  1231. listof.Add(line.trim)
  1232. End If
  1233. Catch ex As Exception
  1234. MessageBox.Show(ex.Message)
  1235. End Try
  1236. Loop Until line = Nothing
  1237. userConfig.Close()
  1238. userConfig = Nothing
  1239. Catch ex As Exception
  1240. MessageBox.Show(ex.Message)
  1241. End Try
  1242. If listof.Count > 0 Then
  1243. If Pref.GenreCustomBefore Then
  1244. listof.Sort()
  1245. genrelist.Sort()
  1246. genrelist.InsertRange(0, listof)
  1247. Else
  1248. genrelist.AddRange(listof)
  1249. genrelist.Sort()
  1250. End If
  1251. End If
  1252. End Sub
  1253. Private Sub util_PrefsLoad()
  1254. Dim tempstring As String
  1255. For Each prof In profileStruct.ProfileList
  1256. If prof.profilename = workingProfile.profilename Then
  1257. tempstring = prof.Config
  1258. If IO.File.Exists(tempstring) Then Pref.configpath = tempstring
  1259. Pref.configpath = tempstring
  1260. Pref.SetUpPreferences()
  1261. Pref.ConfigLoad()
  1262. If Pref.CheckForNewVersion Then
  1263. BckWrkCheckNewVersion.RunWorkerAsync(False)
  1264. Do Until Not BckWrkCheckNewVersion.IsBusy
  1265. Application.DoEvents()
  1266. Loop
  1267. If CloseMC AndAlso Pref.CloseMCForDLNewVersion Then
  1268. frmSplash.Close()
  1269. Process.GetCurrentProcess.Kill()
  1270. Application.Exit()
  1271. Me.Close()
  1272. Else
  1273. CloseMC = False
  1274. End If
  1275. End If
  1276. Me.util_ConfigLoad()
  1277. End If
  1278. Next
  1279. For Each item In Pref.moviesets
  1280. cbMovieDisplay_MovieSet.Items.Add(If(Pref.MovSetTitleIgnArticle, Pref.RemoveIgnoredArticles(item), item))
  1281. Next
  1282. End Sub
  1283. Private Sub util_ProfilesLoad()
  1284. profileStruct.ProfileList.Clear()
  1285. Dim profilepath As String = IO.Path.Combine(applicationPath, "Settings")
  1286. profilepath = IO.Path.Combine(profilepath, "profile.xml")
  1287. Dim notportable As Boolean = False
  1288. Dim path As String = profilepath
  1289. If IO.File.Exists(path) Then
  1290. Try
  1291. Dim profilelist As New XmlDocument
  1292. profilelist.Load(path)
  1293. If profilelist.DocumentElement.Name = "profile" Then
  1294. For Each thisresult In profilelist("profile")
  1295. Select Case thisresult.Name
  1296. Case "default"
  1297. profileStruct.DefaultProfile = thisresult.innertext
  1298. Case "startup"
  1299. profileStruct.StartupProfile = thisresult.innertext
  1300. Case "profiledetails"
  1301. Dim currentprofile As New ListOfProfiles
  1302. Dim result As XmlNode
  1303. For Each result In thisresult.childnodes
  1304. Dim t As Integer = result.innertext.ToString.ToLower.IndexOf("\s")
  1305. If t > 0 Then notportable = True
  1306. Select Case result.name
  1307. Case "actorcache"
  1308. Dim s As String = result.innertext.ToString.Substring(t)
  1309. currentprofile.ActorCache = applicationPath & s
  1310. Case "directorcache"
  1311. Dim s As String = result.innertext.ToString.Substring(t)
  1312. currentprofile.DirectorCache = applicationPath & s
  1313. Case "config"
  1314. Dim s As String = result.innertext.ToString.Substring(t)
  1315. currentprofile.Config = applicationPath & s
  1316. Case "moviecache"
  1317. Dim s As String = result.innertext.ToString.Substring(t)
  1318. currentprofile.MovieCache = applicationPath & s
  1319. Case "profilename"
  1320. currentprofile.ProfileName = result.innertext
  1321. Case "regex"
  1322. Dim s As String = result.innertext.ToString.Substring(t)
  1323. currentprofile.RegExList = applicationPath & s
  1324. Case "genres"
  1325. Dim s As String = ""
  1326. If result.innertext = "" Then
  1327. s = "\Settings\genres.txt" 'incase missing from existing profile.xml
  1328. Else
  1329. s = result.innertext.ToString.Substring(t)
  1330. End If
  1331. currentprofile.Genres = applicationPath & s
  1332. Case "tvcache"
  1333. Dim s As String = result.innertext.ToString.Substring(t)
  1334. currentprofile.TvCache = applicationPath & s
  1335. Case "musicvideocache"
  1336. Dim s As String = result.innertext.ToString.Substring(t)
  1337. currentprofile.MusicVideoCache = applicationPath & s
  1338. Case "moviesetcache"
  1339. Dim s As String = result.innertext.ToString.Substring(t)
  1340. currentprofile.MovieSetCache = applicationPath & s
  1341. Case "customtvcache"
  1342. Dim s As String = result.InnerText.ToString.Substring(t)
  1343. currentprofile.CustomTvCache = applicationPath & s
  1344. End Select
  1345. Next
  1346. profileStruct.ProfileList.Add(currentprofile)
  1347. End Select
  1348. Next
  1349. End If
  1350. Catch ex As Exception
  1351. #If SilentErrorScream Then
  1352. Throw ex
  1353. #End If
  1354. End Try
  1355. Else
  1356. End If
  1357. If notportable Then util_ProfileSave()
  1358. If profileStruct.ProfileList.Count > 1 Then
  1359. ProfilesToolStripMenuItem.Visible = True
  1360. ProfilesToolStripMenuItem.Enabled = True
  1361. ProfilesToolStripMenuItem.DropDownItems.Clear()
  1362. For Each prof In profileStruct.ProfileList
  1363. If prof.ProfileName <> Nothing Then
  1364. ProfilesToolStripMenuItem.DropDownItems.Add(prof.ProfileName)
  1365. End If
  1366. Next
  1367. For Each item In ProfilesToolStripMenuItem.DropDownItems
  1368. If item.text = workingProfile.profilename Then
  1369. With item
  1370. item.checked = True
  1371. End With
  1372. Else
  1373. item.checked = False
  1374. End If
  1375. Next
  1376. End If
  1377. End Sub
  1378. Public Sub util_ProfileSave()
  1379. Dim profilepath As String = IO.Path.Combine(applicationPath, "Settings")
  1380. profilepath = IO.Path.Combine(profilepath, "profile.xml")
  1381. Dim doc As New XmlDocument
  1382. Dim thispref As XmlNode = Nothing
  1383. Dim xmlproc As XmlDeclaration
  1384. xmlproc = doc.CreateXmlDeclaration("1.0", "UTF-8", "yes")
  1385. doc.AppendChild(xmlproc)
  1386. Dim root As XmlElement
  1387. Dim child As XmlElement
  1388. Dim childchild As XmlElement
  1389. root = doc.CreateElement("profile")
  1390. child = doc.CreateElement("default")
  1391. child.InnerText = profileStruct.DefaultProfile
  1392. root.AppendChild(child)
  1393. child = doc.CreateElement("startup")
  1394. child.InnerText = profileStruct.StartupProfile
  1395. root.AppendChild(child)
  1396. doc.AppendChild(root)
  1397. For Each prof In profileStruct.ProfileList
  1398. child = doc.CreateElement("profiledetails")
  1399. childchild = doc.CreateElement("actorcache") : childchild.InnerText = prof.ActorCache.Replace(applicationPath, "")
  1400. child.AppendChild(childchild)
  1401. childchild = doc.CreateElement("directorcache") : childchild.InnerText = prof.DirectorCache.Replace(applicationPath, "")
  1402. child.AppendChild(childchild)
  1403. childchild = doc.CreateElement("config") : childchild.InnerText = prof.Config.Replace(applicationPath, "")
  1404. child.AppendChild(childchild)
  1405. childchild = doc.CreateElement("moviecache") : childchild.InnerText = prof.MovieCache.Replace(applicationPath, "")
  1406. child.AppendChild(childchild)
  1407. childchild = doc.CreateElement("profilename") : childchild.InnerText = prof.ProfileName
  1408. child.AppendChild(childchild)
  1409. childchild = doc.CreateElement("regex") : childchild.InnerText = prof.RegExList.Replace(applicationPath, "")
  1410. child.AppendChild(childchild)
  1411. childchild = doc.CreateElement("genres") : childchild.InnerText = prof.Genres.Replace(applicationPath, "")
  1412. child.AppendChild(childchild)
  1413. childchild = doc.CreateElement("tvcache") : childchild.InnerText = prof.TvCache.Replace(applicationPath, "")
  1414. child.AppendChild(childchild)
  1415. childchild = doc.CreateElement("musicvideocache") : childchild.InnerText = prof.MusicVideoCache.Replace(applicationPath, "")
  1416. child.AppendChild(childchild)
  1417. childchild = doc.CreateElement("moviesetcache") : childchild.InnerText = prof.MovieSetCache.Replace(applicationPath, "")
  1418. child.AppendChild(childchild)
  1419. childchild = doc.CreateElement("customtvcache") : childchild.InnerText = prof.CustomTvCache.Replace(applicationPath, "")
  1420. child.AppendChild(childchild)
  1421. root.AppendChild(child)
  1422. Next
  1423. doc.AppendChild(root)
  1424. Dim saveing As New XmlTextWriter(profilepath, System.Text.Encoding.UTF8)
  1425. saveing.Formatting = Formatting.Indented
  1426. doc.WriteTo(saveing)
  1427. saveing.Close()
  1428. If profileStruct.ProfileList.Count > 1 Then
  1429. ProfilesToolStripMenuItem.Visible = True
  1430. ProfilesToolStripMenuItem.Enabled = True
  1431. ProfilesToolStripMenuItem.DropDownItems.Clear()
  1432. For Each prof In profileStruct.ProfileList
  1433. If prof.ProfileName <> Nothing Then
  1434. ProfilesToolStripMenuItem.DropDownItems.Add(prof.ProfileName)
  1435. End If
  1436. Next
  1437. For Each item In ProfilesToolStripMenuItem.DropDownItems
  1438. If item.text = workingProfile.profilename Then
  1439. With item
  1440. item.checked = True
  1441. End With
  1442. Else
  1443. item.checked = False
  1444. End If
  1445. Next
  1446. End If
  1447. End Sub
  1448. Private Sub util_CommandListLoad()
  1449. For Each com In Pref.commandlist
  1450. ToolsToolStripMenuItem.DropDownItems.Add(com.title)
  1451. Next
  1452. End Sub
  1453. Private Sub mov_ActorRebuild()
  1454. oMovies.RebuildMoviePeopleCaches
  1455. End Sub
  1456. Private Sub MovToggleReset()
  1457. MovFanartToggle = False
  1458. MovPosterToggle = False
  1459. btnMovFanartToggle.Text = "Show MovieSet Fanart"
  1460. btnMovFanartToggle.BackColor = System.Drawing.Color.Lime
  1461. btnMovPosterToggle.Text = "Show MovieSet Posters"
  1462. btnMovPosterToggle.BackColor = System.Drawing.Color.Lime
  1463. btn_IMPA_posters.Enabled = True
  1464. btn_MPDB_posters.Enabled = True
  1465. btn_IMDB_posters.Enabled = True
  1466. End Sub
  1467. Public Sub mov_FormPopulate(Optional yieldIng As Boolean=False)
  1468. If Not IsNothing(workingMovieDetails) Then
  1469. If workingMovie.fullpathandfilename <> workingMovieDetails.fileinfo.fullpathandfilename Then
  1470. Try
  1471. For i = panelAvailableMoviePosters.Controls.Count - 1 To 0 Step -1
  1472. panelAvailableMoviePosters.Controls.RemoveAt(i)
  1473. Next
  1474. Catch
  1475. End Try
  1476. Try
  1477. For i = Panel2.Controls.Count - 1 To 0 Step -1
  1478. Panel2.Controls.RemoveAt(i)
  1479. Next
  1480. MovToggleReset()
  1481. Catch
  1482. End Try
  1483. Try
  1484. TextBox8.Text = ""
  1485. Catch
  1486. End Try
  1487. End If
  1488. End If
  1489. If Yield(yieldIng) Then Return
  1490. If workingMovie.fullpathandfilename <> Nothing And DataGridViewMovies.Rows.Count > 0 Then
  1491. workingMovieDetails = WorkingWithNfoFiles.mov_NfoLoadFull(workingMovie.fullpathandfilename)
  1492. If Yield(yieldIng) Then Return
  1493. If IsNothing(workingMovieDetails) = False Then
  1494. If workingMovieDetails.fullmoviebody.playcount = Nothing Then workingMovieDetails.fullmoviebody.playcount = "0"
  1495. If workingMovieDetails.fullmoviebody.lastplayed = Nothing Then workingMovieDetails.fullmoviebody.lastplayed = ""
  1496. If workingMovieDetails.fullmoviebody.credits = Nothing Then workingMovieDetails.fullmoviebody.credits = ""
  1497. If workingMovieDetails.fullmoviebody.director = Nothing Then workingMovieDetails.fullmoviebody.director = ""
  1498. If workingMovieDetails.fullmoviebody.stars = Nothing Then workingMovieDetails.fullmoviebody.stars = ""
  1499. If workingMovieDetails.fullmoviebody.filename = Nothing Then workingMovieDetails.fullmoviebody.filename = ""
  1500. If workingMovieDetails.fullmoviebody.genre = Nothing Then workingMovieDetails.fullmoviebody.genre = ""
  1501. If workingMovieDetails.fullmoviebody.imdbid = Nothing Then workingMovieDetails.fullmoviebody.imdbid = ""
  1502. If workingMovieDetails.fullmoviebody.mpaa = Nothing Then workingMovieDetails.fullmoviebody.mpaa = ""
  1503. If workingMovieDetails.fullmoviebody.outline = Nothing Then workingMovieDetails.fullmoviebody.outline = ""
  1504. If workingMovieDetails.fullmoviebody.playcount = Nothing Then workingMovieDetails.fullmoviebody.playcount = ""
  1505. If workingMovieDetails.fullmoviebody.plot = Nothing Then workingMovieDetails.fullmoviebody.plot = ""
  1506. If workingMovieDetails.fullmoviebody.premiered = Nothing Then workingMovieDetails.fullmoviebody.premiered = ""
  1507. If workingMovieDetails.fullmoviebody.rating = Nothing Then workingMovieDetails.fullmoviebody.rating = ""
  1508. If workingMovieDetails.fullmoviebody.runtime = Nothing Then workingMovieDetails.fullmoviebody.runtime = ""
  1509. If workingMovieDetails.fullmoviebody.studio = Nothing Then workingMovieDetails.fullmoviebody.studio = ""
  1510. If workingMovieDetails.fullmoviebody.tagline = Nothing Then workingMovieDetails.fullmoviebody.tagline = ""
  1511. If workingMovieDetails.fullmoviebody.title = Nothing Then workingMovieDetails.fullmoviebody.title = ""
  1512. If workingMovieDetails.fullmoviebody.originaltitle = Nothing Then workingMovieDetails.fullmoviebody.originaltitle = ""
  1513. If workingMovieDetails.fullmoviebody.top250 = Nothing Then workingMovieDetails.fullmoviebody.top250 = ""
  1514. If workingMovieDetails.fullmoviebody.trailer = Nothing Then workingMovieDetails.fullmoviebody.trailer = ""
  1515. If workingMovieDetails.fullmoviebody.votes = Nothing Then workingMovieDetails.fullmoviebody.votes = ""
  1516. If workingMovieDetails.fullmoviebody.year = Nothing Then workingMovieDetails.fullmoviebody.year = ""
  1517. If workingMovieDetails.fullmoviebody.source = Nothing Then workingMovieDetails.fullmoviebody.source = ""
  1518. titletxt.Items.Clear()
  1519. titletxt.Items.Add(workingMovieDetails.fullmoviebody.title)
  1520. For Each title In workingMovieDetails.alternativetitles
  1521. titletxt.Items.Add(title)
  1522. Next
  1523. titletxt.Text = workingMovieDetails.fullmoviebody.title
  1524. TextBox3.Text = workingMovieDetails.fullmoviebody.title & " (" & workingMovieDetails.fullmoviebody.year & ")"
  1525. tbCurrentMoviePoster.Text = workingMovieDetails.fullmoviebody.title & " (" & workingMovieDetails.fullmoviebody.year & ")"
  1526. Me.ToolTip1.SetToolTip(Me.titletxt, "Original Title: '" & workingMovieDetails.fullmoviebody.originaltitle & "'")
  1527. If workingMovieDetails.fullmoviebody.sortorder = "" Then workingMovieDetails.fullmoviebody.sortorder = workingMovieDetails.fullmoviebody.title
  1528. TextBox34.Text = workingMovieDetails.fullmoviebody.sortorder
  1529. outlinetxt.Text = workingMovieDetails.fullmoviebody.outline
  1530. plottxt.Text = workingMovieDetails.fullmoviebody.plot
  1531. taglinetxt.Text = workingMovieDetails.fullmoviebody.tagline
  1532. txtStars.Text = workingMovieDetails.fullmoviebody.stars
  1533. genretxt.Text = workingMovieDetails.fullmoviebody.genre
  1534. premiertxt.Text = workingMovieDetails.fullmoviebody.premiered
  1535. creditstxt.Text = workingMovieDetails.fullmoviebody.credits
  1536. directortxt.Text = workingMovieDetails.fullmoviebody.director
  1537. studiotxt.Text = workingMovieDetails.fullmoviebody.studio
  1538. countrytxt.Text = workingMovieDetails.fullmoviebody.country
  1539. pathtxt.Text = workingMovie.fullpathandfilename
  1540. ratingtxt.Text = workingMovieDetails.fullmoviebody.rating.FormatRating
  1541. cbUsrRated.Text = If(workingMovieDetails.fullmoviebody.usrrated = "0", "None", workingMovieDetails.fullmoviebody.usrrated)
  1542. SetTagTxtField
  1543. tagtxt.Text = ""
  1544. tb_tagtxt_changed = False
  1545. If workingMovieDetails.fullmoviebody.tag.Count <> 0 Then
  1546. Dim first As Boolean = True
  1547. For Each t In workingMovieDetails.fullmoviebody.tag
  1548. If Not first Then tagtxt.Text &= ", "
  1549. tagtxt.Text &= t
  1550. first = False
  1551. Next
  1552. End If
  1553. 'Catch exception thrown when votes is an empty string
  1554. If workingMovieDetails.fullmoviebody.votes <> "" Then
  1555. Dim votestext As String = workingMovieDetails.fullmoviebody.votes
  1556. votestext = votestext.RemoveWhitespace
  1557. votestxt.Text = Double.Parse(votestext.Replace(".",",")).ToString("N0")
  1558. Else
  1559. votestxt.Text = workingMovieDetails.fullmoviebody.votes
  1560. End If
  1561. certtxt.Text = workingMovieDetails.fullmoviebody.mpaa
  1562. If lbl_movTop250.Text = "Top 250" Then
  1563. top250txt.Text = workingMovieDetails.fullmoviebody.top250
  1564. Else
  1565. top250txt.Text = workingMovieDetails.fullmoviebody.metascore
  1566. End If
  1567. 'top250txt.Text = workingMovieDetails.fullmoviebody.top250
  1568. If Pref.movieRuntimeDisplay = "file" Then
  1569. displayRuntimeScraper = False
  1570. Else
  1571. displayRuntimeScraper = True
  1572. End If
  1573. Call mov_SwitchRuntime()
  1574. workingMovieDetails.fileinfo.fullpathandfilename = workingMovie.fullpathandfilename
  1575. workingMovieDetails.fileinfo.filename = IO.Path.GetFileName(workingMovie.fullpathandfilename)
  1576. workingMovieDetails.fileinfo.path = IO.Path.GetFullPath(workingMovie.fullpathandfilename)
  1577. workingMovieDetails.fileinfo.foldername = workingMovie.foldername
  1578. workingMovieDetails.fileinfo.trailerpath = pref.ActualTrailerPath(workingMovieDetails.fileinfo.path)
  1579. If Yield(yieldIng) Then Return
  1580. HandleTrailerBtn(workingMovieDetails)
  1581. If Yield(yieldIng) Then Return
  1582. If workingMovieDetails.fileinfo.posterpath <> Nothing Then
  1583. If Not File.Exists(workingMovieDetails.fileinfo.posterpath) Then
  1584. If IO.File.Exists(workingMovieDetails.fileinfo.posterpath.Replace(IO.Path.GetFileName(workingMovieDetails.fileinfo.fanartpath), "folder.jpg")) Then
  1585. workingMovieDetails.fileinfo.posterpath = workingMovieDetails.fileinfo.posterpath.Replace(IO.Path.GetFileName(workingMovieDetails.fileinfo.posterpath), "folder.jpg")
  1586. End If
  1587. End If
  1588. End If
  1589. If Yield(yieldIng) Then Return
  1590. If workingMovieDetails.fileinfo.posterpath <> Nothing Then
  1591. Dim workingposter As String = workingMovieDetails.fileinfo.posterpath
  1592. util_ImageLoad(PbMoviePoster, workingposter, Utilities.DefaultPosterPath)
  1593. If Yield(yieldIng) Then Return
  1594. util_ImageLoad(PictureBoxAssignedMoviePoster, workingposter, Utilities.DefaultPosterPath)
  1595. If Yield(yieldIng) Then Return
  1596. lblCurrentLoadedPoster.Text = "Width: " & PictureBoxAssignedMoviePoster.Image.Width.ToString & " Height: " & PictureBoxAssignedMoviePoster.Image.Height.ToString
  1597. lblMovPosterPages.Visible = False
  1598. End If
  1599. If workingMovieDetails.fileinfo.fanartpath <> Nothing Then
  1600. Dim workingfanart As String = workingMovieDetails.fileinfo.fanartpath
  1601. util_ImageLoad(PbMovieFanArt, workingfanart, Utilities.DefaultFanartPath)
  1602. End If
  1603. If Yield(yieldIng) Then Return
  1604. If Convert.ToInt32(workingMovieDetails.fullmoviebody.playcount) > 0 Then
  1605. btnMovWatched.Text = "&Watched"
  1606. btnMovWatched.BackColor = Color.LawnGreen
  1607. btnMovWatched.Refresh()
  1608. Else
  1609. btnMovWatched.Text = "Un&watched"
  1610. btnMovWatched.BackColor = Color.Red
  1611. btnMovWatched.Refresh()
  1612. End If
  1613. cbMovieDisplay_Actor.Items.Clear()
  1614. For Each actor In workingMovieDetails.listactors
  1615. If actor.actorname <> Nothing Then cbMovieDisplay_Actor.Items.Add(actor.actorname)
  1616. Next
  1617. If cbMovieDisplay_Actor.Items.Count > 0 Then
  1618. cbMovieDisplay_Actor.SelectedIndex = 0
  1619. Else
  1620. util_ImageLoad(PictureBoxActor, Utilities.DefaultActorPath, Utilities.DefaultActorPath)
  1621. End If
  1622. Dim fi As New FilteredItems(cbFilterActor)
  1623. fi.SelectFirstMatch(cbMovieDisplay_Actor)
  1624. If Yield(yieldIng) Then Return
  1625. If workingMovieDetails.fullmoviebody.MovieSet.MovieSetName <> "-None-" And workingMovieDetails.fullmoviebody.MovieSet.MovieSetName <> "" Then
  1626. Dim add As Boolean = True
  1627. For Each item In Pref.moviesets
  1628. If item = workingMovieDetails.fullmoviebody.MovieSet.MovieSetName Then
  1629. add = False
  1630. Exit For
  1631. End If
  1632. Next
  1633. If add Then
  1634. Pref.moviesets.Add(workingMovieDetails.fullmoviebody.MovieSet.MovieSetName)
  1635. End If
  1636. End If
  1637. cbMovieDisplay_MovieSet.SelectedItem=Nothing
  1638. pop_cbMovieDisplay_MovieSet
  1639. For f = 0 To cbMovieDisplay_Source.Items.Count - 1
  1640. If cbMovieDisplay_Source.Items(f) = workingMovieDetails.fullmoviebody.source Then
  1641. cbMovieDisplay_Source.SelectedIndex = f
  1642. Exit For
  1643. End If
  1644. Next
  1645. btnPlayMovie.Enabled = True
  1646. mov_SplitContainerAutoPosition
  1647. Dim video_flags = VidMediaFlags(workingMovieDetails.filedetails, workingMovieDetails.fullmoviebody.title.ToLower.Contains("3d"))
  1648. movieGraphicInfo.OverlayInfo(PbMovieFanArt, ratingtxt.Text, video_flags,workingMovie.DisplayFolderSize)
  1649. MovPanel6Update()
  1650. End If
  1651. Else
  1652. cbMovieDisplay_Actor.Items.Clear()
  1653. PictureBoxActor.CancelAsync()
  1654. PictureBoxActor.Image = Nothing
  1655. PictureBoxActor.Refresh()
  1656. btnMoviePosterSaveCroppedImage.Enabled = False
  1657. btnMoviePosterResetImage.Enabled = False
  1658. thumbedItsMade = False
  1659. cbMoviePosterSaveLoRes.Enabled = False
  1660. btnPosterTabs_SaveImage.Enabled = False
  1661. btnMovPosterNext.Visible = False
  1662. btnMovPosterPrev.Visible = False
  1663. lblMovPosterPages.Visible = False
  1664. titletxt.Text = ""
  1665. TextBox3.Text = ""
  1666. outlinetxt.Text = ""
  1667. plottxt.Text = ""
  1668. taglinetxt.Text = ""
  1669. txtStars.Text = ""
  1670. genretxt.Text = ""
  1671. premiertxt.Text = ""
  1672. creditstxt.Text = ""
  1673. directortxt.Text = ""
  1674. studiotxt.Text = ""
  1675. countrytxt.Text = ""
  1676. pathtxt.Text = ""
  1677. cbUsrRated.SelectedIndex = -1
  1678. ratingtxt.Text = ""
  1679. runtimetxt.Text = ""
  1680. votestxt.Text = ""
  1681. top250txt.Text = ""
  1682. certtxt.Text = ""
  1683. PbMovieFanArt.Image = Nothing
  1684. PictureBox2.Image = Nothing
  1685. PbMoviePoster.Image = Nothing
  1686. lblMovFanartWidth.Text = ""
  1687. lblMovFanartHeight.Text = ""
  1688. PictureBoxAssignedMoviePoster.Image = Nothing
  1689. lblCurrentLoadedPoster.Text = ""
  1690. TextBox34.Text = ""
  1691. titletxt.Text = ""
  1692. tagtxt.Text = "" : tb_tagtxt_changed = False
  1693. roletxt.Text = ""
  1694. PictureBoxActor.Image = Nothing
  1695. Panel6.Visible = False
  1696. FanTvArtList.Items.Clear()
  1697. btnPlayMovie.Enabled = False
  1698. Me.Refresh()
  1699. Application.DoEvents()
  1700. End If
  1701. If ratingtxt.Text.IndexOf("/10") <> -1 Then
  1702. ratingtxt.Text = ratingtxt.Text.Replace("/10", "")
  1703. workingMovieDetails.fullmoviebody.rating = ratingtxt.Text
  1704. End If
  1705. If ratingtxt.Text.Length > 3 Then
  1706. ratingtxt.Text = ratingtxt.Text.Substring(0, 3).Trim
  1707. End If
  1708. If Yield(yieldIng) Then Return
  1709. GC.Collect()
  1710. End Sub
  1711. Private Sub Mov_PictureboxLoad()
  1712. util_ImageLoad(PbMoviePoster, workingMovieDetails.fileinfo.posterpath, Utilities.DefaultPosterPath)
  1713. util_ImageLoad(PbMovieFanArt, workingMovieDetails.fileinfo.fanartpath, Utilities.DefaultPosterPath)
  1714. End Sub
  1715. Public Function CheckforExtraArt() As Boolean
  1716. Dim confirmedpresent As Boolean = False
  1717. If File.Exists(workingMovieDetails.fileinfo.movsetposterpath) Then FanTvArtList.Items.Add("Set Poster") : confirmedpresent = True
  1718. If File.Exists(workingMovieDetails.fileinfo.movsetfanartpath) Then FanTvArtList.Items.Add("Set Fanart") : confirmedpresent = True
  1719. If Not Pref.GetRootFolderCheck(workingMovieDetails.fileinfo.fullpathandfilename) Then
  1720. Dim MovPath As String = IO.Path.GetDirectoryName(workingMovieDetails.fileinfo.fullpathandfilename) & "\"
  1721. If Pref.MovFanartNaming Then MovPath = workingMovieDetails.fileinfo.fullpathandfilename.Replace(".nfo", "-")
  1722. If File.Exists(MovPath & "clearart.png") Then FanTvArtList.Items.Add("ClearArt") : confirmedpresent = True
  1723. If File.Exists(MovPath & "logo.png") Then FanTvArtList.Items.Add("Logo") : confirmedpresent = True
  1724. If File.Exists(MovPath & "banner.jpg") Then FanTvArtList.Items.Add("Banner") : confirmedpresent = True
  1725. If File.Exists(MovPath & "landscape.jpg") Then FanTvArtList.Items.Add("Landscape") : confirmedpresent = True
  1726. If File.Exists(MovPath & "disc.png") Then FanTvArtList.Items.Add("Disc") : confirmedpresent = True
  1727. If File.Exists(MovPath & "poster.jpg") AndAlso Not Pref.posterjpg AndAlso Not Pref.MovFanartNaming Then FanTvArtList.Items.Add("Poster") : confirmedpresent = True
  1728. If File.Exists(MovPath & "fanart.jpg") AndAlso Not Pref.fanartjpg AndAlso Not Pref.MovFanartNaming Then FanTvArtList.Items.Add("Fanart") : confirmedpresent = True
  1729. If File.Exists(MovPath & "folder.jpg") Then FanTvArtList.Items.Add("Folder") : confirmedpresent = True
  1730. End If
  1731. Return confirmedpresent
  1732. End Function
  1733. Public Sub MovPanel6Update()
  1734. FanTvArtList.Items.Clear()
  1735. Panel6.Visible = CheckforExtraArt()
  1736. End Sub
  1737. Private Sub FanTvArtList_Mouse(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles FanTvArtList.MouseDown
  1738. Dim imagepath As String = Nothing
  1739. Dim item As String = Nothing
  1740. Dim pbheight As Integer = 112
  1741. If e.button = Windows.Forms.MouseButtons.Right Then
  1742. Dim index As Integer = FanTvArtList.IndexFromPoint(New Point(e.X, e.Y))
  1743. If index >= 0 Then FanTvArtList.SelectedItem = FanTvArtList.Items(index)
  1744. End If
  1745. If IsNothing(FanTvArtList.SelectedItem) Then Exit Sub
  1746. item = FanTvArtList.SelectedItem.ToString.ToLower
  1747. If Not String.IsNullOrEmpty(item) Then
  1748. If item.ToLower = "set poster" Or item.ToLower = "set fanart" Then
  1749. If item.ToLower = "set poster" Then
  1750. imagepath = workingMovieDetails.fileinfo.movsetposterpath
  1751. Else
  1752. imagepath = workingMovieDetails.fileinfo.movsetfanartpath
  1753. End If
  1754. Else
  1755. If Pref.MovFanartNaming Then
  1756. imagepath = workingMovieDetails.fileinfo.fullpathandfilename.Replace(".nfo", "-")
  1757. Else
  1758. imagepath = IO.Path.GetDirectoryName(workingMovieDetails.fileinfo.fullpathandfilename) & "\"
  1759. End If
  1760. Dim suffix As String = If((item = "clearart" or item = "logo" or item = "disc"),".png", ".jpg")
  1761. imagepath &= item & suffix
  1762. End If
  1763. End If
  1764. If e.Button = Windows.Forms.MouseButtons.Left Then
  1765. ftvArtPicBox.Visible = True
  1766. If IsNothing(imagepath) Then Exit Sub
  1767. util_ImageLoad(ftvArtPicBox, imagepath, "")
  1768. Try
  1769. Dim panelwidth As Integer = SplitContainer1.Panel2.Width
  1770. Dim panelheight As Integer = SplitContainer1.Panel2.Height
  1771. Dim pbw As Integer = Math.Ceiling(panelwidth*.413)
  1772. Dim pbh As Integer = Math.Ceiling(PbMovieFanArt.Height*.90)
  1773. Dim imgw As Integer = ftvArtPicBox.Image.Width
  1774. Dim imgh As Integer = ftvArtPicBox.Image.Height
  1775. If item.ToLower.Contains("poster") Or item.ToLower.Contains("disc") Then
  1776. ftvArtPicBox.Height = pbh
  1777. ftvArtPicBox.Width = Math.Ceiling(pbh/(imgh/imgw))
  1778. ftvArtPicBox.Location = New System.Drawing.Point(Math.Ceiling((panelwidth*.4)-(ftvArtPicBox.Width/2)), 45)
  1779. Else
  1780. ftvArtPicBox.Height = Math.Ceiling(pbw*(imgh/imgw))
  1781. ftvArtPicBox.Width = pbw
  1782. ftvArtPicBox.Location = New System.Drawing.Point(140, Math.Ceiling((panelheight*.3)-(ftvArtPicBox.Height/2)))
  1783. End If
  1784. Catch
  1785. End Try
  1786. ElseIf e.button = Windows.Forms.MouseButtons.Right Then
  1787. Dim tempint = MessageBox.show("Do you wish to delete this image from" & vbCrLf & "this Movie?", "Fanart.Tv Artwork Delete", MessageBoxButtons.YesNoCancel)
  1788. If tempint = Windows.Forms.DialogResult.No or tempint = DialogResult.Cancel Then Exit Sub
  1789. If tempint = Windows.Forms.DialogResult.Yes Then
  1790. Utilities.SafeDeleteFile(imagepath)
  1791. MovPanel6Update()
  1792. End If
  1793. End If
  1794. End Sub
  1795. Private Sub FanTvArtList_MouseLeave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FanTvArtList.MouseLeave
  1796. FanTvArtList.ClearSelected()
  1797. ftvArtPicBox.Image = Nothing
  1798. ftvArtPicBox.Visible = False
  1799. End Sub
  1800. Private Sub HandleTrailerBtn(ByVal fmd As FullMovieDetails)
  1801. If IsNothing(fmd) Then
  1802. Return
  1803. End If
  1804. DeleteZeroLengthFile(fmd.fileinfo.trailerpath)
  1805. ButtonTrailer.Enabled = False
  1806. If IO.File.Exists(fmd.fileinfo.trailerpath) Then
  1807. ButtonTrailer.Text = "Play Trailer"
  1808. ButtonTrailer.Enabled = True
  1809. Else
  1810. If fmd.fullmoviebody.trailer = ""
  1811. ButtonTrailer.Text = "No trailer found"
  1812. Else
  1813. ButtonTrailer.Text = "Download Trailer"
  1814. ButtonTrailer.Enabled = True
  1815. End If
  1816. End If
  1817. End Sub
  1818. Private Function mov_FileCheckValid(ByVal fullpathandfilename As String) As Boolean
  1819. Dim validfile As Boolean = True
  1820. Dim tempint2 As Integer = 0
  1821. Dim tempstring As String
  1822. Dim extension As String
  1823. Dim tempname As String
  1824. 'First check, is it a video file!
  1825. extension = System.IO.Path.GetExtension(fullpathandfilename)
  1826. Dim isvideofile As Boolean = False
  1827. For Each extn In Utilities.VideoExtensions
  1828. If extn = extension Then isvideofile = True
  1829. Next
  1830. If Not isvideofile Then Return False
  1831. 'if the file is a .vob then check it is not part of a dvd folder (Stop dvdfolders vobs getting seperate nfos)
  1832. If IO.Path.GetExtension(fullpathandfilename) = ".vob" Then
  1833. If IO.File.Exists(fullpathandfilename.Replace(System.IO.Path.GetFileName(fullpathandfilename), "VIDEO_TS.IFO")) Then
  1834. validfile = False
  1835. End If
  1836. End If
  1837. Dim filename2 As String = System.IO.Path.GetFileName(fullpathandfilename).ToLower
  1838. For each cleanmultipart In Utilities.cleanMultipart
  1839. For Each separator In Utilities.separators
  1840. For I = 2 To 5
  1841. Dim lookfor As String = cleanmultipart & separator & I.ToString
  1842. If filename2.IndexOf(cleanmultipart & separator & I.ToString) <> -1 Then validfile = False
  1843. Next
  1844. Next
  1845. Next
  1846. If filename2.IndexOf("-trailer") <> -1 Then validfile = False
  1847. If filename2.IndexOf(".trailer") <> -1 Then validfile = False
  1848. If filename2.IndexOf("_trailer") <> -1 Then validfile = False
  1849. If filename2.IndexOf("-theme") <> -1 Then validfile = False
  1850. If filename2.IndexOf(".theme") <> -1 Then validfile = False
  1851. If filename2.IndexOf("_theme") <> -1 Then validfile = False
  1852. If filename2.IndexOf("sample") <> -1 And filename2.IndexOf("people") = -1 Then validfile = False
  1853. 'check for movies ending a,b,c, etc (moviea, movieb) for multipart. movieb is multipart if moviea exists
  1854. 'extension = System.IO.Path.GetExtension(fullpathandfilename)
  1855. tempname = fullpathandfilename.Replace(extension, "")
  1856. If tempname.Substring(tempname.Length - 1) = "b" Or tempname.Substring(tempname.Length - 1) = "c" Or tempname.Substring(tempname.Length - 1) = "d" Or tempname.Substring(tempname.Length - 1) = "e" Or tempname.Substring(tempname.Length - 1) = "B" Or tempname.Substring(tempname.Length - 1) = "C" Or tempname.Substring(tempname.Length - 1) = "D" Or tempname.Substring(tempname.Length - 1) = "E" Then
  1857. tempname = fullpathandfilename.Substring(0, fullpathandfilename.Length - (1 + extension.Length)) & "a" & extension
  1858. If System.IO.File.Exists(tempname) Then validfile = False
  1859. End If
  1860. 'now need to deal with multipart rar files
  1861. Dim tempmovie2 As String = fullpathandfilename.Replace(".nfo", ".rar")
  1862. Dim tempmovie As String = String.Empty
  1863. If IO.File.Exists(tempmovie2) = True Then
  1864. If IO.File.Exists(fullpathandfilename) = False Then
  1865. Dim rarname As String = tempmovie2
  1866. Dim SizeOfFile As Integer = FileLen(rarname)
  1867. tempint2 = Convert.ToInt32(Pref.rarsize) * 1048576
  1868. If SizeOfFile > tempint2 Then
  1869. Dim mat As Match
  1870. mat = Regex.Match(rarname, "\.part[0-9][0-9]?[0-9]?[0-9]?.rar")
  1871. If mat.Success = True Then
  1872. rarname = mat.Value
  1873. If rarname.ToLower.IndexOf(".part1.rar") <> -1 Or rarname.ToLower.IndexOf(".part01.rar") <> -1 Or rarname.ToLower.IndexOf(".part001.rar") <> -1 Or rarname.ToLower.IndexOf(".part0001.rar") <> -1 Then
  1874. Dim stackrarexists As Boolean = False
  1875. rarname = fullpathandfilename.Replace(".nfo", ".rar")
  1876. If rarname.ToLower.IndexOf(".part1.rar") <> -1 Then
  1877. rarname = rarname.Replace(".part1.rar", ".nfo")
  1878. If IO.File.Exists(rarname) Then
  1879. stackrarexists = True
  1880. tempmovie = rarname
  1881. Else
  1882. stackrarexists = False
  1883. tempmovie = rarname
  1884. End If
  1885. End If
  1886. If rarname.ToLower.IndexOf(".part01.rar") <> -1 Then
  1887. rarname = rarname.Replace(".part01.rar", ".nfo")
  1888. If IO.File.Exists(rarname) Then
  1889. stackrarexists = True
  1890. tempmovie = rarname
  1891. Else
  1892. stackrarexists = False
  1893. tempmovie = rarname
  1894. End If
  1895. End If
  1896. If rarname.ToLower.IndexOf(".part001.rar") <> -1 Then
  1897. rarname = rarname.Replace(".part001.rar", ".nfo")
  1898. If IO.File.Exists(rarname) Then
  1899. tempmovie = rarname
  1900. stackrarexists = True
  1901. Else
  1902. stackrarexists = False
  1903. tempmovie = rarname
  1904. End If
  1905. End If
  1906. If rarname.ToLower.IndexOf(".part0001.rar") <> -1 Then
  1907. rarname = rarname.Replace(".part0001.rar", ".nfo")
  1908. If IO.File.Exists(rarname) Then
  1909. tempmovie = rarname
  1910. stackrarexists = True
  1911. Else
  1912. stackrarexists = False
  1913. tempmovie = rarname
  1914. End If
  1915. End If
  1916. If stackrarexists = True Then
  1917. Dim allok As Boolean = False
  1918. Try
  1919. Dim filechck As IO.StreamReader = IO.File.OpenText(tempmovie)
  1920. Do
  1921. tempstring = filechck.ReadLine
  1922. If tempstring = Nothing Then Exit Do
  1923. If tempstring.IndexOf("<movie") <> -1 Then
  1924. allok = True
  1925. Exit Do
  1926. End If
  1927. Loop Until tempstring.IndexOf("</movie>") <> -1
  1928. filechck.Close()
  1929. filechck = Nothing
  1930. Catch ex As Exception
  1931. #If SilentErrorScream Then
  1932. Throw ex
  1933. #End If
  1934. Finally
  1935. End Try
  1936. If allok = True Then
  1937. validfile = False
  1938. End If
  1939. End If
  1940. Else
  1941. validfile = False
  1942. End If
  1943. End If
  1944. Else
  1945. validfile = False
  1946. End If
  1947. End If
  1948. End If
  1949. 'rename fullpathandfilename to that of the nfo file
  1950. fullpathandfilename = fullpathandfilename.Replace(fullpathandfilename.Substring(fullpathandfilename.LastIndexOf("."), fullpathandfilename.Length - fullpathandfilename.LastIndexOf(".")), ".nfo")
  1951. 'check for both variations of the filename
  1952. Dim nfopaths(1) As String
  1953. nfopaths(0) = fullpathandfilename
  1954. nfopaths(1) = fullpathandfilename.Replace(IO.Path.GetFileName(fullpathandfilename), "movie.nfo")
  1955. 'check if the file exists
  1956. For f = 0 To 1
  1957. If IO.File.Exists(nfopaths(f)) Then
  1958. 'if it does check if it is a valid xbmc nfo, if it is not then move it or delete it according to prefs
  1959. Try
  1960. Dim filechck As IO.StreamReader = IO.File.OpenText(nfopaths(f))
  1961. tempstring = filechck.ReadToEnd
  1962. filechck.Close()
  1963. If tempstring.IndexOf("<movie") = -1 And tempstring.IndexOf("</movie>") = -1 Then
  1964. If Pref.renamenfofiles = True Then
  1965. Dim fi As New IO.FileInfo(nfopaths(f))
  1966. Dim newpath As String = nfopaths(f).Replace(nfopaths(f).Substring(nfopaths(f).LastIndexOf("."), nfopaths(f).Length - nfopaths(f).LastIndexOf(".")), ".info")
  1967. fi.MoveTo(newpath)
  1968. End If
  1969. Else
  1970. validfile = False
  1971. End If
  1972. filechck.Close()
  1973. filechck = Nothing
  1974. Catch ex As Exception
  1975. #If SilentErrorScream Then
  1976. Throw ex
  1977. #End If
  1978. Finally
  1979. End Try
  1980. End If
  1981. Next
  1982. Return validfile
  1983. End Function
  1984. Private Sub DeleteZeroLengthFile(ByVal fileName)
  1985. If IO.File.Exists(fileName) Then
  1986. If (New IO.FileInfo(fileName)).Length = 0 Then
  1987. Utilities.SafeDeleteFile(fileName)
  1988. End If
  1989. End If
  1990. End Sub
  1991. Private Sub ReloadMovieCacheToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ReloadMovieCacheToolStripMenuItem.Click
  1992. mov_CacheLoad()
  1993. End Sub
  1994. Private Sub StartVideo(ByVal tempstring As String)
  1995. If Pref.videomode = 1 Then
  1996. Call util_VideoMode(1, tempstring)
  1997. Exit Sub
  1998. End If
  1999. If Pref.videomode = 2 OrElse Pref.videomode = 3 Then
  2000. Call util_VideoMode(2, tempstring)
  2001. Exit Sub
  2002. End If
  2003. If Pref.videomode >= 4 Then
  2004. If Pref.selectedvideoplayer <> Nothing Then
  2005. Call util_VideoMode(4, tempstring)
  2006. Else
  2007. Call util_VideoMode(1, tempstring)
  2008. End If
  2009. End If
  2010. End Sub
  2011. Private Sub util_VideoMode(ByVal mode As Integer, ByVal tempstring As String)
  2012. Dim action As String = ""
  2013. Dim errors As String = ""
  2014. If mode = 1 Then
  2015. Try
  2016. Dim myProc As Process = Process.Start(tempstring)
  2017. Catch ex As Exception
  2018. errors = ex.ToString
  2019. action = "Dim myProc As Process = Process.Start(" & tempstring & ")"
  2020. Call util_ErrorLog(action, errors)
  2021. End Try
  2022. ElseIf mode = 2 Then
  2023. Try
  2024. Dim thePSI As New System.Diagnostics.ProcessStartInfo("wmplayer")
  2025. thePSI.Arguments = """" & tempstring & """"
  2026. System.Diagnostics.Process.Start(thePSI)
  2027. Catch ex As Exception
  2028. errors = ex.ToString
  2029. action = "Dim thePSI As New System.Diagnostics.ProcessStartInfo(""wmplayer"")" & vbCrLf & "thePSI.Arguments = "" & tempstring & """ & vbCrLf & "System.Diagnostics.Process.Start(thePSI)"
  2030. Call util_ErrorLog(action, errors)
  2031. End Try
  2032. ElseIf mode = 4 Then
  2033. Try
  2034. Dim myProc As Process = Process.Start("""" & Pref.selectedvideoplayer & """", """" & tempstring & """")
  2035. Catch ex As Exception
  2036. errors = ex.ToString
  2037. action = "Dim myProc As Process = Process.Start(""" & Pref.selectedvideoplayer & """," & """" & tempstring & """)"
  2038. Call util_ErrorLog(action, errors)
  2039. End Try
  2040. End If
  2041. End Sub
  2042. 'Private Sub util_VideoMode1(ByVal tempstring As String)
  2043. ' Dim action As String
  2044. ' Dim errors As String
  2045. ' Try
  2046. ' Dim myProc As Process = Process.Start(tempstring)
  2047. ' Catch ex As Exception
  2048. ' errors = ex.ToString
  2049. ' action = "Dim myProc As Process = Process.Start(" & tempstring & ")"
  2050. ' Call util_ErrorLog(action, errors)
  2051. ' End Try
  2052. 'End Sub
  2053. 'Private Sub util_VideoMode2(ByVal tempstring As String)
  2054. ' Dim action As String
  2055. ' Dim errors As String
  2056. ' Try
  2057. ' Dim thePSI As New System.Diagnostics.ProcessStartInfo("wmplayer")
  2058. ' thePSI.Arguments = """" & tempstring & """"
  2059. ' System.Diagnostics.Process.Start(thePSI)
  2060. ' Catch ex As Exception
  2061. ' errors = ex.ToString
  2062. ' action = "Dim thePSI As New System.Diagnostics.ProcessStartInfo(""wmplayer"")" & vbCrLf & "thePSI.Arguments = "" & tempstring & """ & vbCrLf & "System.Diagnostics.Process.Start(thePSI)"
  2063. ' Call util_ErrorLog(action, errors)
  2064. ' End Try
  2065. 'End Sub
  2066. 'Private Sub util_VideoMode4(ByVal tempstring As String)
  2067. ' Dim action As String
  2068. ' Dim errors As String
  2069. ' Try
  2070. ' Dim myProc As Process = Process.Start("""" & Pref.selectedvideoplayer & """", """" & tempstring & """")
  2071. ' Catch ex As Exception
  2072. ' errors = ex.ToString
  2073. ' action = "Dim myProc As Process = Process.Start(""" & Pref.selectedvideoplayer & """," & """" & tempstring & """)"
  2074. ' Call util_ErrorLog(action, errors)
  2075. ' End Try
  2076. 'End Sub
  2077. Private Sub util_ErrorLog(ByVal action As String, Optional ByVal errors As String = "")
  2078. Dim errpath As String = applicationPath & "\error.log"
  2079. Try
  2080. Dim objWriter As New System.IO.StreamWriter(errpath, True)
  2081. objWriter.WriteLine(errors)
  2082. objWriter.WriteLine(action)
  2083. objWriter.WriteLine() '(Chr(13))
  2084. objWriter.Close()
  2085. Catch ex As Exception
  2086. MsgBox("Error, cant write to " & errpath & vbCrLf & vbCrLf & ex.ToString)
  2087. End Try
  2088. End Sub
  2089. Public Sub tv_RefreshLog(ByVal action As String, Optional ByVal errors As String = "", Optional ByVal clear As Boolean = False)
  2090. If Pref.tvshowrefreshlog = False Then
  2091. Exit Sub
  2092. End If
  2093. Dim errpath As String = IO.Path.Combine(applicationPath, "tvrefresh.log")
  2094. If clear = True Then
  2095. If IO.File.Exists(errpath) Then
  2096. Try
  2097. IO.File.Delete(errpath)
  2098. Catch ex As Exception
  2099. MsgBox("Error deleting: " & errpath & vbCrLf & vbCrLf & ex.ToString)
  2100. End Try
  2101. End If
  2102. End If
  2103. Try
  2104. Dim objWriter As New System.IO.StreamWriter(errpath, True)
  2105. objWriter.WriteLine(action)
  2106. If errors <> "" Then
  2107. objWriter.WriteLine(errors)
  2108. End If
  2109. objWriter.Close()
  2110. Catch ex As Exception
  2111. MsgBox("Error, cant write to " & errpath & vbCrLf & vbCrLf & ex.ToString)
  2112. End Try
  2113. End Sub
  2114. Private Sub util_ThreadsRunningCheck()
  2115. 'If globalthreadcounter = 0 Then
  2116. ' ToolStripButton10.Visible = False
  2117. 'Else
  2118. ' ToolStripButton10.Visible = True
  2119. 'End If
  2120. End Sub
  2121. Private Sub util_ThreadsAllExit()
  2122. Dim busy As Boolean = False
  2123. Try
  2124. If bckgroundscanepisodes.IsBusy Then
  2125. busy = True
  2126. bckgroundscanepisodes.CancelAsync()
  2127. End If
  2128. If BckWrkScnMovies.IsBusy Then
  2129. busy = True
  2130. BckWrkScnMovies.CancelAsync()
  2131. End If
  2132. If bckepisodethumb.IsBusy Then
  2133. busy = True
  2134. bckepisodethumb.CancelAsync()
  2135. End If
  2136. If BWs.Count > 0 Then
  2137. busy = True
  2138. Bw.CancelAsync()
  2139. End If
  2140. If ImgBw.IsBusy Then
  2141. busy = True
  2142. ImgBw.CancelAsync()
  2143. End If
  2144. Dim exitnowok As Boolean = False
  2145. If busy = True Then
  2146. messbox.TextBox1.Text = "Please Wait"
  2147. messbox.TextBox2.Text = ""
  2148. messbox.TextBox3.Text = "Stopping threads when it is Safe to do so"
  2149. messbox.Refresh()
  2150. messbox.Visible = True
  2151. End If
  2152. Do Until busy = False
  2153. If Not bckepisodethumb.IsBusy And Not bckgroundscanepisodes.IsBusy And Not BckWrkScnMovies.IsBusy And Not BWs.Count > 0 And Not ImgBw.IsBusy Then
  2154. busy = False
  2155. Exit Do
  2156. End If
  2157. Threading.Thread.Sleep(100)
  2158. Application.DoEvents()
  2159. Loop
  2160. messbox.Visible = False
  2161. Catch ex As Exception
  2162. #If SilentErrorScream Then
  2163. Throw ex
  2164. #End If
  2165. Finally
  2166. End Try
  2167. End Sub
  2168. Public Sub util_ZoomImage(ByVal file As String)
  2169. bigPanel = New Panel
  2170. With bigPanel
  2171. .Width = Me.Width
  2172. .Height = Me.Height
  2173. .BringToFront()
  2174. .Dock = DockStyle.Fill
  2175. End With
  2176. bigPictureBox = New PictureBox()
  2177. With bigPictureBox
  2178. .Location = New Point(0, 0)
  2179. .Width = bigPanel.Width
  2180. .Height = bigPanel.Height
  2181. .SizeMode = PictureBoxSizeMode.Zoom
  2182. .Visible = True
  2183. .BorderStyle = BorderStyle.Fixed3D
  2184. AddHandler bigPictureBox.DoubleClick, AddressOf util_PicBoxClose
  2185. .Dock = DockStyle.Fill
  2186. End With
  2187. util_ImageLoad(bigPictureBox, file, Utilities.DefaultPosterPath)
  2188. 'Dim sizex As Integer = bigpicbox.Width
  2189. 'Dim sizey As Integer = bigpicbox.Height
  2190. Dim bigpanellabel As Label
  2191. bigpanellabel = New Label
  2192. With bigpanellabel
  2193. .Location = New Point(20, 200)
  2194. .Width = 170
  2195. .Height = 75
  2196. .Visible = True
  2197. .Text = "Double Click Image To Return To Browser"
  2198. .Font = New System.Drawing.Font("Microsoft Sans Serif", 12!, System.Drawing.FontStyle.Bold)
  2199. End With
  2200. Me.bigPanel.Controls.Add(bigpanellabel)
  2201. bigpanellabel.BringToFront()
  2202. Application.DoEvents()
  2203. If Not bigPictureBox.Image Is Nothing And bigPictureBox.Image.Width > 20 Then
  2204. Dim sizey As Integer = bigPictureBox.Image.Height
  2205. Dim sizex As Integer = bigPictureBox.Image.Width
  2206. Dim tempstring As String
  2207. tempstring = "Full Image Resolution :- " & sizex.ToString & " x " & sizey.ToString
  2208. Dim resolutionlbl As New Label
  2209. With resolutionlbl
  2210. .Location = New Point(20, 450)
  2211. .Width = 200
  2212. .Text = tempstring
  2213. .BackColor = Color.Transparent
  2214. End With
  2215. Me.bigPanel.Controls.Add(resolutionlbl)
  2216. resolutionlbl.BringToFront()
  2217. Me.Refresh()
  2218. Application.DoEvents()
  2219. Dim tempstring2 As String = resolutionlbl.Text
  2220. End If
  2221. Me.Controls.Add(bigPanel)
  2222. bigPanel.BringToFront()
  2223. Me.bigPanel.Controls.Add(bigPictureBox)
  2224. Me.Refresh()
  2225. End Sub
  2226. Private Sub util_PicBoxClose()
  2227. Me.Controls.Remove(bigPanel)
  2228. bigPanel = Nothing
  2229. Me.Controls.Remove(bigPictureBox)
  2230. bigPictureBox.Image = Nothing
  2231. bigPictureBox = Nothing
  2232. Me.ControlBox = True
  2233. MenuStrip1.Enabled = True
  2234. End Sub
  2235. Public Sub resetallfilters()
  2236. Try
  2237. ResetFilters()
  2238. Mc.clsGridViewMovie.mov_FiltersAndSortApply(Me)
  2239. Try
  2240. If DataGridViewMovies.SelectedRows.Count = 1 Then
  2241. If workingMovieDetails.fileinfo.fullpathandfilename = DataGridViewMovies.SelectedCells(NFO_INDEX).Value.ToString Then Return
  2242. End If
  2243. Catch
  2244. End Try
  2245. DisplayMovie()
  2246. Catch ex As Exception
  2247. ExceptionHandler.LogError(ex)
  2248. End Try
  2249. End Sub
  2250. Sub ResetFilters()
  2251. ProgState = ProgramState.ResettingFilters
  2252. filterOverride = False
  2253. TextBox1.Text = ""
  2254. txt_titlesearch.Text = ""
  2255. txt_titlesearch.BackColor = Color.White
  2256. TextBox1.BackColor = Color.White
  2257. rbTitleAndYear.Checked = True
  2258. cbFilterGeneral.SelectedIndex = 0
  2259. UpdateMinMaxMovieFilters()
  2260. oMovies.ActorsFilter_AlsoInclude.Clear()
  2261. oMovies.SetsFilter_AlsoInclude.Clear()
  2262. cbFilterActor .UpdateItems(oMovies.ActorsFilter )
  2263. cbFilterDirector.UpdateItems(oMovies.DirectorsFilter)
  2264. cbFilterSet .UpdateItems(oMovies.SetsFilter )
  2265. cbFilterTag .UpdateItems(oMovies.TagsFilter )
  2266. Dim query = From c As Control In SplitContainer5.Panel2.Controls Where c.Name.IndexOf("cbFilter") = 0 And c.GetType().Namespace = "MC_UserControls"
  2267. For Each c As Object In query
  2268. c.Reset()
  2269. Next
  2270. ProgState = ProgramState.Other
  2271. End Sub
  2272. Public Sub UpdateMovieSetDisplayNames
  2273. oMovies.UpdateMovieSetDisplayNames
  2274. pop_cbMovieDisplay_MovieSet
  2275. cbFilterSet.UpdateItems(oMovies.SetsFilter)
  2276. End Sub
  2277. Sub UpdateMinMaxMovieFilters()
  2278. If cbFilterVotes .Visible Then cbFilterVotes .Values = oMovies.ListVotes
  2279. If cbFilterRuntime .Visible Then cbFilterRuntime .Values = oMovies.ListRuntimes
  2280. If cbFilterFolderSizes.Visible Then
  2281. cbFilterFolderSizes.Min = oMovies.MinFolderSize
  2282. cbFilterFolderSizes.Max = oMovies.MaxFolderSize
  2283. End If
  2284. If cbFilterYear.Visible Then
  2285. cbFilterYear.Min = If(oMovies.MinYear < 1850, 1850, oMovies.MinYear)
  2286. cbFilterYear.Max = oMovies.MaxYear
  2287. End If
  2288. End Sub
  2289. 'Medianfo.dll to outputlog
  2290. Private Sub util_FileDetailsGet()
  2291. Try
  2292. Dim tempstring As String = String.Empty
  2293. Dim appPath As String = ""
  2294. Dim exists As Boolean
  2295. Dim movieinfo As String = String.Empty
  2296. Dim medianfoexists As Boolean = False
  2297. tempstring = Utilities.GetFileName(pathtxt.Text)
  2298. If IO.Path.GetFileName(tempstring).ToLower = "video_ts.ifo" Then
  2299. Dim temppath As String = tempstring.Replace(IO.Path.GetFileName(tempstring), "VTS_01_0.IFO")
  2300. If IO.File.Exists(temppath) Then
  2301. tempstring = temppath
  2302. End If
  2303. End If
  2304. Dim fileisiso As Boolean = (IO.Path.GetExtension(tempstring).ToLower = ".iso")
  2305. If fileisiso Then
  2306. If applicationPath.IndexOf("/") <> -1 Then appPath = applicationPath & "/" & "mediainfo-rar.exe"
  2307. If applicationPath.IndexOf("\") <> -1 Then appPath = applicationPath & "\" & "mediainfo-rar.exe"
  2308. If Not IO.File.Exists(appPath) Then
  2309. MsgBox("Unable to find th file ""mediainfo-rar.exe""" & vbCrLf & vbCrLf & "Please make sure this file is available in the programs root directory")
  2310. Exit Sub
  2311. End If
  2312. Try
  2313. Dim NewProcess As New System.Diagnostics.Process()
  2314. With NewProcess.StartInfo
  2315. .FileName = appPath
  2316. .Arguments = tempstring
  2317. .RedirectStandardOutput = True
  2318. .RedirectStandardError = True
  2319. .RedirectStandardInput = True
  2320. .UseShellExecute = False
  2321. .WindowStyle = ProcessWindowStyle.Hidden
  2322. .CreateNoWindow = False
  2323. End With
  2324. Dim To_Display As String = ""
  2325. NewProcess.Start()
  2326. movieinfo = NewProcess.StandardOutput.ReadToEnd
  2327. Catch ex As Exception
  2328. End Try
  2329. Else
  2330. If applicationPath.IndexOf("/") <> -1 Then appPath = applicationPath & "/" & "MediaInfo.dll"
  2331. If applicationPath.IndexOf("\") <> -1 Then appPath = applicationPath & "\" & "MediaInfo.dll"
  2332. exists = IO.File.Exists(appPath)
  2333. If exists = True Then
  2334. medianfoexists = True
  2335. End If
  2336. If medianfoexists = False Then
  2337. MsgBox("Unable to find th file ""MediaInfo.dll""" & vbCrLf & vbCrLf & "Please make sure this file is available in the programs root directory")
  2338. Exit Sub
  2339. End If
  2340. Dim To_Display As String = ""
  2341. Dim tempstring5 As String
  2342. Dim MI As mediainfo
  2343. MI = New mediainfo
  2344. tempstring5 = MI.Option_("Info_Version", "0.7.0.0;MediaInfoDLL_Example_MSVB;0.7.0.0")
  2345. If (tempstring5.Length() = 0) Then
  2346. TextBox1.Text = "MediaInfo.Dll: this version of the DLL is not compatible"
  2347. Exit Sub
  2348. End If
  2349. If IO.File.Exists(tempstring) Then
  2350. MI.Open(tempstring)
  2351. To_Display = MI.Inform
  2352. movieinfo = To_Display
  2353. MI.Close()
  2354. End If
  2355. End If
  2356. TextBox8.Text = movieinfo
  2357. Catch
  2358. End Try
  2359. End Sub
  2360. Private Sub mov_Rescrape()
  2361. If outlinetxt.Text = "MC cannot find this file, either the file no longer exists, or MC cannot access the file path" Then
  2362. MsgBox("MC cannot find this file, either the file no longer exists, or MC cannot access the file path")
  2363. Exit Sub
  2364. End If
  2365. If workingMovieDetails Is Nothing Then Exit Sub
  2366. If workingMovieDetails.fullmoviebody.title = Nothing And workingMovieDetails.fullmoviebody.imdbid = Nothing Then
  2367. MsgBox("Can't rescrape this movie because it doesn't have any NFO File" & vbCrLf & "refresh movie database, and search for new movies", MsgBoxStyle.OkOnly, "Error")
  2368. Exit Sub
  2369. End If
  2370. Dim tempint = MessageBox.Show("Rescraping the movie will Overwrite all the current details" & vbCrLf & "Do you wish to continue?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning)
  2371. If tempint = DialogResult.No Then
  2372. Exit Sub
  2373. End If
  2374. RunBackgroundMovieScrape("RescrapeDisplayedMovie")
  2375. End Sub
  2376. Private Sub mov_SaveQuick()
  2377. If DataGridViewMovies.SelectedRows.Count = 0 Then Return
  2378. If DataGridViewMovies.SelectedRows.Count = 1 Then
  2379. Dim movie As Movie = oMovies.LoadMovie(workingMovieDetails.fileinfo.fullpathandfilename)
  2380. movie.ScrapedMovie.fullmoviebody.title = titletxt.Text.Replace(" (" & workingMovieDetails.fullmoviebody.year & ")", "")
  2381. If movie.ScrapedMovie.fullmoviebody.originaltitle = Nothing Or movie.ScrapedMovie.fullmoviebody.originaltitle = "" Then
  2382. movie.ScrapedMovie.fullmoviebody.originaltitle = movie.ScrapedMovie.fullmoviebody.title
  2383. End If
  2384. movie.ScrapedMovie.fullmoviebody.director = directortxt.Text
  2385. movie.ScrapedMovie.fullmoviebody.playcount = workingMovieDetails.fullmoviebody.playcount
  2386. movie.ScrapedMovie.fullmoviebody.lastplayed = workingMovieDetails.fullmoviebody.lastplayed
  2387. movie.ScrapedMovie.fullmoviebody.credits = creditstxt.Text
  2388. movie.ScrapedMovie.fullmoviebody.studio = studiotxt.Text
  2389. movie.ScrapedMovie.fullmoviebody.country = countrytxt.Text
  2390. movie.ScrapedMovie.fullmoviebody.genre = genretxt.Text
  2391. movie.ScrapedMovie.fullmoviebody.premiered = premiertxt.Text
  2392. movie.ScrapedMovie.fullmoviebody.votes = votestxt.Text
  2393. If lbl_movTop250.Text = "Top 250" Then
  2394. movie.ScrapedMovie.fullmoviebody.top250 = top250txt.Text
  2395. Else
  2396. movie.ScrapedMovie.fullmoviebody.metascore = top250txt.Text
  2397. End If
  2398. 'movie.ScrapedMovie.fullmoviebody.top250 = top250txt.Text
  2399. movie.ScrapedMovie.fullmoviebody.rating = ratingtxt.Text
  2400. movie.ScrapedMovie.fullmoviebody.usrrated = If(cbUsrRated.Text = "None", "0", cbUsrRated.Text)
  2401. movie.ScrapedMovie.fullmoviebody.runtime = runtimetxt.Text
  2402. movie.ScrapedMovie.fullmoviebody.outline = outlinetxt.Text
  2403. movie.ScrapedMovie.fullmoviebody.plot = plottxt.Text
  2404. movie.ScrapedMovie.fullmoviebody.tagline = taglinetxt.Text
  2405. movie.ScrapedMovie.fullmoviebody.stars = txtStars.Text.ToString.Replace(", See full cast and crew", "")
  2406. movie.ScrapedMovie.fullmoviebody.mpaa = certtxt.Text
  2407. movie.ScrapedMovie.fullmoviebody.sortorder = TextBox34.Text
  2408. If movie.ScrapedMovie.fullmoviebody.MovieSet.MovieSetName <> cbMovieDisplay_MovieSet.Items(cbMovieDisplay_MovieSet.SelectedIndex) AndAlso cbMovieDisplay_MovieSet.SelectedIndex <> -1 Then
  2409. movie.ScrapedMovie.fullmoviebody.MovieSet.MovieSetName = cbMovieDisplay_MovieSet.Items(cbMovieDisplay_MovieSet.SelectedIndex)
  2410. movie.ScrapedMovie.fullmoviebody.MovieSet.MovieSetId = oMovies.GetMovieSetIdFromName(movie.ScrapedMovie.fullmoviebody.MovieSet.MovieSetName)
  2411. End If
  2412. movie.ScrapedMovie.fullmoviebody.source = If(cbMovieDisplay_Source.SelectedIndex < 1, Nothing, cbMovieDisplay_Source.Items(cbMovieDisplay_Source.SelectedIndex))
  2413. If TabControl2.SelectedTab.Name = tpMovSetsTags.Name Then
  2414. For Each t In NewTagList
  2415. Dim remtag As String = t.Replace("- ","").Replace("+ ","")
  2416. If t.Contains("- ") Then
  2417. If movie.ScrapedMovie.fullmoviebody.tag.Contains(remtag) Then
  2418. movie.ScrapedMovie.fullmoviebody.tag.Remove(remtag)
  2419. End If
  2420. ElseIf t.Contains("+ ") Then
  2421. If Not movie.ScrapedMovie.fullmoviebody.tag.Contains(remtag) Then
  2422. movie.ScrapedMovie.fullmoviebody.tag.Add(remtag)
  2423. End If
  2424. End If
  2425. Next
  2426. If movie.ScrapedMovie.fullmoviebody.tag.Count <> 0 Then
  2427. Dim first As Boolean = True
  2428. tagtxt.Text = ""
  2429. For Each t In movie.ScrapedMovie.fullmoviebody.tag
  2430. If Not first Then
  2431. tagtxt.Text &= ", " & t
  2432. Else
  2433. tagtxt.Text &= t
  2434. End If
  2435. first = False
  2436. Next
  2437. tb_tagtxt_changed = False
  2438. End If
  2439. Else
  2440. If Pref.AllowUserTags AndAlso tb_tagtxt_changed Then
  2441. tb_tagtxt_changed = False
  2442. movie.ScrapedMovie.fullmoviebody.tag.Clear()
  2443. For Each wd In tagtxt.Text.Split(",")
  2444. wd = wd.Trim
  2445. If wd.Length = 0 Then Continue For
  2446. movie.ScrapedMovie.fullmoviebody.tag.Add(wd)
  2447. If Not Pref.movietags.Contains(wd) Then
  2448. Pref.movietags.Add(wd)
  2449. End If
  2450. If movie.ScrapedMovie.fullmoviebody.tag.Count >= Pref.keywordlimit Then Exit For
  2451. Next
  2452. ConfigSave()
  2453. End If
  2454. End If
  2455. 'If TabControl2.SelectedTab.Name = tpMovSets.Name Then
  2456. ' For Each t In NewTagList
  2457. ' Dim remtag As String = t.Replace("- ", "").Replace("+ ", "")
  2458. ' If t.Contains("- ") Then
  2459. ' If movie.ScrapedMovie.fullmoviebody.tag.Contains(remtag) Then
  2460. ' movie.ScrapedMovie.fullmoviebody.tag.Remove(remtag)
  2461. ' End If
  2462. ' ElseIf t.Contains("+ ") Then
  2463. ' If Not movie.ScrapedMovie.fullmoviebody.tag.Contains(remtag) Then
  2464. ' movie.ScrapedMovie.fullmoviebody.tag.Add(remtag)
  2465. ' End If
  2466. ' End If
  2467. ' Next
  2468. ' If movie.ScrapedMovie.fullmoviebody.tag.Count <> 0 Then
  2469. ' Dim first As Boolean = True
  2470. ' For Each t In movie.ScrapedMovie.fullmoviebody.tag
  2471. ' If Not first Then tagtxt.Text &= ", "
  2472. ' tagtxt.Text &= t
  2473. ' first = False
  2474. ' Next
  2475. ' End If
  2476. 'Else
  2477. ' If Pref.AllowUserTags Then
  2478. ' movie.ScrapedMovie.fullmoviebody.tag.Clear()
  2479. ' For Each wd In tagtxt.Text.Split(",")
  2480. ' wd = wd.Trim
  2481. ' If wd.Length = 0 Then Continue For
  2482. ' movie.ScrapedMovie.fullmoviebody.tag.Add(wd)
  2483. ' If Not Pref.movietags.Contains(wd) Then
  2484. ' Pref.movietags.Add(wd)
  2485. ' End If
  2486. ' ConfigSave()
  2487. ' If movie.ScrapedMovie.fullmoviebody.tag.Count >= Pref.keywordlimit Then Exit For
  2488. ' Next
  2489. ' End If
  2490. 'End If
  2491. movie.AssignMovieToCache()
  2492. movie.UpdateMovieCache()
  2493. movie.SaveNFO()
  2494. UpdateFilteredList()
  2495. If TabControl2.SelectedTab.Name = tpMovSetsTags.Name Then TagsPopulate()
  2496. Else
  2497. messbox = New frmMessageBox("Saving Selected Movies", , " Please Wait. ") 'Multiple movies selected
  2498. messbox.TextBox3.Text = "Press ESC to cancel"
  2499. messbox.TopMost = True
  2500. messbox.Show()
  2501. messbox.Refresh()
  2502. Application.DoEvents()
  2503. Dim Startfullpathandfilename As String = ""
  2504. If Not ISNothing(DataGridViewMovies.CurrentRow) Then
  2505. Dim i As Integer = DataGridViewMovies.CurrentRow.Index
  2506. Startfullpathandfilename = DataGridViewMovies.Item(5, i).Value.ToString
  2507. messbox.Cancelled = False
  2508. Dim pos As Integer = 0
  2509. Dim NfosToSave As List(Of String) = (From x As datagridviewrow In DataGridViewMovies.SelectedRows Select nfo=x.Cells("fullpathandfilename").Value.ToString).ToList
  2510. For Each nfo As String In NfosToSave
  2511. If Not File.Exists(nfo) Then Continue For
  2512. Dim movie As Movie = oMovies.LoadMovie(nfo)
  2513. If IsNothing(movie) Then Continue For
  2514. pos += 1
  2515. messbox.TextBox2.Text = pos.ToString + " of " + NfosToSave.Count.ToString
  2516. If directortxt.Text <> "" Then movie.ScrapedMovie.fullmoviebody.director = directortxt.Text
  2517. If creditstxt.Text <> "" Then movie.ScrapedMovie.fullmoviebody.credits = creditstxt.Text
  2518. If genretxt.Text <> "" Then movie.ScrapedMovie.fullmoviebody.genre = genretxt.Text
  2519. If premiertxt.Text <> "" Then movie.ScrapedMovie.fullmoviebody.premiered = premiertxt.Text
  2520. If certtxt.Text <> "" Then movie.ScrapedMovie.fullmoviebody.mpaa = certtxt.Text
  2521. If outlinetxt.Text <> "" Then movie.ScrapedMovie.fullmoviebody.outline = outlinetxt.Text
  2522. If runtimetxt.Text <> "" Then movie.ScrapedMovie.fullmoviebody.runtime = runtimetxt.Text
  2523. If studiotxt.Text <> "" Then movie.ScrapedMovie.fullmoviebody.studio = studiotxt.Text
  2524. If countrytxt.Text <> "" then movie.ScrapedMovie.fullmoviebody.country = countrytxt.Text
  2525. If plottxt.Text <> "" Then movie.ScrapedMovie.fullmoviebody.plot = plottxt.Text
  2526. If taglinetxt.Text <> "" Then movie.ScrapedMovie.fullmoviebody.tagline = taglinetxt.Text
  2527. If txtStars.Text <> "" Then movie.ScrapedMovie.fullmoviebody.stars = txtStars.Text.ToString.Replace(", See full cast and crew", "")
  2528. If ratingtxt.Text <> "" Then movie.ScrapedMovie.fullmoviebody.rating = ratingtxt.Text
  2529. If votestxt.Text <> "" Then movie.ScrapedMovie.fullmoviebody.votes = votestxt.Text
  2530. If top250txt.Text <> "" Then
  2531. If lbl_movTop250.Text = "Top 250" Then
  2532. movie.ScrapedMovie.fullmoviebody.top250 = top250txt.Text
  2533. Else
  2534. movie.ScrapedMovie.fullmoviebody.metascore = top250txt.Text
  2535. End If
  2536. 'movie.ScrapedMovie.fullmoviebody.top250 = top250txt.Text
  2537. End If
  2538. If Not cbMovieDisplay_MovieSet.SelectedIndex < 1 Then
  2539. movie.ScrapedMovie.fullmoviebody.MovieSet.MovieSetName = cbMovieDisplay_MovieSet.Items(cbMovieDisplay_MovieSet.SelectedIndex)
  2540. movie.ScrapedMovie.fullmoviebody.MovieSet.MovieSetId = oMovies.GetMovieSetIdFromName(movie.ScrapedMovie.fullmoviebody.MovieSet.MovieSetName)
  2541. End If
  2542. If cbUsrRated.SelectedIndex <> -1 Then movie.ScrapedMovie.fullmoviebody.usrrated = cbUsrRated.SelectedIndex.ToString'text
  2543. movie.ScrapedMovie.fullmoviebody.source = If(cbMovieDisplay_Source.SelectedIndex < 1, Nothing, cbMovieDisplay_Source.Items(cbMovieDisplay_Source.SelectedIndex))
  2544. If TabControl2.SelectedTab.Name = tpMovSetsTags.Name Then
  2545. For Each t In NewTagList
  2546. Dim remtag As String = t.Replace("- ","").Replace("+ ","")
  2547. If t.Contains("- ") Then
  2548. If movie.ScrapedMovie.fullmoviebody.tag.Contains(remtag) Then
  2549. movie.ScrapedMovie.fullmoviebody.tag.Remove(remtag)
  2550. End If
  2551. ElseIf t.Contains("+ ") Then
  2552. If Not movie.ScrapedMovie.fullmoviebody.tag.Contains(remtag) Then
  2553. movie.ScrapedMovie.fullmoviebody.tag.Add(remtag)
  2554. End If
  2555. End If
  2556. Next
  2557. Else
  2558. If tb_tagtxt_changed Then
  2559. 'tb_tagtxt_changed = False
  2560. movie.ScrapedMovie.fullmoviebody.tag.Clear()
  2561. If tagtxt.Text <> "" AndAlso tagtxt.Text.Contains(",") Then
  2562. Dim tags() As String = tagtxt.Text.Split(",")
  2563. For Each strtag In tags
  2564. If Not movie.ScrapedMovie.fullmoviebody.tag.Contains(strtag.Trim()) Then movie.ScrapedMovie.fullmoviebody.tag.Add(strtag.Trim())
  2565. Next
  2566. ElseIf tagtxt.Text <> "" Then
  2567. If Not movie.ScrapedMovie.fullmoviebody.tag.Contains(tagtxt.Text.Trim()) Then movie.ScrapedMovie.fullmoviebody.tag.Add(tagtxt.Text.Trim())
  2568. End If
  2569. End If
  2570. End If
  2571. 'If TabControl2.SelectedTab.Name = tpMovSets.Name Then
  2572. ' For Each t In NewTagList
  2573. ' Dim remtag As String = t.Replace("- ", "").Replace("+ ", "")
  2574. ' If t.Contains("- ") Then
  2575. ' If movie.ScrapedMovie.fullmoviebody.tag.Contains(remtag) Then
  2576. ' movie.ScrapedMovie.fullmoviebody.tag.Remove(remtag)
  2577. ' End If
  2578. ' ElseIf t.Contains("+ ") Then
  2579. ' If Not movie.ScrapedMovie.fullmoviebody.tag.Contains(remtag) Then
  2580. ' movie.ScrapedMovie.fullmoviebody.tag.Add(remtag)
  2581. ' End If
  2582. ' End If
  2583. ' Next
  2584. 'Else
  2585. ' If tb_tagtxt_changed Then
  2586. ' tb_tagtxt_changed = False
  2587. ' movie.ScrapedMovie.fullmoviebody.tag.Clear()
  2588. ' If tagtxt.Text <> "" AndAlso tagtxt.Text.Contains(",") Then
  2589. ' Dim tags() As String = tagtxt.Text.Split(",")
  2590. ' For Each strtag In tags
  2591. ' If Not movie.ScrapedMovie.fullmoviebody.tag.Contains(strtag.Trim()) Then movie.ScrapedMovie.fullmoviebody.tag.Add(strtag.Trim())
  2592. ' Next
  2593. ' ElseIf tagtxt.Text <> "" Then
  2594. ' If Not movie.ScrapedMovie.fullmoviebody.tag.Contains(tagtxt.Text.Trim()) Then movie.ScrapedMovie.fullmoviebody.tag.Add(tagtxt.Text.Trim())
  2595. ' End If
  2596. ' End If
  2597. 'End If
  2598. movie.AssignMovieToCache()
  2599. movie.UpdateMovieCache()
  2600. movie.SaveNFO()
  2601. Application.DoEvents()
  2602. If messbox.Cancelled Then Exit For
  2603. Next
  2604. If tb_tagtxt_changed Then tb_tagtxt_changed = False
  2605. UpdateFilteredList()
  2606. ProgState = ProgramState.Other
  2607. Else
  2608. messbox.Close()
  2609. MsgBox("Must Select an Initial Movie" & vbCrLf & "Save Cancelled")
  2610. Exit Sub
  2611. End If
  2612. workingMovie.fullpathandfilename = Startfullpathandfilename
  2613. mov_FormPopulate()
  2614. messbox.Close()
  2615. If TabControl2.SelectedTab.Name = tpMovSetsTags.Name Then TabControl2.SelectedIndex = 0
  2616. End If
  2617. End Sub
  2618. Private Sub mov_Edit()
  2619. If outlinetxt.Text = "MC cannot find this file, either the file no longer exists, or MC cannot access the file path" Then
  2620. MsgBox("MC cannot find this file, either the file no longer exists, or MC cannot access the file path")
  2621. Exit Sub
  2622. End If
  2623. Dim oldmovietitle As String = workingMovieDetails.fileinfo.fullpathandfilename
  2624. Dim newmovietitle As String = ""
  2625. Dim MyFormObject As New Form2()
  2626. MyFormObject.ShowDialog()
  2627. newmovietitle = workingMovieDetails.fileinfo.fullpathandfilename
  2628. For f = 0 To oMovies.MovieCache.Count - 1
  2629. If oMovies.MovieCache(f).fullpathandfilename = newmovietitle Then
  2630. Dim newfullmovie As New ComboList
  2631. oMovies.MovieCache.RemoveAt(f)
  2632. newfullmovie = nfoFunction.mov_NfoLoadBasic(workingMovieDetails.fileinfo.fullpathandfilename, "movielist")
  2633. If workingMovie.title <> "ERROR" Then 'if there is a problem with the nfo being invalid we need to skip
  2634. oMovies.MovieCache.Add(newfullmovie)
  2635. End If
  2636. Exit For
  2637. End If
  2638. Next
  2639. 'Todo: need to update all details after edit.
  2640. For f = 0 To filteredList.Count - 1
  2641. If filteredList(f).fullpathandfilename = oldmovietitle Then
  2642. Dim newfullmovie2 As New ComboList
  2643. newfullmovie2 = filteredList(f)
  2644. filteredList.RemoveAt(f)
  2645. Dim filecreation2 As New IO.FileInfo(workingMovieDetails.fileinfo.fullpathandfilename)
  2646. Dim myDate2 As Date = filecreation2.LastWriteTime
  2647. Try
  2648. newfullmovie2.filedate = Format(myDate2, datePattern).ToString
  2649. Catch ex As Exception
  2650. #If SilentErrorScream Then
  2651. Throw ex
  2652. #End If
  2653. End Try
  2654. newfullmovie2.filename = workingMovieDetails.fileinfo.filename
  2655. newfullmovie2.foldername = workingMovieDetails.fileinfo.foldername
  2656. newfullmovie2.fullpathandfilename = workingMovieDetails.fileinfo.fullpathandfilename
  2657. newfullmovie2.genre = workingMovieDetails.fullmoviebody.genre
  2658. newfullmovie2.id = workingMovieDetails.fullmoviebody.imdbid
  2659. newfullmovie2.playcount = workingMovieDetails.fullmoviebody.playcount
  2660. newfullmovie2.lastplayed = workingMovieDetails.fullmoviebody.lastplayed
  2661. newfullmovie2.rating = workingMovieDetails.fullmoviebody.rating.ToRating
  2662. newfullmovie2.year = workingMovieDetails.fullmoviebody.year
  2663. newfullmovie2.rootfolder = workingMovieDetails.fileinfo.rootfolder
  2664. filteredList.Add(newfullmovie2)
  2665. Exit For
  2666. End If
  2667. Next
  2668. Call mov_FormPopulate()
  2669. Call Mc.clsGridViewMovie.mov_FiltersAndSortApply(Me)
  2670. End Sub
  2671. Private Sub XBMCMCThreadToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles XBMCMCThreadToolStripMenuItem.Click
  2672. Try
  2673. Dim webAddress As String = "http://forum.xbmc.org/showthread.php?t=129134"
  2674. OpenUrl(webAddress)
  2675. Catch ex As Exception
  2676. ExceptionHandler.LogError(ex)
  2677. End Try
  2678. End Sub
  2679. Private Sub ListMoviesWithoutFanartToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
  2680. Try
  2681. filterOverride = True
  2682. Dim newlist As New List(Of ComboList)
  2683. newlist.Clear()
  2684. For Each movie In oMovies.MovieCache
  2685. If Not IO.File.Exists(Pref.GetFanartPath(movie.fullpathandfilename)) Then
  2686. Dim movietoadd As New ComboList
  2687. movietoadd.fullpathandfilename = movie.fullpathandfilename
  2688. movietoadd.filename = movie.filename
  2689. movietoadd.year = movie.year
  2690. movietoadd.filedate = movie.filedate
  2691. movietoadd.foldername = movie.foldername
  2692. movietoadd.rating = movie.rating
  2693. movietoadd.top250 = movie.top250
  2694. movietoadd.rootfolder = movie.rootfolder
  2695. newlist.Add(movietoadd)
  2696. End If
  2697. Next
  2698. filteredList = newlist
  2699. mov_CacheLoad()
  2700. filterOverride = False
  2701. Catch ex As Exception
  2702. ExceptionHandler.LogError(ex)
  2703. End Try
  2704. End Sub
  2705. Private Sub ListMoviesWithoutPostersToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
  2706. Try
  2707. filterOverride = True
  2708. Dim newlist As New List(Of ComboList)
  2709. newlist.Clear()
  2710. For Each movie In oMovies.MovieCache
  2711. If Not IO.File.Exists(Pref.GetPosterPath(movie.fullpathandfilename)) Then
  2712. Dim movietoadd As New ComboList
  2713. movietoadd.fullpathandfilename = movie.fullpathandfilename
  2714. movietoadd.filename = movie.filename
  2715. movietoadd.year = movie.year
  2716. movietoadd.filedate = movie.filedate
  2717. movietoadd.foldername = movie.foldername
  2718. movietoadd.rating = movie.rating
  2719. movietoadd.top250 = movie.top250
  2720. movietoadd.rootfolder = movie.rootfolder
  2721. newlist.Add(movietoadd)
  2722. End If
  2723. Next
  2724. filteredList = newlist
  2725. mov_CacheLoad()
  2726. filterOverride = False
  2727. Catch ex As Exception
  2728. ExceptionHandler.LogError(ex)
  2729. End Try
  2730. End Sub
  2731. Private Sub BatchRescraperToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BatchRescraperToolStripMenuItem.Click
  2732. rescrapeList.ResetFields()
  2733. Dim displaywizard As New frmBatchScraper
  2734. displaywizard.ShowDialog()
  2735. If rescrapeList.AnyEnabled Then
  2736. _rescrapeList.FullPathAndFilenames.Clear()
  2737. If DataGridViewMovies.SelectedRows.Count > 1 Then 'run batch wizard on multiple selected movies
  2738. For Each row As DataGridViewRow In DataGridViewMovies.SelectedRows
  2739. Dim fullpath As String = row.Cells("fullpathandfilename").Value.ToString
  2740. If Not File.Exists(fullpath) Then Continue For
  2741. If rescrapeList.EmptyMainTags AndAlso MovieHasEmptyMainTags(fullpath) Then Continue For
  2742. _rescrapeList.FullPathAndFilenames.Add(fullpath)
  2743. Next
  2744. Else 'Otherwise run batch wizard on all movies.
  2745. For Each row As DataGridViewRow In DataGridViewMovies.Rows
  2746. Dim m As Data_GridViewMovie = row.DataBoundItem
  2747. Dim fullpath As String = m.fullpathandfilename.ToString
  2748. If Not File.Exists(fullpath) Then Continue For
  2749. If rescrapeList.EmptyMainTags AndAlso MovieHasEmptyMainTags(fullpath) Then Continue For
  2750. _rescrapeList.FullPathAndFilenames.Add(fullpath)
  2751. Next
  2752. End If
  2753. RunBackgroundMovieScrape("BatchRescrape")
  2754. End If
  2755. End Sub
  2756. Public Function MovieHasEmptyMainTags(ByVal checkmovie As String) As Boolean
  2757. If rescrapeList.AnyNonMainEnabled Then Return True
  2758. For each movie As ComboList In oMovies.MovieCache
  2759. If Not movie.fullpathandfilename = checkmovie Then Continue For
  2760. If rescrapeList.rating AndAlso movie.rating < 1 Then Return False
  2761. If rescrapeList.votes AndAlso movie.Votes = 0 Then Return False
  2762. If rescrapeList.mpaa AndAlso movie.Certificate = "" Then Return False
  2763. If rescrapeList.genre AndAlso movie.genre = "" Then Return False
  2764. If rescrapeList.year AndAlso movie.year < 1900 Then Return False
  2765. If rescrapeList.top250 AndAlso movie.top250 = "" Then Return False
  2766. If rescrapeList.outline AndAlso movie.outline = "" Then Return False
  2767. If rescrapeList.plot AndAlso movie.plot = "" Then Return False
  2768. If rescrapeList.tagline AndAlso movie.tagline = "" Then Return False
  2769. If rescrapeList.runtime AndAlso movie.runtime = "" Then Return False
  2770. If rescrapeList.director AndAlso movie.director = "" Then Return False
  2771. If rescrapeList.credits AndAlso movie.credits = "" Then Return False
  2772. If rescrapeList.title AndAlso movie.title = "" Then Return False
  2773. If rescrapeList.premiered AndAlso movie.Premiered = "" Then Return False
  2774. If rescrapeList.stars AndAlso movie.stars = "" Then Return False
  2775. If rescrapeList.studio AndAlso movie.studios = "" Then Return False
  2776. If rescrapeList.country AndAlso movie.countries = "" Then Return False
  2777. If rescrapeList.metascore AndAlso movie.metascore = 0 Then Return False
  2778. Exit For
  2779. Next
  2780. Return True
  2781. End Function
  2782. 'Public Function GetTrailerPath(ByVal s As String)
  2783. ' Dim FileName As String = ""
  2784. ' For Each extension In Utilities.TrailerExtensions
  2785. ' FileName = IO.Path.Combine(s.Replace(IO.Path.GetFileName(s), ""), System.IO.Path.GetFileNameWithoutExtension(s) & "-trailer" & extension)
  2786. ' If File.Exists(FileName) Then Return FileName
  2787. ' Next
  2788. ' 'set default trailer path and filename
  2789. ' Return IO.Path.Combine(s.Replace(IO.Path.GetFileName(s), ""), System.IO.Path.GetFileNameWithoutExtension(s) & "-trailer.flv")
  2790. 'End Function
  2791. Private Sub mov_Play(ByVal type As String)
  2792. If DataGridViewMovies.SelectedRows.Count < 1 Then Return
  2793. Dim tempstring As String
  2794. tempstring = DataGridViewMovies.SelectedCells(NFO_INDEX).Value.ToString
  2795. Dim playlist As New List(Of String)
  2796. Select Case type
  2797. Case "Movie"
  2798. If tempstring.IndexOf("index.nfo") <> -1 Then
  2799. tempstring = tempstring.Replace(".nfo", ".bdmv")
  2800. Else
  2801. tempstring = Utilities.GetFileName(tempstring)
  2802. End If
  2803. playlist = Utilities.GetMediaList(tempstring)
  2804. Case "Trailer"
  2805. Dim movie = oMovies.LoadMovie(tempstring)
  2806. If movie.TrailerExists Then playlist.Add(movie.ActualTrailerPath)
  2807. Case "HomeMovie"
  2808. tempstring = CType(ListBox18.SelectedItem, ValueDescriptionPair).Value
  2809. tempstring = Utilities.GetFileName(tempstring)
  2810. playlist = Utilities.GetMediaList(tempstring)
  2811. End Select
  2812. If playlist.Count <= 0 Then
  2813. MsgBox("No Media File Found For This nfo")
  2814. Exit Sub
  2815. End If
  2816. LaunchPlayList(playlist)
  2817. End Sub
  2818. Public Function CleanMovieTitle(ByVal s As String) As String
  2819. Dim tmplist As New List(Of String)
  2820. Dim q = From el In MovSepLst Order By el.Length Descending
  2821. tmplist.AddRange(q.tolist)
  2822. For each item In tmplist
  2823. Dim t As String = " " & item
  2824. If s.Contains(t) Then s = s.Replace(t, "")
  2825. Next
  2826. tmplist.Clear()
  2827. Dim r = From el In ThreeDKeyWords Order By el.Length Descending
  2828. tmplist.AddRange(r.ToList)
  2829. For each item In tmplist
  2830. Dim t As String = " " & item & " "
  2831. If s.Contains(t) Then s = s.Replace(t, "")
  2832. If s.Contains(t.TrimEnd) Then s = s.Replace(t.TrimEnd, "")
  2833. Next
  2834. Return s
  2835. End Function
  2836. Public Sub LaunchPlayList(ByVal plist As List(Of String))
  2837. Statusstrip_Enable()
  2838. ToolStripStatusLabel2.Text = ""
  2839. ToolStripStatusLabel2.Visible = True
  2840. Dim tempstring = applicationPath & "\Settings\temp.m3u"
  2841. ToolStripStatusLabel2.Text = "Playing Movie...Creating m3u file:..." & tempstring
  2842. Application.DoEvents()
  2843. Dim aok As Boolean = True
  2844. If IO.File.Exists(tempstring) Then
  2845. aok = Utilities.SafeDeleteFile(tempstring)
  2846. End If
  2847. If aok Then
  2848. Dim file As New StreamWriter(tempstring, False, Encoding.GetEncoding(1252))
  2849. For Each part In plist
  2850. If part <> Nothing Then file.WriteLine(part)
  2851. Next
  2852. file.Close()
  2853. ToolStripStatusLabel2.Text &= "............Launching Player."
  2854. StartVideo(tempstring)
  2855. Else
  2856. ToolStripStatusLabel2.Text = "Failed to create playlist"
  2857. End If
  2858. statusstripclear.Start()
  2859. End Sub
  2860. Private Sub MovieFormInit()
  2861. workingMovie.filedate = Nothing
  2862. workingMovie.filename = Nothing
  2863. workingMovie.foldername = Nothing
  2864. workingMovie.fullpathandfilename = Nothing
  2865. workingMovie.genre = Nothing
  2866. workingMovie.id = Nothing
  2867. workingMovie.playcount = Nothing
  2868. workingMovie.lastplayed = Nothing
  2869. workingMovie.rating = Nothing
  2870. workingMovie.title = Nothing
  2871. workingMovie.top250 = Nothing
  2872. workingMovie.year = Nothing
  2873. workingMovie.MovieSet = Nothing
  2874. workingMovie.rootfolder = Nothing
  2875. titletxt.Text = ""
  2876. TextBox3.Text = ""
  2877. outlinetxt.Text = ""
  2878. TextBox34.Text = ""
  2879. plottxt.Text = ""
  2880. taglinetxt.Text = ""
  2881. txtStars.Text = ""
  2882. genretxt.Text = ""
  2883. premiertxt.Text = ""
  2884. creditstxt.Text = ""
  2885. directortxt.Text = ""
  2886. studiotxt.Text = ""
  2887. countrytxt.Text = ""
  2888. pathtxt.Text = ""
  2889. cbMovieDisplay_Actor.Items.Clear()
  2890. ratingtxt.Text = ""
  2891. runtimetxt.Text = ""
  2892. votestxt.Text = ""
  2893. top250txt.Text = ""
  2894. certtxt.Text = ""
  2895. PbMovieFanArt.Image = Nothing
  2896. PbMoviePoster.Image = Nothing
  2897. roletxt.Text = ""
  2898. PictureBoxActor.Image = Nothing
  2899. btnPlayMovie.Enabled = False
  2900. End Sub
  2901. Public Sub genretxt_MouseClick(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles genretxt.MouseDown
  2902. If e.Button = Windows.Forms.MouseButtons.Right Then
  2903. Dim multicount As Integer = 0
  2904. Try
  2905. Dim genre As String = ""
  2906. Dim listof As New List(Of str_genre)
  2907. Dim Multi As Boolean = DataGridViewMovies.SelectedRows.Count > 1
  2908. If Not Multi Then
  2909. Dim item As List(Of String) = workingMovieDetails.fullmoviebody.genre.Split("/").[Select](Function(p) p.Trim()).ToList
  2910. If item(0) = "" Then item.RemoveAt(0)
  2911. multicount = multicount +1
  2912. listof.Clear()
  2913. For Each i In item
  2914. Dim g As New str_genre
  2915. g.genre = i.Trim
  2916. g.count = 1
  2917. listof.Add(g)
  2918. Next
  2919. Else
  2920. For Each row As DataGridViewRow In DataGridViewMovies.SelectedRows
  2921. multicount = multicount +1
  2922. Dim genretxt As String = row.Cells("genre").Value.ToString
  2923. Dim spltgenre As List(Of String) = genretxt.Split("/").[Select](Function(p) p.Trim()).ToList
  2924. If spltgenre(0) = "" Then spltgenre.RemoveAt(0)
  2925. For Each i In spltgenre
  2926. Dim g As New str_genre
  2927. g.genre = i
  2928. g.count = 1
  2929. For each item In listof
  2930. If item.genre.ToLower = g.genre.ToLower Then
  2931. g.count = item.count
  2932. Exit For
  2933. End If
  2934. Next
  2935. If listof.Contains(g) Then
  2936. listof.RemoveAt(listof.IndexOf(g))
  2937. g.count = g.count + 1
  2938. End If
  2939. listof.Add(g)
  2940. Next
  2941. Next
  2942. End If
  2943. Dim frm As New frmGenreSelect
  2944. frm.multicount = multicount
  2945. frm.SelectedGenres = listof
  2946. frm.Init()
  2947. If frm.ShowDialog() = Windows.Forms.DialogResult.OK Then
  2948. listof.Clear()
  2949. listof.AddRange(frm.SelectedGenres)
  2950. If Not Multi Then
  2951. genre = ""
  2952. For each g In listof
  2953. If g.count = 0 Then Continue For
  2954. If genre = "" Then
  2955. genre = g.genre
  2956. Else
  2957. genre += " / " & g.genre
  2958. End If
  2959. Next
  2960. genretxt.Text = genre
  2961. Call mov_SaveQuick()
  2962. Else
  2963. Dim NfosToSave As List(Of String) = (From x As datagridviewrow In DataGridViewMovies.SelectedRows Select nfo=x.Cells("fullpathandfilename").Value.ToString).ToList
  2964. For Each nfo As String In NfosToSave
  2965. If Not File.Exists(nfo) Then Continue For
  2966. Dim movie As Movie = oMovies.LoadMovie(nfo)
  2967. If IsNothing(movie) Then Continue For
  2968. Dim genretxt As String = movie.ScrapedMovie.fullmoviebody.genre
  2969. Dim spgenre2 As List(Of String) = genretxt.Split("/").[Select](Function(p) p.Trim()).ToList
  2970. genre = ""
  2971. For Each g In listof
  2972. Dim ToAdd As Boolean = False
  2973. If g.count = 0 Then Continue For
  2974. If (g.count = 1 AndAlso spgenre2.Contains(g.genre)) OrElse g.count = 2 Then ToAdd = True
  2975. If Not ToAdd Then Continue For
  2976. If genre = "" Then
  2977. genre = g.genre
  2978. Else
  2979. genre += " / " & g.genre
  2980. End If
  2981. Next
  2982. movie.ScrapedMovie.fullmoviebody.genre = genre
  2983. movie.AssignMovieToCache()
  2984. movie.UpdateMovieCache()
  2985. movie.SaveNFO()
  2986. Application.DoEvents()
  2987. Next
  2988. End If
  2989. End If
  2990. frm.Dispose()
  2991. Catch
  2992. End Try
  2993. End If
  2994. End Sub
  2995. Public Sub DisplayMovie(Optional yielding As Boolean = False)
  2996. Try
  2997. DisplayMovie(DataGridViewMovies.SelectedCells, DataGridViewMovies.SelectedRows, yielding)
  2998. Catch
  2999. Return
  3000. End Try
  3001. End Sub
  3002. Public Sub DisplayMovie(ByVal selectedCells As DataGridViewSelectedCellCollection, ByVal selectedRows As DataGridViewSelectedRowCollection, yielding As Boolean)
  3003. Try
  3004. If selectedRows.Count = 1 Then
  3005. If LastMovieDisplayed = selectedCells(NFO_INDEX).Value.ToString Then Return
  3006. LastMovieDisplayed = selectedCells(NFO_INDEX).Value.ToString
  3007. Else
  3008. LastMovieDisplayed = ""
  3009. End If
  3010. Catch
  3011. Return
  3012. End Try
  3013. If yielding Then
  3014. _yield = True
  3015. Application.DoEvents()
  3016. _yield = False
  3017. End If
  3018. 'Clear all fields of the movie
  3019. MovieFormInit()
  3020. If selectedRows.Count = 0 Then Exit Sub
  3021. Dim needtoload As Boolean = False
  3022. Dim done As Boolean = False
  3023. Dim blnShow = (selectedRows.Count=1)
  3024. tsmiMov_PlayMovie.Visible = blnShow
  3025. tsmiMov_OpenFolder.Visible = blnShow
  3026. tsmiMov_ViewNfo.Visible = blnShow
  3027. tsmiMov_Separator1.Visible = blnShow
  3028. tsmiMov_Separator7.Visible = blnShow
  3029. tsmiMov_FanartBrowserAlt.Visible = blnShow
  3030. tsmiMov_PosterBrowserAlt.Visible = blnShow
  3031. tsmiMov_EditMovieAlt.Visible = blnShow
  3032. tsmiMov_ReloadFromCache.Visible = blnShow
  3033. If Yield(yielding) Then Return
  3034. If selectedRows.Count = 1 Then
  3035. 'mov_ToolStripPlayMovie.Visible = True
  3036. 'mov_ToolStripOpenFolder.Visible = True
  3037. 'mov_ToolStripViewNfo.Visible = True
  3038. 'ToolStripSeparator17.Visible = True
  3039. 'ToolStripSeparator24.Visible = True
  3040. 'ToolStripSeparator4.Visible = True
  3041. 'mov_ToolStripFanartBrowserAlt.Visible = True
  3042. 'mov_ToolStripPosterBrowserAlt.Visible = True
  3043. 'mov_ToolStripEditMovieAlt.Visible = True
  3044. 'mov_ToolStripReloadFromCache.Visible = True
  3045. If titletxt.Visible = False Then
  3046. needtoload = True
  3047. End If
  3048. titletxt.Visible = True
  3049. TextBoxMutisave.Visible = False
  3050. btnMovRescrape.Visible = True
  3051. SplitContainer2.Visible = True
  3052. Label128.Visible = False
  3053. Label75.Visible = True
  3054. TextBox34.Visible = True
  3055. If Yield(yielding) Then Return
  3056. If Yield(yielding) Then Return
  3057. Dim query = From f In oMovies.Data_GridViewMovieCache Where f.fullpathandfilename = selectedCells(NFO_INDEX).Value.ToString
  3058. Dim queryList As List(Of Data_GridViewMovie) = query.ToList()
  3059. If Yield(yielding) Then Return
  3060. If Not queryList.Count = 0 AndAlso Not File.Exists(queryList(0).MoviePathAndFileName) Then 'Detect if video file is missing
  3061. If Mov_MissingMovie(queryList) Then Exit Sub
  3062. End If
  3063. If queryList.Count > 0 Then
  3064. workingMovie.filedate = queryList(0).filedate
  3065. workingMovie.filename = queryList(0).filename
  3066. workingMovie.foldername = queryList(0).foldername
  3067. workingMovie.fullpathandfilename = queryList(0).fullpathandfilename
  3068. workingMovie.genre = queryList(0).genre
  3069. workingMovie.id = queryList(0).id
  3070. workingMovie.playcount = queryList(0).playcount
  3071. workingMovie.rating = queryList(0).Rating
  3072. workingMovie.title = queryList(0).title
  3073. workingMovie.top250 = queryList(0).top250
  3074. workingMovie.year = queryList(0).year
  3075. workingMovie.FolderSize = queryList(0).FolderSize
  3076. workingMovie.rootfolder = queryList(0).rootfolder
  3077. workingMovie.MovieSet = queryList(0).movieset
  3078. workingMovie.tmdbid = queryList(0).tmdbid
  3079. tsmiMov_PlayTrailer.Visible = Not queryList(0).MissingTrailer
  3080. tsmiMov_ViewMovieDbSetPage.Enabled = Not IsNothing(workingMovie.MovieSet) AndAlso Integer.TryParse(workingMovie.MovieSet.MovieSetId,Nothing)
  3081. tsmiMov_ViewMovieDbMoviePage.Enabled = Integer.TryParse(workingMovie.tmdbid,Nothing) And Not workingMovie.tmdbid=""
  3082. Call mov_FormPopulate(yielding)
  3083. Else
  3084. If needtoload = True Then Call mov_FormPopulate(yielding)
  3085. End If
  3086. done = True
  3087. Else
  3088. outlinetxt.Text = ""
  3089. PbMovieFanArt.Image = Nothing
  3090. PbMoviePoster.Image = Nothing
  3091. roletxt.Text = ""
  3092. PictureBoxActor.Image = Nothing
  3093. SplitContainer2.Visible = False
  3094. titletxt.Visible = False
  3095. Label75.Visible = False
  3096. TextBox34.Visible = False
  3097. TextBoxMutisave.Visible = True
  3098. Panel6.Visible = False
  3099. FanTvArtList.Items.Clear()
  3100. btnMovRescrape.Visible = False
  3101. Label128.Visible = True
  3102. cbMovieDisplay_MovieSet.Items.Insert(0, "")
  3103. cbMovieDisplay_MovieSet.SelectedIndex = 0
  3104. cbUsrRated.SelectedIndex = -1
  3105. Dim add As Boolean = True
  3106. Dim watched As String = ""
  3107. For Each sRow As DataGridViewRow In selectedRows
  3108. Dim old As String = watched
  3109. For Each item In oMovies.MovieCache
  3110. If item.fullpathandfilename = sRow.Cells(NFO_INDEX).Value.ToString Then
  3111. If watched = "" Then
  3112. watched = item.playcount
  3113. old = watched
  3114. Else
  3115. watched = item.playcount
  3116. End If
  3117. If watched <> old Then
  3118. add = False
  3119. End If
  3120. Exit For
  3121. End If
  3122. If Yield(yielding) Then Return
  3123. Next
  3124. Next
  3125. If add = False Then
  3126. btnMovWatched.Text = ""
  3127. btnMovWatched.BackColor = Color.Gray
  3128. Else
  3129. If watched = "1" Then
  3130. btnMovWatched.Text = "&Watched"
  3131. btnMovWatched.BackColor = Color.LawnGreen
  3132. btnMovWatched.Refresh()
  3133. Else
  3134. btnMovWatched.Text = "Un&watched"
  3135. btnMovWatched.BackColor = Color.Red
  3136. btnMovWatched.Refresh()
  3137. End If
  3138. End If
  3139. End If
  3140. End Sub
  3141. #Region "DataGridViewMovies Events"
  3142. Private Sub DataGridViewMovies_CellClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridViewMovies.CellClick
  3143. _yield = True
  3144. Application.DoEvents()
  3145. _yield = False
  3146. DisplayMovie()
  3147. End Sub
  3148. Private Sub DataGridViewMovies_ColumnHeaderMouseClick( sender As Object, e As DataGridViewCellMouseEventArgs) Handles DataGridViewMovies.ColumnHeaderMouseClick
  3149. Dim col_index = e.ColumnIndex
  3150. DGVMoviesColName = DataGridViewMovies.Columns(col_index).Name
  3151. btnreverse.Checked = Not btnreverse.Checked
  3152. btnreverse_CheckedChanged(Nothing,Nothing)
  3153. End Sub
  3154. Private Sub DataGridViewMovies_DoubleClick(ByVal sender As System.Object, ByVal e As MouseEventArgs) Handles DataGridViewMovies.DoubleClick
  3155. Try
  3156. Dim info = DataGridViewMovies.HitTest(e.X, e.Y)
  3157. If info.ColumnX = -1 Then
  3158. Return
  3159. End If
  3160. Try
  3161. If IsNumeric(DataGridViewMovies.SelectedCells(NFO_INDEX).Value.ToString) Then Return
  3162. Catch
  3163. Return
  3164. End Try
  3165. If info.Type <> DataGridViewHitTestType.ColumnHeader Then
  3166. mov_Play("Movie")
  3167. End If
  3168. Catch ex As Exception
  3169. ExceptionHandler.LogError(ex)
  3170. End Try
  3171. End Sub
  3172. Private Sub DataGridViewMovies_DragDrop(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles DataGridViewMovies.DragDrop
  3173. Dim files() As String
  3174. files = e.Data.GetData(DataFormats.FileDrop)
  3175. For f = 0 To UBound(files)
  3176. If IO.File.Exists(files(f)) Then
  3177. ' This path is a file.
  3178. Dim skip As Boolean = False
  3179. For Each item In oMovies.MovieCache
  3180. If item.fullpathandfilename = files(f) Then
  3181. skip = True
  3182. Exit For
  3183. End If
  3184. Next
  3185. For Each item In droppedItems
  3186. If item = files(f) Then
  3187. skip = True
  3188. Exit For
  3189. End If
  3190. Next
  3191. If mov_FileCheckValid(files(f)) = True Then
  3192. If skip = False Then droppedItems.Add(files(f))
  3193. End If
  3194. Else
  3195. If IO.Directory.Exists(files(f)) Then
  3196. ' This path is a directory.
  3197. Dim di As New IO.DirectoryInfo(files(f))
  3198. Dim diar1 As IO.FileInfo() = di.GetFiles()
  3199. Dim dra As IO.FileInfo
  3200. 'list the names of all files in the specified directory
  3201. For Each dra In diar1
  3202. Dim skip As Boolean = False
  3203. For Each item In oMovies.MovieCache
  3204. If item.fullpathandfilename = dra.FullName Then
  3205. skip = True
  3206. Exit For
  3207. End If
  3208. Next
  3209. For Each item In droppedItems
  3210. If item = dra.FullName Then
  3211. skip = True
  3212. Exit For
  3213. End If
  3214. Next
  3215. If mov_FileCheckValid(dra.FullName) = True Then
  3216. If skip = False Then droppedItems.Add(dra.FullName)
  3217. End If
  3218. Next
  3219. End If
  3220. End If
  3221. Next
  3222. If droppedItems.Count > 0 Then
  3223. DoScrapeDroppedFiles()
  3224. End If
  3225. End Sub
  3226. Private Sub DataGridViewMovies_DragEnter(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles DataGridViewMovies.DragEnter
  3227. Try
  3228. e.Effect = DragDropEffects.Copy
  3229. Catch ex As Exception
  3230. ExceptionHandler.LogError(ex)
  3231. End Try
  3232. End Sub
  3233. Private Sub DataGridViewMovies_KeyUp(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles DataGridViewMovies.KeyUp
  3234. DisplayMovie(True)
  3235. End Sub
  3236. Private Sub DataGridViewMovies_KeyPress(sender As Object, e As KeyPressEventArgs) Handles DataGridViewMovies.Keypress
  3237. If [Char].IsLetter(e.KeyChar) or [Char].IsDigit(e.KeyChar) Then
  3238. Dim ekey As String = e.KeyChar.ToString.ToLower
  3239. keypresstimer.Stop()
  3240. MovieKeyPress &= ekey
  3241. keypresstimer.Start()
  3242. For i As Integer = 0 To (DataGridViewMovies.Rows.Count) - 1
  3243. Dim rtitle As String = DataGridViewMovies.Rows(i).Cells("DisplayTitle").Value.ToString.ToLower
  3244. If rtitle.StartsWith(MovieKeyPress) Then
  3245. Dim icell As Integer = DataGridViewMovies.CurrentCell.ColumnIndex
  3246. DataGridViewMovies.CurrentCell = DataGridViewMovies.Rows(i).Cells(icell)
  3247. DisplayMovie()
  3248. Return
  3249. End If
  3250. Next
  3251. End If
  3252. End Sub
  3253. Private Sub DataGridViewMovies_MouseLeave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DataGridViewMovies.MouseLeave
  3254. TooltipGridViewMovies1.Visible = False
  3255. TimerToolTip.Enabled = False
  3256. End Sub
  3257. Private Sub DataGridViewMovies_MouseHover(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DataGridViewMovies.MouseHover
  3258. TimerToolTip.Start()
  3259. End Sub
  3260. Private Sub DataGridViewMovies_MouseMove(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles DataGridViewMovies.MouseMove
  3261. Try
  3262. Dim MousePos As Point = DataGridViewMovies.PointToClient(Control.MousePosition)
  3263. Dim objHitTestInfo As DataGridView.HitTestInfo = DataGridViewMovies.HitTest (MousePos.X, MousePos.Y)
  3264. Dim MouseRowIndex As Integer = objHitTestInfo.RowIndex
  3265. TimerToolTip.Enabled = True
  3266. If MouseRowIndex > -1 Then
  3267. Dim Runtime As String = ""
  3268. Dim RatingRuntime As String = ""
  3269. Dim movietitle As String = DataGridViewMovies.Rows(MouseRowIndex).Cells("Title").Value.ToString
  3270. Dim movieYear As String = DataGridViewMovies.Rows(MouseRowIndex).Cells("Year").Value.ToString
  3271. Dim Rating As String = "Rating: " & DataGridViewMovies.Rows(MouseRowIndex).Cells("Rating").Value.ToString.FormatRating
  3272. If DataGridViewMovies.Rows(MouseRowIndex).Cells("Runtime").Value.ToString.Length > 3 Then
  3273. Runtime = "Runtime: " & DataGridViewMovies.Rows(MouseRowIndex).Cells("IntRuntime").Value.ToString
  3274. End If
  3275. RatingRuntime = Rating & " " & Runtime
  3276. Dim Plot As String = DataGridViewMovies.Rows(MouseRowIndex).Cells("Plot").Value.ToString
  3277. If objHitTestInfo.RowY > -1 Then
  3278. TooltipGridViewMovies1.Visible = Pref.ShowMovieGridToolTip
  3279. TooltipGridViewMovies1.Textinfo(Plot)
  3280. TooltipGridViewMovies1.TextLabelMovieYear(movieYear)
  3281. TooltipGridViewMovies1.TextMovieName(movietitle)
  3282. TooltipGridViewMovies1.TextLabelRatingRuntime(RatingRuntime)
  3283. TooltipGridViewMovies1.Left = MousePos.X + 10
  3284. TooltipGridViewMovies1.Top = MousePos.Y + TooltipGridViewMovies1.Height + 30
  3285. End If
  3286. End If
  3287. Catch
  3288. End Try
  3289. End Sub
  3290. Private Sub DataGridViewMovies_MouseUp(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles DataGridViewMovies.MouseUp
  3291. tsmiMov_PlayTrailer.Visible = True
  3292. tsmiMov_ViewMovieDbSetPage.Enabled = False
  3293. tsmiMov_ViewMovieDbMoviePage.Enabled = False
  3294. If e.Button = MouseButtons.Right Then
  3295. Dim multiselect As Boolean = False
  3296. 'If more than one movie is selected, check if right-click is on the selection.
  3297. If DataGridViewMovies.SelectedRows.Count > 1 Then
  3298. multiselect = True
  3299. End If
  3300. 'Otherwise, bring up the context menu for a single movie
  3301. If multiselect = True Then
  3302. tsmiMov_MovieName.BackColor = Color.Orange
  3303. tsmiMov_MovieName.Text = "Multisave Mode"
  3304. tsmiMov_MovieName.Font = New Font("Arial", 10, FontStyle.Bold)
  3305. tsmiMov_PlayTrailer.Visible = False 'multisave mode the "Play Trailer' is always hidden
  3306. Else
  3307. Try
  3308. 'update context menu with movie name & also if we show the 'Play Trailer' menu item
  3309. tsmiMov_MovieName.BackColor = Color.Honeydew
  3310. tsmiMov_MovieName.Text = "'" & DataGridViewMovies.SelectedCells(NFO_INDEX+4).Value.ToString & "'"
  3311. tsmiMov_MovieName.Font = New Font("Arial", 10, FontStyle.Bold)
  3312. Dim movie As Data_GridViewMovie = (From f In oMovies.Data_GridViewMovieCache Where f.fullpathandfilename = DataGridViewMovies.selectedCells(NFO_INDEX).Value.ToString).ToList(0)
  3313. tsmiMov_PlayTrailer.Visible = Not movie.MissingTrailer
  3314. tsmiMov_ViewMovieDbSetPage.Enabled = Not IsNothing(workingMovie.MovieSet) AndAlso Integer.TryParse(movie.MovieSet.MovieSetId,Nothing)
  3315. tsmiMov_ViewMovieDbMoviePage.Enabled = Integer.TryParse(workingMovie.tmdbid,Nothing) And Not workingMovie.tmdbid=""
  3316. Catch
  3317. End Try
  3318. End If
  3319. End If
  3320. End Sub
  3321. #End Region ' DataGridViewMovies Events
  3322. Private Function Mov_MissingMovie(ByVal qrylst As List(Of Data_GridViewMovie)) As Boolean
  3323. Dim missingstr As String
  3324. Dim Filepathandname As String
  3325. Filepathandname = qrylst(0).fullpathandfilename.Replace(".nfo","")
  3326. missingstr = "Video file Missing" & vbCrLf & Filepathandname & vbCrLf & "Do you wish to remove from database?"
  3327. If MsgBox(missingstr,MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then
  3328. Mov_RemoveMovie()
  3329. Return True
  3330. End If
  3331. Return False
  3332. End Function
  3333. Private Sub TextBox1_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyUp
  3334. Try
  3335. If filterOverride = False Then
  3336. If TextBox1.Text.Length > 0 Then
  3337. TextBox1.BackColor = Color.Pink
  3338. Else
  3339. TextBox1.BackColor = Color.White
  3340. End If
  3341. TextBox1.Refresh()
  3342. Call Mc.clsGridViewMovie.mov_FiltersAndSortApply(Me)
  3343. End If
  3344. Catch ex As Exception
  3345. ExceptionHandler.LogError(ex)
  3346. End Try
  3347. End Sub
  3348. Private Sub TabControl2_MouseWheel(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles TabControl2.MouseWheel
  3349. Try
  3350. If TabControl2.SelectedIndex = 1 Then
  3351. mouseDelta = e.Delta / 120
  3352. Try
  3353. tpMovWall.AutoScrollPosition = New Point(0, tpMovWall.VerticalScroll.Value - (mouseDelta * 30))
  3354. Catch ex As Exception
  3355. #If SilentErrorScream Then
  3356. Throw ex
  3357. #End If
  3358. End Try
  3359. End If
  3360. Catch ex As Exception
  3361. ExceptionHandler.LogError(ex)
  3362. End Try
  3363. End Sub
  3364. Private Sub TabControl2_Selecting(ByVal sender As Object, ByVal e As CancelEventArgs) Handles TabControl2.Selecting
  3365. Dim tab As String = TabControl2.SelectedTab.Text
  3366. If tab.ToLower = "movie preferences" Then
  3367. e.Cancel = True
  3368. OpenPreferences(1)
  3369. End If
  3370. End Sub
  3371. Private Sub TabControl2_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TabControl2.SelectedIndexChanged
  3372. mov_PreferencesDisplay()
  3373. Dim tempstring As String = ""
  3374. Dim tab As String = TabControl2.SelectedTab.Name
  3375. If tab <> tpMovMain.Name And tab <> tpMovFolders.Name And tab <> tpMovStubs.Name Then
  3376. 'If tab <> "Main Browser" And tab <> "Folders" And tab <> "Movie Preferences" And tab <> "Media Stubs" Then
  3377. If workingMovieDetails Is Nothing And movieFolders.Count = 0 And Pref.offlinefolders.Count = 0 Then
  3378. Me.TabControl2.SelectedIndex = currentTabIndex
  3379. MsgBox("There are no movies in your list to work on" & vbCrLf & "Add movie folders in the Folders Tab" & vbCrLf & "Then select the ""Search For New Movies"" Tab")
  3380. Exit Sub
  3381. ElseIf workingMovieDetails Is Nothing And movieFolders.Count > 0 Then 'And tab <> "Search for new movies" Then
  3382. Me.TabControl2.SelectedIndex = currentTabIndex
  3383. If oMovies.MovieCache.Count > 0 Then
  3384. MsgBox("No Movie is selected")
  3385. Exit Sub
  3386. Else
  3387. MsgBox("There are no movies in your list to work on" & vbCrLf & "If The Folders You Have Added In The" & vbCrLf & "Preferences Menu Contain Movie Files" & vbCrLf & "Then select the ""Search For New Movies"" Tab")
  3388. Exit Sub
  3389. End If
  3390. End If
  3391. Else
  3392. currentTabIndex = Me.TabControl2.SelectedIndex
  3393. End If
  3394. If tab = tpMovWebBrowser.Name Then 'Movie WebBrowser tab.
  3395. 'If tab = "" Then
  3396. If workingMovieDetails.fullmoviebody.imdbid <> Nothing OrElse workingMovieDetails.fullmoviebody.tmdbid <> "" Then
  3397. Dim weburl As String = ""
  3398. Dim TMDB As String = workingMovieDetails.fullmoviebody.tmdbid
  3399. Dim IMDB As String = workingMovieDetails.fullmoviebody.imdbid
  3400. Dim TMDBLan As List(Of String) = Utilities.GetTmdbLanguage(Pref.TMDbSelectedLanguageName)
  3401. If (IMDB <> "" And IMDB <> "0") AndAlso TMDB <> "" Then
  3402. Dim tpi As Integer = tpMovWebBrowser.ImageIndex
  3403. If tpi = 1 Then
  3404. weburl = "https://www.themoviedb.org/movie/" & TMDB & "?language=" & TMDBLan(0) 'de"
  3405. Else
  3406. weburl = "http://www.imdb.com/title/" & IMDB & "/"
  3407. End If
  3408. ElseIf (IMDB <> "" And IMDB <> "0") AndAlso TMDB = "" Then
  3409. weburl = "http://www.imdb.com/title/" & IMDB & "/"
  3410. ElseIf IMDB = "0" AndAlso TMDB <> "" Then
  3411. weburl = "https://www.themoviedb.org/movie/" & TMDB & "?language=" & TMDBLan(0) 'de"
  3412. End If
  3413. If Pref.externalbrowser = True Then
  3414. Me.TabControl2.SelectedIndex = currentTabIndex
  3415. 'AnotherPhil bug fix - If the default browser is <goz> IE <goz/> then not stating the exe throws an exception
  3416. OpenUrl(weburl)
  3417. Else
  3418. Try
  3419. currentTabIndex = TabControl2.SelectedIndex
  3420. WebBrowser2.Hide()
  3421. WebBrowser2.Navigate("about:blank")
  3422. Do Until WebBrowser2.ReadyState = WebBrowserReadyState.Complete
  3423. Application.DoEvents()
  3424. System.Threading.Thread.Sleep(100)
  3425. Loop
  3426. WebBrowser2.Show()
  3427. If IsNothing(WebBrowser2.Url) OrElse WebBrowser2.Url.AbsoluteUri.ToLower.ToString <> weburl Then
  3428. WebBrowser2.Stop()
  3429. WebBrowser2.ScriptErrorsSuppressed = True
  3430. WebBrowser2.Navigate(weburl)
  3431. currentTabIndex = TabControl2.SelectedIndex
  3432. End If
  3433. Catch
  3434. WebBrowser2.Stop()
  3435. WebBrowser2.ScriptErrorsSuppressed = True
  3436. WebBrowser2.Navigate(weburl)
  3437. End Try
  3438. WebBrowser2.Focus()
  3439. End If
  3440. Else
  3441. MsgBox("No IMDB or TMDB ID is available for this movie")
  3442. End If
  3443. ElseIf tab = tpMovMain.Name Then 'Movie Main Browser tab
  3444. 'ElseIf tab = "Main Browser" Then
  3445. 'Need to update displayed movies list as user may have invalidated it by have a 'missing...' filter selected and assigning one or more missing items
  3446. currentTabIndex = TabControl2.SelectedIndex
  3447. UpdateFilteredList()
  3448. ElseIf tab = tpMovFileDetails.Name Then 'Movie File Details tab
  3449. 'ElseIf tab.ToLower = "file details" Then
  3450. currentTabIndex = TabControl2.SelectedIndex
  3451. If TextBox8.Text = "" Then Call util_FileDetailsGet()
  3452. ElseIf tab = tpMovFanart.Name Then 'Movie Fanart tab
  3453. 'ElseIf tab.ToLower = "fanart" Then
  3454. Dim isrootfolder As Boolean = False
  3455. If Pref.movrootfoldercheck Then
  3456. For Each moviefolder In movieFolders
  3457. Dim movfolder As String = workingMovieDetails.fileinfo.fullpathandfilename.Replace("\" & workingMovieDetails.fileinfo.filename, "")
  3458. If moviefolder.rpath = movfolder Then
  3459. isrootfolder = True 'Check movie isn't in a rootfolder, if so, disable extrathumbs option from displaying
  3460. Exit For
  3461. End If
  3462. Next
  3463. End If
  3464. If String.IsNullOrEmpty(tb_MovFanartScrnShtTime.Text) Then tb_MovFanartScrnShtTime.Text = "50"
  3465. GroupBoxFanartExtrathumbs.Enabled = Not isrootfolder 'Or usefoldernames Or allfolders ' Visible 'hide or show fanart/extrathumbs depending of if we are using foldenames or not (extrathumbs needs foldernames to be used)
  3466. UpdateMissingFanartNav()
  3467. If Panel2.Controls.Count = 0 Then
  3468. btn_MovFanartScrnSht.Visible = False
  3469. tb_MovFanartScrnShtTime.Visible = False
  3470. Label2.Visible = False
  3471. Call mov_FanartLoad()
  3472. End If
  3473. If Panel2.Controls.Count = 1 AndAlso Panel2.Controls().Item(0).GetType Is GetType(Label) Then
  3474. btn_MovFanartScrnSht.Visible = True
  3475. tb_MovFanartScrnShtTime.Visible = True
  3476. Label2.Visible = True
  3477. End If
  3478. currentTabIndex = TabControl2.SelectedIndex
  3479. If Panel2.Controls.Count > 1 Then EnableFanartScrolling()
  3480. ElseIf tab = tpMovPoster.Name Then 'Poster Tab
  3481. 'ElseIf tab.ToLower = "posters" Then
  3482. currentTabIndex = TabControl2.SelectedIndex
  3483. gbMoviePostersAvailable.Refresh()
  3484. btnMovPosterToggle.Visible = workingMovieDetails.fullmoviebody.MovieSet.MovieSetId <> ""
  3485. UpdateMissingPosterNav()
  3486. If Pref.MovPosterTabTMDBSelect Then btn_TMDb_posters.PerformClick()
  3487. ElseIf tab = tpMovChange.Name Then 'Change Movie
  3488. 'ElseIf tab.ToLower = "change movie" Then
  3489. Call mov_ChangeMovieSetup(MovieSearchEngine)
  3490. currentTabIndex = TabControl2.SelectedIndex
  3491. ElseIf tab = tpMovWall.Name Then 'Wall Tab
  3492. 'ElseIf tab.ToLower = "wall" Then
  3493. Call mov_WallSetup()
  3494. ElseIf tab = tpMovSetsTags.Name Then 'This will become obsolete
  3495. 'ElseIf tab.ToLower = "moviesets & tags" Then
  3496. Call MovieSetsAndTagsSetup()
  3497. ElseIf tab = tpMovSets.Name Then 'Movie Sets & Tags tab
  3498. 'ElseIf tab.ToLower = "moviesets & tags" Then
  3499. Call MovieSetsAndTagsSetup() '' Change this to split Movie Sets and Tags
  3500. ElseIf tab = tpMovTags.Name Then 'Movie Sets & Tags tab
  3501. 'ElseIf tab.ToLower = "moviesets & tags" Then
  3502. Call MovieSetsAndTagsSetup() '' Change this to split Movie Sets and Tags
  3503. ElseIf tab = tpMovFanartTv.Name Then 'Fanart.Tv tab
  3504. 'ElseIf tab.ToLower = "fanart.tv"
  3505. UcFanartTv1.ucFanartTv_Refresh(workingMovieDetails)
  3506. ElseIf tab = tpMovTable.Name Then 'Table tab
  3507. 'ElseIf tab.ToLower = "table" Then
  3508. currentTabIndex = TabControl2.SelectedIndex
  3509. Call mov_TableSetup()
  3510. Else
  3511. currentTabIndex = TabControl2.SelectedIndex
  3512. End If
  3513. End Sub
  3514. Private Sub TabControl2_Selecting(ByVal sender As System.Object, ByVal e As System.Windows.Forms.TabControlCancelEventArgs) Handles TabControl2.Selecting
  3515. Try
  3516. If Not IsNothing(messbox) AndAlso messbox.visible Then e.Cancel = True
  3517. Dim selOption = cbFilterGeneral.Text.RemoveAfterMatch
  3518. If selOption.IndexOf("Missing from set")=0 Then e.Cancel = True
  3519. Catch
  3520. End Try
  3521. End Sub
  3522. Private Sub TabControl2_MouseClick(ByVal sender As Object, ByVal e As MouseEventArgs) Handles TabControl2.MouseClick
  3523. If e.Button = Windows.Forms.MouseButtons.Right Then
  3524. For index As Integer = 0 To TabControl2.TabCount - 1 Step 1
  3525. If TabControl2.GetTabRect(index).Contains(e.Location) Then
  3526. If index = 8 Then
  3527. Dim tpi As Integer = tpMovWebBrowser.ImageIndex
  3528. If tpi = 0 Then
  3529. tpMovWebBrowser.ImageIndex = 1
  3530. Else
  3531. tpMovWebBrowser.ImageIndex = 0
  3532. End If
  3533. tpMovWebBrowser.Refresh()
  3534. End If
  3535. Exit For
  3536. End If
  3537. Next index
  3538. End If
  3539. End Sub
  3540. Private Sub mov_ChangeMovieSetup(ByVal engine As String)
  3541. Dim tempstring As String = ""
  3542. Dim isroot As Boolean = Pref.GetRootFolderCheck(workingMovieDetails.fileinfo.fullpathandfilename)
  3543. If Pref.usefoldernames = False OrElse isroot Then
  3544. tempstring = Utilities.RemoveFilenameExtension(IO.Path.GetFileName(workingMovieDetails.fileinfo.fullpathandfilename))
  3545. Else
  3546. tempstring = Utilities.GetLastFolder(workingMovieDetails.fileinfo.fullpathandfilename)
  3547. End If
  3548. If workingMovieDetails.fileinfo.fullpathandfilename.ToLower.IndexOf("\video_ts\") <> -1 Then
  3549. tempstring = Utilities.GetLastFolder(workingMovieDetails.fileinfo.fullpathandfilename)
  3550. End If
  3551. Dim url As String
  3552. If engine = "imdb" Then
  3553. url = Pref.imdbmirror & "find?s=tt&q=" & Utilities.CleanFileName(tempstring)
  3554. Else
  3555. url = "http://www.themoviedb.org/search?query=" & Utilities.CleanFileName(tempstring)
  3556. End If
  3557. Dim uri As New Uri(url)
  3558. WebBrowser1.Stop()
  3559. WebBrowser1.ScriptErrorsSuppressed = True
  3560. WebBrowser1.Navigate(uri.AbsoluteUri)
  3561. WebBrowser1.Refresh()
  3562. Panel2.Visible = True
  3563. End Sub
  3564. Public Sub util_OpenFolder(ByVal path As String)
  3565. Dim tempstring As String = ""
  3566. Dim action As String = String.Empty
  3567. Dim errors As String = String.Empty
  3568. Try
  3569. If path <> "" Then
  3570. tempstring = path
  3571. Try
  3572. If Not tempstring.ToLower.Contains("nfo") Then
  3573. errors = "Trying to open Folder :- " & tempstring
  3574. action = "Command - ""Call Shell(""explorer """ & tempstring & ", AppWinStyle.NormalFocus)"""
  3575. Call Shell("explorer " & """" & tempstring & """", AppWinStyle.NormalFocus) 'opens the selected folder showing contents, no focus on any file.
  3576. Else
  3577. errors = "Trying to open Folder :- " & tempstring
  3578. action = "Command - ""Call Shell(""explorer /select,""" & tempstring & ", AppWinStyle.NormalFocus)"""
  3579. Call Shell("explorer /select," & """" & tempstring & """", AppWinStyle.NormalFocus) 'this shows the item as selected provided as tempstring i.e. a folder or a file (.nfo)
  3580. End If
  3581. Catch ex As Exception
  3582. MsgBox("Can't open folder :- " & path)
  3583. Call util_ErrorLog(action, errors)
  3584. End Try
  3585. Else
  3586. MsgBox("No Folder To Open")
  3587. End If
  3588. Catch
  3589. MsgBox("No Folder To Open")
  3590. End Try
  3591. End Sub
  3592. Private Sub mov_FanartLoad()
  3593. rbMovFanart.Checked = True
  3594. MovFanartToggle = False
  3595. btnMovFanartToggle.Visible = workingMovieDetails.fullmoviebody.MovieSet.MovieSetId <> ""
  3596. Dim isfanartpath As String = workingMovieDetails.fileinfo.fanartpath
  3597. Dim isvideotspath As String = If(workingMovieDetails.fileinfo.videotspath = "", "", workingMovieDetails.fileinfo.videotspath + "fanart.jpg")
  3598. Dim movfanartpath As String = Utilities.DefaultFanartPath
  3599. If isfanartpath <> Nothing Or isvideotspath <> "" Then
  3600. Try
  3601. If IO.File.Exists(isvideotspath) Then
  3602. movfanartpath = isvideotspath
  3603. ElseIf IO.File.Exists(isfanartpath) Then
  3604. movfanartpath = isfanartpath
  3605. End If
  3606. util_ImageLoad(PictureBox2, movfanartpath, Utilities.DefaultFanartPath)
  3607. If movfanartpath = "" Then
  3608. lblMovFanartWidth.Text = ""
  3609. lblMovFanartHeight.Text = ""
  3610. Else
  3611. lblMovFanartWidth.Text = PictureBox2.Image.Width
  3612. lblMovFanartHeight.Text = PictureBox2.Image.Height
  3613. End If
  3614. Catch ex As Exception
  3615. End Try
  3616. End If
  3617. MovFanartDisplay()
  3618. End Sub
  3619. Public Sub MovFanartClear()
  3620. Try
  3621. For i = Panel2.Controls.Count - 1 To 0 Step -1
  3622. Panel2.Controls.RemoveAt(i)
  3623. Next
  3624. Catch
  3625. End Try
  3626. End Sub
  3627. Public Sub MovFanartDisplay(Optional ByVal SetId As String = "")
  3628. Me.Refresh()
  3629. fanartArray.Clear()
  3630. messbox = New frmMessageBox("", "Retrieving Fanart...", "Please wait...")
  3631. messbox.Show()
  3632. messbox.Refresh()
  3633. Dim tmdb As New TMDb
  3634. If SetId = "" Then
  3635. tmdb.Imdb = If(workingMovieDetails.fullmoviebody.imdbid.Contains("tt"), workingMovieDetails.fullmoviebody.imdbid, "")
  3636. tmdb.TmdbId = workingMovieDetails.fullmoviebody.tmdbid
  3637. Try
  3638. fanartArray.AddRange(tmdb.McFanart)
  3639. Catch
  3640. End Try
  3641. Else
  3642. tmdb.SetId = SetId
  3643. Try
  3644. fanartArray.AddRange(tmdb.McSetFanart)
  3645. Catch
  3646. End Try
  3647. End If
  3648. messbox.TextBox2.Text = "Setting up display...."
  3649. messbox.Refresh()
  3650. Try
  3651. If fanartArray.Count > 0 Then
  3652. Dim MovFanartPicBox As New List(Of FanartPicBox)
  3653. Dim location As Integer = 0
  3654. Dim itemcounter As Integer = 0
  3655. For Each item In fanartArray
  3656. Dim thispicbox As New FanartPicBox
  3657. fanartBoxes() = New PictureBox()
  3658. With fanartBoxes
  3659. .Location = New Point(0, location)
  3660. If fanartArray.Count > 2 Then
  3661. .Width = 410
  3662. .Height = 233
  3663. Else
  3664. .Width = 424
  3665. .Height = 243
  3666. End If
  3667. .SizeMode = PictureBoxSizeMode.Zoom
  3668. .Visible = True
  3669. .BorderStyle = BorderStyle.Fixed3D
  3670. .Name = "moviefanart" & itemcounter.ToString
  3671. AddHandler fanartBoxes.DoubleClick, AddressOf util_ZoomImage2
  3672. End With
  3673. thispicbox.pbox = fanartBoxes
  3674. thispicbox.imagepath = item.ldurl
  3675. MovFanartPicBox.Add(thispicbox)
  3676. Application.DoEvents()
  3677. If fanartArray.Count > 2 Then
  3678. fanartCheckBoxes() = New RadioButton()
  3679. With fanartCheckBoxes
  3680. .BringToFront()
  3681. .Location = New Point(199, location + 229)
  3682. .Name = "moviefanartcheckbox" & itemcounter.ToString
  3683. End With
  3684. resLabels = New Label()
  3685. With resLabels
  3686. .BringToFront()
  3687. .Location = New Point(0, location + 235)
  3688. .Name = "label" & itemcounter.ToString
  3689. .Text = "(" & item.hdwidth & " x " & item.hdheight & ") (" & item.ldwidth & " x " & item.ldheight & ")"
  3690. .Width = 200
  3691. End With
  3692. votelabels = New Label()
  3693. With votelabels
  3694. .BringToFront()
  3695. .Location = New Point(300, location + 235)
  3696. .Name = "votelabel" & itemcounter.ToString
  3697. .Text = "Votes: " & item.votes.ToString
  3698. '.Width = 200
  3699. End With
  3700. itemcounter += 1
  3701. location += 260
  3702. Else
  3703. fanartCheckBoxes() = New RadioButton()
  3704. With fanartCheckBoxes
  3705. .BringToFront()
  3706. .Location = New Point(199, location + 243)
  3707. .Name = "moviefanartcheckbox" & itemcounter.ToString
  3708. .Text = ""
  3709. End With
  3710. resLabels = New Label()
  3711. With resLabels
  3712. .BringToFront()
  3713. .Location = New Point(0, location + 249)
  3714. .Name = "label" & itemcounter.ToString
  3715. .Text = "(" & item.hdwidth & " x " & item.hdheight & ") (" & item.ldwidth & " x " & item.ldheight & ")"
  3716. .Width = 200
  3717. End With
  3718. votelabels = New Label()
  3719. With votelabels
  3720. .BringToFront()
  3721. .Location = New Point(300, location + 249)
  3722. .Name = "votelabel" & itemcounter.ToString
  3723. .Text = "Votes: " & item.votes.ToString
  3724. .Width = 200
  3725. End With
  3726. itemcounter += 1
  3727. location += 275
  3728. End If
  3729. Me.Panel2.Controls.Add(fanartBoxes())
  3730. Me.Panel2.Controls.Add(fanartCheckBoxes())
  3731. Me.Panel2.Controls.Add(resLabels)
  3732. Me.Panel2.Controls.Add(votelabels)
  3733. Application.DoEvents()
  3734. Next
  3735. Me.Panel2.Refresh()
  3736. Me.Refresh()
  3737. If MovFanartPicBox.Count > 0 Then
  3738. messbox.Close()
  3739. If Not ImgBw.IsBusy Then
  3740. ToolStripStatusLabel2.Text = "Starting Download of Images..."
  3741. ToolStripStatusLabel2.Visible = True
  3742. ImgBw.RunWorkerAsync({MovFanartPicBox, 0, MovFanartPicBox.Count, Me.Panel2})
  3743. End If
  3744. End If
  3745. EnableFanartScrolling()
  3746. Me.Panel2.Refresh()
  3747. Me.Refresh
  3748. Else
  3749. Dim mainlabel2 As Label
  3750. mainlabel2 = New Label
  3751. With mainlabel2
  3752. .Location = New Point(0, 100)
  3753. .AutoSize = False
  3754. .TextAlign = ContentAlignment.MiddleCenter
  3755. .Width = 410
  3756. .Height = 400
  3757. .Font = New System.Drawing.Font("Arial", 15, FontStyle.Bold)
  3758. .Text = "No Fanart Was Found At" & Environment.NewLine & "www.themoviedb.org For This Movie"
  3759. End With
  3760. Me.Panel2.Controls.Add(mainlabel2)
  3761. End If
  3762. messbox.Close()
  3763. Catch ex As Exception
  3764. #If SilentErrorScream Then
  3765. Throw ex
  3766. #End If
  3767. If Not IsNothing(messbox) Then messbox.Close()
  3768. End Try
  3769. End Sub
  3770. Sub EnableFanartScrolling()
  3771. Try
  3772. Panel2.Focus()
  3773. 'Dim rb As RadioButton = Panel2.Controls("moviefanartcheckbox0")
  3774. 'If rb Is Nothing Then Exit Sub
  3775. 'rb.Select() 'Causes RadioButtons checked state to toggle
  3776. 'rb.Checked = Not rb.Checked 'Undo unwanted checked state toggling
  3777. Catch
  3778. End Try
  3779. End Sub
  3780. Private Sub util_ZoomImage2(ByVal sender As Object, ByVal e As EventArgs)
  3781. Dim tempstring As String = sender.name
  3782. Dim tempstring2 As String = String.Empty
  3783. Dim tempint As Integer = 0
  3784. If tempstring.IndexOf("poster") <> -1 Then
  3785. tempstring = tempstring.Replace("poster", "")
  3786. tempint = Convert.ToDecimal(tempstring)
  3787. If tempstring2 = Nothing Then
  3788. tempint = Convert.ToDecimal(tempstring)
  3789. tempint = tempint + ((currentPage - 1) * 10)
  3790. tempstring2 = posterArray(tempint).hdUrl
  3791. End If
  3792. End If
  3793. If tempstring.IndexOf("moviefanart") <> -1 Then
  3794. tempstring = tempstring.Replace("moviefanart", "")
  3795. tempint = Convert.ToDecimal(tempstring)
  3796. tempstring2 = fanartArray(tempint).hdUrl
  3797. End If
  3798. If tempstring.IndexOf("tvfanart") <> -1 Then
  3799. tempstring = tempstring.Replace("tvfanart", "")
  3800. tempint = Convert.ToDecimal(tempstring)
  3801. tempstring2 = listOfTvFanarts(tempint).bigUrl
  3802. End If
  3803. Dim buffer(4000000) As Byte
  3804. Dim size As Integer = 0
  3805. Dim bytesRead As Integer = 0
  3806. bigPanel = New Panel
  3807. With bigPanel
  3808. .Width = Me.Width
  3809. .Height = Me.Height
  3810. .BringToFront()
  3811. .Dock = DockStyle.Fill
  3812. End With
  3813. Me.Controls.Add(bigPanel)
  3814. bigPanel.BringToFront()
  3815. bigPictureBox = New PictureBox()
  3816. With bigPictureBox
  3817. .Location = New Point(0, 0)
  3818. .Width = bigPanel.Width
  3819. .Height = bigPanel.Height
  3820. .SizeMode = PictureBoxSizeMode.Zoom
  3821. .WaitOnLoad = True
  3822. .Visible = False
  3823. .BorderStyle = BorderStyle.Fixed3D
  3824. AddHandler bigPictureBox.DoubleClick, AddressOf util_PicBoxClose
  3825. .Dock = DockStyle.Fill
  3826. End With
  3827. Try
  3828. util_ImageLoad(bigPictureBox, tempstring2, "")
  3829. Catch ex As Exception
  3830. #If SilentErrorScream Then
  3831. Throw ex
  3832. #End If
  3833. End Try
  3834. Me.bigPanel.Controls.Add(bigPictureBox)
  3835. Dim bigpanellabel As Label
  3836. bigpanellabel = New Label
  3837. With bigpanellabel
  3838. .Location = New Point(20, 200)
  3839. .Width = 150
  3840. .Height = 50
  3841. .Visible = True
  3842. .Text = "Double Click Image To" & vbCrLf & "Return To Browser"
  3843. End With
  3844. Me.bigPanel.Controls.Add(bigpanellabel)
  3845. bigpanellabel.BringToFront()
  3846. Application.DoEvents()
  3847. Me.Refresh()
  3848. Try
  3849. If bigPictureBox.Image Is Nothing Then
  3850. tempstring2 = posterArray(tempint).ldUrl
  3851. util_ImageLoad(bigPictureBox, tempstring2, "")
  3852. End If
  3853. Catch ex As Exception
  3854. #If SilentErrorScream Then
  3855. Throw ex
  3856. #End If
  3857. End Try
  3858. Try
  3859. If bigPictureBox.Image.Width < 20 Then
  3860. tempstring2 = posterArray(tempint).ldUrl
  3861. util_ImageLoad(bigPictureBox, tempstring2, "")
  3862. End If
  3863. Catch ex As Exception
  3864. #If SilentErrorScream Then
  3865. Throw ex
  3866. #End If
  3867. End Try
  3868. Dim sizex As Integer = bigPictureBox.Image.Width
  3869. Dim sizey As Integer = bigPictureBox.Image.Height
  3870. tempstring = "Full Image Resolution :- " & sizex.ToString & " x " & sizey.ToString
  3871. Dim resolutionlbl As New Label
  3872. With resolutionlbl
  3873. .Location = New Point(20, 450)
  3874. .Width = 180
  3875. .Text = tempstring
  3876. .BackColor = Color.Transparent
  3877. End With
  3878. Me.bigPanel.Controls.Add(resolutionlbl)
  3879. resolutionlbl.BringToFront()
  3880. bigPictureBox.Visible = True
  3881. bigPictureBox.Refresh()
  3882. End Sub
  3883. Private Sub SaveFanart(hd As Boolean, Optional clipbrd As Boolean = False)
  3884. Try
  3885. If ImgBw.Isbusy Then
  3886. ImgBw.CancelAsync()
  3887. Do Until Not ImgBw.IsBusy
  3888. Application.DoEvents()
  3889. Loop
  3890. End If
  3891. Try
  3892. messbox.Close()
  3893. Catch
  3894. End Try
  3895. messbox = New frmMessageBox("", "Downloading Fanart...", "")
  3896. messbox.Show()
  3897. messbox.Refresh()
  3898. Application.DoEvents()
  3899. System.Windows.Forms.Cursor.Current = Cursors.WaitCursor
  3900. Dim tempstring As String = String.Empty
  3901. Dim tempint As Integer = 0
  3902. Dim tempstring2 As String = String.Empty
  3903. Dim allok As Boolean = False
  3904. If clipbrd Then
  3905. tempstring2 = PictureBox2.Tag.tostring
  3906. allok = True
  3907. Else
  3908. 'Find selected fanart, if any
  3909. For Each button As Control In Me.Panel2.Controls
  3910. If button.Name.IndexOf("checkbox") <> -1 Then
  3911. Dim b1 As RadioButton = CType(button, RadioButton)
  3912. If b1.Checked = True Then
  3913. tempstring = b1.Name
  3914. tempstring = tempstring.Replace("moviefanartcheckbox", "")
  3915. tempint = Convert.ToDecimal(tempstring)
  3916. If hd Then
  3917. tempstring2 = fanartArray(tempint).hdUrl
  3918. Else
  3919. tempstring2 = fanartArray(tempint).ldUrl
  3920. End If
  3921. allok = True
  3922. Exit For
  3923. End If
  3924. End If
  3925. Next
  3926. End If
  3927. If Not allok Then
  3928. MsgBox("No Fanart Is Selected")
  3929. Else
  3930. Try
  3931. If Not MovFanartToggle Then
  3932. Dim issavefanart As Boolean = Pref.savefanart
  3933. Dim FanartOrExtraPath As String = mov_FanartORExtrathumbPath
  3934. Dim xtra As Boolean = False
  3935. Dim extrfanart As Boolean = False
  3936. If rbMovThumb1.Checked Or rbMovThumb2.Checked Or rbMovThumb3.Checked Or rbMovThumb4.Checked Or rbMovThumb5.Checked Then xtra = True
  3937. Pref.savefanart = True
  3938. If xtra Then extrfanart = Movie.SaveFanartImageToCacheAndPath(tempstring2, FanartOrExtraPath)
  3939. If xtra OrElse Movie.SaveFanartImageToCacheAndPath(tempstring2, FanartOrExtraPath) Then
  3940. If Not xtra Then
  3941. Dim paths As List(Of String) = Pref.GetfanartPaths(workingMovieDetails.fileinfo.fullpathandfilename,If(workingMovieDetails.fileinfo.videotspath <>"",workingMovieDetails.fileinfo.videotspath,""))
  3942. Movie.SaveFanartImageToCacheAndPaths(tempstring2, paths)
  3943. End If
  3944. Pref.savefanart = issavefanart
  3945. mov_DisplayFanart()
  3946. util_ImageLoad(PbMovieFanArt, workingMovieDetails.fileinfo.fanartpath, Utilities.DefaultFanartPath)
  3947. Dim video_flags = VidMediaFlags(workingMovieDetails.filedetails, workingMovieDetails.fullmoviebody.title.ToLower.Contains("3d"))
  3948. movieGraphicInfo.OverlayInfo(PbMovieFanArt, ratingtxt.Text, video_flags, workingMovie.DisplayFolderSize)
  3949. For Each paths In Pref.offlinefolders
  3950. Dim offlinepath As String = paths & "\"
  3951. If workingMovieDetails.fileinfo.fanartpath.IndexOf(offlinepath) <> -1 Then
  3952. Dim mediapath As String
  3953. mediapath = Utilities.GetFileName(workingMovieDetails.fileinfo.fullpathandfilename)
  3954. messbox.TextBox1.Text = "Creating Offline Movie..."
  3955. Call mov_OfflineDvdProcess(workingMovieDetails.fileinfo.fullpathandfilename, workingMovieDetails.fullmoviebody.title, mediapath)
  3956. End If
  3957. Next
  3958. Else
  3959. util_ImageLoad(PictureBox2, Utilities.DefaultFanartPath, Utilities.DefaultFanartPath)
  3960. Pref.savefanart = issavefanart
  3961. End If
  3962. lblMovFanartWidth.Text = PictureBox2.Image.Width
  3963. lblMovFanartHeight.Text = PictureBox2.Image.Height
  3964. UpdateMissingFanart()
  3965. XbmcLink_UpdateArtwork
  3966. Else
  3967. Dim MovSetFanartSavePath As String = workingMovieDetails.fileinfo.movsetfanartpath
  3968. If MovSetFanartSavePath <> "" Then
  3969. Movie.SaveFanartImageToCacheAndPath(tempstring2, MovSetFanartSavePath)
  3970. MovPanel6Update()
  3971. util_ImageLoad(PictureBox2, MovSetFanartSavePath, Utilities.DefaultFanartPath)
  3972. Else
  3973. MsgBox("!! Problem formulating correct save location for Fanart" & vbCrLf & " Please check your settings")
  3974. End If
  3975. End If
  3976. Catch ex As WebException
  3977. MsgBox(ex.Message)
  3978. End Try
  3979. End If
  3980. Catch ex As Exception
  3981. ExceptionHandler.LogError(ex)
  3982. Finally
  3983. messbox.Close()
  3984. End Try
  3985. End Sub
  3986. Sub UpdateMissingFanart
  3987. oMovies.LoadMovie(workingMovieDetails.fileinfo.fullpathandfilename)
  3988. ProgState = ProgramState.ResettingFilters
  3989. Assign_FilterGeneral()
  3990. ProgState = ProgramState.Other
  3991. UpdateMissingFanartNav
  3992. End Sub
  3993. Sub UpdateMissingFanartNav
  3994. 'Default to selecting first row if non selected
  3995. If DataGridViewMovies.SelectedRows.Count=0 And DataGridViewMovies.Rows.Count>1 Then
  3996. DataGridViewMovies.Rows(0).Selected=True
  3997. End If
  3998. UpdateMissingFanartNextBtn
  3999. UpdateMissingFanartPrevBtn
  4000. UpdatelblFanartMissingCount
  4001. End Sub
  4002. Sub UpdatelblFanartMissingCount
  4003. Dim i As Integer = 0
  4004. Dim x As Integer = 0
  4005. While i<DataGridViewMovies.Rows.Count
  4006. Dim row As Data_GridViewMovie = DataGridViewMovies.DataSource(i)
  4007. If row.MissingFanart Then x = x + 1
  4008. i = i + 1
  4009. End While
  4010. lblFanartMissingCount.Text = x & " Missing"
  4011. lblFanartMissingCount.Visible = x <> 0
  4012. End Sub
  4013. Sub UpdateMissingFanartNextBtn
  4014. btnNextMissingFanart.Enabled = False
  4015. If DataGridViewMovies.SelectedRows.Count=0 Then Return
  4016. Dim i As Integer = DataGridViewMovies.SelectedRows(0).Index + 1
  4017. While i<DataGridViewMovies.Rows.Count
  4018. Dim row As Data_GridViewMovie = DataGridViewMovies.DataSource(i)
  4019. If row.MissingFanart Then
  4020. btnNextMissingFanart.Enabled = True
  4021. btnNextMissingFanart.Tag = i
  4022. Return
  4023. End If
  4024. i = i + 1
  4025. End While
  4026. btnNextMissingFanart.Visible = btnNextMissingFanart.Enabled
  4027. End Sub
  4028. Sub UpdateMissingFanartPrevBtn
  4029. btnPrevMissingFanart.Enabled = False
  4030. If DataGridViewMovies.SelectedRows.Count=0 Then Return
  4031. Dim i As Integer = DataGridViewMovies.SelectedRows(0).Index - 1
  4032. While i>=0
  4033. Dim row As Data_GridViewMovie = DataGridViewMovies.DataSource(i)
  4034. If row.MissingFanart Then
  4035. btnPrevMissingFanart.Enabled = True
  4036. btnPrevMissingFanart.Tag = i
  4037. Return
  4038. End If
  4039. i = i - 1
  4040. End While
  4041. btnPrevMissingFanart.Visible = btnPrevMissingFanart.Enabled
  4042. End Sub
  4043. Sub UpdateMissingPoster
  4044. oMovies.LoadMovie(workingMovieDetails.fileinfo.fullpathandfilename)
  4045. ProgState = ProgramState.ResettingFilters
  4046. Assign_FilterGeneral()
  4047. ProgState = ProgramState.Other
  4048. UpdateMissingPosterNav
  4049. End Sub
  4050. Sub UpdateMissingPosterNav
  4051. 'Default to selecting first row if non selected
  4052. If DataGridViewMovies.SelectedRows.Count=0 And DataGridViewMovies.Rows.Count>1 Then DataGridViewMovies.Rows(0).Selected=True
  4053. UpdateMissingPosterNextBtn
  4054. UpdateMissingPosterPrevBtn
  4055. UpdatelblPosterMissingCount
  4056. End Sub
  4057. Sub UpdatelblPosterMissingCount
  4058. Dim i As Integer = 0
  4059. Dim x As Integer = 0
  4060. While i<DataGridViewMovies.Rows.Count
  4061. Dim row As Data_GridViewMovie = DataGridViewMovies.DataSource(i)
  4062. If row.MissingPoster Then x = x + 1
  4063. i = i + 1
  4064. End While
  4065. lblPosterMissingCount.Text = x & " Missing"
  4066. lblPosterMissingCount.Visible = x <> 0
  4067. End Sub
  4068. Sub UpdateMissingPosterNextBtn
  4069. btnNextMissingPoster.Enabled = False
  4070. If DataGridViewMovies.SelectedRows.Count=0 Then Return
  4071. Dim i As Integer = DataGridViewMovies.SelectedRows(0).Index + 1
  4072. While i<DataGridViewMovies.Rows.Count
  4073. Dim row As Data_GridViewMovie = DataGridViewMovies.DataSource(i)
  4074. If row.MissingPoster Then
  4075. btnNextMissingPoster.Enabled = True
  4076. btnNextMissingPoster.Tag = i
  4077. Return
  4078. End If
  4079. i = i + 1
  4080. End While
  4081. btnNextMissingPoster.Visible = btnNextMissingPoster.Enabled
  4082. End Sub
  4083. Sub UpdateMissingPosterPrevBtn
  4084. btnPrevMissingPoster.Enabled = False
  4085. If DataGridViewMovies.SelectedRows.Count=0 Then Return
  4086. Dim i As Integer = DataGridViewMovies.SelectedRows(0).Index - 1
  4087. While i>=0
  4088. Dim row As Data_GridViewMovie = DataGridViewMovies.DataSource(i)
  4089. If row.MissingPoster Then
  4090. btnPrevMissingPoster.Enabled = True
  4091. btnPrevMissingPoster.Tag = i
  4092. Return
  4093. End If
  4094. i = i - 1
  4095. End While
  4096. btnPrevMissingPoster.Visible = btnPrevMissingPoster.Enabled
  4097. End Sub
  4098. Private Function util_ImageCrop(ByVal SrcBmp As Bitmap, ByVal NewSize As Size, ByVal StartPoint As Point) As Bitmap
  4099. If NewSize.Width < 1 Or NewSize.Height < 1 Then
  4100. Return SrcBmp
  4101. Exit Function
  4102. End If
  4103. Dim SrcRect As New Rectangle(StartPoint.X, StartPoint.Y, NewSize.Width, NewSize.Height)
  4104. Dim DestRect As New Rectangle(0, 0, NewSize.Width, NewSize.Height)
  4105. Dim DestBmp As New Bitmap(NewSize.Width, NewSize.Height, Imaging.PixelFormat.Format32bppArgb)
  4106. Dim g As Graphics = Graphics.FromImage(DestBmp)
  4107. g.DrawImage(SrcBmp, DestRect, SrcRect, GraphicsUnit.Pixel)
  4108. Return DestBmp
  4109. End Function ' Crop Image Function
  4110. Private Sub util_ImageCropTop()
  4111. If PictureBox2.Image Is Nothing Then Exit Sub
  4112. Dim imagewidth As Integer
  4113. Dim imageheight As Integer
  4114. imagewidth = PictureBox2.Image.Width
  4115. imageheight = PictureBox2.Image.Height
  4116. PictureBox2.Image = util_ImageCrop(PictureBox2.Image, New Size(imagewidth, imageheight - 1), New Point(0, 1)).Clone
  4117. PictureBox2.SizeMode = PictureBoxSizeMode.Zoom
  4118. End Sub
  4119. Private Sub util_ImageCropBottom()
  4120. If PictureBox2.Image Is Nothing Then Exit Sub
  4121. Dim imagewidth As Integer
  4122. Dim imageheight As Integer
  4123. imagewidth = PictureBox2.Image.Width
  4124. imageheight = PictureBox2.Image.Height
  4125. PictureBox2.Image = util_ImageCrop(PictureBox2.Image, New Size(imagewidth, imageheight - 1), New Point(0, 0)).Clone
  4126. PictureBox2.SizeMode = PictureBoxSizeMode.Zoom
  4127. End Sub
  4128. Private Sub util_ImageCropLeft()
  4129. If PictureBox2.Image Is Nothing Then Exit Sub
  4130. Dim imagewidth As Integer
  4131. Dim imageheight As Integer
  4132. imagewidth = PictureBox2.Image.Width
  4133. imageheight = PictureBox2.Image.Height
  4134. PictureBox2.Image = util_ImageCrop(PictureBox2.Image, New Size(imagewidth - 1, imageheight), New Point(1, 0)).Clone
  4135. PictureBox2.SizeMode = PictureBoxSizeMode.Zoom
  4136. End Sub
  4137. Private Sub util_ImageCropRight()
  4138. If PictureBox2.Image Is Nothing Then Exit Sub
  4139. Dim imagewidth As Integer
  4140. Dim imageheight As Integer
  4141. thumbedItsMade = True
  4142. imagewidth = PictureBox2.Image.Width
  4143. imageheight = PictureBox2.Image.Height
  4144. PictureBox2.Image = util_ImageCrop(PictureBox2.Image, New Size(imagewidth - 1, imageheight), New Point(0, 0)).Clone
  4145. PictureBox2.SizeMode = PictureBoxSizeMode.Zoom
  4146. End Sub
  4147. Private Sub mov_PosterPanelClear()
  4148. For i = panelAvailableMoviePosters.Controls.Count - 1 To 0 Step -1
  4149. panelAvailableMoviePosters.Controls.RemoveAt(i)
  4150. Next
  4151. End Sub
  4152. Private Sub mov_PosterInitialise()
  4153. pageCount = 0
  4154. currentPage = 1
  4155. cbMoviePosterSaveLoRes.Enabled = False
  4156. btnPosterTabs_SaveImage.Enabled = False
  4157. mov_PosterPanelClear()
  4158. If Pref.maximumthumbs < 1 Then
  4159. Else
  4160. Pref.maximumthumbs = 10
  4161. End If
  4162. btnPosterTabs_SaveImage.Enabled = False
  4163. cbMoviePosterSaveLoRes.Enabled = False
  4164. posterPicBoxes = Nothing
  4165. posterCheckBoxes = Nothing
  4166. resLabel = Nothing
  4167. Application.DoEvents()
  4168. posterArray.Clear()
  4169. End Sub
  4170. Private Sub mov_PosterSelectionDisplay()
  4171. Dim names As New List(Of McImage)
  4172. Me.panelAvailableMoviePosters.Visible = False
  4173. If pageCount = 0 Then
  4174. messbox = New frmMessageBox("", "Retrieving Posters...", "Please wait...")
  4175. System.Windows.Forms.Cursor.Current = Cursors.WaitCursor
  4176. messbox.Show()
  4177. Me.Refresh()
  4178. messbox.Refresh()
  4179. End If
  4180. Dim itemcounter As Integer = 0
  4181. If posterArray.Count > 0 Then
  4182. Dim MovPosterPicBox As New List(Of FanartPicBox)
  4183. If pageCount = 0 Then pageCount = Math.Ceiling(posterArray.count/10)
  4184. If posterArray.Count > 10 Then
  4185. Dim totalthispagecount As Integer = ((currentPage*10)-1)
  4186. If totalthispagecount >= posterArray.Count Then totalthispagecount = posterArray.Count -1
  4187. For f = ((currentPage-1)*10) To totalthispagecount '((currentPage*10)-1)
  4188. names.Add(posterArray(f))
  4189. Next
  4190. Else
  4191. For f = 0 To posterArray.Count - 1
  4192. names.Add(posterArray(f))
  4193. Next
  4194. End If
  4195. If pageCount > 1 Then
  4196. btnMovPosterNext.Visible = True
  4197. btnMovPosterPrev.Visible = True
  4198. If posterArray.Count >= 10 Then
  4199. lblMovPosterPages.Text = "Displaying " & ((currentPage*10) - 9) & " to " & (currentPage*10) & " of " & posterArray.Count.ToString & " Images"
  4200. Else
  4201. lblMovPosterPages.Text = "Displaying 1 to " & posterArray.Count.ToString & " of " & posterArray.Count.ToString & " Images"
  4202. End If
  4203. lblMovPosterPages.Visible = True
  4204. Me.Refresh()
  4205. Application.DoEvents()
  4206. btnMovPosterPrev.Enabled = currentPage > 1
  4207. btnMovPosterNext.Enabled = currentPage < pagecount
  4208. Else
  4209. btnMovPosterPrev.Visible = False
  4210. btnMovPosterNext.Visible = False
  4211. lblMovPosterPages.Text = "Displaying 1 to " & posterArray.Count.ToString & " of " & posterArray.Count.ToString & " Images"
  4212. lblMovPosterPages.Visible = True
  4213. Me.Refresh()
  4214. Application.DoEvents()
  4215. End If
  4216. Dim tempboolean As Boolean = True
  4217. Dim locationX As Integer = 0
  4218. Dim locationY As Integer = 0
  4219. messbox.TextBox2.Text = "Setting up display...."
  4220. messbox.Refresh()
  4221. For Each item In names
  4222. Dim thispicbox As New FanartPicBox
  4223. Try
  4224. posterPicBoxes() = New PictureBox()
  4225. With posterPicBoxes
  4226. .WaitOnLoad = True
  4227. .Location = New Point(locationX, locationY)
  4228. .Width = 126
  4229. .Height = 189
  4230. .SizeMode = PictureBoxSizeMode.Zoom
  4231. .Visible = True
  4232. .BorderStyle = BorderStyle.Fixed3D
  4233. .Name = "poster" & itemcounter.ToString
  4234. AddHandler posterPicBoxes.DoubleClick, AddressOf util_ZoomImage2
  4235. AddHandler posterPicBoxes.LoadCompleted, AddressOf util_ImageRes
  4236. End With
  4237. thispicbox.imagepath = item.ldUrl
  4238. thispicbox.pbox = posterPicBoxes
  4239. MovPosterPicBox.Add(thispicbox)
  4240. posterCheckBoxes() = New RadioButton()
  4241. With posterCheckBoxes
  4242. .Location = New Point(locationX + 18, locationY + 187) '179
  4243. .Width = 79
  4244. .Height = 32
  4245. .Name = "postercheckbox" & itemcounter.ToString
  4246. .SendToBack()
  4247. .CheckAlign = ContentAlignment.TopCenter
  4248. If item.hdheight <> "" Then
  4249. .Text = item.hdwidth & " x " & item.hdheight
  4250. Else
  4251. .Text = "?"
  4252. End If
  4253. .TextAlign = ContentAlignment.BottomCenter
  4254. AddHandler posterCheckBoxes.CheckedChanged, AddressOf mov_PosterRadioChanged
  4255. End With
  4256. itemcounter += 1
  4257. Me.panelAvailableMoviePosters.Controls.Add(posterPicBoxes())
  4258. Me.panelAvailableMoviePosters.Controls.Add(posterCheckBoxes())
  4259. Me.Refresh()
  4260. Application.DoEvents()
  4261. If tempboolean = True Then
  4262. locationY = (213 + 19)
  4263. Else
  4264. locationX += 126
  4265. locationY = 0
  4266. End If
  4267. tempboolean = Not tempboolean
  4268. Catch ex As Exception
  4269. #If SilentErrorScream Then
  4270. Throw ex
  4271. #End If
  4272. End Try
  4273. Next
  4274. Me.panelAvailableMoviePosters.Refresh()
  4275. Me.Refresh()
  4276. Me.panelAvailableMoviePosters.Visible = True
  4277. If MovPosterPicBox.Count > 0 Then
  4278. messbox.Close()
  4279. If Not ImgBw.IsBusy Then
  4280. ToolStripStatusLabel2.Text = "Starting Download of Images..."
  4281. ToolStripStatusLabel2.Visible = True
  4282. ImgBw.RunWorkerAsync({MovPosterPicBox, 0, If(posterArray.Count >= 10, 10, posterArray.Count), Me.panelAvailableMoviePosters})
  4283. End If
  4284. End If
  4285. Else
  4286. Dim mainlabel2 As Label
  4287. mainlabel2 = New Label
  4288. With mainlabel2
  4289. .Location = New Point(0, 100)
  4290. .Width = 700
  4291. .Height = 100
  4292. .Font = New System.Drawing.Font("Arial", 15, FontStyle.Bold)
  4293. .Text = "No Posters Were Found For This Movie"
  4294. End With
  4295. Me.panelAvailableMoviePosters.Controls.Add(mainlabel2)
  4296. End If
  4297. If itemcounter = 0 Then
  4298. btnMovPosterNext.Visible = False
  4299. btnMovPosterPrev.Visible = False
  4300. Dim mainlabel2 As Label
  4301. mainlabel2 = New Label
  4302. With mainlabel2
  4303. .Location = New Point(0, 100)
  4304. .Width = 700
  4305. .Height = 100
  4306. .Font = New System.Drawing.Font("Arial", 15, FontStyle.Bold)
  4307. .Text = "No Posters Were Found For This Movie"
  4308. End With
  4309. lblMovPosterPages.Text = "0 of 0 Images"
  4310. Me.panelAvailableMoviePosters.Controls.Add(mainlabel2)
  4311. End If
  4312. Me.panelAvailableMoviePosters.Visible = True
  4313. messbox.Close()
  4314. End Sub
  4315. Private Sub mov_PosterSelectionDisplayPrev()
  4316. Try
  4317. mov_PosterPanelClear()
  4318. currentPage -= 1
  4319. If currentPage = 1 Then
  4320. btnMovPosterPrev.Enabled = False
  4321. End If
  4322. btnMovPosterNext.Enabled = True
  4323. mov_PosterSelectionDisplay()
  4324. Catch ex As Exception
  4325. ExceptionHandler.LogError(ex)
  4326. End Try
  4327. End Sub
  4328. Private Sub mov_PosterSelectionDisplayNext()
  4329. Try
  4330. mov_PosterPanelClear()
  4331. currentPage += 1
  4332. If currentPage = pageCount Then
  4333. btnMovPosterNext.Enabled = False
  4334. End If
  4335. btnMovPosterPrev.Enabled = True
  4336. mov_PosterSelectionDisplay()
  4337. Catch ex As Exception
  4338. ExceptionHandler.LogError(ex)
  4339. End Try
  4340. End Sub
  4341. Private Sub mov_PosterRadioChanged(ByVal sender As Object, ByVal e As EventArgs)
  4342. Dim tempstring As String = sender.name
  4343. Dim tempint As Integer = 0
  4344. Dim tempstring2 As String = tempstring
  4345. Dim allok As Boolean = False
  4346. tempstring = tempstring.Replace("postercheckbox", "")
  4347. tempint = Convert.ToDecimal(tempstring)
  4348. For Each button As Control In Me.panelAvailableMoviePosters.Controls
  4349. If button.Name.IndexOf("postercheckbox") <> -1 Then
  4350. Dim b1 As RadioButton = CType(button, RadioButton)
  4351. If b1.Checked = True Then
  4352. allok = True
  4353. Exit For
  4354. End If
  4355. End If
  4356. Next
  4357. If allok = True Then
  4358. btnPosterTabs_SaveImage.Enabled = True
  4359. cbMoviePosterSaveLoRes.Enabled = ( posterArray(0).ldUrl.ToLower.IndexOf("impawards")<>-1 Or posterArray(0).ldUrl.ToLower.IndexOf("image.tmdb")<>-1 )
  4360. Else
  4361. cbMoviePosterSaveLoRes.Enabled = False
  4362. btnPosterTabs_SaveImage.Enabled = False
  4363. End If
  4364. End Sub
  4365. Private Sub util_ImageRes(ByVal sender As Object, ByVal e As EventArgs)
  4366. resLabel = New Label
  4367. Dim tempstring As String
  4368. tempstring = sender.image.width.ToString
  4369. tempstring = tempstring & " x "
  4370. tempstring = tempstring & sender.image.height.ToString
  4371. Dim locx As Integer = sender.location.x
  4372. Dim locy As Integer = sender.location.y
  4373. locy = locy + sender.height
  4374. With resLabel
  4375. .Location = New Point(locx + 30, locy)
  4376. .Text = tempstring
  4377. .BringToFront()
  4378. End With
  4379. Me.panelAvailableMoviePosters.Controls.Add(resLabel)
  4380. Me.Refresh()
  4381. Application.DoEvents()
  4382. End Sub
  4383. Private Sub cmbxEpActor_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmbxEpActor.SelectedIndexChanged
  4384. Try
  4385. Dim Episode As Media_Companion.TvEpisode
  4386. If TvTreeview.SelectedNode IsNot Nothing Then
  4387. If TypeOf TvTreeview.SelectedNode.Tag Is Media_Companion.TvEpisode Then
  4388. Episode = TvTreeview.SelectedNode.Tag
  4389. Else
  4390. Exit Sub
  4391. End If
  4392. Else
  4393. Exit Sub
  4394. End If
  4395. pbEpActorImage.Image = Nothing
  4396. pbEpActorImage.Visible = True
  4397. For Each actor In Episode.ListActors
  4398. If actor.actorname = cmbxEpActor.Text Then
  4399. tbEpRole.Text = actor.actorrole
  4400. Dim temppath As String = Episode.ShowObj.FolderPath
  4401. Dim tempname As String = actor.actorname.Replace(" ", "_") & If(Pref.FrodoEnabled, ".jpg", ".tbn")
  4402. temppath = temppath & ".actors\" & tempname
  4403. If IO.File.Exists(temppath) Then
  4404. util_ImageLoad(pbEpActorImage, temppath, Utilities.DefaultActorPath)
  4405. Exit Sub
  4406. End If
  4407. If actor.actorthumb <> Nothing Then
  4408. If actor.actorthumb.IndexOf("http") <> -1 Or IO.File.Exists(actor.actorthumb) Then
  4409. util_ImageLoad(pbEpActorImage, actor.actorthumb, Utilities.DefaultActorPath)
  4410. Else
  4411. util_ImageLoad(pbEpActorImage, Utilities.DefaultActorPath, Utilities.DefaultActorPath)
  4412. End If
  4413. Else
  4414. util_ImageLoad(pbEpActorImage, Utilities.DefaultActorPath, Utilities.DefaultActorPath)
  4415. End If
  4416. pbEpActorImage.SizeMode = PictureBoxSizeMode.Zoom
  4417. End If
  4418. Next
  4419. Catch ex As Exception
  4420. ExceptionHandler.LogError(ex)
  4421. End Try
  4422. End Sub
  4423. Private Sub ExpandAllToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExpandAllToolStripMenuItem.Click
  4424. Try
  4425. Dim node As TreeNode
  4426. For Each node In TvTreeview.Nodes
  4427. node.ExpandAll()
  4428. Next
  4429. Catch ex As Exception
  4430. ExceptionHandler.LogError(ex)
  4431. End Try
  4432. End Sub
  4433. Private Sub CollapseAllToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CollapseAllToolStripMenuItem.Click
  4434. Try
  4435. Dim node As TreeNode
  4436. For Each node In TvTreeview.Nodes
  4437. node.Collapse()
  4438. Next
  4439. Catch ex As Exception
  4440. ExceptionHandler.LogError(ex)
  4441. End Try
  4442. End Sub
  4443. Private Sub ExpandSelectedShowToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExpandSelectedShowToolStripMenuItem.Click
  4444. Try
  4445. Dim WorkingTvShow As TvShow = tv_ShowSelectedCurrently(TvTreeview)
  4446. WorkingTvShow.ShowNode.ExpandAll()
  4447. Catch ex As Exception
  4448. ExceptionHandler.LogError(ex)
  4449. End Try
  4450. End Sub
  4451. Private Sub CollapseSelectedShowToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CollapseSelectedShowToolStripMenuItem.Click
  4452. Try
  4453. Dim WorkingTvShow As TvShow = tv_ShowSelectedCurrently(TvTreeview)
  4454. WorkingTvShow.ShowNode.Collapse()
  4455. Catch ex As Exception
  4456. ExceptionHandler.LogError(ex)
  4457. End Try
  4458. End Sub
  4459. Private Sub ReloadItemToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Tv_TreeViewContext_ReloadFromCache.Click
  4460. Try
  4461. Call tv_ShowReload(True)
  4462. Catch ex As Exception
  4463. ExceptionHandler.LogError(ex)
  4464. End Try
  4465. End Sub
  4466. Private Sub tv_ShowReload(Optional ByVal force As Boolean = False)
  4467. Dim Show As Media_Companion.TvShow = tv_ShowSelectedCurrently(TvTreeview)
  4468. Dim Season As Media_Companion.TvSeason = tv_SeasonSelectedCurrently(TvTreeview)
  4469. Dim Episode As Media_Companion.TvEpisode = ep_SelectedCurrently(TvTreeview)
  4470. End Sub
  4471. Private Sub TabControl3_Selecting(ByVal sender As Object, ByVal e As CancelEventArgs) Handles TabControl3.Selecting
  4472. If TabControl3.SelectedTab.Name = tpTvPrefs.Name Then
  4473. e.Cancel = True
  4474. OpenPreferences(2)
  4475. End If
  4476. End Sub
  4477. Private Sub TabControl3_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TabControl3.SelectedIndexChanged
  4478. Try
  4479. Dim Show As Media_Companion.TvShow = tv_ShowSelectedCurrently(TvTreeview)
  4480. Dim tab As String = TabControl3.SelectedTab.Name
  4481. Dim WorkingEpisode As TvEpisode = ep_SelectedCurrently(TvTreeview)
  4482. If (tab <> tpTvMainBrowser.Name And tab <> tpTvFolders.Name And tab <> tpTvPrefs.Name) AndAlso Show Is Nothing Then
  4483. MsgBox("No TV Show is selected")
  4484. Exit Sub
  4485. End If
  4486. Dim tempstring As String = ""
  4487. If tab <> tpTvMainBrowser.Name And tab <> tpTvFolders.Name And tab <> tpTvPrefs.Name Then
  4488. If Show.NfoFilePath = "" And tvFolders.Count = 0 Then
  4489. Me.TabControl3.SelectedIndex = tvCurrentTabIndex
  4490. MsgBox("There are no TV Shows in your list to work on" & vbCrLf & "Set the Preferences as you want them" & vbCrLf & "Using the Preferences Tab, then" & vbCrLf & "add your TV Folders using the Folders Tab" & vbCrLf & "Once the tvshow has been scraped then" & vbCrLf & "Use the tab, ""Search for new episodes""")
  4491. If tab <> tpTvPrefs.Name Then Exit Sub
  4492. ElseIf Show.NfoFilePath = "" And tvFolders.Count > 0 And tab <> tpTvPrefs.Name Then
  4493. Me.TabControl3.SelectedIndex = tvCurrentTabIndex
  4494. If Cache.TvCache.Shows.Count > 0 Then
  4495. MsgBox("No TV Show is selected")
  4496. Exit Sub
  4497. Else
  4498. MsgBox("There are no TV Shows in your list to work on")
  4499. Exit Sub
  4500. End If
  4501. End If
  4502. ElseIf tab = tpTvFolders.Name Then 'Tv Folders tab
  4503. tvCurrentTabIndex = TabControl3.SelectedIndex
  4504. TabControl3.SelectedIndex = tvCurrentTabIndex
  4505. Call tv_FoldersSetup()
  4506. Else
  4507. tvCurrentTabIndex = 0
  4508. Exit Sub
  4509. End If
  4510. If tab = tpTvSelector.Name Then 'Tv Show Change tba
  4511. If ListBox3.Items.Count = 0 Then
  4512. tvCurrentTabIndex = TabControl3.SelectedIndex
  4513. Call tv_ShowChangedRePopulate()
  4514. End If
  4515. ElseIf tab = tpTvMainBrowser.Name Then 'Tv Main Browser tab
  4516. If TvTreeview.Nodes.Count = 0 Then TvTreeview.SelectedNode = TvTreeview.TopNode
  4517. TvTreeview.Focus()
  4518. tvCurrentTabIndex = 0
  4519. ElseIf tab = tpTvPosters.Name Then 'Tv Posters tab
  4520. tvCurrentTabIndex = TabControl3.SelectedIndex
  4521. Call tv_PosterSetup()
  4522. ElseIf tab = tpTvTable.Name Then 'Tv TableView tab
  4523. tvCurrentTabIndex = TabControl3.SelectedIndex
  4524. Call tv_TableView()
  4525. ElseIf tab = tpTvWall.Name Then 'Tv Wall View tab
  4526. tvCurrentTabIndex = TabControl3.SelectedIndex
  4527. Call tv_wallSetup()
  4528. ElseIf tab = tpTvWeb.Name Then 'Tv Web Browser tab
  4529. Dim TvdbId As Integer = 0
  4530. If Not String.IsNullOrEmpty(Show.TvdbId.Value) AndAlso Integer.TryParse(Show.TvdbId.Value, TvdbId) Then
  4531. Dim tpi As Integer = tpTvWeb.ImageIndex
  4532. If tpi = 0 Then
  4533. tempstring = "http://thetvdb.com/?tab=series&id=" & TvdbId & "&lid=7"
  4534. Else
  4535. tempstring = "http://www.imdb.com/title/" & Show.ImdbId.Value & "/"
  4536. End If
  4537. Call GoTvWebBrowser(tempstring)
  4538. ElseIf String.IsNullOrEmpty(Show.TvdbId.Value) AndAlso String.IsNullOrEmpty(Show.ImdbId.Value) Then
  4539. TabControl3.SelectedIndex = 0
  4540. MsgBox("No TVDB or IMDB ID present for selected Show" & vbCrLf & "Use Tv Show Selector Tab, to select" & vbCrLf & "correct show")
  4541. End If
  4542. ElseIf tab = tpTvFanart.Name Then 'Tv Fanart tab
  4543. Call tv_Fanart_Load()
  4544. tvCurrentTabIndex = TabControl3.SelectedIndex
  4545. ElseIf tab = tpTvFanartTv.Name Then 'Tv Fanart.Tv tab
  4546. UcFanartTvTv1.ucFanartTv_Refresh(tv_ShowSelectedCurrently(TvTreeview))
  4547. ElseIf tab = tpTvScreenshot.Name Then 'Tv Episode Screenshot tab
  4548. tvCurrentTabIndex = TabControl3.SelectedIndex
  4549. Call GoScreenshotTab(WorkingEpisode)
  4550. End If
  4551. Catch ex As Exception
  4552. ExceptionHandler.LogError(ex)
  4553. End Try
  4554. End Sub
  4555. Private Sub TabControl3_MouseClick(ByVal sender As Object, ByVal e As MouseEventArgs) Handles TabControl3.MouseClick
  4556. If e.Button = Windows.Forms.MouseButtons.Right Then
  4557. For index As Integer = 0 To TabControl3.TabCount - 2 Step 1
  4558. If TabControl3.GetTabRect(index).Contains(e.X,e.Y) AndAlso TabControl3.TabPages(index).Name.ToLower = "tptvweb" Then
  4559. Dim tpi As Integer = tpTvWeb.ImageIndex
  4560. If tpi = 0 Then
  4561. tpTvWeb.ImageIndex = 1
  4562. Else
  4563. tpTvWeb.ImageIndex = 0
  4564. End If
  4565. tpTvWeb.Refresh()
  4566. Exit For
  4567. End If
  4568. Next
  4569. End If
  4570. End Sub
  4571. Private Sub TabControl3_MouseWheel(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles TabControl3.MouseWheel
  4572. Try
  4573. If Tabcontrol3.TabPages(TabControl3.SelectedIndex).Text.ToLower = "wall" Then
  4574. mouseDelta = e.Delta / 120
  4575. Try
  4576. tptvwall.AutoScrollPosition = New Point(0, tptvwall.VerticalScroll.Value - (mouseDelta * 30))
  4577. Catch ex As Exception
  4578. End Try
  4579. End If
  4580. Catch ex As Exception
  4581. ExceptionHandler.LogError(ex)
  4582. End Try
  4583. End Sub
  4584. Private Sub GoTvWebBrowser(ByVal tempstring As String)
  4585. If Pref.externalbrowser = True Then
  4586. Me.TabControl3.SelectedIndex = tvCurrentTabIndex
  4587. OpenUrl(tempstring)
  4588. Else
  4589. tvCurrentTabIndex = TabControl3.SelectedIndex
  4590. Try
  4591. WebBrowser4.Stop()
  4592. WebBrowser4.ScriptErrorsSuppressed = True
  4593. WebBrowser4.Navigate(tempstring)
  4594. Catch
  4595. WebBrowser4.Stop()
  4596. WebBrowser4.ScriptErrorsSuppressed = True
  4597. WebBrowser4.Navigate(tempstring)
  4598. End Try
  4599. WebBrowser4.Focus()
  4600. End If
  4601. End Sub
  4602. Private Sub GoScreenshotTab(ByRef WorkingEpisode As TvEpisode)
  4603. If Pref.EdenEnabled Then
  4604. util_ImageLoad(pbTvEpScrnShot, WorkingEpisode.VideoFilePath.Replace(IO.Path.GetExtension(WorkingEpisode.VideoFilePath), ".tbn"), Utilities.DefaultScreenShotPath)
  4605. End If
  4606. If Pref.FrodoEnabled Then
  4607. util_ImageLoad(pbTvEpScrnShot, WorkingEpisode.VideoFilePath.Replace(IO.Path.GetExtension(WorkingEpisode.VideoFilePath), "-thumb.jpg"), Utilities.DefaultScreenShotPath)
  4608. End If
  4609. If TextBox35.Text = "" Then
  4610. TextBox35.Text = Pref.ScrShtDelay
  4611. End If
  4612. End Sub
  4613. Private Sub tv_TableView()
  4614. Dim availableshows As New List(Of TvShow)
  4615. messbox = New frmMessageBox("Loading all tvshow.nfo")
  4616. messbox.Show
  4617. For Each sh As TvShow In Cache.TvCache.Shows
  4618. Dim shload As New TvShow
  4619. shload.NfoFilePath = sh.NfoFilePath
  4620. shload = nfoFunction.tvshow_NfoLoad(sh.NfoFilePath) '.Load()
  4621. availableshows.Add(shload)
  4622. Next
  4623. messbox.Close()
  4624. Dim tvdbase(availableshows.Count, 8) as String
  4625. DataGridView2.Rows.Clear()
  4626. DataGridView2.Columns.Item(1).DefaultCellStyle.WrapMode = DataGridViewTriState.True
  4627. Try
  4628. Dim lst As List(Of TvShow) = (From x In availableshows Order By x.Title.Value).ToList
  4629. For Each sh As TvShow In lst
  4630. Dim n As Integer = DataGridView2.Rows.Add()
  4631. DataGridView2.Rows(n).Cells(0).Value = sh.Title.Value
  4632. DataGridView2.Rows(n).Cells(1).Value = sh.Plot.Value
  4633. DataGridView2.Rows(n).Cells(2).Value = sh.Premiered.Value
  4634. DataGridView2.Rows(n).Cells(3).Value = sh.Rating.Value
  4635. DataGridView2.Rows(n).Cells(4).Value = sh.Genre.Value
  4636. DataGridView2.Rows(n).Cells(5).Value = sh.Studio.Value
  4637. DataGridView2.Rows(n).Cells(6).Value = sh.TvdbId.Value
  4638. DataGridView2.Rows(n).Cells(7).Value = sh.ImdbId.Value
  4639. DataGridView2.Rows(n).Cells(8).Value = sh.Mpaa.Value
  4640. Next
  4641. Catch
  4642. End Try
  4643. End Sub
  4644. Public Sub util_LanguageListLoad()
  4645. languageList.Clear()
  4646. Application.DoEvents()
  4647. System.Threading.Thread.Sleep(500)
  4648. Dim XmlFile As String
  4649. XmlFile = Utilities.DownloadTextFiles("http://thetvdb.com/api/6E82FED600783400/languages.xml")
  4650. Dim LangList As New Tvdb.Languages()
  4651. LangList.LoadXml(XmlFile)
  4652. For Each Lang As Tvdb.Language In LangList.Languages
  4653. languageList.Add(Lang)
  4654. Next
  4655. ListBox1.Items.Clear()
  4656. For Each lan In languageList
  4657. ListBox1.Items.Add(lan.Language.Value)
  4658. Next
  4659. End Sub
  4660. Private Sub tv_ShowChangedRePopulate()
  4661. Dim WorkingTvShow As TvShow = tv_ShowSelectedCurrently(TvTreeview)
  4662. Try
  4663. TextBox26.Text = Utilities.GetLastFolder(WorkingTvShow.NfoFilePath)
  4664. tb_TvShSelectSeriesPath.Enabled = True
  4665. tb_TvShSelectSeriesPath.Text = WorkingTvShow.NfoFilePath.Replace("tvshow.nfo", "")
  4666. PictureBox9.Image = Nothing
  4667. If languageList.Count = 0 Then
  4668. util_LanguageListLoad()
  4669. End If
  4670. If workingTvShow.language <> Nothing Then
  4671. For Each language In languageList
  4672. If language.Abbreviation.Value = WorkingTvShow.Language.Value Then
  4673. ListBox1.SelectedItem = language.Language.Value
  4674. Exit For
  4675. End If
  4676. Next
  4677. Else
  4678. ListBox1.SelectedItem = Pref.TvdbLanguage
  4679. End If
  4680. Label55.Text = "Default Language for TV Shows is :- " & Pref.TvdbLanguage
  4681. Call tv_ShowListLoad()
  4682. Try
  4683. If Pref.sortorder <> Nothing Then
  4684. If Pref.sortorder = "dvd" Then
  4685. RadioButton14.Checked = True
  4686. Else
  4687. RadioButton15.Checked = True
  4688. End If
  4689. Else
  4690. RadioButton15.Checked = True
  4691. End If
  4692. Catch ex As Exception
  4693. #If SilentErrorScream Then
  4694. Throw ex
  4695. #End If
  4696. RadioButton15.Checked = True
  4697. End Try
  4698. Select Case Pref.seasonall
  4699. Case "none"
  4700. RadioButton18.Checked = True
  4701. Case "poster"
  4702. RadioButton17.Checked = True
  4703. Case "wide"
  4704. RadioButton16.Checked = True
  4705. End Select
  4706. '0 - Everything from TVDB
  4707. '1 - Everything from IMDB
  4708. '2 - TV show Nfo From IMDB, Episode nfo from TVDB
  4709. '3 - TV show Nfo From TVDB, Episode nfo from IMDB
  4710. If Pref.tvdbactorscrape = 0 Then
  4711. RadioButton13.Checked = True
  4712. RadioButton11.Checked = True
  4713. End If
  4714. If Pref.tvdbactorscrape = 1 Then
  4715. RadioButton12.Checked = True
  4716. RadioButton10.Checked = True
  4717. End If
  4718. If Pref.tvdbactorscrape = 2 Then
  4719. RadioButton12.Checked = True
  4720. RadioButton11.Checked = True
  4721. End If
  4722. If Pref.tvdbactorscrape = 3 Then
  4723. RadioButton13.Checked = True
  4724. RadioButton10.Checked = True
  4725. End If
  4726. If Pref.postertype = "poster" Then
  4727. RadioButton9.Checked = True
  4728. Else
  4729. RadioButton8.Checked = True
  4730. End If
  4731. cbTvChgShowDLFanart .Checked = Pref.tvdlfanart
  4732. cbTvChgShowDLPoster .Checked = Pref.tvdlposter
  4733. cbTvChgShowDLSeason .Checked = Pref.tvdlseasonthumbs
  4734. cbTvChgShowDLFanartTvArt .Checked = Pref.TvDlFanartTvArt
  4735. If Pref.tvshow_useXBMC_Scraper = True Then
  4736. GroupBox2.Enabled = False
  4737. GroupBox3.Enabled = False
  4738. GroupBox5.Enabled = False
  4739. Else
  4740. GroupBox2.Enabled = True
  4741. GroupBox3.Enabled = True
  4742. GroupBox5.Enabled = True
  4743. End If
  4744. cbTvChgShowOverwriteImgs.CheckState = CheckState.Checked 'set overwrite images for changing shows.
  4745. Catch ex As WebException
  4746. MsgBox("There seems to be a problem with the tvdb website, please try again later")
  4747. tvCurrentTabIndex = 0
  4748. TabControl3.SelectedIndex = 0
  4749. End Try
  4750. End Sub
  4751. Private Sub util_LanguageCheck()
  4752. Try
  4753. If ListBox1.SelectedIndex < 0 Then ListBox1.SelectedIndex = languageList.FindIndex(Function(index As Tvdb.Language) index.Abbreviation.Value = Pref.TvdbLanguageCode)
  4754. If ListBox3.SelectedIndex = -1 orElse listOfShows(ListBox3.SelectedIndex).showid = "none" Then Exit Sub
  4755. Dim languagecode As String = languageList(ListBox1.SelectedIndex).Abbreviation.Value
  4756. Dim url As String = "http://thetvdb.com/api/6E82FED600783400/series/" & listOfShows(ListBox3.SelectedIndex).showid & "/" & languagecode & ".xml"
  4757. Dim websource(10000)
  4758. Dim urllinecount As Integer = 0
  4759. Try
  4760. Dim wrGETURL As WebRequest
  4761. wrGETURL = WebRequest.Create(url)
  4762. wrGETURL.Proxy = Utilities.MyProxy
  4763. Dim objStream As Stream
  4764. objStream = wrGETURL.GetResponse.GetResponseStream()
  4765. Dim objReader As New StreamReader(objStream)
  4766. Dim sLine As String = ""
  4767. urllinecount = 0
  4768. Do While Not sLine Is Nothing
  4769. urllinecount += 1
  4770. sLine = objReader.ReadLine
  4771. If Not sLine Is Nothing Then
  4772. websource(urllinecount) = sLine
  4773. End If
  4774. Loop
  4775. objReader.Close()
  4776. objStream.Close()
  4777. objReader = Nothing
  4778. objStream = Nothing
  4779. urllinecount -= 1
  4780. Catch ex As Exception
  4781. End Try
  4782. For f = 1 To urllinecount
  4783. If websource(f).IndexOf("<Language>") <> -1 Then
  4784. websource(f) = websource(f).Replace("<Language>", "")
  4785. websource(f) = websource(f).Replace("</Language>", "")
  4786. websource(f) = websource(f).Replace(" ", "")
  4787. If websource(f).ToLower <> languagecode Then
  4788. Label55.BackColor = Color.Red
  4789. Label55.Text = ListBox3.SelectedItem.ToString & " is not available in " & ListBox1.SelectedItem.ToString & ", Please try another language"
  4790. Else
  4791. Label55.BackColor = Color.Transparent
  4792. Label55.Text = ListBox3.SelectedItem.ToString & " is available in " & ListBox1.SelectedItem.ToString
  4793. Label55.Font = New Font(Label55.Font, FontStyle.Bold)
  4794. End If
  4795. End If
  4796. Next
  4797. Catch ex As Exception
  4798. #If SilentErrorScream Then
  4799. Throw ex
  4800. #End If
  4801. End Try
  4802. End Sub
  4803. Private Sub RefreshShowsToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RefreshShowsToolStripMenuItem.Click
  4804. Call tv_CacheRefresh()
  4805. End Sub
  4806. Private Sub Tv_tsmi_CheckDuplicateEpisodes_Click(sender As Object, e As EventArgs) Handles Tv_tsmi_CheckDuplicateEpisodes.Click
  4807. Tv_CacheCheckDuplicates()
  4808. End Sub
  4809. Private Sub ReloadShowCacheToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ReloadShowCacheToolStripMenuItem.Click
  4810. Try
  4811. If IO.File.Exists(workingProfile.tvcache) Then
  4812. Call tv_CacheLoad()
  4813. Else
  4814. MsgBox("No Cache exists to load")
  4815. End If
  4816. Catch ex As Exception
  4817. ExceptionHandler.LogError(ex)
  4818. End Try
  4819. End Sub
  4820. Private Function util_ReplaceXMLChrs(ByVal Text As String) 'Convert textcodes to real characters
  4821. If Text.IndexOf("‘") <> -1 Then Text = Text.Replace("‘", "'")
  4822. If Text.IndexOf("’") <> -1 Then Text = Text.Replace("’", "'")
  4823. If Text.IndexOf("’") <> -1 Then Text = Text.Replace("’", "'")
  4824. If Text.IndexOf("â€" & Chr(147)) <> -1 Then Text = Text.Replace("â€" & Chr(147), "-")
  4825. Return Text
  4826. End Function
  4827. Private Function ep_NfoValidate(ByVal nfopath As String)
  4828. Dim validated As Boolean = True
  4829. If IO.File.Exists(nfopath) Then
  4830. Dim tvshow As New XmlDocument
  4831. Try
  4832. tvshow.Load(nfopath)
  4833. Catch ex As Exception
  4834. If ex.Message.ToLower.Contains("multiple root elements") Then
  4835. validated = chkxbmcmultinfo(nfopath)
  4836. Else
  4837. validated = False
  4838. End If
  4839. End Try
  4840. If validated = True Then
  4841. Try
  4842. Dim tempstring As String
  4843. Dim filechck As IO.StreamReader = IO.File.OpenText(nfopath)
  4844. tempstring = filechck.ReadToEnd.ToLower
  4845. filechck.Close()
  4846. filechck = Nothing
  4847. If tempstring = Nothing Then
  4848. validated = False
  4849. End If
  4850. Try
  4851. Dim seasonno As String = tempstring.Substring(tempstring.IndexOf("<season>") + 8, tempstring.IndexOf("</season>") - tempstring.IndexOf("<season>") - 8)
  4852. If Not IsNumeric(seasonno) Then
  4853. validated = False
  4854. End If
  4855. Catch ex As Exception
  4856. validated = False
  4857. End Try
  4858. Try
  4859. Dim episodeno As String = tempstring.Substring(tempstring.IndexOf("<episode>") + 9, tempstring.IndexOf("</episode>") - tempstring.IndexOf("<episode>") - 9)
  4860. If Not IsNumeric(episodeno) Then
  4861. validated = False
  4862. End If
  4863. Catch ex As Exception
  4864. validated = False
  4865. End Try
  4866. Catch ex As Exception
  4867. #If SilentErrorScream Then
  4868. Throw ex
  4869. #End If
  4870. End Try
  4871. End If
  4872. Return validated
  4873. End If
  4874. Return False
  4875. End Function
  4876. Private Function chkxbmcmultinfo(ByVal xmlpath As String) As Boolean
  4877. Try
  4878. Dim testxml() As String = File.ReadAllLines(xmlpath)
  4879. Dim first As Boolean = True
  4880. Dim finalxml As String = ""
  4881. For Each line In testxml
  4882. If line.Contains("<episodedetails>") AndAlso first Then
  4883. finalxml &= "<multiepisodenfo>"
  4884. End If
  4885. finalxml &= line
  4886. If line.Contains("</episodedetails>") Then first = False
  4887. Next
  4888. finalxml &= "</multiepisodenfo>"
  4889. Dim Finaldoc As New XmlDocument
  4890. Finaldoc.LoadXml(finalxml)
  4891. Finaldoc.Save(xmlpath)
  4892. Return ep_NfoValidate(xmlpath)
  4893. Catch
  4894. Return False
  4895. End Try
  4896. Return False
  4897. End Function
  4898. Private Sub tv_NewFind(ByVal path As String, ByVal pattern As String)
  4899. Dim episode As New List(Of TvEpisode)
  4900. Dim propfile As Boolean = False
  4901. Dim allok As Boolean = False
  4902. Dim dir_info As New System.IO.DirectoryInfo(path)
  4903. Dim fs_infos() As String = IO.Directory.GetFiles(path, "*" & pattern, SearchOption.TopDirectoryOnly)
  4904. Dim counter As Integer = 1
  4905. Dim counter2 As Integer = 1
  4906. For Each FilePath As String In fs_infos
  4907. Dim filename_video As String = FilePath
  4908. Dim filename_nfo As String = filename_video.Replace(IO.Path.GetExtension(filename_video), ".nfo")
  4909. If IO.File.Exists(filename_nfo) Then
  4910. If ep_NfoValidate(filename_nfo) = False And Pref.renamenfofiles = True Then
  4911. Dim movefilename As String = filename_nfo.Replace(IO.Path.GetExtension(filename_nfo), ".info")
  4912. Try
  4913. If File.Exists(movefilename) Then
  4914. Utilities.SafeDeleteFile(movefilename)
  4915. End If
  4916. IO.File.Move(filename_nfo, movefilename)
  4917. Catch ex As Exception
  4918. Utilities.SafeDeleteFile(movefilename)
  4919. End Try
  4920. End If
  4921. End If
  4922. If Not IO.File.Exists(filename_nfo) Then
  4923. Dim add As Boolean = True
  4924. If pattern = ".vob" Then 'If a vob file is detected, check that it is not part of a dvd file structure
  4925. Dim name As String = filename_nfo
  4926. name = name.Replace(IO.Path.GetFileName(name), "VIDEO_TS.IFO")
  4927. If IO.File.Exists(name) Then
  4928. add = False
  4929. End If
  4930. End If
  4931. If pattern = "*.rar" Then
  4932. Dim tempmovie As String = String.Empty
  4933. Dim tempint2 As Integer = 0
  4934. Dim tempmovie2 As String = FilePath
  4935. If IO.Path.GetExtension(tempmovie2).ToLower = ".rar" Then
  4936. If IO.File.Exists(tempmovie2) = True Then
  4937. If IO.File.Exists(tempmovie) = False Then
  4938. Dim rarname As String = tempmovie2
  4939. Dim SizeOfFile As Integer = FileLen(rarname)
  4940. tempint2 = Convert.ToInt32(Pref.rarsize) * 1048576
  4941. If SizeOfFile > tempint2 Then
  4942. Dim mat As Match
  4943. mat = Regex.Match(rarname, "\.part[0-9][0-9]?[0-9]?[0-9]?.rar")
  4944. If mat.Success = True Then
  4945. rarname = mat.Value
  4946. If rarname.ToLower.IndexOf(".part1.rar") <> -1 Or rarname.ToLower.IndexOf(".part01.rar") <> -1 Or rarname.ToLower.IndexOf(".part001.rar") <> -1 Or rarname.ToLower.IndexOf(".part0001.rar") <> -1 Then
  4947. Dim stackrarexists As Boolean = False
  4948. rarname = tempmovie.Replace(".nfo", ".rar")
  4949. If rarname.ToLower.IndexOf(".part1.rar") <> -1 Then
  4950. rarname = rarname.Replace(".part1.rar", ".nfo")
  4951. If IO.File.Exists(rarname) Then
  4952. stackrarexists = True
  4953. tempmovie = rarname
  4954. Else
  4955. stackrarexists = False
  4956. tempmovie = rarname
  4957. End If
  4958. End If
  4959. If rarname.ToLower.IndexOf(".part01.rar") <> -1 Then
  4960. rarname = rarname.Replace(".part01.rar", ".nfo")
  4961. If IO.File.Exists(rarname) Then
  4962. stackrarexists = True
  4963. tempmovie = rarname
  4964. Else
  4965. stackrarexists = False
  4966. tempmovie = rarname
  4967. End If
  4968. End If
  4969. If rarname.ToLower.IndexOf(".part001.rar") <> -1 Then
  4970. rarname = rarname.Replace(".part001.rar", ".nfo")
  4971. If IO.File.Exists(rarname) Then
  4972. tempmovie = rarname
  4973. stackrarexists = True
  4974. Else
  4975. stackrarexists = False
  4976. tempmovie = rarname
  4977. End If
  4978. End If
  4979. If rarname.ToLower.IndexOf(".part0001.rar") <> -1 Then
  4980. rarname = rarname.Replace(".part0001.rar", ".nfo")
  4981. If IO.File.Exists(rarname) Then
  4982. tempmovie = rarname
  4983. stackrarexists = True
  4984. Else
  4985. stackrarexists = False
  4986. tempmovie = rarname
  4987. End If
  4988. End If
  4989. Else
  4990. add = False
  4991. End If
  4992. Else
  4993. 'remove = True
  4994. End If
  4995. Else
  4996. add = False
  4997. End If
  4998. End If
  4999. End If
  5000. End If
  5001. End If
  5002. Dim truefilename As String = Utilities.GetFileNameFromPath(filename_video)
  5003. If truefilename.Substring(0,2)="._" Then add = False
  5004. If add = True Then
  5005. Dim newep As New TvEpisode
  5006. newep.NfoFilePath = filename_nfo
  5007. newep.VideoFilePath = filename_video
  5008. newep.MediaExtension = IO.Path.GetExtension(filename_video)
  5009. newEpisodeList.Add(newep)
  5010. End If
  5011. End If
  5012. Next
  5013. fs_infos = Nothing
  5014. End Sub
  5015. Private Sub OpenFolderToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Tv_TreeViewContext_OpenFolder.Click
  5016. Try
  5017. If Not TvTreeview.SelectedNode Is Nothing Then
  5018. Dim Path As String = Nothing
  5019. Dim WorkingTvShow As TvShow = tv_ShowSelectedCurrently(TvTreeview) 'set WORKINGTVSHOW to show obj irrelavent if we have selected show/season/episode
  5020. Dim WorkingTvEpisode As TvEpisode = ep_SelectedCurrently(TvTreeview)
  5021. Dim WorkingTvSeason As TvSeason = tv_SeasonSelectedCurrently(TvTreeview)
  5022. If Not IsNothing(WorkingTvEpisode) AndAlso Not WorkingTvEpisode.IsMissing Then
  5023. Path = WorkingTvEpisode.NfoFilePath
  5024. ElseIf Not IsNothing(WorkingTvSeason) AndAlso Not IsNothing(WorkingTvSeason.FolderPath) Then
  5025. Path = WorkingTvSeason.FolderPath
  5026. ElseIf Not WorkingTvShow.NfoFilePath Is Nothing And Not WorkingTvShow.NfoFilePath = "" Then
  5027. Path = WorkingTvShow.NfoFilePath 'we send the path of the tvshow.nfo, that way in explorer it will be highlighted in the folder
  5028. Else
  5029. MsgBox("There is no show selected to open")
  5030. End If
  5031. If Not IsNothing(Path) Then
  5032. Call util_OpenFolder(Path)
  5033. End If
  5034. Else
  5035. MsgBox("There is no show selected to open")
  5036. End If
  5037. Catch ex As Exception
  5038. ExceptionHandler.LogError(ex)
  5039. End Try
  5040. End Sub
  5041. Private Sub WebBrowser2_NewWindow(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles WebBrowser2.NewWindow
  5042. Try
  5043. e.Cancel = True
  5044. Catch ex As Exception
  5045. ExceptionHandler.LogError(ex)
  5046. End Try
  5047. End Sub
  5048. Private Sub WebBrowser4_NewWindow(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles WebBrowser4.NewWindow
  5049. Try
  5050. Dim myelement As HtmlElement = WebBrowser4.Document.ActiveElement
  5051. Dim target As String = myelement.GetAttribute("href")
  5052. e.Cancel = True
  5053. WebBrowser4.Navigate(target)
  5054. Catch ex As Exception
  5055. ExceptionHandler.LogError(ex)
  5056. End Try
  5057. End Sub
  5058. Private Sub PictureBox_Zoom(ByVal sender As Object, ByVal e As System.EventArgs) Handles tv_PictureBoxBottom.DoubleClick, tv_PictureBoxRight.DoubleClick, tv_PictureBoxLeft.DoubleClick
  5059. Try
  5060. Dim picBox As PictureBox = sender
  5061. Dim imageLocation As String = picBox.tag
  5062. If imageLocation <> Nothing Then
  5063. If IO.File.Exists(imageLocation) Then
  5064. Me.ControlBox = False
  5065. MenuStrip1.Enabled = False
  5066. Call util_ZoomImage(imageLocation)
  5067. End If
  5068. End If
  5069. Catch ex As Exception
  5070. ExceptionHandler.LogError(ex)
  5071. End Try
  5072. End Sub
  5073. Private Sub tv_Fanart_Load()
  5074. Dim WorkingTvShow As TvShow = tv_ShowSelectedCurrently(TvTreeview)
  5075. Me.Panel13.Controls.Clear()
  5076. listOfTvFanarts.Clear()
  5077. btnTvFanartResetImage.Visible = False
  5078. btnTvFanartSaveCropped.Visible = False
  5079. If TvTreeview.SelectedNode.Name.ToLower.IndexOf("tvshow.nfo") <> -1 Or TvTreeview.SelectedNode.Name = "" Then
  5080. If Not tv_PictureBoxLeft.Image Is Nothing Then
  5081. util_ImageLoad(PictureBox10, WorkingTvShow.FolderPath & "fanart.jpg", Utilities.DefaultTvFanartPath)
  5082. Else
  5083. PictureBox10.Image = Nothing
  5084. End If
  5085. Else
  5086. util_ImageLoad(PictureBox10, WorkingTvShow.FolderPath & "fanart.jpg", Utilities.DefaultTvFanartPath)
  5087. End If
  5088. Try
  5089. Label58.Text = PictureBox10.Image.Height.ToString
  5090. Label59.Text = PictureBox10.Image.Width.ToString
  5091. Catch ex As Exception
  5092. End Try
  5093. TextBox28.Text = WorkingTvShow.Title.Value
  5094. messbox = New frmMessageBox("Please wait,", "", "Querying TVDB for fanart list")
  5095. System.Windows.Forms.Cursor.Current = Cursors.WaitCursor
  5096. messbox.Show()
  5097. Me.Refresh()
  5098. messbox.Refresh()
  5099. Dim fanarturl As String = "http://www.thetvdb.com/api/6E82FED600783400/series/" & WorkingTvShow.TvdbId.Value & "/banners.xml"
  5100. Dim apple2(4000) As String
  5101. Dim fanartlinecount As Integer = 0
  5102. Dim tmplistOfTvFanarts As New List(Of str_FanartList)
  5103. Try
  5104. Dim wrGETURL As WebRequest
  5105. wrGETURL = WebRequest.Create(fanarturl)
  5106. wrGETURL.Proxy = Utilities.MyProxy
  5107. Dim objStream As Stream
  5108. objStream = wrGETURL.GetResponse.GetResponseStream()
  5109. Dim objReader As New StreamReader(objStream)
  5110. Dim sLine As String = ""
  5111. fanartlinecount = 0
  5112. sLine = objReader.ReadToEnd
  5113. Dim bannerslist As New XmlDocument
  5114. Dim bannerlist As String = "<banners>"
  5115. bannerslist.LoadXml(sLine)
  5116. Dim thisresult As XmlNode = Nothing
  5117. objReader.Close()
  5118. objStream.Close()
  5119. objReader = Nothing
  5120. objStream = Nothing
  5121. For Each thisresult In bannerslist("Banners")
  5122. Select Case thisresult.Name
  5123. Case "Banner"
  5124. Dim fanart As New str_FanartList(SetDefaults)
  5125. Dim bannerselection As XmlNode = Nothing
  5126. For Each bannerselection In thisresult.ChildNodes
  5127. Select Case bannerselection.Name
  5128. Case "BannerPath"
  5129. fanart.bigUrl = "http://thetvdb.com/banners/" & bannerselection.InnerXml
  5130. fanart.smallUrl = "http://thetvdb.com/banners/_cache/" & bannerselection.InnerXml
  5131. Case "BannerType"
  5132. fanart.type = bannerselection.InnerXml
  5133. Case "BannerType2"
  5134. fanart.resolution = bannerselection.InnerXml
  5135. Case "Rating"
  5136. fanart.rating = bannerselection.InnerXml.ToRating
  5137. End Select
  5138. Next
  5139. If fanart.type = "fanart" Then
  5140. tmplistOfTvFanarts.Add(fanart)
  5141. 'listOfTvFanarts.Add(fanart)
  5142. End If
  5143. End Select
  5144. Next
  5145. Catch ex As WebException
  5146. Dim webmsg As String = ex.Message
  5147. MsgBox("TVDB appears to be down at the moment, please try again later")
  5148. End Try
  5149. If tmplistOfTvFanarts.Count > 1 Then
  5150. Dim q = From x In tmplistOfTvFanarts Order By x.rating Descending
  5151. listOfTvFanarts.AddRange(q.ToList)
  5152. End If
  5153. If listOfTvFanarts.Count > 0 Then
  5154. Dim MovFanartPicBox As New List(Of FanartPicBox)
  5155. Dim location As Integer = 0
  5156. Dim itemcounter As Integer = 0
  5157. For Each item In listOfTvFanarts
  5158. Dim thispicbox As New FanartPicBox
  5159. tvFanartBoxes() = New PictureBox()
  5160. With tvFanartBoxes
  5161. .Location = New Point(0, location)
  5162. If listOfTvFanarts.Count > 2 Then
  5163. .Width = 400
  5164. .Height = 225
  5165. Else
  5166. .Width = 415
  5167. .Height = 225
  5168. End If
  5169. .SizeMode = PictureBoxSizeMode.Zoom
  5170. .Visible = True
  5171. .BorderStyle = BorderStyle.Fixed3D
  5172. .Name = "tvfanart" & itemcounter.ToString
  5173. AddHandler tvFanartBoxes.DoubleClick, AddressOf util_ZoomImage2
  5174. End With
  5175. thispicbox.pbox = tvFanartBoxes
  5176. thispicbox.imagepath = item.smallUrl
  5177. MovFanartPicBox.Add(thispicbox)
  5178. Application.DoEvents()
  5179. tvFanartCheckBoxes() = New RadioButton()
  5180. With tvFanartCheckBoxes
  5181. .BringToFront()
  5182. .Location = New Point(199, location + 225)
  5183. .Name = "checkbox" & itemcounter.ToString
  5184. End With
  5185. resolutionLabels() = New Label
  5186. With resolutionLabels
  5187. .BringToFront()
  5188. .Location = New Point(10, location + 225)
  5189. .Name = item.resolution
  5190. .Text = item.resolution
  5191. End With
  5192. itemcounter += 1
  5193. location += 250
  5194. Me.Panel13.Controls.Add(tvFanartBoxes())
  5195. Me.Panel13.Controls.Add(tvFanartCheckBoxes())
  5196. Me.Panel13.Controls.Add(resolutionLabels())
  5197. Application.DoEvents()
  5198. Next
  5199. Me.Panel13.Refresh()
  5200. Me.Refresh()
  5201. If MovFanartPicBox.Count > 0 Then
  5202. messbox.Close()
  5203. If Not ImgBw.IsBusy Then
  5204. ToolStripStatusLabel2.Text = "Starting Download of Images..."
  5205. ToolStripStatusLabel2.Visible = True
  5206. ImgBw.RunWorkerAsync({MovFanartPicBox, 0, MovFanartPicBox.Count, Me.Panel13})
  5207. End If
  5208. End If
  5209. Me.Panel13.Refresh()
  5210. Me.Refresh()
  5211. EnableTvFanartScrolling
  5212. Else
  5213. Dim mainlabel2 As Label
  5214. mainlabel2 = New Label
  5215. With mainlabel2
  5216. .Location = New Point(0, 100)
  5217. .Width = 700
  5218. .Height = 100
  5219. .Font = New System.Drawing.Font("Arial", 15, FontStyle.Bold)
  5220. .Text = "No Fanart Was Found At TVDB For This Movie"
  5221. End With
  5222. Me.Panel13.Controls.Add(mainlabel2)
  5223. End If
  5224. System.Windows.Forms.Cursor.Current = Cursors.Default
  5225. messbox.Close()
  5226. End Sub
  5227. 'Set focus on the first checkbox to enable mouse wheel scrolling
  5228. Sub EnableTvFanartScrolling
  5229. Try
  5230. Dim rb As RadioButton = Panel13.Controls("checkbox0")
  5231. rb.Select 'Causes RadioButtons checked state to toggle
  5232. rb.Checked = Not rb.Checked 'Undo unwanted checked state toggling
  5233. Catch
  5234. End Try
  5235. End Sub
  5236. Sub EnableTvBannerScrolling
  5237. Try
  5238. Panel16.Focus()
  5239. Catch
  5240. End Try
  5241. End Sub
  5242. Private Sub Tv_FanartDisplay()
  5243. Dim WorkingTvShow As TvShow = tv_ShowSelectedCurrently(TvTreeview)
  5244. If IsNothing(WorkingTvShow) Then Exit Sub
  5245. If TvTreeview.SelectedNode.Name.ToLower.IndexOf("tvshow.nfo") <> -1 Or TvTreeview.SelectedNode.Name = "" Then
  5246. If Not tv_PictureBoxLeft.Image Is Nothing Then
  5247. util_ImageLoad(PictureBox10, WorkingTvShow.FolderPath & "fanart.jpg", Utilities.DefaultTvFanartPath)
  5248. Else
  5249. PictureBox10.Image = Nothing
  5250. End If
  5251. Else
  5252. util_ImageLoad(PictureBox10, WorkingTvShow.FolderPath & "fanart.jpg", Utilities.DefaultTvFanartPath)
  5253. End If
  5254. End Sub
  5255. Private Sub tv_FanartCropTop()
  5256. Dim imagewidth As Integer = PictureBox10.Image.Width
  5257. Dim imageheight As Integer = PictureBox10.Image.Height
  5258. PictureBox10.Image = util_ImageCrop(PictureBox10.Image, New Size(imagewidth, imageheight - 1), New Point(0, 1)).Clone
  5259. PictureBox10.SizeMode = PictureBoxSizeMode.Zoom
  5260. End Sub
  5261. Private Sub tv_FanartCropBottom()
  5262. Dim imagewidth As Integer = PictureBox10.Image.Width
  5263. Dim imageheight As Integer = PictureBox10.Image.Height
  5264. PictureBox10.Image = util_ImageCrop(PictureBox10.Image, New Size(imagewidth, imageheight - 1), New Point(0, 0)).Clone
  5265. PictureBox10.SizeMode = PictureBoxSizeMode.Zoom
  5266. End Sub
  5267. Private Sub tv_FanartCropLeft()
  5268. Dim imagewidth As Integer = PictureBox10.Image.Width
  5269. Dim imageheight As Integer = PictureBox10.Image.Height
  5270. PictureBox10.Image = util_ImageCrop(PictureBox10.Image, New Size(imagewidth - 1, imageheight), New Point(1, 0)).Clone
  5271. PictureBox10.SizeMode = PictureBoxSizeMode.Zoom
  5272. End Sub
  5273. Private Sub tv_FanartCropRight()
  5274. Dim imagewidth As Integer = PictureBox10.Image.Width
  5275. Dim imageheight As Integer = PictureBox10.Image.Height
  5276. PictureBox10.Image = util_ImageCrop(PictureBox10.Image, New Size(imagewidth - 1, imageheight), New Point(0, 0)).Clone
  5277. PictureBox10.SizeMode = PictureBoxSizeMode.Zoom
  5278. End Sub
  5279. Sub tv_Rescrape() 'Panel9 visibility indicates which is selected - a tvshow or an episode
  5280. Dim WorkingTvShow As TvShow = tv_ShowSelectedCurrently(TvTreeview)
  5281. Dim WorkingEpisode As TvEpisode = ep_SelectedCurrently(TvTreeview)
  5282. If IsNothing(WorkingTvShow.TvdbId.Value) = True Then
  5283. WorkingTvShow.TvdbId.Value = ""
  5284. End If
  5285. If WorkingTvShow.TvdbId.Value.IndexOf("tt").Equals(0) Then tv_IMDbID_detected = True
  5286. If Panel_EpisodeInfo.Visible = False Then 'i.e. rescrape selected TVSHOW else rescrape selected EPISODE
  5287. 'its a tv show
  5288. Dim selectednode As Integer = TvTreeview.SelectedNode.Index
  5289. tv_Rescrape_Show(WorkingTvShow)
  5290. TvTreeview.SelectedNode = TvTreeview.Nodes(selectednode)
  5291. Else
  5292. 'its an episode
  5293. tv_Rescrape_Episode(WorkingTvShow, WorkingEpisode)
  5294. End If
  5295. If Not tv_IMDbID_warned And tv_IMDbID_detected Then
  5296. MessageBox.Show(tv_IMDbID_detectedMsg, "TV Show ID", MessageBoxButtons.OK, MessageBoxIcon.Information)
  5297. tv_IMDbID_warned = True
  5298. End If
  5299. End Sub
  5300. Private Sub Tv_TreeViewContext_RenameEp_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Tv_TreeViewContext_RenameEp.Click
  5301. Try
  5302. Dim renamelog As String = ""
  5303. Dim tempint As Integer = 0
  5304. Dim oldname As String = ""
  5305. Dim nfofilestorename As New List(Of String)
  5306. nfofilestorename.Clear()
  5307. Dim donelist As New List(Of String)
  5308. donelist.Clear()
  5309. If TvTreeview.SelectedNode.Name.IndexOf("\missing\") = -1 Then
  5310. If TypeOf TvTreeview.SelectedNode.Tag Is Media_Companion.TvEpisode Then
  5311. 'individual episode
  5312. tempint = MessageBox.Show("Using this option will rename the selected episode" & vbCrLf & "Do you wish to continue?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning)
  5313. If tempint = DialogResult.No Then
  5314. Exit Sub
  5315. End If
  5316. If Not nfofilestorename.Contains(TvTreeview.SelectedNode.Name) And TvTreeview.SelectedNode.Name.IndexOf("Missing: ") <> 0 Then
  5317. nfofilestorename.Add(TvTreeview.SelectedNode.Name)
  5318. End If
  5319. ElseIf TypeOf TvTreeview.SelectedNode.Tag Is Media_Companion.TvSeason Then
  5320. 'season
  5321. tempint = MessageBox.Show("Using this option will rename all episode nfo's within the selected season" & vbCrLf & "Do you wish to continue?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning)
  5322. If tempint = DialogResult.No Then
  5323. Exit Sub
  5324. End If
  5325. Dim childnode As TreeNode
  5326. For Each childnode In TvTreeview.SelectedNode.Nodes
  5327. If Not nfofilestorename.Contains(childnode.Name) And childnode.Name.IndexOf("\missing\") = -1 Then
  5328. nfofilestorename.Add(childnode.Name)
  5329. End If
  5330. Next
  5331. ElseIf TypeOf TvTreeview.SelectedNode.Tag Is Media_Companion.TvShow Then
  5332. 'full show
  5333. tempint = MessageBox.Show("Using this option will rename all episode nfo's within the selected show" & vbCrLf & "Do you wish to continue?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning)
  5334. If tempint = DialogResult.No Then
  5335. Exit Sub
  5336. End If
  5337. Dim childnode As TreeNode
  5338. Dim childchildnode As TreeNode
  5339. For Each childnode In TvTreeview.SelectedNode.Nodes
  5340. For Each childchildnode In childnode.Nodes
  5341. If Not nfofilestorename.Contains(childchildnode.Name) And childchildnode.Name.IndexOf("\missing\") = -1 Then
  5342. nfofilestorename.Add(childchildnode.Name)
  5343. End If
  5344. Next
  5345. Next
  5346. End If
  5347. Else
  5348. MsgBox("This is a Missing Episode, and can not be renamed!")
  5349. Exit Sub
  5350. End If
  5351. messbox = New frmMessageBox("Renaming episodes,", "", " Please Wait")
  5352. messbox.Show()
  5353. messbox.Refresh()
  5354. Application.DoEvents()
  5355. If nfofilestorename.Count <= 0 Then
  5356. messbox.Close()
  5357. Exit Sub
  5358. End If
  5359. renamelog += "!!! " & nfofilestorename.Count & " nfo's to rename..." & vbCrLf & vbCrLf
  5360. For Each renamefile In nfofilestorename
  5361. Dim seasonno As String = ""
  5362. Dim episodetitle As String = ""
  5363. Dim showtitle As String = ""
  5364. Dim episodeno As New List(Of String)
  5365. episodeno.Clear()
  5366. For Each tvshow In Cache.TvCache.Shows
  5367. Dim showpath As String = tvshow.NfoFilePath.Replace(IO.Path.GetFileName(tvshow.NfoFilePath), "")
  5368. If renamefile.IndexOf(showpath) <> -1 Then
  5369. showtitle = Pref.RemoveIgnoredArticles(tvshow.Title.Value)
  5370. For Each episode In tvshow.Episodes
  5371. If episode.NfoFilePath = renamefile Then
  5372. If seasonno = "" Then
  5373. seasonno = episode.Season.Value
  5374. End If
  5375. If episodetitle = "" Then
  5376. episodetitle = episode.Title.Value
  5377. End If
  5378. episodeno.Add(episode.Episode.Value)
  5379. End If
  5380. Next
  5381. Dim newfilename As String
  5382. newfilename = ""
  5383. If seasonno.Length = 1 Then
  5384. seasonno = "0" & seasonno
  5385. End If
  5386. For f = 0 To episodeno.Count - 1
  5387. If episodeno(f).Length = 1 Then
  5388. episodeno(f) = "0" & episodeno(f)
  5389. End If
  5390. Next
  5391. newfilename = Renamer.setTVFilename(showtitle, episodetitle, episodeno, seasonno)
  5392. newfilename = newfilename.Replace("?", "")
  5393. newfilename = newfilename.Replace("/", "")
  5394. newfilename = newfilename.Replace("\", "")
  5395. newfilename = newfilename.Replace("<", "")
  5396. newfilename = newfilename.Replace(">", "")
  5397. newfilename = newfilename.Replace(":", "")
  5398. newfilename = newfilename.Replace("""", "")
  5399. newfilename = newfilename.Replace("*", "")
  5400. If Pref.TvRenameReplaceSpace Then
  5401. If Pref.TvRenameReplaceSpaceDot Then
  5402. newfilename = newfilename.Replace(" ", ".")
  5403. Else
  5404. newfilename = newfilename.Replace(" ", "_")
  5405. End If
  5406. End If
  5407. Dim listtorename As New List(Of String)
  5408. listtorename.Clear()
  5409. listtorename.Add(renamefile)
  5410. For Each ext In Utilities.VideoExtensions
  5411. If ext = "VIDEO_TS.IFO" Then Continue For
  5412. Dim temppath2 As String = renamefile.Replace(IO.Path.GetExtension(renamefile), ext)
  5413. If IO.File.Exists(temppath2) Then
  5414. listtorename.Add(temppath2)
  5415. End If
  5416. Next
  5417. Dim di As DirectoryInfo = New DirectoryInfo(renamefile.Replace(IO.Path.GetFileName(renamefile), ""))
  5418. Dim filenama As String = IO.Path.GetFileNameWithoutExtension(renamefile)
  5419. Dim fils As IO.FileInfo() = di.GetFiles(filenama & ".*")
  5420. For Each fiNext In fils
  5421. If Not listtorename.Contains(fiNext.FullName) Then
  5422. listtorename.Add(fiNext.FullName)
  5423. End If
  5424. Next
  5425. Dim temppath As String = renamefile
  5426. temppath = temppath.Replace(IO.Path.GetExtension(temppath), ".tbn")
  5427. If IO.File.Exists(temppath) Then
  5428. If Not listtorename.Contains(temppath) Then
  5429. listtorename.Add(temppath)
  5430. End If
  5431. End If
  5432. temppath = temppath.Replace(IO.Path.GetExtension(temppath), ".rar")
  5433. If IO.File.Exists(temppath) Then
  5434. If Not listtorename.Contains(temppath) Then
  5435. listtorename.Add(temppath)
  5436. End If
  5437. End If
  5438. temppath = temppath.Replace(IO.Path.GetExtension(temppath), "-thumb.jpg")
  5439. If IO.File.Exists(temppath) Then
  5440. If Not listtorename.Contains(temppath) Then
  5441. listtorename.Add(temppath)
  5442. End If
  5443. End If
  5444. Dim oldnfofile As String = ""
  5445. Dim newnfofile As String = ""
  5446. For Each items In listtorename
  5447. If IO.Path.GetExtension(items).ToLower = ".nfo" And oldnfofile = "" Then
  5448. oldnfofile = items
  5449. newnfofile = items.Replace(IO.Path.GetFileName(items), newfilename) & IO.Path.GetExtension(items)
  5450. End If
  5451. Dim newname As String = items.Replace(filenama, newfilename)
  5452. Try
  5453. Dim pathsep As String = If(items.Contains("/"), "/", "\")
  5454. Dim origpath As String = items.Substring(0, items.LastIndexOf(pathsep)+1)
  5455. renamelog += "!!! " & items.Replace(origpath, "") & " -- to -- " & newname.Replace(origpath, "")
  5456. Dim fi As New IO.FileInfo(items)
  5457. If Not IO.File.Exists(newname) Then
  5458. fi.MoveTo(newname)
  5459. If items.ToLower = IO.Path.Combine(tb_EpPath.Text, tb_EpFilename.Text).ToLower Then
  5460. tb_EpFilename.Text = IO.Path.GetFileName(fi.FullName)
  5461. End If
  5462. renamelog += " ---Succeeded" & vbCrLf
  5463. Else
  5464. renamelog += " --! Not Renamed - Same" & vbCrLf
  5465. End If
  5466. Catch ex As Exception
  5467. renamelog += "!!! *** Not Succeeded - Please rename all files manually!" & vbCrLf & "!!! Reported Message: " & ex.Message.ToString & vbCrLf
  5468. End Try
  5469. Next
  5470. renamelog += "!!! " & vbCrLf
  5471. renamelog += "!!! Updating Tables" & vbCrLf
  5472. Try
  5473. For Each noder2 In TvTreeview.Nodes
  5474. If noder2.name = oldnfofile Then
  5475. noder2.name = newnfofile
  5476. End If
  5477. For Each noder3 In noder2.nodes
  5478. If noder3.name = oldnfofile Then
  5479. noder3.name = newnfofile
  5480. End If
  5481. For Each noder4 In noder3.nodes
  5482. If noder4.name = oldnfofile Then
  5483. noder4.name = newnfofile
  5484. End If
  5485. Next
  5486. Next
  5487. Next
  5488. For Each episode In tvshow.Episodes
  5489. If episode.NfoFilePath = oldnfofile Then
  5490. episode.NfoFilePath = newnfofile
  5491. End If
  5492. Next
  5493. renamelog += "!!! Tables Updated" & vbCrLf & vbCrLf
  5494. Catch
  5495. renamelog += "!!! Failed to update tables, use 'Refresh TV Shows' menu item to fix" & vbCrLf & vbCrLf
  5496. End Try
  5497. End If
  5498. Next
  5499. Next
  5500. Call Tv_CacheSave()
  5501. messbox.Close()
  5502. If Pref.disabletvlogs Then
  5503. Dim MyFormObject As New frmoutputlog(renamelog, True)
  5504. Try
  5505. MyFormObject.ShowDialog()
  5506. Catch ex As ObjectDisposedException
  5507. Catch ex As Exception
  5508. #If SilentErrorScream Then
  5509. Throw ex
  5510. #End If
  5511. End Try
  5512. End If
  5513. Catch ex As Exception
  5514. ExceptionHandler.LogError(ex)
  5515. End Try
  5516. End Sub
  5517. Private Sub Tv_TreeViewContext_RescrapeWizard_Click(sender As System.Object, e As System.EventArgs) Handles Tv_TreeViewContext_RescrapeWizard.Click
  5518. Try
  5519. singleshow = True
  5520. TV_BatchRescrapeWizardToolStripMenuItem.PerformClick()
  5521. While tvbckrescrapewizard.IsBusy
  5522. Application.DoEvents()
  5523. End While
  5524. singleshow = False
  5525. Catch ex As Exception
  5526. End Try
  5527. End Sub
  5528. Private Sub Tv_TreeViewContext_RescrapeMediaTags_Click(sender As System.Object, e As System.EventArgs) Handles Tv_TreeViewContext_RescrapeMediaTags.Click
  5529. Try
  5530. Dim tmp As Integer = Utilities.languagelibrary.count
  5531. Dim WorkingTvShow As TvShow = tv_ShowSelectedCurrently(TvTreeview)
  5532. Dim tempint As Integer = 0
  5533. Dim nfofilestorename As New List(Of String)
  5534. nfofilestorename.Clear()
  5535. Dim donelist As New List(Of String)
  5536. donelist.Clear()
  5537. If TvTreeview.SelectedNode.Name.IndexOf("\missing\") = -1 Then
  5538. If TypeOf TvTreeview.SelectedNode.Tag Is Media_Companion.TvEpisode Then
  5539. 'individual episode
  5540. If Not nfofilestorename.Contains(TvTreeview.SelectedNode.Name) And TvTreeview.SelectedNode.Name.IndexOf("\missing\") = -1 Then
  5541. nfofilestorename.Add(TvTreeview.SelectedNode.Name)
  5542. End If
  5543. ElseIf TypeOf TvTreeview.SelectedNode.Tag Is Media_Companion.TvSeason Then
  5544. 'season
  5545. tempint = MessageBox.Show("This option will Rescrape Media tags for the selected season" & vbCrLf & "Do you wish to continue?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning)
  5546. If tempint = DialogResult.No Then
  5547. Exit Sub
  5548. End If
  5549. Dim childnode As TreeNode
  5550. For Each childnode In TvTreeview.SelectedNode.Nodes
  5551. If Not nfofilestorename.Contains(childnode.Name) And childnode.Name.IndexOf("\missing\") = -1 Then
  5552. nfofilestorename.Add(childnode.Name)
  5553. End If
  5554. Next
  5555. ElseIf TypeOf TvTreeview.SelectedNode.Tag Is Media_Companion.TvShow Then
  5556. 'full show
  5557. tempint = MessageBox.Show("This option will Rescrape Media tags for the selected show" & vbCrLf & "Do you wish to continue?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning)
  5558. If tempint = DialogResult.No Then
  5559. Exit Sub
  5560. End If
  5561. Dim childnode As TreeNode
  5562. Dim childchildnode As TreeNode
  5563. For Each childnode In TvTreeview.SelectedNode.Nodes
  5564. For Each childchildnode In childnode.Nodes
  5565. If Not nfofilestorename.Contains(childchildnode.Name) And childchildnode.Name.IndexOf("\missing\") = -1 Then
  5566. nfofilestorename.Add(childchildnode.Name)
  5567. End If
  5568. Next
  5569. Next
  5570. End If
  5571. End If
  5572. messbox = New frmMessageBox("Getting Media Tags for episodes,", "", " Please Wait")
  5573. messbox.Show()
  5574. messbox.Refresh()
  5575. Application.DoEvents()
  5576. If nfofilestorename.Count <= 0 Then
  5577. messbox.Close()
  5578. Exit Sub
  5579. End If
  5580. For Each nfo In nfofilestorename
  5581. Try
  5582. Dim ThisEp As New List(Of TvEpisode)
  5583. ThisEp.Clear()
  5584. ThisEp = WorkingWithNfoFiles.ep_NfoLoad(nfo)
  5585. For h = ThisEp.Count - 1 To 0 Step -1
  5586. Dim fileStreamDetails As FullFileDetails = Pref.Get_HdTags(Utilities.GetFileName(ThisEp(h).VideoFilePath))
  5587. ThisEp(h).Details.StreamDetails.Video = fileStreamDetails.filedetails_video
  5588. ThisEp(h).Details.StreamDetails.Audio.Clear()
  5589. For Each audioStream In fileStreamDetails.filedetails_audio
  5590. ThisEp(h).Details.StreamDetails.Audio.Add(audioStream)
  5591. Next
  5592. ThisEp(h).Details.StreamDetails.Subtitles.Clear()
  5593. For each langStream In fileStreamDetails.filedetails_subtitles
  5594. ThisEp(h).Details.StreamDetails.Subtitles.Add(langStream)
  5595. Next
  5596. If ThisEp(h).Details.StreamDetails.Video.DurationInSeconds.Value <> Nothing Then
  5597. Try
  5598. Dim tempstring As String
  5599. tempstring = ThisEp(h).Details.StreamDetails.Video.DurationInSeconds.Value
  5600. If Pref.intruntime Then
  5601. ThisEp(h).Runtime.Value = Math.Round(tempstring / 60).ToString
  5602. Else
  5603. ThisEp(h).Runtime.Value = Math.Round(tempstring / 60).ToString & " min"
  5604. End If
  5605. Catch
  5606. End Try
  5607. End If
  5608. Next
  5609. WorkingWithNfoFiles.ep_NfoSave(ThisEp, ThisEp(0).NfoFilePath)
  5610. Catch ex As Exception
  5611. messbox.Close()
  5612. ExceptionHandler.LogError(ex)
  5613. End Try
  5614. Next
  5615. messbox.Close()
  5616. tv_CacheRefresh(WorkingTvShow)
  5617. Catch ex As Exception
  5618. messbox.Close()
  5619. ExceptionHandler.LogError(ex)
  5620. End Try
  5621. End Sub
  5622. Private Sub Tv_TreeViewContext_MissingEpThumbs_Click(sender As System.Object, e As System.EventArgs) Handles Tv_TreeViewContext_MissingEpThumbs.Click
  5623. Try
  5624. Dim tmp As Integer = Utilities.languagelibrary.count
  5625. Dim WorkingTvShow As TvShow = tv_ShowSelectedCurrently(TvTreeview)
  5626. Dim tempint As Integer = 0
  5627. Dim seasonnumber As Integer = -1
  5628. Dim nfofilestorename As New List(Of String)
  5629. nfofilestorename.Clear()
  5630. Dim donelist As New List(Of String)
  5631. donelist.Clear()
  5632. If WorkingTvShow.Episodes.Count = 0 Then
  5633. MsgBox("No Episodes in this Show")
  5634. Exit Sub
  5635. End If
  5636. If TvTreeview.SelectedNode.Name.IndexOf("\missing\") = -1 Then
  5637. If TypeOf TvTreeview.SelectedNode.Tag Is Media_Companion.TvSeason Then
  5638. Dim Thisseason As TvSeason = TvTreeview.SelectedNode.Tag
  5639. seasonnumber = Thisseason.SeasonNumber
  5640. End If
  5641. End If
  5642. messbox = New frmMessageBox("Scanning for Missing episode thumbnails,", "and downloading if available.", " Please Wait")
  5643. messbox.Show()
  5644. messbox.Refresh()
  5645. Application.DoEvents()
  5646. Dim tvdbstuff As New TVDBScraper
  5647. Dim tvseriesdata As New Tvdb.ShowData
  5648. Dim language As String = WorkingTvShow.Language.Value
  5649. If language = "" Then language = "en"
  5650. tvseriesdata = tvdbstuff.GetShow(WorkingTvShow.TvdbId.Value, language, SeriesXmlPath)
  5651. For Each ep As TvEpisode In WorkingTvShow.Episodes
  5652. If ep.IsMissing Then Continue For
  5653. If Not seasonnumber = -1 AndAlso ep.Season.Value <> seasonnumber.ToString Then Continue For
  5654. Dim Episodedata As New Tvdb.Episode
  5655. Dim epfound As Boolean = False
  5656. If Not tvseriesdata.FailedLoad Then
  5657. For Each NewEpisode As Tvdb.Episode In tvseriesdata.Episodes
  5658. If Not String.IsNullOrEmpty(ep.UniqueId.Value) Then
  5659. If NewEpisode.Id.Value = ep.UniqueId.Value Then epfound = True
  5660. ElseIf NewEpisode.SeasonNumber.Value = ep.Season.Value
  5661. If NewEpisode.EpisodeNumber.Value = ep.Episode.Value Then epfound = True
  5662. End If
  5663. If epfound Then
  5664. Episodedata = NewEpisode
  5665. Episodedata.ThumbNail.Value = "http://www.thetvdb.com/banners/" & NewEpisode.ThumbNail.value
  5666. Exit For
  5667. End If
  5668. Next
  5669. End If
  5670. If Not epfound Then
  5671. Dim sortorder As String = WorkingTvShow.SortOrder.Value
  5672. If sortorder = "" Then sortorder = "default"
  5673. Dim tvdbid As String = WorkingTvShow.TvdbId.Value
  5674. Dim imdbid As String = WorkingTvShow.ImdbId.Value
  5675. Dim seasonno As String = ep.Season.Value
  5676. Dim episodeno As String = ep.Episode.Value
  5677. Episodedata = tvdbstuff.getepisodefromxml(tvdbid, sortorder, seasonno, episodeno, language, True)
  5678. If Episodedata.FailedLoad Then Continue For
  5679. End If
  5680. Dim epdata As New TvEpisode
  5681. epdata.AbsorbTvdbEpisode(Episodedata)
  5682. epdata.NfoFilePath = ep.NfoFilePath
  5683. epdata.VideoFilePath = ep.VideoFilePath
  5684. epdata.Thumbnail.Url = Episodedata.ThumbNail.Value
  5685. tv_EpisodeFanartGet(epdata, False)
  5686. Next
  5687. messbox.Close()
  5688. Catch ex As Exception
  5689. messbox.Close()
  5690. ExceptionHandler.LogError(ex)
  5691. End Try
  5692. End Sub
  5693. Private Sub tv_PosterSetup(Optional ByVal IsOfType As String = "")
  5694. Dim WorkingTvShow As TvShow = tv_ShowSelectedCurrently(TvTreeview)
  5695. Dim WorkingSeason As TvSeason = tv_SeasonSelectedCurrently(TvTreeview)
  5696. tvposterpage = 0
  5697. imdbposterlist.Clear()
  5698. tvdbposterlist.Clear()
  5699. rbTVposter.Checked = True
  5700. rbTVposter.Enabled = False
  5701. rbTVbanner.Enabled = False
  5702. ComboBox2.Items.Clear()
  5703. tvobjects.Clear()
  5704. TextBox31.Text = WorkingTvShow.Title.Value
  5705. Label72.Text = ""
  5706. tv_PosterPanelClear()
  5707. ComboBox2.Items.Add("Main Image")
  5708. ComboBox2.Items.Add("Season All")
  5709. For Each tvshow In Cache.TvCache.Shows
  5710. If tvshow.TvdbId = WorkingTvShow.TvdbId Then
  5711. For Each Season As Media_Companion.TvSeason In tvshow.Seasons.Values
  5712. For Each ep As Media_Companion.TvEpisode In Season.Episodes
  5713. Dim seasonstring As String = ""
  5714. If ep.Season.Value < 1 Then
  5715. seasonstring = "Specials"
  5716. Else
  5717. seasonstring = "Season " & Utilities.PadNumber(ep.Season.Value.ToString, 2)
  5718. End If
  5719. If Not ComboBox2.Items.Contains(seasonstring) Then
  5720. ComboBox2.Items.Add(seasonstring)
  5721. End If
  5722. Next
  5723. Next
  5724. Exit For
  5725. End If
  5726. Next
  5727. ComboBox2.SelectedIndex = 0
  5728. If Not WorkingSeason is Nothing then
  5729. Dim ThisSeason As String = WorkingSeason.ToString
  5730. If ThisSeason = "Season 00" then ThisSeason = "Specials"
  5731. For i=0 to ComboBox2.Items.Count
  5732. ComboBox2.SelectedIndex = i
  5733. If ComboBox2.text = ThisSeason Then
  5734. If IsOfType = "banner" Then rbTVbanner.Checked = True
  5735. Exit For
  5736. End If
  5737. Next
  5738. End If
  5739. End Sub
  5740. Public Function BannerAndPosterViewer()
  5741. Try
  5742. Me.Panel16.Hide()
  5743. Label72.Text = ""
  5744. Dim WorkingTvShow As TvShow = tv_ShowSelectedCurrently(TvTreeview)
  5745. rbTVposter.Enabled = True
  5746. rbTVbanner.Enabled = True
  5747. btnTvPosterTVDBSpecific.Enabled = True
  5748. Dim eden As Boolean = Pref.EdenEnabled
  5749. Dim frodo As Boolean = Pref.FrodoEnabled
  5750. Dim edenpath As String =""
  5751. Dim frodopath As string =""
  5752. Dim tempstring As String = ComboBox2.SelectedItem
  5753. Dim PresentImage As String = ""
  5754. Dim defimg As String = ""
  5755. Dim path As String = ""
  5756. EdenImageTrue.Visible = False
  5757. FrodoImageTrue.Visible=False
  5758. If tempstring = "Main Image" Then
  5759. If eden Then
  5760. path = WorkingTvShow.NfoFilePath.Replace("tvshow.nfo", "folder.jpg")
  5761. edenpath = path
  5762. End If
  5763. If frodo Then
  5764. If rbTVbanner.Checked = True Then
  5765. path = WorkingTvShow.NfoFilePath.Replace("tvshow.nfo", "banner.jpg")
  5766. frodopath = path
  5767. ElseIf rbTVposter.Checked = True Then
  5768. path = WorkingTvShow.NfoFilePath.Replace("tvshow.nfo", "poster.jpg")
  5769. frodopath = path
  5770. End If
  5771. End If
  5772. ElseIf tempstring = "Specials" Then
  5773. If eden Then
  5774. path = WorkingTvShow.NfoFilePath.Replace("tvshow.nfo", "season-specials.tbn")
  5775. edenpath = path
  5776. End If
  5777. If frodo Then
  5778. If rbTVbanner.Checked = True Then
  5779. path = WorkingTvShow.NfoFilePath.Replace("tvshow.nfo", "season-specials-banner.jpg")
  5780. frodopath = path
  5781. ElseIf rbTVposter.Checked = True Then
  5782. path = WorkingTvShow.NfoFilePath.Replace("tvshow.nfo", "season-specials-poster.jpg")
  5783. frodopath = path
  5784. End If
  5785. End If
  5786. ElseIf tempstring.IndexOf("Season") = 0 And tempstring.IndexOf("Season All") = -1 Then
  5787. path = tempstring.Replace("Season ", "")
  5788. path = WorkingTvShow.NfoFilePath.Replace("tvshow.nfo", "season" & path & ".tbn")
  5789. edenpath = path
  5790. If frodo Then
  5791. If rbTVbanner.Checked = True Then
  5792. path = path.Replace(".tbn", "-banner.jpg")
  5793. frodopath = path
  5794. ElseIf rbTVposter.Checked = True Then
  5795. path = path.Replace(".tbn", "-poster.jpg")
  5796. frodopath = path
  5797. End If
  5798. End If
  5799. ElseIf tempstring = "Season All" Then
  5800. btnTvPosterTVDBSpecific.Enabled = False
  5801. If eden Then
  5802. path = WorkingTvShow.NfoFilePath.Replace("tvshow.nfo", "season-all.tbn")
  5803. edenpath = path
  5804. End If
  5805. If frodo Then
  5806. If rbTVbanner.Checked = True Then
  5807. path = WorkingTvShow.NfoFilePath.Replace("tvshow.nfo", "season-all-banner.jpg")
  5808. frodopath = path
  5809. ElseIf rbTVposter.Checked = True Then
  5810. path = WorkingTvShow.NfoFilePath.Replace("tvshow.nfo", "season-all-poster.jpg")
  5811. frodopath = path
  5812. End If
  5813. End If
  5814. End If
  5815. If (eden and IO.File.Exists(edenpath)) or (frodo and IO.File.Exists(frodopath)) Then
  5816. EdenImageTrue.Visible =False
  5817. EdenImageTrue.Text = "Eden Image Present"
  5818. FrodoImageTrue.Visible=False
  5819. FrodoImageTrue.Text = "Frodo Image Present"
  5820. ArtMode.Text=""
  5821. If eden Then
  5822. EdenImageTrue.Visible = True
  5823. ArtMode.Text="Pre-Frodo Enabled"
  5824. End If
  5825. If frodo Then
  5826. FrodoImageTrue.Visible = True
  5827. ArtMode.Text="Frodo Enabled"
  5828. End If
  5829. If frodo and eden then
  5830. ArtMode.text="Both Enabled"
  5831. EdenImageTrue.Visible=True
  5832. FrodoImageTrue.Visible=True
  5833. End If
  5834. If IO.File.Exists(edenpath) then
  5835. PresentImage = edenpath
  5836. EdenImageTrue.Text = "Eden Image Present"
  5837. Else
  5838. EdenImageTrue.Text = "No Eden Image"
  5839. End If
  5840. If IO.File.Exists(frodopath) then
  5841. PresentImage = frodopath
  5842. FrodoImageTrue.Text="Frodo Image Present"
  5843. Else
  5844. FrodoImageTrue.Text = "No Frodo Image"
  5845. End If
  5846. Else
  5847. If rbTVbanner.Checked = True Then
  5848. defimg = Utilities.DefaultBannerPath
  5849. If eden and not frodo then
  5850. EdenImageTrue.Text="No Eden Image"
  5851. EdenImageTrue.Visible=True
  5852. FrodoImageTrue.Visible=False
  5853. ElseIf frodo and Not eden then
  5854. FrodoImageTrue.Text="No Frodo Image"
  5855. FrodoImageTrue.Visible=True
  5856. EdenImageTrue.Visible=False
  5857. ElseIf frodo and eden then
  5858. EdenImageTrue.Text="No Eden Image"
  5859. EdenImageTrue.Visible=True
  5860. FrodoImageTrue.Text="No Frodo Image"
  5861. FrodoImageTrue.Visible=True
  5862. End If
  5863. Else
  5864. defimg = Utilities.DefaultPosterPath
  5865. If eden and not frodo then
  5866. EdenImageTrue.Text="No Eden Image"
  5867. EdenImageTrue.Visible=True
  5868. FrodoImageTrue.Visible=False
  5869. ElseIf frodo and Not eden then
  5870. FrodoImageTrue.Text="No Frodo Image"
  5871. FrodoImageTrue.Visible=True
  5872. EdenImageTrue.Visible=False
  5873. ElseIf frodo and eden then
  5874. EdenImageTrue.Text="No Eden Image"
  5875. EdenImageTrue.Visible=True
  5876. FrodoImageTrue.Text="No Frodo Image"
  5877. FrodoImageTrue.Visible=True
  5878. End If
  5879. End If
  5880. End If
  5881. util_ImageLoad(PictureBox12, PresentImage, If(rbTVbanner.Checked, Utilities.DefaultTvBannerPath, Utilities.DefaultTvPosterPath))
  5882. If rbTVbanner.Checked = True Then
  5883. Label73.Text = "Current Banner - " & PictureBox12.Image.Width.ToString & " x " & PictureBox12.Image.Height.ToString
  5884. Else
  5885. Label73.Text = "Current Poster - " & PictureBox12.Image.Width.ToString & " x " & PictureBox12.Image.Height.ToString
  5886. End If
  5887. Return 0
  5888. Catch ex As Exception
  5889. Return 0
  5890. ExceptionHandler.LogError(ex)
  5891. End Try
  5892. End Function
  5893. Private Sub tv_TvdbThumbsGet()
  5894. Dim WorkingTvShow As TvShow = tv_ShowSelectedCurrently(TvTreeview)
  5895. Dim showlist As New XmlDocument
  5896. Dim tvdbstuff As New TVDBScraper
  5897. 'Dim AListOfBanners As New List(Of TvBanners)
  5898. Dim thumblist As String = tvdbstuff.GetPosterList(WorkingTvShow.TvdbId.Value, tvdbposterlist)
  5899. If thumblist <> "ok" Then MsgBox(thumblist, MsgBoxStyle.OkOnly, "TVdb site returned.....")
  5900. 'Try
  5901. ' showlist.LoadXml(thumblist)
  5902. 'Catch ex As Exception
  5903. ' MsgBox(thumblist, MsgBoxStyle.OkOnly, "TVdb site returned.....")
  5904. ' Exit Sub
  5905. 'End Try
  5906. 'For Each thisresult In showlist("banners")
  5907. ' Select Case thisresult.Name
  5908. ' Case "banner"
  5909. ' Dim individualposter As New TvBanners
  5910. ' For Each results In thisresult.ChildNodes
  5911. ' Select Case results.Name
  5912. ' Case "id"
  5913. ' individualposter.id = results.InnerText
  5914. ' Case "url"
  5915. ' individualposter.Url = results.InnerText
  5916. ' Case "bannertype"
  5917. ' individualposter.BannerType = results.InnerText
  5918. ' Case "resolution"
  5919. ' individualposter.Resolution = results.InnerText
  5920. ' Case "language"
  5921. ' individualposter.Language = results.InnerText
  5922. ' Case "season"
  5923. ' individualposter.Season = results.InnerText
  5924. ' End Select
  5925. ' Next
  5926. ' individualposter.SmallUrl = individualposter.Url.Replace("http://thetvdb.com/banners/", "http://thetvdb.com/banners/_cache/")
  5927. ' tvdbposterlist.Add(individualposter)
  5928. ' End Select
  5929. 'Next
  5930. End Sub
  5931. Private Sub tv_PosterPanelPopulate()
  5932. Me.Panel16.Show()
  5933. tvposterpage = 1
  5934. If usedlist.Count <= 0 Then
  5935. Label72.Text = "Displaying 0 of 0 Images"
  5936. Label72.Visible = True
  5937. btnTvPosterNext.Visible = False
  5938. btnTvPosterPrev.Visible = False
  5939. Call tv_PosterPanelClear()
  5940. Exit Sub
  5941. End If
  5942. If Not rbTVbanner.Checked Then
  5943. If usedlist.Count > 10 Then
  5944. btnTvPosterNext.Visible = True
  5945. btnTvPosterPrev.Visible = True
  5946. If usedlist.Count >= 10 Then
  5947. Label72.Text = "Displaying 1 to 10 of " & usedlist.Count.ToString & " Images"
  5948. Else
  5949. Label72.Text = "Displaying 1 to " & usedlist.Count.ToString & " of " & usedlist.Count.ToString & " Images"
  5950. End If
  5951. Label72.Visible = True
  5952. Me.Refresh()
  5953. Application.DoEvents()
  5954. btnTvPosterPrev.Enabled = False
  5955. btnTvPosterNext.Enabled = True
  5956. Else
  5957. btnTvPosterNext.Visible = False
  5958. btnTvPosterPrev.Visible = False
  5959. If posterArray.Count >= 10 Then
  5960. Label72.Text = "Displaying 1 to 10 of " & usedlist.Count.ToString & " Images"
  5961. 'Label72.Text = "Displaying 1 to " & Pref.maximumthumbs & " of " & usedlist.Count.ToString & " Images"
  5962. Else
  5963. Label72.Text = "Displaying 1 to " & usedlist.Count.ToString & " of " & usedlist.Count.ToString & " Images"
  5964. End If
  5965. Label72.Visible = True
  5966. Me.Refresh()
  5967. Application.DoEvents()
  5968. End If
  5969. Else
  5970. btnTvPosterNext.Visible = False
  5971. btnTvPosterPrev.Visible = False
  5972. Label72.Text = "Displaying 1 to " & usedlist.Count.ToString
  5973. End If
  5974. Call tv_PosterSelectionDisplay()
  5975. End Sub
  5976. Private Sub tv_PosterPanelClear()
  5977. For i = Panel16.Controls.Count - 1 To 0 Step -1
  5978. Panel16.Controls.RemoveAt(i)
  5979. Next
  5980. End Sub
  5981. Private Sub tv_PosterSelectionDisplay()
  5982. tv_PosterPanelClear()
  5983. Dim tempint As Integer = ((tvposterpage * 10) + 1) - 10
  5984. Dim tempint2 As Integer = tvposterpage * 10
  5985. If tempint2 > usedlist.Count Then
  5986. tempint2 = usedlist.Count
  5987. End If
  5988. If Not rbTVbanner.Checked Then
  5989. Label72.Text = "Displaying " & tempint.ToString & " to " & tempint2 & " of " & usedlist.Count.ToString & " Images"
  5990. Else
  5991. Label72.Text = "Displaying 1 to " & usedlist.Count.ToString
  5992. tempint2 = usedlist.Count
  5993. End If
  5994. Dim locationX As Integer = 0
  5995. Dim locationY As Integer = 0
  5996. Dim itemcounter As Integer = 0
  5997. Dim tempboolean As Boolean = True
  5998. Dim MovFanartPicBox As New List(Of FanartPicBox)
  5999. If rbTVposter.Checked = True Or rbTVbanner.Enabled = False Then
  6000. For f = tempint - 1 To tempint2 - 1
  6001. Dim thispicbox As New FanartPicBox
  6002. tvposterpicboxes() = New PictureBox()
  6003. With tvposterpicboxes
  6004. .Location = New Point(locationX, locationY)
  6005. .Width = 123
  6006. .Height = 168
  6007. .SizeMode = PictureBoxSizeMode.Zoom
  6008. .Tag = usedlist(f).Url
  6009. .Visible = True
  6010. .BorderStyle = BorderStyle.Fixed3D
  6011. .Name = "poster" & itemcounter.ToString
  6012. AddHandler tvposterpicboxes.DoubleClick, AddressOf tv_PosterDoubleClick
  6013. 'AddHandler tvposterpicboxes.LoadCompleted, AddressOf imageres
  6014. End With
  6015. thispicbox.pbox = tvposterpicboxes
  6016. thispicbox.imagepath = usedlist(f).SmallUrl
  6017. MovFanartPicBox.Add(thispicbox)
  6018. tvpostercheckboxes() = New RadioButton()
  6019. With tvpostercheckboxes
  6020. .Location = New Point(locationX + 19, locationY + 166) '179
  6021. .Width = 79
  6022. .Height = 32
  6023. .Name = "postercheckbox" & itemcounter.ToString
  6024. .SendToBack()
  6025. .CheckAlign = ContentAlignment.TopCenter
  6026. If usedlist(f).Resolution = "season" Then
  6027. .Text = " "
  6028. ElseIf usedlist(f).Resolution <> "" Then
  6029. .Text = usedlist(f).Resolution
  6030. Else
  6031. .Text = "?"
  6032. End If
  6033. .TextAlign = ContentAlignment.BottomCenter
  6034. .Tag = usedlist(f).Url
  6035. AddHandler tvpostercheckboxes.CheckedChanged, AddressOf tv_PosterRadioChanged
  6036. End With
  6037. itemcounter += 1
  6038. Me.Panel16.Controls.Add(tvposterpicboxes())
  6039. Me.Panel16.Controls.Add(tvpostercheckboxes())
  6040. Application.DoEvents()
  6041. If tempboolean = True Then
  6042. locationY = (192 + 19)
  6043. Else
  6044. locationX += 120
  6045. locationY = 0
  6046. End If
  6047. tempboolean = Not tempboolean
  6048. Next
  6049. Else
  6050. For f = tempint - 1 To tempint2 - 1
  6051. Dim thispicbox As New FanartPicBox
  6052. tvposterpicboxes() = New PictureBox()
  6053. With tvposterpicboxes
  6054. .Location = New Point(0, locationY)
  6055. .Width = 600
  6056. .Height = 114
  6057. .SizeMode = PictureBoxSizeMode.Zoom
  6058. .Tag = usedlist(f).Url
  6059. .Visible = True
  6060. .BorderStyle = BorderStyle.Fixed3D
  6061. .Name = "poster" & itemcounter.ToString
  6062. AddHandler tvposterpicboxes.DoubleClick, AddressOf tv_PosterDoubleClick
  6063. 'AddHandler tvposterpicboxes.LoadCompleted, AddressOf imageres
  6064. End With
  6065. thispicbox.pbox = tvposterpicboxes
  6066. thispicbox.imagepath = usedlist(f).Url
  6067. MovFanartPicBox.Add(thispicbox)
  6068. tvpostercheckboxes() = New RadioButton()
  6069. With tvpostercheckboxes
  6070. .Location = New Point(290, locationY + 110)
  6071. .Name = "postercheckbox" & itemcounter.ToString
  6072. .SendToBack()
  6073. .Text = " "
  6074. .Tag = usedlist(f).Url
  6075. AddHandler tvpostercheckboxes.CheckedChanged, AddressOf tv_PosterRadioChanged
  6076. End With
  6077. itemcounter += 1
  6078. locationY += 140
  6079. Me.Panel16.Controls.Add(tvposterpicboxes())
  6080. Me.Panel16.Controls.Add(tvpostercheckboxes())
  6081. Application.DoEvents()
  6082. Next
  6083. End If
  6084. Me.Panel16.Refresh()
  6085. Me.Refresh()
  6086. If MovFanartPicBox.Count > 0 Then
  6087. messbox.Close()
  6088. If Not ImgBw.IsBusy Then
  6089. ToolStripStatusLabel2.Text = "Starting Download of Images..."
  6090. ToolStripStatusLabel2.Visible = True
  6091. ImgBw.RunWorkerAsync({MovFanartPicBox, tempint, tempint2, Me.Panel16})
  6092. End If
  6093. End If
  6094. Me.Panel16.Refresh()
  6095. Me.Refresh()
  6096. Application.DoEvents()
  6097. If rbTVbanner.Checked AndAlso Me.Panel16.Controls.Count > 0 Then EnableTvBannerScrolling
  6098. Me.Refresh()
  6099. End Sub
  6100. Private Sub tv_PosterRadioChanged(ByVal sender As Object, ByVal e As EventArgs)
  6101. Dim tempstring As String = sender.name
  6102. Dim tempint As Integer = 0
  6103. Dim tempstring2 As String = tempstring
  6104. Dim allok As Boolean = False
  6105. tempstring = tempstring.Replace("postercheckbox", "")
  6106. tempint = Convert.ToDecimal(tempstring)
  6107. Dim hires(1)
  6108. Dim lores(1)
  6109. lores(0) = ""
  6110. hires(0) = ""
  6111. lores(1) = ""
  6112. hires(1) = ""
  6113. For Each cont As Control In Me.Panel16.Controls()
  6114. If cont.Name.Replace("poster", "") = tempint.ToString Then
  6115. Dim picbox As PictureBox = cont
  6116. lores(0) = "Save Image (" & picbox.Image.Width & " x " & picbox.Image.Height & ")"
  6117. lores(1) = picbox.Name
  6118. For Each poster In usedlist
  6119. If poster.url = sender.tag Then
  6120. If Not IsNothing(poster.Resolution) AndAlso IsNumeric(poster.resolution.Replace("x", "")) Then
  6121. hires(0) = "Save Image (" & poster.resolution & ")"
  6122. hires(0) = hires(0).replace("x", " x ")
  6123. Else
  6124. hires(0) = "Save Image (Hi-Res)"
  6125. End If
  6126. hires(1) = poster.url
  6127. Exit For
  6128. End If
  6129. Next
  6130. allok = True
  6131. Exit For
  6132. End If
  6133. Next
  6134. If allok = True Then
  6135. btnTvPosterSaveBig.Text = hires(0)
  6136. btnTvPosterSaveBig.Visible = True
  6137. btnTvPosterSaveBig.Tag = hires(1)
  6138. Else
  6139. btnTvPosterSaveBig.Visible = False
  6140. End If
  6141. End Sub
  6142. Private Sub tv_PosterDoubleClick(ByVal sender As Object, ByVal e As EventArgs)
  6143. Dim tempstring As String = sender.name.replace("poster", "postercheckbox")
  6144. Dim hdurl As String = ""
  6145. For Each Control In Panel16.Controls
  6146. If Control.name = tempstring Then
  6147. Dim rb As RadioButton = Control
  6148. rb.Checked = True
  6149. hdurl = rb.Tag.ToString
  6150. End If
  6151. Next
  6152. messbox = New frmMessageBox("Please wait,", "", "Downloading Full Image")
  6153. System.Windows.Forms.Cursor.Current = Cursors.WaitCursor
  6154. messbox.Show()
  6155. Me.Refresh()
  6156. messbox.Refresh()
  6157. If hdurl = "" Then hdurl = sender.tag.tostring
  6158. Dim cachefile As String = Utilities.Download2Cache(hdurl)
  6159. Call util_ZoomImage(cachefile)
  6160. messbox.Close()
  6161. End Sub
  6162. Private Sub TvPosterSave(ByVal imageUrl As String)
  6163. If ImgBw.IsBusy Then
  6164. ImgBw.CancelAsync()
  6165. Do Until Not ImgBw.IsBusy
  6166. Application.DoEvents()
  6167. Loop
  6168. End If
  6169. Try
  6170. Dim witherror As Boolean = False
  6171. Dim witherror2 As Boolean = False
  6172. Dim path As String = ""
  6173. Dim eden As Int16=0
  6174. Dim frodo As Int16=0
  6175. Dim imagePaths As New List(Of String)
  6176. Dim WorkingTvShow As TvShow = tv_ShowSelectedCurrently(TvTreeview)
  6177. Dim workingposterpath = WorkingTvShow.FolderPath & "folder.jpg"
  6178. If ComboBox2.Text.ToLower = "main image" Then
  6179. If (Pref.EdenEnabled OrElse Pref.tvfolderjpg) And Not (Pref.FrodoEnabled AndAlso rbTVbanner.Checked) Then
  6180. imagePaths.Add(workingposterpath)
  6181. eden = 1
  6182. End If
  6183. If Pref.FrodoEnabled Then
  6184. If rbTVbanner.Checked = True Then
  6185. imagePaths.Add(workingposterpath.Replace(IO.Path.GetFileName(workingposterpath), "banner.jpg"))
  6186. frodo = 1
  6187. ElseIf rbTVposter.Checked = True Then
  6188. imagePaths.Add(workingposterpath.Replace(IO.Path.GetFileName(workingposterpath), "poster.jpg"))
  6189. frodo = 1
  6190. End If
  6191. End If
  6192. If Pref.tvfolderjpg AndAlso rbTVposter.Checked Then
  6193. imagePaths.Add(workingposterpath)
  6194. End If
  6195. ElseIf ComboBox2.Text.ToLower.IndexOf("season") <> -1 And ComboBox2.Text.ToLower.IndexOf("all") = -1 Then
  6196. Dim temp As String = ComboBox2.Text.ToLower
  6197. temp = temp.Replace(" ", "")
  6198. If Pref.EdenEnabled Then
  6199. imagePaths.Add(workingposterpath.Replace(IO.Path.GetFileName(workingposterpath), temp & ".tbn"))
  6200. eden =1
  6201. End If
  6202. If Pref.FrodoEnabled Then
  6203. If rbTVbanner.Checked = True Then
  6204. imagePaths.Add(workingposterpath.Replace(IO.Path.GetFileName(workingposterpath), temp & "-banner.jpg"))
  6205. frodo = 1
  6206. ElseIf rbTVposter.Checked = True Then
  6207. imagePaths.Add(workingposterpath.Replace(IO.Path.GetFileName(workingposterpath), temp & "-poster.jpg"))
  6208. frodo = 1
  6209. End If
  6210. End If
  6211. If Pref.seasonfolderjpg Then
  6212. temp = temp.Replace("season", "")
  6213. Dim seasonno As Integer = temp.ToInt
  6214. Dim seasonpath As String = Nothing
  6215. For Each ep As TvEpisode In WorkingTvShow.Episodes
  6216. If ep.Season.Value = seasonno Then
  6217. seasonpath = ep.FolderPath.Replace(WorkingTvShow.FolderPath, "")
  6218. Exit For
  6219. End If
  6220. Next
  6221. If Not IsNothing(seasonpath) Then imagePaths.Add(WorkingTvShow.FolderPath & seasonpath & "folder.jpg")
  6222. End If
  6223. ElseIf ComboBox2.Text.ToLower.IndexOf("season") <> -1 And ComboBox2.Text.ToLower.IndexOf("all") <> -1 Then
  6224. If Pref.EdenEnabled Then
  6225. If Pref.seasonall="poster" and rbTVposter.Checked Then
  6226. imagePaths.Add(workingposterpath.Replace(IO.Path.GetFileName(workingposterpath), "season-all.tbn"))
  6227. eden =1
  6228. ElseIf Pref.seasonall="wide" and rbTVbanner.Checked Then
  6229. imagePaths.Add(workingposterpath.Replace(IO.Path.GetFileName(workingposterpath), "season-all.tbn"))
  6230. eden =1
  6231. End If
  6232. End If
  6233. If Pref.FrodoEnabled Then
  6234. If rbTVbanner.Checked = True Then
  6235. imagePaths.Add(workingposterpath.Replace(IO.Path.GetFileName(workingposterpath), "season-all-banner.jpg"))
  6236. frodo = 1
  6237. ElseIf rbTVposter.Checked = True Then
  6238. imagePaths.Add(workingposterpath.Replace(IO.Path.GetFileName(workingposterpath), "season-all-poster.jpg"))
  6239. frodo = 1
  6240. End If
  6241. End If
  6242. ElseIf ComboBox2.Text.ToLower = "specials" Then
  6243. If Pref.EdenEnabled Then
  6244. imagePaths.Add(workingposterpath.Replace(IO.Path.GetFileName(workingposterpath), "season-specials.tbn"))
  6245. eden =1
  6246. End If
  6247. If Pref.FrodoEnabled Then
  6248. If rbTVbanner.Checked = True Then
  6249. imagePaths.Add(workingposterpath.Replace(IO.Path.GetFileName(workingposterpath), "season-specials-banner.jpg"))
  6250. frodo = 1
  6251. ElseIf rbTVposter.Checked = True Then
  6252. imagePaths.Add(workingposterpath.Replace(IO.Path.GetFileName(workingposterpath), "season-specials-poster.jpg"))
  6253. frodo = 1
  6254. End If
  6255. End If
  6256. If Pref.seasonfolderjpg AndAlso rbTVposter.Checked Then
  6257. Dim seasonpath As String = ""
  6258. For Each seas In WorkingTvShow.Seasons.Values
  6259. If seas.SeasonNumber = 0 Then
  6260. seasonpath = seas.FolderPath
  6261. Exit For
  6262. End If
  6263. Next
  6264. If seasonpath <> "" Then
  6265. imagePaths.Add(seasonpath & "folder.jpg")
  6266. End If
  6267. End If
  6268. End If
  6269. messbox = New frmMessageBox("Please wait,", "", "Downloading Full Resolution Image")
  6270. System.Windows.Forms.Cursor.Current = Cursors.WaitCursor
  6271. messbox.Show()
  6272. Me.Refresh()
  6273. messbox.Refresh()
  6274. Try
  6275. If Not IsNothing(imageUrl) Then
  6276. witherror = Not DownloadCache.SaveImageToCacheAndPaths(imageUrl, ImagePaths, True)
  6277. If Not witherror Then
  6278. path = imagePaths(0)
  6279. If rbTVbanner.Checked Then
  6280. util_ImageLoad(tv_PictureBoxBottom, path, Utilities.DefaultTvBannerPath)
  6281. End If
  6282. If rbTVposter.Checked Then
  6283. util_ImageLoad(tv_PictureBoxRight, path, Utilities.DefaultTvPosterPath)
  6284. End If
  6285. util_ImageLoad(PictureBox12, path, Utilities.DefaultTvPosterPath)
  6286. Label73.Text = "Current Poster - " & PictureBox12.Image.Width.ToString & " x " & PictureBox12.Image.Height.ToString
  6287. End If
  6288. End If
  6289. If witherror = True Then
  6290. MsgBox("Unable to download image")
  6291. Else
  6292. If eden =1 then
  6293. EdenImageTrue.Visible =True
  6294. EdenImageTrue.Text="Eden Image Present"
  6295. End if
  6296. If frodo =1 then
  6297. FrodoImageTrue.Visible =True
  6298. FrodoImageTrue.Text="Frodo Image Present"
  6299. End if
  6300. End If
  6301. Catch ex As Exception
  6302. MsgBox(ex.ToString)
  6303. Finally
  6304. messbox.Close()
  6305. End Try
  6306. If ComboBox2.Text.ToLower = "main image" AndAlso rbtvposter.Checked Then
  6307. Dim popath As String = Utilities.save2postercache(WorkingTvShow.NfoFilePath, WorkingTvShow.ImagePoster.Path, WallPicWidth, WallPicHeight)
  6308. updateTvPosterWall(popath, WorkingTvShow.NfoFilePath)
  6309. End If
  6310. path = ""
  6311. Catch ex As Exception
  6312. ExceptionHandler.LogError(ex)
  6313. End Try
  6314. End Sub
  6315. Private Sub RefreshMovieNfoFilesToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RefreshMovieNfoFilesToolStripMenuItem.Click
  6316. Try
  6317. Call Batch_Rewritenfo()
  6318. Catch ex As Exception
  6319. ExceptionHandler.LogError(ex)
  6320. End Try
  6321. End Sub
  6322. Sub ShowMovieFilter(cbFilter As Control)
  6323. If Not cbFilter.Visible Then
  6324. movie_filters.GetItem(cbFilter.Name).Visible = True
  6325. Pref.movie_filters.SetMovieFiltersVisibility
  6326. UpdateMovieFiltersPanel
  6327. End If
  6328. End Sub
  6329. #Region "Media Info Export"
  6330. Dim exportMovieInfo As Boolean = False 'these are used to allow only a single execution of media export functions
  6331. Dim exportTVInfo As Boolean = False 'when there may be mulitple drop-down events. (Found that out the hard way!)
  6332. Private Sub ExportMovieListInfoToolStripMenuItem_DropDownItemClicked(ByVal sender As Object, ByVal e As System.Windows.Forms.ToolStripItemClickedEventArgs) Handles ExportMovieListInfoToolStripMenuItem.DropDownItemClicked
  6333. If Not exportMovieInfo Then exportMovieInfo = mediaInfoExp.setTemplate(e.ClickedItem.Text)
  6334. End Sub
  6335. Private Sub ExportTVShowInfoToolStripMenuItem_DropDownItemClicked(sender As Object, e As System.Windows.Forms.ToolStripItemClickedEventArgs) Handles ExportTVShowInfoToolStripMenuItem.DropDownItemClicked
  6336. If Not exportTVInfo Then exportTVInfo = mediaInfoExp.setTemplate(e.ClickedItem.Text)
  6337. End Sub
  6338. Private Sub ExportMovieListInfoToolStripMenuItem_DropDownClosed(ByVal sender As Object, ByVal e As System.EventArgs) Handles ExportMovieListInfoToolStripMenuItem.DropDownClosed
  6339. If exportMovieInfo Then
  6340. exportMovieInfo = False
  6341. Call util_ExportMediaListInfo(MediaInfoExport.mediaType.Movie)
  6342. End If
  6343. End Sub
  6344. Private Sub ExportTVShowInfoToolStripMenuItem_DropDownClosed(sender As Object, e As System.EventArgs) Handles ExportTVShowInfoToolStripMenuItem.DropDownClosed
  6345. If exportTVInfo = True Then
  6346. exportTVInfo = False
  6347. Call util_ExportMediaListInfo(MediaInfoExport.mediaType.TV)
  6348. End If
  6349. End Sub
  6350. Private Sub util_ExportMediaListInfo(ByVal mediaType As String)
  6351. Dim savepath As String
  6352. Dim extensions As New Dictionary(Of String, String)
  6353. extensions.Add("html", "Html Documents (*.html)|*.html")
  6354. extensions.Add("xml", "XML Data (*.xml)|*.xml")
  6355. extensions.Add("csv", "CSV (Comma delimited) (*.csv)|*.csv")
  6356. Dim ext As String = mediaInfoExp.getPossibleFileType
  6357. Dim idx As Integer
  6358. For idx = 1 To extensions.Count
  6359. If extensions.Keys(idx - 1) = ext Then Exit For
  6360. Next
  6361. With SaveFileDialog1
  6362. .DefaultExt = ext
  6363. .Filter = String.Join("|", extensions.Values)
  6364. .FilterIndex = idx
  6365. .Title = "ExportMedia File"
  6366. .OverwritePrompt = True
  6367. .CheckPathExists = True
  6368. If mediaInfoExp.workingTemplate.FileName <> "" Then
  6369. .FileName = mediaInfoExp.workingTemplate.FileName
  6370. End If
  6371. End With
  6372. If SaveFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
  6373. savepath = SaveFileDialog1.FileName
  6374. Dim mediaCollection As Object
  6375. If mediaType = MediaInfoExport.mediaType.Movie Then
  6376. 'Dirty hack to get the media export to use the data grid source. Wasn't as straight forward as hoped,
  6377. 'and after spending many hours trying to find an elegant solution, I gave up.
  6378. 'If anyone comes across this and thinks "Huey, you twat, just do it like this", then please go right
  6379. 'ahead! - HueyHQ 15Feb13
  6380. Dim mediaList As New List(Of ComboList)
  6381. For Each mediaItem As Data_GridViewMovie In DataGridViewMovies.DataSource
  6382. mediaList.Add(mediaItem.Export)
  6383. Next
  6384. mediaCollection = mediaList
  6385. Else
  6386. mediaCollection = Cache.TvCache.Shows
  6387. End If
  6388. mediaInfoExp.createDocument(savepath, mediaCollection)
  6389. End If
  6390. End Sub
  6391. #End Region 'Media Info Export
  6392. Private Sub bckgroundscanepisodes_DoWork(ByVal sender As Object, ByVal e As System.ComponentModel.DoWorkEventArgs, Optional ByVal manual As Boolean = False) Handles bckgroundscanepisodes.DoWork
  6393. Try
  6394. Dim List As List(Of TvShow) = e.Argument(0)
  6395. Dim Force As Boolean = e.Argument(1)
  6396. Statusstrip_Enable()
  6397. 'StatusStrip1.BackColor = Color.Honeydew
  6398. 'StatusStrip1.Visible = True
  6399. 'tsStatusLabel1.Visible = False
  6400. Call TV_EpisodeScraper(List, Force)
  6401. Catch ex As Exception
  6402. ExceptionHandler.LogError(ex)
  6403. End Try
  6404. End Sub
  6405. Private Sub bckgroundscanepisodes_ProgressChanged(ByVal sender As Object, ByVal e As System.ComponentModel.ProgressChangedEventArgs) Handles bckgroundscanepisodes.ProgressChanged
  6406. Try
  6407. If e.ProgressPercentage = 0 Then
  6408. ToolStripStatusLabel6.Text = e.UserState
  6409. ToolStripStatusLabel6.Visible = True
  6410. ElseIf e.ProgressPercentage = 1 Then
  6411. If TypeOf e.UserState Is TvEpisode Then
  6412. Dim TempEpisode As TvEpisode = CType(e.UserState, TvEpisode)
  6413. TempEpisode.ShowObj.AddEpisode(TempEpisode)
  6414. TempEpisode.SeasonObj.UpdateTreenode()
  6415. TempEpisode.UpdateTreenode(True)
  6416. 'This bit updates the Epsiode Count on the fly when the progress is updated. It has to be done here to avoid thread issues. (GUI wouldn't update properly)
  6417. TextBox_TotEpisodeCount.Text = Cache.TvCache.Episodes.Count
  6418. End If
  6419. End If
  6420. Catch ex As Exception
  6421. ExceptionHandler.LogError(ex)
  6422. End Try
  6423. End Sub
  6424. Private Sub bckgroundscanepisodes_RunWorkerCompleted(ByVal sender As Object, ByVal e As System.ComponentModel.RunWorkerCompletedEventArgs) Handles bckgroundscanepisodes.RunWorkerCompleted
  6425. Try
  6426. If scrapeAndQuit = True Then
  6427. sandq = sandq -1
  6428. Exit Sub
  6429. End If
  6430. If Not (e.Error Is Nothing) Then
  6431. tvScraperLog = tvScraperLog & vbCrLf
  6432. tvScraperLog = tvScraperLog & "!!! Error, exiting TV episode scraper" & vbCrLf
  6433. tvScraperLog = tvScraperLog & "Error:-" & vbCrLf
  6434. tvScraperLog = tvScraperLog & e.Error.ToString & vbCrLf
  6435. Else
  6436. tvScraperLog = tvScraperLog & vbCrLf & "!!! Operation Completed" & vbCrLf
  6437. End If
  6438. ToolStripStatusLabel6.Text = "TV Show Scraper"
  6439. ToolStripStatusLabel6.Visible = False
  6440. StatusStrip1.Visible = BckWrkScnMovies.IsBusy OrElse Not Pref.AutoHideStatusBar
  6441. If Not BckWrkScnMovies.IsBusy Then StatusStrip1.BackColor = Color.LightGray
  6442. tsStatusLabel1.Visible = Not BckWrkScnMovies.IsBusy
  6443. btnTvSearchNew.Text = "Search New"
  6444. Call util_ThreadsRunningCheck()
  6445. Tv_CacheSave()
  6446. tv_CacheLoad()
  6447. tv_Filter()
  6448. If Pref.disabletvlogs Or ScraperErrorDetected Then
  6449. Dim MyFormObject As New frmoutputlog(tvScraperLog, True)
  6450. Try
  6451. MyFormObject.ShowDialog()
  6452. Catch ex As ObjectDisposedException
  6453. #If SilentErrorScream Then
  6454. Throw ex
  6455. #End If
  6456. End Try
  6457. ScraperErrorDetected = False
  6458. Else
  6459. BlinkTaskBar()
  6460. End If
  6461. GC.Collect()
  6462. Catch ex As Exception
  6463. ExceptionHandler.LogError(ex)
  6464. End Try
  6465. End Sub
  6466. Private Sub ep_Search()
  6467. Dim ShowList As New List(Of TvShow)
  6468. If Not bckgroundscanepisodes.IsBusy And Not Bckgrndfindmissingepisodes.IsBusy Then
  6469. btnTvSearchNew.Text = "Cancel "
  6470. For Each item In Cache.TvCache.Shows
  6471. If (item.NfoFilePath.ToLower.IndexOf("tvshow.nfo") <> -1) And ((item.State = Media_Companion.ShowState.Open) Or TVSearchALL = True) Then
  6472. ShowList.Add(item)
  6473. End If
  6474. Next
  6475. bckgroundscanepisodes.RunWorkerAsync({ShowList, TVSearchALL}) 'if searching all episodes (inc locked) TVSearchALL is true
  6476. ElseIf bckgroundscanepisodes.IsBusy Then
  6477. MsgBox("This Episode Scraper is already running")
  6478. ElseIf Bckgrndfindmissingepisodes.IsBusy Then
  6479. MsgBox("The missing episode search cannot be performed" & vbCrLf & " while the episode scraper is running")
  6480. End If
  6481. End Sub
  6482. Private Sub SearchThisShowForNewEpisodesToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Tv_TreeViewContext_SearchNewEp.Click
  6483. Try
  6484. If TvTreeview.SelectedNode Is Nothing Then Exit Sub
  6485. Dim Season As TvSeason
  6486. Dim Episode As TvEpisode
  6487. Dim ShowList As New List(Of TvShow)
  6488. Dim selectednode As Integer = TvTreeview.SelectedNode.Index
  6489. If TypeOf TvTreeview.SelectedNode.Tag Is Media_Companion.TvShow Then
  6490. ShowList.Add(TvTreeview.SelectedNode.Tag)
  6491. ElseIf TypeOf TvTreeview.SelectedNode.Tag Is Media_Companion.TvSeason Then
  6492. Season = TvTreeview.SelectedNode.Tag
  6493. ShowList.Add(Season.ShowObj)
  6494. ElseIf TypeOf TvTreeview.SelectedNode.Tag Is Media_Companion.TvEpisode Then
  6495. Episode = TvTreeview.SelectedNode.Tag
  6496. ShowList.Add(Episode.ShowObj)
  6497. End If
  6498. Dim OverrideLock As Boolean = False
  6499. If ShowList(0).State <> 0 Then 'i.e. it is either locked or unverified
  6500. If MsgBox("This show is either 'Locked' or 'Unverified'. Do you want to continue scan?", MsgBoxStyle.YesNo, "Question?") = MsgBoxResult.Yes Then
  6501. OverrideLock = True
  6502. Else
  6503. Exit Sub
  6504. End If
  6505. End If
  6506. If Not bckgroundscanepisodes.IsBusy And Not Bckgrndfindmissingepisodes.IsBusy Then
  6507. btnTvSearchNew.Text = "Cancel "
  6508. bckgroundscanepisodes.RunWorkerAsync({ShowList, OverrideLock})
  6509. ElseIf bckgroundscanepisodes.IsBusy Then
  6510. MsgBox("This Episode Scraper is already running")
  6511. ElseIf Bckgrndfindmissingepisodes.IsBusy Then
  6512. MsgBox("The missing episode search cannot be performed" & vbCrLf & " while the episode scraper is running")
  6513. End If
  6514. Do Until Not bckgroundscanepisodes.IsBusy
  6515. Application.DoEvents()
  6516. Loop
  6517. TvTreeview.SelectedNode = TvTreeview.Nodes(selectednode)
  6518. Catch ex As Exception
  6519. ExceptionHandler.LogError(ex)
  6520. End Try
  6521. End Sub
  6522. Private Sub tpMovWall_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles tpMovWall.LostFocus
  6523. Try
  6524. tpMovWall.Focus()
  6525. Catch ex As Exception
  6526. ExceptionHandler.LogError(ex)
  6527. End Try
  6528. End Sub
  6529. Private Sub RefreshActorDBToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
  6530. Try
  6531. Call mov_ActorRebuild()
  6532. Catch ex As Exception
  6533. ExceptionHandler.LogError(ex)
  6534. End Try
  6535. End Sub
  6536. Private Sub DownsizeAllFanartsToSelectedSizeToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DownsizeAllFanartsToSelectedSizeToolStripMenuItem.Click
  6537. DownSizeAll("Backdrops")
  6538. End Sub
  6539. Private Sub DownsizeAllPostersToSelectedSizeToolStripMenuItem_Click( sender As System.Object, e As System.EventArgs) Handles DownsizeAllPostersToSelectedSizeToolStripMenuItem.Click
  6540. DownSizeAll("Posters")
  6541. End Sub
  6542. Private Sub DownSizeAll(postersOrBackdrops As String)
  6543. Dim tempint As Integer = oMovies.MovieCache.Count
  6544. System.Windows.Forms.Cursor.Current = Cursors.WaitCursor
  6545. Dim point As Point
  6546. Dim height = 0
  6547. If postersOrBackdrops = "Backdrops" then
  6548. point = Movie.GetBackDropResolution(Pref.BackDropResolutionSI)
  6549. Else
  6550. height = Movie.GetHeightResolution(Pref.PosterResolutionSI)
  6551. End If
  6552. Using messbox As frmMessageBox = New frmMessageBox("Please wait - " & postersOrBackdrops & " are being resized", "", tempint.ToString & " remaining")
  6553. messbox.Show
  6554. Me.Refresh
  6555. messbox.Refresh
  6556. Dim path = ""
  6557. For Each m In oMovies.MovieCache
  6558. If postersOrBackdrops = "Backdrops" then
  6559. path = Pref.GetFanartPath(m.fullpathandfilename)
  6560. If File.Exists(path) Then DownloadCache.CopyAndDownSizeImage(path, path, point.x, point.y)
  6561. Else
  6562. path = Pref.GetPosterPath(m.fullpathandfilename)
  6563. If File.Exists(path) Then DownloadCache.CopyAndDownSizeImage(path, path, , height )
  6564. End If
  6565. tempint -= 1
  6566. messbox.TextBox3.Text = tempint.ToString & " remaining"
  6567. messbox.TextBox3.Refresh
  6568. Application.DoEvents
  6569. Next
  6570. End Using
  6571. End Sub
  6572. Public Sub mov_RebuildMovieCaches
  6573. mov_PreferencesDisplay
  6574. RunBackgroundMovieScrape("RebuildCaches")
  6575. End Sub
  6576. Private Sub CheckRootsForToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckRootsForToolStripMenuItem.Click
  6577. Try
  6578. tv_ShowFind(Pref.tvRootFolders, False)
  6579. If newTvFolders.Count > 0 Then
  6580. For Each item In newTvFolders
  6581. Pref.tvFolders.Add(item)
  6582. Next
  6583. Pref.tvFolders.Sort()
  6584. Pref.ConfigSave()
  6585. End If
  6586. tv_ShowScrape()
  6587. Catch ex As Exception
  6588. ExceptionHandler.LogError(ex)
  6589. End Try
  6590. End Sub
  6591. Public Sub tv_ShowFind(ByVal rootfolders As List(Of str_RootPaths), Optional ByVal skiptvfolderschk As Boolean = False)
  6592. Dim Folders As List(Of String)
  6593. newTvFolders.Clear()
  6594. For Each folder In rootfolders
  6595. If Not folder.selected Then Continue For
  6596. Folders = Utilities.EnumerateFolders(folder.rpath, 0)
  6597. For Each strfolder2 As String In Folders
  6598. If skiptvfolderschk Then
  6599. If Not ListBox6.Items.Contains(strfolder2) AndAlso Utilities.ValidMovieDir(strfolder2) Then newTvFolders.Add(strfolder2)
  6600. ElseIf Not Pref.tvFolders.Contains(strfolder2) AndAlso Utilities.ValidMovieDir(strfolder2) Then
  6601. If Not ListBox6.Items.Contains(strfolder2) Then newTvFolders.Add(strfolder2)
  6602. End If
  6603. Next
  6604. Next
  6605. End Sub
  6606. Public Sub tv_ShowScrape()
  6607. If Not bckgrnd_tvshowscraper.IsBusy Then
  6608. If newTvFolders.Count > 0 Then
  6609. ToolStripStatusLabel5.Text = "Scraping TV Shows, " & newTvFolders.Count & " remaining"
  6610. ToolStripStatusLabel5.Visible = True
  6611. End If
  6612. Dim selectedLang As String = If(Pref.tvshow_useXBMC_Scraper, Pref.XBMCTVDbLanguage, Pref.TvdbLanguageCode)
  6613. Dim args As TvdbArgs = New TvdbArgs("", selectedLang)
  6614. bckgrnd_tvshowscraper.RunWorkerAsync(args) ' Even if no shows scraped, saves tvcache and updates treeview in RunWorkerComplete
  6615. End If
  6616. End Sub
  6617. Public Function util_RegexValidate(ByVal regexs As String)
  6618. Try
  6619. Dim test As Match
  6620. test = Regex.Match("", regexs)
  6621. Catch ex As Exception
  6622. Return False
  6623. End Try
  6624. Return True
  6625. End Function
  6626. Public Function tv_LanguageCheck(ByVal id As String, ByVal language As String)
  6627. Try
  6628. Dim languagecode As String = language
  6629. Dim url As String = "http://thetvdb.com/api/6E82FED600783400/series/" & id & "/" & languagecode & ".xml"
  6630. Dim websource(10000)
  6631. Dim urllinecount As Integer = 0
  6632. Try
  6633. Dim wrGETURL As WebRequest
  6634. wrGETURL = WebRequest.Create(url)
  6635. wrGETURL.Proxy = Utilities.MyProxy
  6636. Dim objStream As Stream
  6637. objStream = wrGETURL.GetResponse.GetResponseStream()
  6638. Dim objReader As New StreamReader(objStream)
  6639. Dim sLine As String = ""
  6640. urllinecount = 0
  6641. Do While Not sLine Is Nothing
  6642. urllinecount += 1
  6643. sLine = objReader.ReadLine
  6644. If Not sLine Is Nothing Then
  6645. websource(urllinecount) = sLine
  6646. End If
  6647. Loop
  6648. objReader.Close()
  6649. objStream.Close()
  6650. objReader = Nothing
  6651. objStream = Nothing
  6652. urllinecount -= 1
  6653. Catch ex As Exception
  6654. End Try
  6655. For f = 1 To urllinecount
  6656. If websource(f).IndexOf("<Language>") <> -1 Then
  6657. websource(f) = websource(f).Replace("<Language>", "")
  6658. websource(f) = websource(f).Replace("</Language>", "")
  6659. websource(f) = websource(f).Replace(" ", "")
  6660. If websource(f).ToLower = languagecode Then
  6661. Return True
  6662. Else
  6663. Return False
  6664. End If
  6665. End If
  6666. Next
  6667. Catch ex As Exception
  6668. End Try
  6669. Return "Error"
  6670. End Function
  6671. Private Sub ProfilesToolStripMenuItem_DropDownItemClicked(ByVal sender As Object, ByVal e As System.Windows.Forms.ToolStripItemClickedEventArgs) Handles ProfilesToolStripMenuItem.DropDownItemClicked
  6672. Try
  6673. Pref.ConfigSave()
  6674. For Each prof In profileStruct.ProfileList
  6675. If prof.ProfileName = e.ClickedItem.Text Then
  6676. workingProfile.actorcache = prof.actorcache
  6677. workingProfile.DirectorCache = prof.DirectorCache
  6678. workingProfile.config = prof.config
  6679. workingProfile.Genres = prof.Genres
  6680. workingProfile.moviecache = prof.moviecache
  6681. workingProfile.MusicVideoCache = prof.MusicVideoCache
  6682. workingProfile.profilename = prof.profilename
  6683. workingProfile.regexlist = prof.regexlist
  6684. workingProfile.tvcache = prof.tvcache
  6685. workingProfile.MovieSetCache = prof.MovieSetCache
  6686. workingProfile.CustomTvCache = prof.CustomTvCache
  6687. Call util_ProfileSetup()
  6688. End If
  6689. Next
  6690. If e.ClickedItem.Text <> workingProfile.profilename Then Exit Sub
  6691. For Each item In ProfilesToolStripMenuItem.DropDownItems
  6692. If item.text = workingProfile.profilename Then
  6693. With item
  6694. item.checked = True
  6695. End With
  6696. Else
  6697. item.checked = False
  6698. End If
  6699. Next
  6700. Catch ex As Exception
  6701. ExceptionHandler.LogError(ex)
  6702. End Try
  6703. End Sub
  6704. Private Sub util_ProfileSetup()
  6705. messbox = New frmMessageBox(" Please Wait", , "Loading Profile")
  6706. messbox.Show()
  6707. messbox.Refresh()
  6708. Application.DoEvents()
  6709. Me.Enabled = False
  6710. If IO.File.Exists(workingProfile.config) Then
  6711. Pref.moviesets.Clear()
  6712. Me.util_ConfigLoad()
  6713. Else
  6714. Call SetUpPreferences()
  6715. End If
  6716. util_MainFormTitleUpdate() 'creates & shows new title to Form1, also includes current profile name
  6717. If Not IO.File.Exists(workingProfile.moviecache) Or Pref.startupCache = False Then
  6718. mov_RebuildMovieCaches
  6719. Else
  6720. oMovies.LoadCaches
  6721. End If
  6722. If IO.File.Exists(workingProfile.Genres) Then Call util_GenreLoad()
  6723. If Not IO.File.Exists(workingProfile.tvcache) Or Pref.startupCache = False Then
  6724. Call tv_CacheRefresh()
  6725. Else
  6726. Call tv_CacheLoad()
  6727. End If
  6728. If Not IO.File.Exists(workingProfile.CustomTvCache) Or Pref.startupCache = False Then
  6729. Call Custtv_CacheRefresh()
  6730. Else
  6731. Call Custtv_CacheLoad()
  6732. End If
  6733. If IO.File.Exists(workingProfile.MusicVideoCache) Then Call UcMusicVideo1.MVCacheLoad()
  6734. Me.Refresh()
  6735. Application.DoEvents()
  6736. If Pref.splt5 = 0 Then
  6737. Dim tempint As Integer = SplitContainer1.Height
  6738. tempint = tempint / 4
  6739. tempint = tempint * 3
  6740. Pref.splt5 = If(tempint > 275, tempint, 275)
  6741. End If
  6742. If Pref.startuptab = 0 Then
  6743. SplitContainer1.SplitterDistance = Pref.splt1
  6744. SplitContainer2.SplitterDistance = Pref.splt2
  6745. SplitContainer5.SplitterDistance = Pref.splt5
  6746. TabLevel1.SelectedIndex = 1
  6747. SplitContainer3.SplitterDistance = Pref.splt3
  6748. SplitContainer4.SplitterDistance = Pref.splt4
  6749. _tv_SplitContainer.SplitterDistance = Pref.splt6
  6750. TabLevel1.SelectedIndex = 0
  6751. Else
  6752. SplitContainer1.SplitterDistance = Pref.splt1
  6753. SplitContainer2.SplitterDistance = Pref.splt2
  6754. SplitContainer5.SplitterDistance = Pref.splt5
  6755. TabLevel1.SelectedIndex = 1
  6756. SplitContainer3.SplitterDistance = Pref.splt3
  6757. SplitContainer4.SplitterDistance = Pref.splt4
  6758. _tv_SplitContainer.SplitterDistance = Pref.splt6
  6759. End If
  6760. SplitContainer1.IsSplitterFixed = False
  6761. SplitContainer2.IsSplitterFixed = False
  6762. SplitContainer3.IsSplitterFixed = False
  6763. SplitContainer4.IsSplitterFixed = False
  6764. SplitContainer5.IsSplitterFixed = False
  6765. _tv_SplitContainer.IsSplitterFixed = False
  6766. 'Dim tempboolean As Boolean = UrlIsValid("http://thetvdb.com/")
  6767. Try
  6768. If cbMovieDisplay_MovieSet.Items.Count <> Pref.moviesets.Count Then
  6769. cbMovieDisplay_MovieSet.Items.Clear()
  6770. For Each mset In Pref.moviesets
  6771. cbMovieDisplay_MovieSet.Items.Add(If(Pref.MovSetTitleIgnArticle, Pref.RemoveIgnoredArticles(mset), mset))
  6772. Next
  6773. End If
  6774. If workingMovieDetails.fullmoviebody.MovieSet.MovieSetName <> "-None-" Then
  6775. For Each mset In Pref.moviesets
  6776. cbMovieDisplay_MovieSet.Items.Add(If(Pref.MovSetTitleIgnArticle, Pref.RemoveIgnoredArticles(mset), mset))
  6777. Next
  6778. For te = 0 To cbMovieDisplay_MovieSet.Items.Count - 1
  6779. If cbMovieDisplay_MovieSet.Items(te) = workingMovieDetails.fullmoviebody.MovieSet.MovieSetDisplayName Then
  6780. cbMovieDisplay_MovieSet.SelectedIndex = te
  6781. Exit For
  6782. End If
  6783. Next
  6784. End If
  6785. Catch ex As Exception
  6786. #If SilentErrorScream Then
  6787. Throw ex
  6788. #End If
  6789. End Try
  6790. mov_VideoSourcePopulate()
  6791. ep_VideoSourcePopulate()
  6792. Try
  6793. TabControl2.SelectedIndex = 0
  6794. currentTabIndex = 0
  6795. Catch ex As Exception
  6796. #If SilentErrorScream Then
  6797. Throw ex
  6798. #End If
  6799. End Try
  6800. Try
  6801. TabControl3.SelectedIndex = 0
  6802. tvCurrentTabIndex = 0
  6803. Catch ex As Exception
  6804. #If SilentErrorScream Then
  6805. Throw ex
  6806. #End If
  6807. End Try
  6808. Me.Enabled = True
  6809. messbox.Close()
  6810. End Sub
  6811. Public Sub mov_SwitchRuntime()
  6812. If workingMovieDetails Is Nothing Then Exit Sub
  6813. If Pref.enablehdtags = True And workingMovieDetails.filedetails.filedetails_video.DurationInSeconds <> Nothing And Not displayRuntimeScraper Then
  6814. runtimetxt.Text = Utilities.cleanruntime(workingMovieDetails.filedetails.filedetails_video.DurationInSeconds.Value) & " min"
  6815. runtimetxt.Enabled = False
  6816. Else
  6817. runtimetxt.Text = workingMovieDetails.fullmoviebody.runtime
  6818. runtimetxt.Enabled = True
  6819. End If
  6820. End Sub
  6821. Public Sub mov_Switchtop250()
  6822. If workingMovieDetails Is Nothing Then Exit Sub
  6823. If lbl_movTop250.Text = "Top 250" Then
  6824. lbl_movTop250.Text = "Metascore"
  6825. top250txt.Text = workingMovieDetails.fullmoviebody.metascore
  6826. Else
  6827. lbl_movTop250.Text = "Top 250"
  6828. top250txt.Text = workingMovieDetails.fullmoviebody.top250
  6829. End If
  6830. 'If Pref.enablehdtags = True And workingMovieDetails.filedetails.filedetails_video.DurationInSeconds <> Nothing And Not displayRuntimeScraper Then
  6831. ' runtimetxt.Text = Utilities.cleanruntime(workingMovieDetails.filedetails.filedetails_video.DurationInSeconds.Value) & " min"
  6832. ' runtimetxt.Enabled = False
  6833. 'Else
  6834. ' runtimetxt.Text = workingMovieDetails.fullmoviebody.runtime
  6835. ' runtimetxt.Enabled = True
  6836. 'End If
  6837. End Sub
  6838. Private Sub SearchForNewMoviesToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SearchForNewMoviesToolStripMenuItem.Click
  6839. SearchForNew
  6840. End Sub
  6841. Public Function Yield(yielding As Boolean) As Boolean
  6842. If yielding Then
  6843. Application.DoEvents
  6844. Return _yield
  6845. End If
  6846. Return False
  6847. End Function
  6848. Private Sub util_FontSetup()
  6849. If Pref.font <> Nothing Then
  6850. If Pref.font <> "" Then
  6851. Try
  6852. Dim tcc As TypeConverter = TypeDescriptor.GetConverter(GetType(System.Drawing.Font))
  6853. Dim newFont As System.Drawing.Font = CType(tcc.ConvertFromString(Pref.font), System.Drawing.Font)
  6854. genretxt.Font = newFont
  6855. premiertxt.Font = newFont
  6856. certtxt.Font = newFont
  6857. directortxt.Font = newFont
  6858. creditstxt.Font = newFont
  6859. outlinetxt.Font = newFont
  6860. runtimetxt.Font = newFont
  6861. studiotxt.Font = newFont
  6862. countrytxt.Font = newFont
  6863. taglinetxt.Font = newFont
  6864. cbMovieDisplay_Actor.Font = newFont
  6865. roletxt.Font = newFont
  6866. pathtxt.Font = newFont
  6867. TextBox34.Font = newFont
  6868. DataGridViewMovies.Font = newFont
  6869. plottxt.Font = newFont
  6870. txtStars.Font = newFont
  6871. cbMovieDisplay_MovieSet.Font = newFont
  6872. cmbxEpActor.Font = newFont
  6873. TvTreeview.Font = newFont
  6874. tbEpRole.Font = newFont
  6875. tb_EpDirector.Font = newFont
  6876. tb_EpCredits.Font = newFont
  6877. tb_EpPlot.Font = newFont
  6878. tb_EpAired.Font = newFont
  6879. tb_EpRating.Font = newFont
  6880. tb_EpPath.Font = newFont
  6881. tb_EpFilename.Font = newFont
  6882. tb_ShPlot.Font = newFont
  6883. cbTvActor.Font = newFont
  6884. cbTvActorRole.Font = newFont
  6885. tb_ShRunTime.Font = newFont
  6886. tb_ShStudio.Font = newFont
  6887. tb_ShPremiered.Font = newFont
  6888. tb_ShRating.Font = newFont
  6889. tb_ShVotes.Font = newFont
  6890. tb_ShTvdbId.Font = newFont
  6891. tb_ShGenre.Font = newFont
  6892. tb_ShImdbId.Font = newFont
  6893. tb_ShCert.Font = newFont
  6894. ratingtxt.Font = newFont
  6895. votestxt.Font = newFont
  6896. top250txt.Font = newFont
  6897. cbUsrRated.Font = newFont
  6898. cbFilterGeneral.Font = newFont
  6899. cbFilterGenre.Font = newFont
  6900. cbFilterCountries.Font = newFont
  6901. cbFilterStudios.Font = newFont
  6902. cbFilterSet.Font = newFont
  6903. cbFilterActor.Font = newFont
  6904. cbFilterTag.Font = newFont
  6905. cbFilterDirector.Font = newFont
  6906. cbFilterSource.Font = newFont
  6907. cbFilterResolution.Font = newFont
  6908. cbFilterVideoCodec.Font = newFont
  6909. cbFilterSubTitleLang.Font = newFont
  6910. cbFilterRootFolder.Font = newfont
  6911. cbFilterUserRated.Font = newfont
  6912. cbFilterAudioCodecs.Font = newFont
  6913. cbFilterAudioLanguages.Font = newFont
  6914. cbFilterAudioDefaultLanguages.Font = newFont
  6915. cbFilterAudioBitrates .Font = newFont
  6916. cbFilterAudioChannels .Font = newFont
  6917. cbFilterNumAudioTracks.Font = newFont
  6918. cbFilterCertificate .Font = newFont
  6919. LabelCountFilter.Font = newFont
  6920. Me.Refresh()
  6921. Application.DoEvents()
  6922. Catch ex As Exception
  6923. #If SilentErrorScream Then
  6924. Throw ex
  6925. #End If
  6926. End Try
  6927. End If
  6928. End If
  6929. End Sub
  6930. Private Sub langarrsetup()
  6931. Dim strfilename As String
  6932. Dim num_rows As Long
  6933. Dim num_cols As Long
  6934. Dim x As Integer
  6935. Dim y As Integer
  6936. strfilename = applicationPath & "\Assets\" & "test.csv"
  6937. If File.Exists(strfilename) Then
  6938. Dim tmpstream As StreamReader = File.OpenText(strfilename)
  6939. Dim strlines() As String
  6940. Dim strline() As String
  6941. strlines = tmpstream.ReadToEnd().Split(Environment.NewLine)
  6942. num_rows = UBound(strlines)
  6943. strline = strlines(0).Split(",")
  6944. num_cols = UBound(strline)
  6945. ' Copy the data into the array.
  6946. For x = 0 To num_rows-1
  6947. strline = strlines(x).Split(",")
  6948. For y = 0 To num_cols
  6949. langarray(x, y) = strline(y)
  6950. Next
  6951. Next
  6952. tmpstream.Close()
  6953. tmpstream = Nothing
  6954. End If
  6955. End Sub
  6956. #Region "Movie Table"
  6957. 'tabpage events
  6958. Private Sub tpMovTable_Enter(ByVal sender As Object, ByVal e As System.EventArgs) Handles tpMovTable.Enter
  6959. 'MovSetsRepopulate()
  6960. 'mov_TableSetup()
  6961. End Sub
  6962. Private Sub tpMovTable_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles tpMovTable.Leave
  6963. DataGridView1.EndEdit()
  6964. Pref.tableview.Clear()
  6965. For Each column In DataGridView1.Columns
  6966. Dim tempstring As String = String.Format("{0}|{1}|{2}|{3}", column.name, column.width, column.displayindex, column.visible)
  6967. Pref.tableview.Add(tempstring)
  6968. Next
  6969. If IsNothing(DataGridView1.SortedColumn) = False Then
  6970. Pref.tablesortorder = String.Format("{0} | {1}", DataGridView1.SortedColumn.HeaderText, DataGridView1.SortOrder.ToString)
  6971. Pref.ConfigSave()
  6972. End If
  6973. If DataDirty Then
  6974. Dim tempint As Integer = MessageBox.Show("You appear to have made changes to some of your movie details." & vbCrLf & vbCrLf & "Any changes will be lost if you do not save the changes now." & " Do wish to save the changes?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
  6975. If tempint = DialogResult.Yes Then
  6976. Call mov_TableChangesSave()
  6977. MsgBox("Changes Saved")
  6978. End If
  6979. End If
  6980. DataDirty=False
  6981. btn_movTableSave.Enabled = DataDirty
  6982. End Sub
  6983. 'Table Setup and update
  6984. Private Sub mov_TableViewSetup()
  6985. Pref.tableview.Clear()
  6986. Pref.tableview.Add("title|150|0|true")
  6987. Pref.tableview.Add("year|40|1|true")
  6988. Pref.tableview.Add("genre|160|2|true")
  6989. Pref.tableview.Add("rating|50|3|true")
  6990. Pref.tableview.Add("runtime|60|4|true")
  6991. Pref.tableview.Add("top250|89|5|false")
  6992. Pref.tableview.Add("source|150|6|false")
  6993. Pref.tableview.Add("playcount|120|7|true")
  6994. Pref.tableview.Add("set|150|8|true")
  6995. Pref.tableview.Add("certificate|100|9|false")
  6996. Pref.tableview.Add("sorttitle|100|10|false")
  6997. Pref.tableview.Add("outline|200|11|false")
  6998. Pref.tableview.Add("plot|200|12|false")
  6999. Pref.tableview.Add("stars|200|13|false")
  7000. Pref.tableview.Add("id|82|14|false")
  7001. Pref.tableview.Add("missingdata1|115|15|false")
  7002. Pref.tableview.Add("fullpathandfilename|300|16|false")
  7003. Pref.tableview.Add("createdate|104|17|false")
  7004. Pref.tableview.Add("userrated|100|18|false")
  7005. End Sub
  7006. Private Sub mov_TableSetup()
  7007. DataGridView1.Columns.Clear()
  7008. If Pref.tablesortorder = Nothing Then Pref.tablesortorder = "Title|Ascending"
  7009. If Pref.tablesortorder = "" Then Pref.tablesortorder = "Title|Ascending"
  7010. If Pref.tableview.Count < 19 Then 'Counter. Increase if adding new tableview column else new columns won't be added to config.xml.
  7011. Call mov_TableViewSetup()
  7012. End If
  7013. tableSets.Clear()
  7014. For Each item In Pref.tableview
  7015. Dim tempdata() As String
  7016. tempdata = item.Split("|")
  7017. Dim newcolumn As New str_TableItems(SetDefaults)
  7018. newcolumn.title = tempdata(0)
  7019. newcolumn.width = Convert.ToInt32(tempdata(1))
  7020. newcolumn.index = Convert.ToInt32(tempdata(2))
  7021. newcolumn.visible = (tempdata(3).ToLower = "true")
  7022. tableSets.Add(newcolumn)
  7023. Next
  7024. DataGridView1.AutoGenerateColumns = False
  7025. Dim doc As New XmlDocument
  7026. Dim thispref As XmlNode = Nothing
  7027. Dim xmlproc As XmlDeclaration
  7028. xmlproc = doc.CreateXmlDeclaration("1.0", "UTF-8", "yes")
  7029. doc.AppendChild(xmlproc)
  7030. Dim root As XmlElement
  7031. Dim child As XmlElement
  7032. root = doc.CreateElement("movie_cache")
  7033. Dim childchild As XmlElement
  7034. For Each row As DataGridViewRow In DataGridViewMovies.Rows
  7035. Dim movie As Data_GridViewMovie = row.DataBoundItem
  7036. child = doc.CreateElement("movie")
  7037. childchild = doc.CreateElement("filedate") : childchild.InnerText = movie.filedate : child.AppendChild(childchild)
  7038. childchild = doc.CreateElement("missingdata1") : childchild.InnerText = movie.missingdata1.ToString : child.AppendChild(childchild)
  7039. childchild = doc.CreateElement("filename") : childchild.InnerText = movie.filename : child.AppendChild(childchild)
  7040. childchild = doc.CreateElement("foldername") : childchild.InnerText = movie.foldername : child.AppendChild(childchild)
  7041. childchild = doc.CreateElement("fullpathandfilename") : childchild.InnerText = movie.fullpathandfilename : child.AppendChild(childchild)
  7042. childchild = doc.CreateElement("set") : childchild.InnerText = movie.movieset.MovieSetName : child.AppendChild(childchild)
  7043. childchild = doc.CreateElement("source") : childchild.InnerText = movie.source : child.AppendChild(childchild)
  7044. childchild = doc.CreateElement("genre") : childchild.InnerText = movie.genre : child.AppendChild(childchild)
  7045. childchild = doc.CreateElement("id") : childchild.InnerText = movie.id : child.AppendChild(childchild)
  7046. childchild = doc.CreateElement("playcount") : childchild.InnerText = movie.playcount : child.AppendChild(childchild)
  7047. childchild = doc.CreateElement("rating") : childchild.InnerText = movie.Rating : child.AppendChild(childchild)
  7048. childchild = doc.CreateElement("title") : childchild.InnerText = movie.title : child.AppendChild(childchild)
  7049. childchild = doc.CreateElement("certificate") : childchild.InnerText = movie.Certificate : child.AppendChild(childchild)
  7050. childchild = doc.CreateElement("outline") : childchild.InnerText = movie.outline : child.AppendChild(childchild)
  7051. childchild = doc.CreateElement("plot") : childchild.InnerText = movie.plot : child.AppendChild(childchild)
  7052. childchild = doc.CreateElement("stars") : childchild.InnerText = movie.stars : child.AppendChild(childchild)
  7053. childchild = doc.CreateElement("sortorder") : childchild.InnerText = movie.SortOrder : child.AppendChild(childchild)
  7054. childchild = doc.CreateElement("runtime") : childchild.InnerText = movie.runtime : child.AppendChild(childchild)
  7055. childchild = doc.CreateElement("top250") : childchild.InnerText = movie.top250 : child.AppendChild(childchild)
  7056. childchild = doc.CreateElement("year") : childchild.InnerText = movie.year : child.AppendChild(childchild)
  7057. childchild = doc.CreateElement("createdate") : childchild.InnerText = movie.createdate : child.AppendChild(childchild)
  7058. childchild = doc.CreateElement("usrrated") : childchild.InnerText = movie.usrrated : child.AppendChild(childchild)
  7059. root.AppendChild(child)
  7060. Next
  7061. doc.AppendChild(root)
  7062. For Each thisresult In doc("movie_cache")
  7063. Select Case thisresult.Name
  7064. Case "movie"
  7065. Dim chi As XmlElement
  7066. For Each chi In thisresult.childnodes
  7067. If chi.Name = "runtime" Then
  7068. chi.InnerText = chi.InnerText.Replace("minutes", "")
  7069. chi.InnerText = chi.InnerText.Replace("mins", "")
  7070. chi.InnerText = chi.InnerText.Replace("min", "")
  7071. chi.InnerText = chi.InnerText.Replace(" ", "")
  7072. If chi.InnerText.Length = 1 Then
  7073. chi.InnerText = "00" & chi.InnerText
  7074. End If
  7075. If chi.InnerText.Length = 2 Then
  7076. chi.InnerText = "0" & chi.InnerText
  7077. End If
  7078. chi.InnerText = chi.InnerText & " min"
  7079. End If
  7080. If chi.Name = "top250" Then
  7081. If chi.InnerText = "" Then
  7082. chi.InnerText = "000" & chi.InnerText
  7083. End If
  7084. If IsNumeric(chi.InnerText) Then
  7085. If chi.InnerText.Length = 0 Then
  7086. chi.InnerText = "000" & chi.InnerText
  7087. End If
  7088. If chi.InnerText.Length = 1 Then
  7089. chi.InnerText = "00" & chi.InnerText
  7090. End If
  7091. If chi.InnerText.Length = 2 Then
  7092. chi.InnerText = "0" & chi.InnerText
  7093. End If
  7094. End If
  7095. End If
  7096. If chi.Name = "playcount" Then
  7097. If chi.InnerText = "" OrElse chi.InnerText = "0" OrElse Not IsNumeric(chi.InnerText) Then
  7098. chi.InnerText = "UnWatched"
  7099. Else
  7100. chi.InnerText = "Watched"
  7101. End If
  7102. End If
  7103. If chi.Name = "missingdata1" Then
  7104. If chi.InnerText = "" Or Not IsNumeric(chi.InnerText) Then
  7105. chi.InnerText = "0"
  7106. Else
  7107. chi.InnerText = Movie.GetMissingDataText( Convert.ToByte(chi.InnerText) )
  7108. End If
  7109. End If
  7110. If chi.Name = "createdate" Then
  7111. If chi.InnerText = "" Or Not IsNumeric(chi.InnerText) Then
  7112. chi.InnerText = "0"
  7113. Else
  7114. chi.InnerText = Utilities.DecodeDateTime(chi.InnerText, Pref.DateFormat)
  7115. End If
  7116. End If
  7117. Next
  7118. End Select
  7119. Next
  7120. Dim movstring As String = doc.InnerXml
  7121. Dim XMLreader2 As StringReader = New System.IO.StringReader(movstring)
  7122. ' Create the dataset
  7123. Dim newDS As DataSet = New DataSet
  7124. newDS.ReadXml(XMLreader2)
  7125. XMLreader2.Dispose()
  7126. DataGridView1.DataSource = Nothing
  7127. Try
  7128. DataGridView1.DataSource = newDS.Tables(0)
  7129. Catch
  7130. End Try
  7131. DataGridView1.AllowUserToOrderColumns = True
  7132. DataGridView1.RowHeadersVisible = True
  7133. DataGridView1.RowHeadersWidth = 25
  7134. Dim titlecolumn As New DataGridViewColumn()
  7135. With titlecolumn
  7136. Dim oCell As DataGridViewCell = New DataGridViewTextBoxCell
  7137. .CellTemplate = oCell
  7138. .HeaderText = "Title"
  7139. .DataPropertyName = "title"
  7140. .Name = "title"
  7141. .SortMode = DataGridViewColumnSortMode.Automatic
  7142. End With
  7143. Dim yearcolumn As New DataGridViewColumn()
  7144. With yearcolumn
  7145. Dim oCell As DataGridViewCell = New DataGridViewTextBoxCell
  7146. .CellTemplate = oCell
  7147. .HeaderText = "Year"
  7148. .DataPropertyName = "year"
  7149. .Name = "year"
  7150. .SortMode = DataGridViewColumnSortMode.Automatic
  7151. .DefaultCellStyle.Alignment = DataGridViewContentAlignment.BottomCenter
  7152. End With
  7153. Dim idcolumn As New DataGridViewColumn()
  7154. With idcolumn
  7155. Dim oCell As DataGridViewCell = New DataGridViewTextBoxCell
  7156. .CellTemplate = oCell
  7157. .HeaderText = "IMDB ID"
  7158. .DataPropertyName = "id"
  7159. .Name = "id"
  7160. .SortMode = DataGridViewColumnSortMode.Automatic
  7161. .ReadOnly = True
  7162. End With
  7163. Dim pathcolumn As New DataGridViewColumn()
  7164. With pathcolumn
  7165. Dim oCell As DataGridViewCell = New DataGridViewTextBoxCell
  7166. .CellTemplate = oCell
  7167. .HeaderText = "Full Path"
  7168. .DataPropertyName = "fullpathandfilename"
  7169. .Name = "fullpathandfilename"
  7170. .SortMode = DataGridViewColumnSortMode.Automatic
  7171. .ReadOnly = True
  7172. End With
  7173. Dim genrecolumn As New DataGridViewColumn()
  7174. With genrecolumn
  7175. Dim oCell As DataGridViewCell = New DataGridViewTextBoxCell
  7176. .CellTemplate = oCell
  7177. .HeaderText = "Genre"
  7178. .DataPropertyName = "genre"
  7179. .Name = "genre"
  7180. .SortMode = DataGridViewColumnSortMode.Automatic
  7181. .ToolTipText = "Separate Genre's with a ""Space/Space"", ie: Action / Horror"
  7182. End With
  7183. Dim ratingcolumn As New DataGridViewColumn()
  7184. With ratingcolumn
  7185. Dim oCell As DataGridViewCell = New DataGridViewTextBoxCell
  7186. .CellTemplate = oCell
  7187. .HeaderText = "Rating"
  7188. .DataPropertyName = "rating"
  7189. .Name = "rating"
  7190. .SortMode = DataGridViewColumnSortMode.Automatic
  7191. .DefaultCellStyle.Alignment = DataGridViewContentAlignment.BottomCenter
  7192. End With
  7193. Dim outlinecolumn As New DataGridViewColumn()
  7194. With outlinecolumn
  7195. Dim oCell As DataGridViewCell = New DataGridViewTextBoxCell
  7196. .CellTemplate = oCell
  7197. .HeaderText = "Outline"
  7198. .DataPropertyName = "outline"
  7199. .Name = "outline"
  7200. .SortMode = DataGridViewColumnSortMode.Automatic
  7201. End With
  7202. Dim plotcolumn As New DataGridViewColumn()
  7203. With plotcolumn
  7204. Dim oCell As DataGridViewCell = New DataGridViewTextBoxCell
  7205. .CellTemplate = oCell
  7206. .HeaderText = "Plot"
  7207. .DataPropertyName = "plot"
  7208. .Name = "plot"
  7209. .SortMode = DataGridViewColumnSortMode.Automatic
  7210. End With
  7211. Dim starscolumn As New DataGridViewColumn()
  7212. With starscolumn
  7213. Dim oCell As DataGridViewCell = New DataGridViewTextBoxCell
  7214. .CellTemplate = oCell
  7215. .HeaderText = "Stars"
  7216. .DataPropertyName = "stars"
  7217. .Name = "stars"
  7218. .SortMode = DataGridViewColumnSortMode.Automatic
  7219. .ReadOnly = True
  7220. End With
  7221. Dim sorttitlecolumn As New DataGridViewColumn()
  7222. With sorttitlecolumn
  7223. Dim oCell As DataGridViewCell = New DataGridViewTextBoxCell
  7224. .CellTemplate = oCell
  7225. .HeaderText = "Sort Title"
  7226. .DataPropertyName = "sortorder"
  7227. .Name = "sorttitle"
  7228. .SortMode = DataGridViewColumnSortMode.Automatic
  7229. End With
  7230. Dim top250column As New DataGridViewColumn()
  7231. With top250column
  7232. Dim oCell As DataGridViewCell = New DataGridViewTextBoxCell
  7233. .CellTemplate = oCell
  7234. .HeaderText = "Top 250"
  7235. .DataPropertyName = "top250"
  7236. .Name = "top250"
  7237. .SortMode = DataGridViewColumnSortMode.Automatic
  7238. End With
  7239. Dim watchedcolumn As New DataGridViewComboBoxColumn()
  7240. watchedcolumn.Items.Add("UnWatched")
  7241. watchedcolumn.Items.Add("Watched")
  7242. With watchedcolumn
  7243. .HeaderText = "Watched"
  7244. .Name = "playcount"
  7245. .DataPropertyName = "playcount"
  7246. .SortMode = DataGridViewColumnSortMode.Automatic
  7247. .DefaultCellStyle.NullValue = ""
  7248. End With
  7249. Dim sourcecolumn As New DataGridViewComboBoxColumn()
  7250. For Each src In Pref.releaseformat
  7251. sourcecolumn.Items.Add(src)
  7252. Next
  7253. sourcecolumn.Items.Insert(0, "")
  7254. With sourcecolumn
  7255. .HeaderText = "Source"
  7256. .Name = "source"
  7257. .DataPropertyName = "source"
  7258. .SortMode = DataGridViewColumnSortMode.Automatic
  7259. .DefaultCellStyle.NullValue = ""
  7260. End With
  7261. Dim runtimecolumn As New DataGridViewColumn()
  7262. With runtimecolumn
  7263. Dim oCell As DataGridViewCell = New DataGridViewTextBoxCell
  7264. .CellTemplate = oCell
  7265. .HeaderText = "Runtime"
  7266. .Name = "runtime"
  7267. .DataPropertyName = "runtime"
  7268. .SortMode = DataGridViewColumnSortMode.Automatic
  7269. End With
  7270. Dim certificatecolumn As New DataGridViewColumn()
  7271. With certificatecolumn
  7272. Dim oCell As DataGridViewCell = New DataGridViewTextBoxCell
  7273. .CellTemplate = oCell
  7274. .HeaderText = "Certificate"
  7275. .Name = "certificate"
  7276. .DataPropertyName = "certificate"
  7277. .SortMode = DataGridViewColumnSortMode.Automatic
  7278. End With
  7279. Dim setscolumn As New DataGridViewComboBoxColumn
  7280. For Each sets In Pref.moviesets
  7281. setscolumn.Items.Add(sets)
  7282. Next
  7283. With setscolumn
  7284. .HeaderText = "Sets"
  7285. .Name = "set"
  7286. .DataPropertyName = "set"
  7287. .SortMode = DataGridViewColumnSortMode.Automatic
  7288. .DefaultCellStyle.NullValue = "-None-"
  7289. End With
  7290. Dim artcolumn As New DataGridViewColumn()
  7291. With artcolumn
  7292. Dim oCell As DataGridViewCell = New DataGridViewTextBoxCell
  7293. .CellTemplate = oCell
  7294. .HeaderText = "Missing"
  7295. .Name = "missingdata1"
  7296. .DataPropertyName = "missingdata1"
  7297. .SortMode = DataGridViewColumnSortMode.Automatic
  7298. .ReadOnly = True
  7299. End With
  7300. Dim createdatecolumn As New DataGridViewColumn()
  7301. With createdatecolumn
  7302. Dim oCell As DataGridViewCell = New DataGridViewTextBoxCell
  7303. .CellTemplate = oCell
  7304. .HeaderText = "Date Added"
  7305. .Name = "createdate"
  7306. .DataPropertyName = "createdate"
  7307. .SortMode = DataGridViewColumnSortMode.Automatic
  7308. End With
  7309. Dim usrratedcolumn As New DataGridViewComboBoxColumn()
  7310. For each t In cbUsrRated.Items
  7311. usrratedcolumn.Items.Add(t)
  7312. Next
  7313. usrratedcolumn.Items.Item(0) = "0"
  7314. With usrratedcolumn
  7315. .HeaderText = "User Rating"
  7316. .DataPropertyName = "usrrated"
  7317. .Name = "userrated"
  7318. .SortMode = DataGridViewColumnSortMode.Automatic
  7319. End With
  7320. For f = 0 To tableview.Count -1
  7321. For Each col In tableSets
  7322. If col.index = f Then
  7323. Select Case col.title
  7324. Case "title"
  7325. titlecolumn.Width = col.width
  7326. titlecolumn.Visible = col.visible
  7327. DataGridView1.Columns.Insert(f, titlecolumn)
  7328. Exit For
  7329. Case "year"
  7330. yearcolumn.Width = col.width
  7331. yearcolumn.Visible = col.visible
  7332. DataGridView1.Columns.Insert(f, yearcolumn)
  7333. Exit For
  7334. Case "sorttitle"
  7335. sorttitlecolumn.Width = col.width
  7336. sorttitlecolumn.Visible = col.visible
  7337. DataGridView1.Columns.Insert(f, sorttitlecolumn)
  7338. Exit For
  7339. Case "genre"
  7340. genrecolumn.Width = col.width
  7341. genrecolumn.Visible = col.visible
  7342. DataGridView1.Columns.Insert(f, genrecolumn)
  7343. Exit For
  7344. Case "rating"
  7345. ratingcolumn.Width = col.width
  7346. ratingcolumn.Visible = col.visible
  7347. DataGridView1.Columns.Insert(f, ratingcolumn)
  7348. Exit For
  7349. Case "runtime"
  7350. runtimecolumn.Width = col.width
  7351. runtimecolumn.Visible = col.visible
  7352. DataGridView1.Columns.Insert(f, runtimecolumn)
  7353. Exit For
  7354. Case "top250"
  7355. top250column.Width = col.width
  7356. top250column.Visible = col.visible
  7357. DataGridView1.Columns.Insert(f, top250column)
  7358. Exit For
  7359. Case "certificate"
  7360. certificatecolumn.Width = col.width
  7361. certificatecolumn.Visible = col.visible
  7362. DataGridView1.Columns.Insert(f, certificatecolumn)
  7363. Case "source"
  7364. sourcecolumn.Width = col.width
  7365. sourcecolumn.Visible = col.visible
  7366. DataGridView1.Columns.Insert(f, sourcecolumn)
  7367. Exit For
  7368. Case "playcount"
  7369. watchedcolumn.Width = col.width
  7370. watchedcolumn.Visible = col.visible
  7371. DataGridView1.Columns.Insert(f, watchedcolumn)
  7372. Exit For
  7373. Case "set"
  7374. setscolumn.Width = col.width
  7375. setscolumn.Visible = col.visible
  7376. DataGridView1.Columns.Insert(f, setscolumn)
  7377. Exit For
  7378. Case "outline"
  7379. outlinecolumn.Width = col.width
  7380. outlinecolumn.Visible = col.visible
  7381. DataGridView1.Columns.Insert(f, outlinecolumn)
  7382. Exit For
  7383. Case "plot"
  7384. plotcolumn.Width = col.width
  7385. plotcolumn.Visible = col.visible
  7386. DataGridView1.Columns.Insert(f, plotcolumn)
  7387. Exit For
  7388. Case "stars"
  7389. starscolumn.Width = col.width
  7390. starscolumn.Visible = col.visible
  7391. DataGridView1.Columns.Insert(f, starscolumn)
  7392. Exit For
  7393. Case "id"
  7394. idcolumn.Width = col.width
  7395. idcolumn.Visible = col.visible
  7396. DataGridView1.Columns.Insert(f, idcolumn)
  7397. Exit For
  7398. Case "missingdata1"
  7399. artcolumn.Width = col.width
  7400. artcolumn.Visible = col.visible
  7401. DataGridView1.Columns.Insert(f, artcolumn)
  7402. Exit For
  7403. Case "fullpathandfilename"
  7404. pathcolumn.Width = col.width
  7405. pathcolumn.Visible = col.visible
  7406. DataGridView1.Columns.Insert(f, pathcolumn)
  7407. Exit For
  7408. Case "createdate"
  7409. createdatecolumn.Width = col.width
  7410. createdatecolumn.Visible = col.visible
  7411. DataGridView1.Columns.Insert(f, createdatecolumn)
  7412. Exit For
  7413. Case "userrated"
  7414. usrratedcolumn.Width = col.width
  7415. usrratedcolumn.Visible = col.visible
  7416. DataGridView1.Columns.Insert(f, usrratedcolumn)
  7417. Exit For
  7418. End Select
  7419. End If
  7420. Next
  7421. Next f
  7422. Dim sortheader As String
  7423. Dim sortord As String
  7424. Dim tempdata2() As String
  7425. tempdata2 = Pref.tablesortorder.Split("|")
  7426. sortheader = tempdata2(0)
  7427. sortord = tempdata2(1)
  7428. For Each col In DataGridView1.Columns
  7429. If col.headertext = sortheader Then
  7430. If sortord.ToLower.IndexOf("desc") <> -1 Then
  7431. DataGridView1.Sort(DataGridView1.Columns(col.index), ListSortDirection.Descending)
  7432. Else
  7433. DataGridView1.Sort(DataGridView1.Columns(col.index), ListSortDirection.Ascending)
  7434. End If
  7435. End If
  7436. Next
  7437. For Each tempRow As System.Windows.Forms.DataGridViewRow In Me.DataGridView1.Rows
  7438. For Each tempCell As Windows.Forms.DataGridViewCell In tempRow.Cells
  7439. If tempCell.Value = "Fanart" Or tempCell.Value = "Poster" Or tempCell.Value = "Poster & Fanart" Then tempCell.Style.BackColor = Color.Red
  7440. Next
  7441. Next
  7442. Call mov_TableEditSetup()
  7443. Try
  7444. For f = 0 To DataGridView1.Rows.Count-1
  7445. If DataGridView1.Rows(f).Cells("fullpathandfilename").Value = workingMovieDetails.fileinfo.fullpathandfilename Then
  7446. DataGridView1.ClearSelection()
  7447. DataGridView1.FirstDisplayedScrollingRowIndex = f
  7448. Exit For
  7449. End If
  7450. Next
  7451. Catch ex As Exception
  7452. #If SilentErrorScream Then
  7453. Throw ex
  7454. #End If
  7455. End Try
  7456. End Sub
  7457. Private Sub mov_TableEditSetup()
  7458. mov_TableEditDGV.Columns.Clear()
  7459. mov_TableEditDGV.AutoGenerateColumns = False
  7460. mov_TableEditDGV.DataSource = Nothing
  7461. For Each dgvCol As DataGridViewColumn In DataGridView1.Columns
  7462. Dim dgvNewCol As New DataGridViewColumn
  7463. dgvNewCol = DirectCast(dgvCol.Clone(), DataGridViewColumn)
  7464. dgvNewCol.CellTemplate = DirectCast(dgvCol.CellTemplate, DataGridViewCell)
  7465. If dgvNewCol.Name = "plot" Or dgvNewCol.Name = "outline" Or dgvNewCol.Name = "stars" Or dgvNewCol.Name = "id" Or dgvNewCol.Name = "missingdata1" or dgvNewCol.Name = "fullpathandfilename"Then
  7466. dgvNewCol.ReadOnly = True
  7467. dgvNewCol.DefaultCellStyle.BackColor = System.Drawing.Color.gray
  7468. End If
  7469. mov_TableEditDGV.Columns.Add(dgvNewCol)
  7470. Next
  7471. 'add "Unchanged"
  7472. Dim src_add As DataGridViewComboBoxColumn = DirectCast(Me.mov_TableEditDGV.Columns("source"), DataGridViewComboBoxColumn)
  7473. src_add.Items.Insert(0, "UnChanged")
  7474. Dim set_add As DataGridViewComboBoxColumn = DirectCast(Me.mov_TableEditDGV.Columns("set"), DataGridViewComboBoxColumn)
  7475. set_add.Items.Insert(0, "UnChanged")
  7476. Dim play_add As DataGridViewComboBoxColumn = DirectCast(Me.mov_TableEditDGV.Columns("playcount"), DataGridViewComboBoxColumn)
  7477. play_add.Items.Insert(0, "UnChanged")
  7478. Dim usrrated_add As DataGridViewComboBoxColumn = DirectCast(Me.mov_TableEditDGV.Columns("userrated"), DataGridViewComboBoxColumn)
  7479. usrrated_add.Items.Insert(0, "UnChanged")
  7480. mov_TableEditDGV.RowHeadersWidth = DataGridView1.RowHeadersWidth
  7481. mov_TableEditDGV.ClearSelection
  7482. mov_TableEditDGV.ScrollBars = ScrollBars.None
  7483. Me.mov_TableEditDGV.DefaultCellStyle.SelectionBackColor = Me.mov_TableEditDGV.DefaultCellStyle.BackColor
  7484. Me.mov_TableEditDGV.DefaultCellStyle.SelectionForeColor = Me.mov_TableEditDGV.DefaultCellStyle.ForeColor
  7485. Dim emptydata As String = FillEmptydoc().InnerXml
  7486. Dim XMLreader3 As StringReader = New System.IO.StringReader(emptydata)
  7487. ' Create the Empty dataset
  7488. Dim emptydataset As DataSet = New DataSet
  7489. emptydataset.ReadXml(XMLreader3)
  7490. XMLreader3.Dispose()
  7491. mov_TableEditDGV.DataSource = emptydataset.tables(0)
  7492. mov_TableEditDGV.CurrentRow.Selected = false
  7493. End Sub
  7494. Private Sub mov_TableChangesSave()
  7495. DataDirty=False
  7496. frmSplash2.Text = "Saving Table Changes..."
  7497. frmSplash2.Label1.Text = "Saving Movie Data....."
  7498. frmSplash2.Label1.Visible = True
  7499. frmSplash2.Label2.Visible = True
  7500. frmSplash2.ProgressBar1.Visible = True
  7501. frmSplash2.ProgressBar1.Maximum = DataGridView1.Rows.Count
  7502. frmSplash2.Show()
  7503. Application.DoEvents
  7504. Dim progcount As Integer = 0
  7505. Dim changed As Boolean
  7506. Dim oCachedMovie As ComboList
  7507. For Each gridrow As DataGridViewRow In DataGridView1.Rows
  7508. changed = False
  7509. progcount += 1
  7510. frmSplash2.ProgressBar1.Value = progcount
  7511. frmSplash2.Label2.Text = gridrow.Cells("Title").Value
  7512. oCachedMovie = oMovies.FindCachedMovie( gridrow.Cells("fullpathandfilename").Value )
  7513. Try
  7514. If oCachedMovie.title <> gridrow.Cells("Title").Value Then changed = True
  7515. Catch
  7516. End Try
  7517. Try
  7518. If oCachedMovie.outline <> gridrow.Cells("Outline").Value Then changed = True
  7519. Catch
  7520. End Try
  7521. Try
  7522. If oCachedMovie.genre <> gridrow.Cells("genre").Value Then changed = True
  7523. Catch
  7524. End Try
  7525. Try
  7526. If oCachedMovie.rating <> gridrow.Cells("rating").Value Then changed = True
  7527. Catch
  7528. End Try
  7529. Try
  7530. Dim playstatus As String = gridrow.Cells("playcount").EditedFormattedValue
  7531. Dim plycnt As Integer = 0
  7532. If playstatus.tolower = "watched" Then plycnt = 1
  7533. If oCachedMovie.playcount <> plycnt Then Changed = True
  7534. Catch
  7535. End Try
  7536. Try
  7537. If oCachedMovie.sortorder <> gridrow.Cells("sorttitle").Value Then changed = True
  7538. Catch
  7539. End Try
  7540. Try
  7541. If oCachedMovie.year <> gridrow.Cells("year").Value Then
  7542. If IsNumeric(gridrow.Cells("year").Value) Then changed = True
  7543. End If
  7544. Catch
  7545. End Try
  7546. Try
  7547. If Convert.ToInt32(oCachedMovie.top250) <> Convert.ToInt32(gridrow.Cells("top250").Value) Then
  7548. If IsNumeric(gridrow.Cells("top250").Value) Then changed = True
  7549. End If
  7550. Catch
  7551. End Try
  7552. Try
  7553. If oCachedMovie.Certificate <> gridrow.Cells("certificate").Value Then changed = True
  7554. Catch
  7555. End Try
  7556. Dim runtime As String=""
  7557. Dim intRunTime As Integer
  7558. Dim runTimeChanged As Boolean
  7559. Dim newRunTime As String=""
  7560. Try
  7561. runtime = gridrow.Cells("runtime").Value
  7562. runtime = runtime.Replace("min", "")
  7563. runtime = runtime.Trim(" ")
  7564. If IsNumeric(runtime) Then
  7565. intRunTime = Convert.ToInt32(runtime)
  7566. newRunTime = intRunTime.ToString & " min"
  7567. If oCachedMovie.runtime <> newRunTime Then changed = True : runTimeChanged = True
  7568. End If
  7569. Catch
  7570. End Try
  7571. If oCachedMovie.source <> If(IsDBNull(gridrow.Cells("source").Value), "", gridrow.Cells("source").Value) Then changed = True
  7572. If oCachedMovie.MovieSet.MovieSetName <> If(IsDBNull(gridrow.Cells("set").Value), "", gridrow.Cells("set").Value) Then changed = True
  7573. If oCachedMovie.usrrated <> gridrow.Cells("userrated").Value Then changed = True
  7574. If changed And IO.File.Exists(oCachedMovie.fullpathandfilename) Then
  7575. Dim oMovie As Movie = oMovies.LoadMovie(oCachedMovie.fullpathandfilename)
  7576. If IsNothing(oMovie) Then Continue For
  7577. Try
  7578. oCachedMovie.genre = gridrow.Cells("genre").Value
  7579. Catch
  7580. End Try
  7581. Try
  7582. oCachedMovie.title = gridrow.Cells("title").Value
  7583. Catch
  7584. End Try
  7585. Try
  7586. oCachedMovie.year = gridrow.Cells("year").Value
  7587. Catch
  7588. End Try
  7589. Try
  7590. oCachedMovie.sortorder = gridrow.Cells("sorttitle").Value
  7591. Catch
  7592. End Try
  7593. Try
  7594. oCachedMovie.rating = gridrow.Cells("rating").Value
  7595. Catch
  7596. End Try
  7597. Try
  7598. oCachedMovie.source = If(IsDBNull(gridrow.Cells("source").Value), "", gridrow.Cells("source").Value)
  7599. Catch
  7600. End Try
  7601. Try
  7602. Dim NewSetName As String = If(IsDBNull(gridrow.Cells("set").Value), "", gridrow.Cells("set").Value)
  7603. If NewSetName = "" Then
  7604. oCachedMovie.MovieSet.MovieSetName = ""
  7605. oCachedMovie.MovieSet.MovieSetId = ""
  7606. Else
  7607. Dim aok As Boolean = False
  7608. For Each m In oMovies.MovieSetDB
  7609. If m.MovieSetName = NewSetName Then
  7610. oCachedMovie.MovieSet.MovieSetName = m.MovieSetName
  7611. oCachedMovie.MovieSet.MovieSetId = m.MovieSetId
  7612. aok = True
  7613. End If
  7614. Next
  7615. If Not aok Then
  7616. For each m In Pref.moviesets
  7617. If m = NewSetName Then
  7618. oCachedMovie.MovieSet.MovieSetName = m
  7619. Exit For
  7620. End If
  7621. Next
  7622. End If
  7623. End If
  7624. Catch
  7625. End Try
  7626. oCachedMovie.top250 = Convert.ToInt32(gridrow.Cells("top250").Value).ToString
  7627. If gridrow.Cells("playcount").EditedFormattedValue = "Watched" Then
  7628. oCachedMovie.playcount = "1"
  7629. Else
  7630. oCachedMovie.playcount = "0"
  7631. End If
  7632. Try
  7633. oCachedMovie.Certificate = gridrow.Cells("certificate").Value
  7634. Catch
  7635. End Try
  7636. Try
  7637. oCachedMovie.usrrated = gridrow.Cells("userrated").Value
  7638. Catch
  7639. End Try
  7640. If runTimeChanged Then
  7641. oMovie.ScrapedMovie.fullmoviebody.runtime = newRunTime
  7642. End If
  7643. oMovie.ScrapedMovie.fullmoviebody.title = oCachedMovie.title
  7644. oMovie.ScrapedMovie.fullmoviebody.year = oCachedMovie.year
  7645. oMovie.ScrapedMovie.fullmoviebody.playcount = oCachedMovie.playcount
  7646. oMovie.ScrapedMovie.fullmoviebody.genre = oCachedMovie.genre
  7647. oMovie.ScrapedMovie.fullmoviebody.rating = oCachedMovie.rating
  7648. oMovie.ScrapedMovie.fullmoviebody.source = oCachedMovie.source
  7649. oMovie.ScrapedMovie.fullmoviebody.MovieSet.MovieSetName = oCachedMovie.MovieSet.MovieSetName
  7650. oMovie.ScrapedMovie.fullmoviebody.MovieSet.MovieSetId = oCachedMovie.MovieSet.MovieSetId
  7651. oMovie.ScrapedMovie.fullmoviebody.sortorder = oCachedMovie.sortorder
  7652. oMovie.ScrapedMovie.fullmoviebody.top250 = oCachedMovie.top250
  7653. oMovie.ScrapedMovie.fullmoviebody.director = oCachedMovie.director
  7654. oMovie.ScrapedMovie.fullmoviebody.credits = oCachedMovie.credits
  7655. oMovie.ScrapedMovie.fullmoviebody.usrrated = oCachedMovie.usrrated.ToString
  7656. Dim checkmpaa = oCachedMovie.Certificate
  7657. oMovie.ScrapedMovie.fullmoviebody.mpaa = checkmpaa
  7658. oMovie.AssignMovieToCache
  7659. oMovie.SaveNFO
  7660. oMovie.UpdateMovieCache
  7661. End If
  7662. Next
  7663. oMovies.SaveMovieCache
  7664. UpdateFilteredList
  7665. frmSplash2.Hide
  7666. Application.DoEvents
  7667. Me.BringToFront
  7668. End Sub
  7669. Private Sub mov_TableUpdate()
  7670. ''Table View is not the best location to edit Outline, Plot, IMDB Id.
  7671. Dim changed As Boolean = False
  7672. For Each row In DataGridView1.SelectedRows
  7673. If mov_TableEditDGV.Columns("title").Visible AndAlso mov_TableEditDGV.Rows(0).Cells("title").Value <> "" Then
  7674. row.cells("title").value = mov_TableEditDGV.Rows(0).Cells("title").Value : changed = True
  7675. End If
  7676. If mov_TableEditDGV.Columns("top250").Visible AndAlso mov_TableEditDGV.Rows(0).Cells("top250").Value <> "" Then
  7677. row.cells("top250").value = mov_TableEditDGV.Rows(0).Cells("top250").Value : changed = True
  7678. End If
  7679. If mov_TableEditDGV.Columns("year").Visible AndAlso mov_TableEditDGV.Rows(0).Cells("year").Value <> "" Then
  7680. row.cells("year").value = mov_TableEditDGV.Rows(0).Cells("year").Value : changed = True
  7681. End If
  7682. If mov_TableEditDGV.Columns("sorttitle").Visible AndAlso mov_TableEditDGV.Rows(0).Cells("sorttitle").Value <> "" Then
  7683. row.cells("sorttitle") = mov_TableEditDGV.Rows(0).Cells("sorttitle").Value : changed = True
  7684. End If
  7685. If mov_TableEditDGV.Columns("runtime").Visible AndAlso mov_TableEditDGV.Rows(0).Cells("runtime").Value <> "" Then
  7686. row.cells("runtime").value = mov_TableEditDGV.Rows(0).Cells("runtime").Value : changed = True
  7687. End If
  7688. If mov_TableEditDGV.Columns("rating").Visible AndAlso mov_TableEditDGV.Rows(0).Cells("rating").Value <> "" Then
  7689. row.cells("rating").value = mov_TableEditDGV.Rows(0).Cells("rating").Value : changed = True
  7690. End If
  7691. If mov_TableEditDGV.Columns("certificate").Visible AndAlso mov_TableEditDGV.Rows(0).Cells("certificate").Value <> "" Then
  7692. row.cells("certificate").value = mov_TableEditDGV.Rows(0).Cells("certificate").Value : changed = True
  7693. End If
  7694. If mov_TableEditDGV.Columns("genre").Visible AndAlso mov_TableEditDGV.Rows(0).Cells("genre").Value <> "" Then
  7695. row.cells("genre").value = mov_TableEditDGV.Rows(0).Cells("genre").Value : changed = True
  7696. End If
  7697. If mov_TableEditDGV.Columns("source").Visible AndAlso mov_TableEditDGV.Rows(0).Cells("source").Value <> "UnChanged" Then
  7698. row.cells("source").value = mov_TableEditDGV.Rows(0).Cells("source").Value : changed = True
  7699. End If
  7700. If mov_TableEditDGV.Columns("playcount").Visible AndAlso mov_TableEditDGV.Rows(0).Cells("playcount").Value <> "UnChanged" Then
  7701. If mov_TableEditDGV.Rows(0).Cells("playcount").Value = "Watched" Then
  7702. row.cells("playcount").value = "Watched"
  7703. Else
  7704. row.cells("playcount").value = "UnWatched"
  7705. End If
  7706. changed = True
  7707. End If
  7708. If mov_TableEditDGV.Columns("set").Visible AndAlso (IsDBNull(mov_TableEditDGV.Rows(0).Cells("set").Value) OrElse mov_TableEditDGV.Rows(0).Cells("set").Value <> "UnChanged") Then
  7709. row.cells("set").value = If(IsDBNull(mov_TableEditDGV.Rows(0).Cells("set").Value), Nothing, mov_TableEditDGV.Rows(0).Cells("set").Value) : changed = True
  7710. End If
  7711. If mov_TableEditDGV.Columns("userrated").Visible AndAlso mov_TableEditDGV.ROws(0).Cells("userrated").Value <> "UnChanged" Then
  7712. row.cells("userrated").Value = mov_TableEditDGV.Rows(0).Cells("userrated").Value : changed = True
  7713. End If
  7714. Next
  7715. DataDirty = changed
  7716. btn_movTableSave.Enabled = changed
  7717. End Sub
  7718. Private Function FillEmptyDoc() As XmlDocument
  7719. Dim doc As New XmlDocument
  7720. Dim thispref As XmlNode = Nothing
  7721. Dim xmlproc As XmlDeclaration
  7722. xmlproc = doc.CreateXmlDeclaration("1.0", "UTF-8", "yes")
  7723. doc.AppendChild(xmlproc)
  7724. Dim root As XmlElement
  7725. Dim child As XmlElement
  7726. root = doc.CreateElement("movie_cache")
  7727. Dim childchild As XmlElement
  7728. child = doc.CreateElement("movie")
  7729. childchild = doc.CreateElement("filedate") : childchild.InnerText = "" : child.AppendChild(childchild)
  7730. childchild = doc.CreateElement("missingdata1") : childchild.InnerText = "" : child.AppendChild(childchild)
  7731. childchild = doc.CreateElement("filename") : childchild.InnerText = "" : child.AppendChild(childchild)
  7732. childchild = doc.CreateElement("foldername") : childchild.InnerText = "" : child.AppendChild(childchild)
  7733. childchild = doc.CreateElement("fullpathandfilename") : childchild.InnerText = "Not Editable in TableView" : child.AppendChild(childchild)
  7734. childchild = doc.CreateElement("set") : childchild.InnerText = "UnChanged" : child.AppendChild(childchild)
  7735. childchild = doc.CreateElement("source") : childchild.InnerText = "UnChanged" : child.AppendChild(childchild)
  7736. childchild = doc.CreateElement("genre") : childchild.InnerText = "" : child.AppendChild(childchild)
  7737. childchild = doc.CreateElement("id") : childchild.InnerText = "" : child.AppendChild(childchild)
  7738. childchild = doc.CreateElement("playcount") : childchild.InnerText = "UnChanged" : child.AppendChild(childchild)
  7739. childchild = doc.CreateElement("rating") : childchild.InnerText = "" : child.AppendChild(childchild)
  7740. childchild = doc.CreateElement("title") : childchild.InnerText = "" : child.AppendChild(childchild)
  7741. childchild = doc.CreateElement("certificate") : childchild.InnerText = "" : child.AppendChild(childchild)
  7742. childchild = doc.CreateElement("outline") : childchild.InnerText = "Not Editable in TableView" : child.AppendChild(childchild)
  7743. childchild = doc.CreateElement("plot") : childchild.InnerText = "Not Editable in TableView" : child.AppendChild(childchild)
  7744. childchild = doc.CreateElement("sortorder") : childchild.InnerText = "" : child.AppendChild(childchild)
  7745. childchild = doc.CreateElement("runtime") : childchild.InnerText = "" : child.AppendChild(childchild)
  7746. childchild = doc.CreateElement("top250") : childchild.InnerText = "" : child.AppendChild(childchild)
  7747. childchild = doc.CreateElement("year") : childchild.InnerText = "" : child.AppendChild(childchild)
  7748. childchild = doc.CreateElement("usrrated") : childchild.InnerText = "UnChanged" : child.AppendChild(childchild)
  7749. root.AppendChild(child)
  7750. doc.AppendChild(root)
  7751. Return doc
  7752. End Function
  7753. 'Table buttons
  7754. Private Sub btnTableColumnsSelect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_movTableColumnsSelect.Click
  7755. Try
  7756. Dim frm As New frmConfigureTableColumns
  7757. frm.Init()
  7758. frm.ShowDialog()
  7759. mov_TableSetup()
  7760. Catch ex As Exception
  7761. ExceptionHandler.LogError(ex)
  7762. End Try
  7763. End Sub
  7764. Private Sub btn_movTableSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_movTableSave.Click
  7765. Try
  7766. Call mov_TableChangesSave()
  7767. MsgBox("Changes Saved")
  7768. Catch ex As Exception
  7769. ExceptionHandler.LogError(ex)
  7770. End Try
  7771. End Sub
  7772. Private Sub btn_movTableApply_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_movTableApply.Click
  7773. Try
  7774. Call mov_TableUpdate()
  7775. Catch ex As Exception
  7776. ExceptionHandler.LogError(ex)
  7777. End Try
  7778. End Sub
  7779. 'Table - DataGridView1 events
  7780. Private Sub DataGridView1_ColumnWidthChanged(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewColumnEventArgs) Handles DataGridView1.ColumnWidthChanged
  7781. Try
  7782. mov_TableEditDGV.Columns(e.Column.Index).Width = e.Column.Width
  7783. Dim offSetValue As Integer = DataGridView1.HorizontalScrollingOffset
  7784. mov_TableEditDGV.HorizontalScrollingOffset = offSetValue
  7785. Catch ex As Exception
  7786. ExceptionHandler.LogError(ex)
  7787. End Try
  7788. End Sub
  7789. Private Sub dataGridViews1_Scroll(sender As Object, e As ScrollEventArgs) Handles DataGridView1.Scroll
  7790. Try
  7791. Dim offSetValue As Integer = DataGridView1.HorizontalScrollingOffset
  7792. mov_TableEditDGV.HorizontalScrollingOffset = offSetValue
  7793. Catch
  7794. End Try
  7795. DataGridView1.Invalidate()
  7796. End Sub
  7797. Private Sub DataGridView1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles DataGridView1.MouseDown
  7798. Try
  7799. Dim ColIndexFromMouseDown = DataGridView1.HitTest(e.X, e.Y).ColumnIndex
  7800. Dim objHitTestInfo As DataGridView.HitTestInfo = DataGridView1.HitTest (e.X, e.Y)
  7801. Dim MouseRowIndex As Integer = objHitTestInfo.RowIndex
  7802. mov_TableRowNum = MouseRowIndex
  7803. If ColIndexFromMouseDown < 0 Then Exit Sub
  7804. mov_TableColumnName = DataGridView1.Columns(ColIndexFromMouseDown).Name
  7805. Catch ex As Exception
  7806. ExceptionHandler.LogError(ex)
  7807. End Try
  7808. End Sub
  7809. Private Sub DataGridView1_ColumnDisplayIndexChanged(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewColumnEventArgs) Handles DataGridView1.ColumnDisplayIndexChanged
  7810. Dim ColNewIndex = DataGridView1.Columns(mov_TableColumnName).DisplayIndex
  7811. mov_TableEditDGV.Columns(mov_TableColumnName).DisplayIndex = ColNewIndex
  7812. End Sub
  7813. Private Sub DataGridView1_SelectionChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DataGridView1.SelectionChanged
  7814. Dim MultiRowsSelected As Boolean = DataGridView1.SelectedRows.Count > 1
  7815. If MultiRowsSelected Then
  7816. mov_TableEditDGV.Visible = True
  7817. lbl_movTableEdit.Visible = True
  7818. lbl_movTableMulti.Visible = True
  7819. btn_movTableApply.Visible = True
  7820. Else
  7821. mov_TableEditDGV.Visible = False
  7822. lbl_movTableEdit.Visible = False
  7823. lbl_movTableMulti.Visible = False
  7824. btn_movTableApply.Visible = False
  7825. End If
  7826. End Sub
  7827. Private Sub DataGridView1_Sorted(ByVal sender As Object, ByVal e As System.EventArgs) Handles DataGridView1.Sorted
  7828. Try
  7829. For Each tempRow As System.Windows.Forms.DataGridViewRow In Me.DataGridView1.Rows
  7830. For Each tempCell As Windows.Forms.DataGridViewCell In tempRow.Cells
  7831. If tempCell.Value = "Fanart" Or tempCell.Value = "Poster" Or tempCell.Value = "Poster & Fanart" Then
  7832. tempCell.Style.BackColor = Color.Red
  7833. End If
  7834. Next
  7835. Next
  7836. Catch ex As Exception
  7837. ExceptionHandler.LogError(ex)
  7838. End Try
  7839. End Sub
  7840. Private Sub mov_TableEditDGV_CellClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles mov_TableEditDGV.CellClick
  7841. Try
  7842. mov_TableEditDGV.CurrentRow.Selected = False
  7843. Catch ex As Exception
  7844. ExceptionHandler.LogError(ex)
  7845. End Try
  7846. End Sub
  7847. Private Sub DataGridView1_CurrentCellDirtyStateChanged(sender As Object, e As EventArgs) Handles DataGridView1.CurrentCellDirtyStateChanged
  7848. DataDirty = True
  7849. btn_movTableSave.Enabled = DataDirty
  7850. End Sub
  7851. 'Table context toolstrips
  7852. Private Sub MarkAllSelectedAsWatchedToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MarkAllSelectedAsWatchedToolStripMenuItem.Click
  7853. Try
  7854. Dim selectedrowindex As New List(Of Integer)
  7855. For Each row in DataGridView1.SelectedRows
  7856. selectedrowindex.Add(row.index)
  7857. Next
  7858. If selectedrowindex.Count = 0 Then selectedrowindex.Add(DataGridView1.CurrentRow.Index)
  7859. DataGridView1.ClearSelection()
  7860. DataGridView1.CurrentCell = DataGridView1.Rows(selectedrowindex.Item(0)).Cells(0)
  7861. For Each row In selectedrowindex
  7862. DataGridView1.rows(row).Selected = True
  7863. DataGridView1.rows(row).Cells("playcount").Value = "Watched"
  7864. Next
  7865. DataDirty = True
  7866. btn_movTableSave.Enabled = True
  7867. Catch ex As Exception
  7868. ExceptionHandler.LogError(ex)
  7869. End Try
  7870. End Sub
  7871. Private Sub MarkAllSelectedAsUnWatchedToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MarkAllSelectedAsUnWatchedToolStripMenuItem.Click
  7872. Try
  7873. Dim selectedrowindex As New List(Of Integer)
  7874. For Each row in DataGridView1.SelectedRows
  7875. selectedrowindex.Add(row.index)
  7876. Next
  7877. If selectedrowindex.Count = 0 Then selectedrowindex.Add(DataGridView1.CurrentRow.Index)
  7878. DataGridView1.ClearSelection()
  7879. DataGridView1.CurrentCell = DataGridView1.Rows(selectedrowindex.Item(0)).Cells(0)
  7880. For Each row In selectedrowindex
  7881. DataGridView1.rows(row).Selected = True
  7882. DataGridView1.rows(row).Cells("playcount").Value = "UnWatched"
  7883. Next
  7884. DataDirty = True
  7885. btn_movTableSave.Enabled = True
  7886. Catch ex As Exception
  7887. ExceptionHandler.LogError(ex)
  7888. End Try
  7889. End Sub
  7890. Private Sub MovieTableContextMenu_Opening(sender As Object, e As CancelEventArgs) Handles MovieTableContextMenu.Opening
  7891. If mov_TableRowNum = -1 Then e.Cancel = True
  7892. End Sub
  7893. Private Sub GoToToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GoToToolStripMenuItem.Click
  7894. Try
  7895. Dim tempstring As String = ""
  7896. tempstring = DataGridView1.Rows(mov_TableRowNum).Cells("fullpathandfilename").Value
  7897. For f = 0 To DataGridViewMovies.Rows.Count - 1
  7898. If DataGridViewMovies.Rows(f).Cells("fullpathandfilename").Value.ToString = tempstring Then
  7899. DataGridViewMovies.ClearSelection()
  7900. DataGridViewMovies.Rows(f).Selected = True
  7901. Application.DoEvents()
  7902. currentTabIndex = 0
  7903. Me.TabControl2.SelectedIndex = 0
  7904. Exit For
  7905. End If
  7906. Next
  7907. Catch ex As Exception
  7908. ExceptionHandler.LogError(ex)
  7909. End Try
  7910. End Sub
  7911. Private Sub GoToSelectedMoviePosterSelectorToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GoToSelectedMoviePosterSelectorToolStripMenuItem.Click
  7912. Try
  7913. Dim tempstring As String = ""
  7914. tempstring = DataGridView1.Rows(mov_TableRowNum).Cells("fullpathandfilename").Value
  7915. For f = 0 To DataGridViewMovies.Rows.Count - 1
  7916. If DataGridViewMovies.Rows(f).Cells("fullpathandfilename").Value.ToString = tempstring Then
  7917. DataGridViewMovies.ClearSelection()
  7918. DataGridViewMovies.Rows(f).Selected = True
  7919. DisplayMovie()
  7920. For Each tabs In TabControl2.TabPages
  7921. If tabs.text = "Posters" Then
  7922. currentTabIndex = tabs.tabindex + 1
  7923. Me.TabControl2.SelectedIndex = tabs.tabindex + 1
  7924. Exit For
  7925. End If
  7926. Next
  7927. Exit For
  7928. End If
  7929. Next
  7930. Catch ex As Exception
  7931. ExceptionHandler.LogError(ex)
  7932. End Try
  7933. End Sub
  7934. Private Sub GoToSelectedMovieFanartSelectorToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GoToSelectedMovieFanartSelectorToolStripMenuItem.Click
  7935. Try
  7936. Dim tempstring As String = ""
  7937. tempstring = DataGridView1.Rows(mov_TableRowNum).Cells("fullpathandfilename").Value
  7938. For f = 0 To DataGridViewMovies.RowCount - 1
  7939. If DataGridViewMovies.Rows(f).Cells("fullpathandfilename").Value.ToString = tempstring Then
  7940. DataGridViewMovies.ClearSelection()
  7941. DataGridViewMovies.Rows(f).Selected = True
  7942. DisplayMovie()
  7943. For Each tabs In TabControl2.TabPages
  7944. If tabs.text = "Fanart" Then
  7945. currentTabIndex = tabs.tabindex + 1
  7946. Me.TabControl2.SelectedIndex = tabs.tabindex + 1
  7947. Exit For
  7948. End If
  7949. Next
  7950. Exit For
  7951. End If
  7952. Next
  7953. Catch ex As Exception
  7954. ExceptionHandler.LogError(ex)
  7955. End Try
  7956. End Sub
  7957. #End Region 'Movie Tableview code
  7958. Private Sub SearchForNewEpisodesToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SearchForNewEpisodesToolStripMenuItem.Click
  7959. Try
  7960. SearchForNewEpisodesToolStripMenuItem.Owner.Hide()
  7961. Call ep_Search()
  7962. Catch ex As Exception
  7963. ExceptionHandler.LogError(ex)
  7964. End Try
  7965. End Sub
  7966. Private Sub SearchALLForNewEpisodesToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SearchALLForNewEpisodesToolStripMenuItem.Click
  7967. Try
  7968. TVSearchALL = True
  7969. Call ep_Search()
  7970. TVSearchALL = False
  7971. Catch ex As Exception
  7972. ExceptionHandler.LogError(ex)
  7973. End Try
  7974. End Sub
  7975. Private Sub mov_ScrapeSpecific(ByVal field As String)
  7976. _rescrapeList.Field = field
  7977. _rescrapeList.FullPathAndFilenames.Clear
  7978. For Each row As DataGridViewRow In DataGridViewMovies.SelectedRows
  7979. Dim fullpath As String = row.Cells("fullpathandfilename").Value.ToString
  7980. If Not File.Exists(fullpath) Then Continue For
  7981. _rescrapeList.FullPathAndFilenames.Add(fullpath)
  7982. Next
  7983. RunBackgroundMovieScrape("RescrapeSpecific")
  7984. End Sub
  7985. Private Sub RescrapeFanartToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RescrapeFanartToolStripMenuItem.Click
  7986. Try
  7987. 'rescrape fanart
  7988. Call mov_FanartGet()
  7989. Catch ex As Exception
  7990. ExceptionHandler.LogError(ex)
  7991. End Try
  7992. End Sub
  7993. Private Sub DownloadFanartToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DownloadFanartToolStripMenuItem.Click
  7994. Try
  7995. 'download fanart
  7996. Call mov_FanartGet()
  7997. UpdateMissingFanart()
  7998. Catch ex As Exception
  7999. ExceptionHandler.LogError(ex)
  8000. End Try
  8001. End Sub
  8002. Private Sub mov_FanartGet(Optional ByVal MovSet As Boolean = False)
  8003. If IsNothing(workingMovieDetails) Then Return
  8004. messbox = New frmMessageBox(" Please Wait,", "", "Attempting to download Fanart")
  8005. messbox.Show() : messbox.Refresh()
  8006. Application.DoEvents()
  8007. Dim tmdb As New TMDb
  8008. tmdb.Imdb = If(workingMovieDetails.fullmoviebody.imdbid.Contains("tt"), workingMovieDetails.fullmoviebody.imdbid, "")
  8009. tmdb.TmdbId = workingMovieDetails.fullmoviebody.tmdbid
  8010. tmdb.SetId = workingMovieDetails.fullmoviebody.MovieSet.MovieSetId
  8011. Try
  8012. Dim FanartUrl As String = ""
  8013. If Not MovSet Then
  8014. FanartUrl = tmdb.GetBackDropUrl()
  8015. Else
  8016. FanartUrl = tmdb.McSetFanart(0).hdUrl
  8017. End If
  8018. Dim isvideotspath As String = If(workingMovieDetails.fileinfo.videotspath="","",workingMovieDetails.fileinfo.videotspath+"fanart.jpg")
  8019. If IsNothing(FanartUrl) then
  8020. MsgBox("No Fanart Found on TMDB")
  8021. Else
  8022. If Not MovSet Then
  8023. Dim paths As List(Of String) = Pref.GetfanartPaths(workingMovieDetails.fileinfo.fullpathandfilename,If(workingMovieDetails.fileinfo.videotspath <>"",workingMovieDetails.fileinfo.videotspath,""))
  8024. Dim point = Movie.GetBackDropResolution(Pref.BackDropResolutionSI)
  8025. Dim aok As Boolean = DownloadCache.SaveImageToCacheAndPaths(FanartUrl, paths, True, point.X, point.Y)
  8026. If Not aok Then Throw New Exception("TMDB is offline")
  8027. util_ImageLoad(PbMovieFanArt, paths(0), Utilities.DefaultFanartPath)
  8028. util_ImageLoad(PictureBox2, paths(0), Utilities.DefaultFanartPath)
  8029. Dim video_flags = VidMediaFlags(workingMovieDetails.filedetails, workingMovieDetails.fullmoviebody.title.ToLower.Contains("3d"))
  8030. movieGraphicInfo.OverlayInfo(PbMovieFanArt, ratingtxt.Text, video_flags, workingMovie.DisplayFolderSize)
  8031. Else
  8032. Dim MovSetFanartSavePath As String = workingMovieDetails.fileinfo.movsetfanartpath
  8033. If MovSetFanartSavePath <> "" Then
  8034. Movie.SaveFanartImageToCacheAndPath(FanartUrl, MovSetFanartSavePath)
  8035. MovPanel6Update()
  8036. Else
  8037. MsgBox("!! Problem formulating correct save location for Fanart" & vbCrLf & " Please check your settings")
  8038. End If
  8039. End If
  8040. End If
  8041. Catch ex As Exception
  8042. If ex.Message = "TMDB is offline" Then
  8043. messbox.Close()
  8044. MsgBox("Unable to connect to TheMovieDb.org." & vbCrLf & "Please confirm site is online")
  8045. ElseIf ex.Message.Contains("Index was out of range") Then
  8046. messbox.Close()
  8047. MsgBox("No Fanart available on TMDB Site")
  8048. End If
  8049. End Try
  8050. If Not IsNothing(messbox) Then messbox.Close()
  8051. End Sub
  8052. 'Rescrape Poster
  8053. Private Sub RescrapePToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RescrapePToolStripMenuItem.Click
  8054. Try
  8055. 'rescrape poster IMPA
  8056. mov_PosterGet("impa")
  8057. Catch ex As Exception
  8058. ExceptionHandler.LogError(ex)
  8059. End Try
  8060. End Sub
  8061. Private Sub RescrapePosterFromTMDBToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RescrapePosterFromTMDBToolStripMenuItem.Click
  8062. Try
  8063. 'rescrape poster tmdb
  8064. mov_PosterGet("tmdb")
  8065. Catch ex As Exception
  8066. ExceptionHandler.LogError(ex)
  8067. End Try
  8068. End Sub
  8069. Private Sub RescraToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RescraToolStripMenuItem.Click
  8070. Try
  8071. 'rescrape poster mpdb
  8072. MsgBox("MoviePoster Db is not longer available")
  8073. 'mov_PosterGet("mpdb")
  8074. Catch ex As Exception
  8075. ExceptionHandler.LogError(ex)
  8076. End Try
  8077. End Sub
  8078. Private Sub PeToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PeToolStripMenuItem.Click
  8079. Try
  8080. 'rescrape poster imdb
  8081. mov_PosterGet("imdb")
  8082. Catch ex As Exception
  8083. ExceptionHandler.LogError(ex)
  8084. End Try
  8085. End Sub
  8086. Private Sub DownloadPosterToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DownloadPosterToolStripMenuItem.Click
  8087. Try
  8088. 'downloadposter impa
  8089. mov_PosterGet("impa")
  8090. Catch ex As Exception
  8091. ExceptionHandler.LogError(ex)
  8092. End Try
  8093. End Sub
  8094. Private Sub DownloadPosterFromTMDBToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DownloadPosterFromTMDBToolStripMenuItem.Click
  8095. Try
  8096. 'downloadposter tmdb
  8097. mov_PosterGet("tmdb")
  8098. Catch ex As Exception
  8099. ExceptionHandler.LogError(ex)
  8100. End Try
  8101. End Sub
  8102. Private Sub DownloadPosterFromMPDBToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DownloadPosterFromMPDBToolStripMenuItem.Click
  8103. Try
  8104. 'downloadposter mpdb
  8105. MsgBox("MoviePoster Db is not longer available")
  8106. 'mov_PosterGet("mpdb")
  8107. Catch ex As Exception
  8108. ExceptionHandler.LogError(ex)
  8109. End Try
  8110. End Sub
  8111. Private Sub DownloadPosterFromIMDBToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DownloadPosterFromIMDBToolStripMenuItem.Click
  8112. Try
  8113. 'downloadposter imdb
  8114. mov_PosterGet("imdb")
  8115. Catch ex As Exception
  8116. ExceptionHandler.LogError(ex)
  8117. End Try
  8118. End Sub
  8119. Private Sub mov_PosterGet(ByVal source As String, Optional ByVal MovSet As Boolean = False)
  8120. Dim success As Boolean = False
  8121. Try
  8122. If workingMovieDetails Is Nothing Then Exit Sub
  8123. messbox = New frmMessageBox(" Please Wait,", "", "Attempting to download Poster from " & source.ToUpper)
  8124. messbox.Show()
  8125. messbox.Refresh()
  8126. Application.DoEvents()
  8127. Dim isvideotspath As String = ""
  8128. If workingMovieDetails.fileinfo.videotspath<>"" Then
  8129. isvideotspath=workingMovieDetails.fileinfo.videotspath+"poster.jpg"
  8130. End If
  8131. Dim moviethumburl As String = ""
  8132. Dim tmdb As New TMDb
  8133. tmdb.Imdb = If(workingMovieDetails.fullmoviebody.imdbid.Contains("tt"), workingMovieDetails.fullmoviebody.imdbid, "")
  8134. tmdb.TmdbId = workingMovieDetails.fullmoviebody.tmdbid
  8135. tmdb.SetId = workingMovieDetails.fullmoviebody.MovieSet.MovieSetId
  8136. If tmdb.Imdb = "" AndAlso tmdb.TmdbId = "" Then Exit Sub
  8137. If source = "impa" Then
  8138. If workingMovieDetails.fullmoviebody.title <> "" And workingMovieDetails.fullmoviebody.year <> "" Then
  8139. moviethumburl = scraperFunction2.impathumb(workingMovieDetails.fullmoviebody.title, workingMovieDetails.fullmoviebody.year)
  8140. End If
  8141. ElseIf source = "tmdb" Then
  8142. If workingMovieDetails.fullmoviebody.imdbid.Contains("tt") OrElse workingMovieDetails.fullmoviebody.tmdbid <> "" Then
  8143. Try
  8144. If Not MovSet Then
  8145. moviethumburl = tmdb.FirstOriginalPosterUrl
  8146. Else
  8147. moviethumburl = tmdb.McSetPosters(0).hdUrl
  8148. End If
  8149. Catch
  8150. End Try
  8151. End If
  8152. ElseIf source = "mpdb" Then
  8153. If workingMovieDetails.fullmoviebody.imdbid.Contains("tt") Then
  8154. moviethumburl = scraperFunction2.mpdbthumb(workingMovieDetails.fullmoviebody.imdbid)
  8155. End If
  8156. ElseIf source = "imdb" Then
  8157. If workingMovieDetails.fullmoviebody.imdbid.Contains("tt") Then
  8158. moviethumburl = scraperFunction2.imdbthumb(workingMovieDetails.fullmoviebody.imdbid)
  8159. End If
  8160. End If
  8161. If moviethumburl <> "" And moviethumburl <> "na" Then
  8162. Try
  8163. If Not MovSet Then
  8164. Dim PostPaths As List(Of String) = Pref.GetPosterPaths(workingMovieDetails.fileinfo.fullpathandfilename,workingMovieDetails.fileinfo.videotspath)
  8165. Dim height As Integer = 0
  8166. height = Movie.GetHeightResolution(Pref.PosterResolutionSI)
  8167. Dim aok As Boolean = DownloadCache.SaveImageToCacheAndPaths(moviethumburl, PostPaths, True, , height)
  8168. If Not aok Then Throw New Exception()
  8169. util_ImageLoad(PictureBoxAssignedMoviePoster, PostPaths(0), Utilities.DefaultPosterPath)
  8170. util_ImageLoad(PbMoviePoster, PostPaths(0), Utilities.DefaultPosterPath)
  8171. Dim path As String = Utilities.save2postercache(workingMovieDetails.fileinfo.fullpathandfilename, PostPaths(0), WallPicWidth, WallPicHeight)
  8172. updateposterwall(path, workingMovieDetails.fileinfo.fullpathandfilename)
  8173. success = True
  8174. Else
  8175. Dim MovSetPosterSavePath As String = workingMovieDetails.fileinfo.movsetposterpath
  8176. If MovSetPosterSavePath <> "" Then
  8177. Movie.SavePosterImageToCacheAndPath(moviethumburl, MovSetPosterSavePath)
  8178. MovPanel6Update()
  8179. Else
  8180. messbox.Close()
  8181. MsgBox("!! Problem formulating correct save location for Poster" & vbCrLf & " Please check your settings")
  8182. End If
  8183. End If
  8184. Catch ex As Exception
  8185. MsgBox("Error [" & ex.Message & "] occurred while trying to download and save the poster")
  8186. End Try
  8187. Else
  8188. MsgBox("Unable to obtain a Poster from " & source.ToUpper)
  8189. End If
  8190. messbox.Close()
  8191. Catch ex As Exception
  8192. #If SilentErrorScream Then
  8193. Throw ex
  8194. #End If
  8195. Finally
  8196. messbox.Close()
  8197. End Try
  8198. If success then UpdateMissingPoster()
  8199. End Sub
  8200. Public Sub mov_OfflineDvdProcess(ByVal nfopath As String, ByVal title As String, ByVal mediapath As String)
  8201. Dim tempint2 As Integer = 2097152
  8202. Dim SizeOfFile As Integer = FileLen(mediapath)
  8203. If SizeOfFile > tempint2 Then
  8204. Exit Sub
  8205. End If
  8206. Try
  8207. Dim fanartpath As String = ""
  8208. If IO.File.Exists(Pref.GetFanartPath(nfopath)) Then
  8209. fanartpath = Pref.GetFanartPath(nfopath)
  8210. Else
  8211. fanartpath = Utilities.DefaultOfflineArtPath
  8212. End If
  8213. Dim curImage As Image = Image.FromFile(fanartpath)
  8214. Dim tempstring As String = Pref.OfflineDVDTitle.Replace("%T", title)
  8215. Dim g As System.Drawing.Graphics
  8216. g = Graphics.FromImage(curImage)
  8217. Dim semiTransBrush As New SolidBrush(Color.FromArgb(80, 0, 0, 0))
  8218. Dim drawString As String = tempstring
  8219. Dim drawFont As New System.Drawing.Font("Arial", 40)
  8220. Dim drawBrush As New SolidBrush(Color.White)
  8221. Dim StringSize As New SizeF
  8222. StringSize = g.MeasureString(drawString, drawFont)
  8223. Dim width As Single = StringSize.Width + 5
  8224. Dim height As Single = StringSize.Height + 5
  8225. If height < (curImage.Height / 100) * 8 Then
  8226. Do
  8227. Dim newsize As Integer = drawFont.Size + 1
  8228. drawFont = New System.Drawing.Font("Arial", newsize)
  8229. StringSize = g.MeasureString(drawString, drawFont)
  8230. height = StringSize.Height
  8231. Loop Until height > (curImage.Height / 100) * 8
  8232. End If
  8233. If height > (curImage.Height / 100) * 8 Then
  8234. Do
  8235. Dim newsize As Integer = drawFont.Size - 1
  8236. drawFont = New System.Drawing.Font("Arial", newsize)
  8237. StringSize = g.MeasureString(drawString, drawFont)
  8238. height = StringSize.Height
  8239. Loop Until height < (curImage.Height / 100) * 8
  8240. End If
  8241. StringSize = g.MeasureString(drawString, drawFont)
  8242. width = StringSize.Width
  8243. height = StringSize.Height
  8244. If width > curImage.Width - 30 Then
  8245. Do
  8246. Dim newsize As Integer = drawFont.Size - 1
  8247. drawFont = New System.Drawing.Font("Arial", newsize)
  8248. StringSize = g.MeasureString(drawString, drawFont)
  8249. width = StringSize.Width + 20
  8250. Loop Until width < curImage.Width - 30
  8251. End If
  8252. StringSize = g.MeasureString(drawString, drawFont)
  8253. width = StringSize.Width + 5
  8254. height = StringSize.Height + 5
  8255. Dim x As Integer = (curImage.Width / 2) - (width / 2)
  8256. Dim y As Integer = (curImage.Height - StringSize.Height) - ((curImage.Height / 100) * 2)
  8257. Dim drawRect As New RectangleF(x, y, width, height)
  8258. g.FillRectangle(semiTransBrush, New Rectangle(x, y, width, height))
  8259. Dim drawFormat As New StringFormat
  8260. drawFormat.Alignment = StringAlignment.Center
  8261. g.DrawString(drawString, drawFont, drawBrush, drawRect, drawFormat)
  8262. For f = 1 To 16
  8263. Dim path As String
  8264. If f < 10 Then
  8265. path = applicationPath & "\Settings\00" & f.ToString & ".jpg"
  8266. Else
  8267. path = applicationPath & "\Settings\0" & f.ToString & ".jpg"
  8268. End If
  8269. curImage.Save(path, Drawing.Imaging.ImageFormat.Jpeg)
  8270. Next
  8271. Dim myProcess As Process = New Process
  8272. myProcess.StartInfo.WindowStyle = ProcessWindowStyle.Hidden
  8273. myProcess.StartInfo.CreateNoWindow = False
  8274. myProcess.StartInfo.FileName = applicationPath & "\Assets\ffmpeg.exe"
  8275. Dim proc_arguments As String = "-r 1 -b 1800 -qmax 6 -i """ & applicationPath & "\Settings\%03d.jpg"" -vcodec msmpeg4v2 -y """ & mediapath & """"
  8276. myProcess.StartInfo.Arguments = proc_arguments
  8277. myProcess.Start()
  8278. myProcess.WaitForExit()
  8279. For f = 1 To 16
  8280. Dim tempstring4 As String
  8281. If f < 10 Then
  8282. tempstring4 = applicationPath & "\Settings\00" & f.ToString & ".jpg"
  8283. Else
  8284. tempstring4 = applicationPath & "\Settings\0" & f.ToString & ".jpg"
  8285. End If
  8286. Try
  8287. IO.File.Delete(tempstring4)
  8288. Catch ex As Exception
  8289. #If SilentErrorScream Then
  8290. Throw ex
  8291. #End If
  8292. End Try
  8293. Next
  8294. Catch ex As Exception
  8295. #If SilentErrorScream Then
  8296. Throw ex
  8297. #End If
  8298. End Try
  8299. End Sub
  8300. Private Sub ToolsToolStripMenuItem_DropDownItemClicked(ByVal sender As Object, ByVal e As System.Windows.Forms.ToolStripItemClickedEventArgs) Handles ToolsToolStripMenuItem.DropDownItemClicked
  8301. Try
  8302. For Each temp In Pref.commandlist
  8303. If temp.title = e.ClickedItem.Text Then
  8304. Try
  8305. Process.Start(temp.command)
  8306. Catch ex As Exception
  8307. End Try
  8308. Exit For
  8309. End If
  8310. Next
  8311. Catch ex As Exception
  8312. ExceptionHandler.LogError(ex)
  8313. End Try
  8314. End Sub
  8315. Private Sub PreferencesToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PreferencesToolStripMenuItem.Click
  8316. OpenPreferences(0)
  8317. End Sub
  8318. Private Sub OpenPreferences(Optional ByVal TabRequired As Integer = 0)
  8319. Try
  8320. Dim t As New frmPreferences
  8321. t.SelectTab = TabRequired
  8322. If Pref.MultiMonitoEnabled Then
  8323. t.Bounds = screen.AllScreens(CurrentScreen).Bounds
  8324. t.StartPosition = FormStartPosition.Manual
  8325. End If
  8326. t.ShowDialog()
  8327. If Not tvbckrescrapewizard.IsBusy AndAlso Not bckgroundscanepisodes.IsBusy AndAlso Not bckgrnd_tvshowscraper.IsBusy AndAlso Not Bckgrndfindmissingepisodes.IsBusy AndAlso Not BckWrkScnMovies.IsBusy Then
  8328. Statusstrip_Enable(False)
  8329. End If
  8330. Catch ex As Exception
  8331. ExceptionHandler.LogError(ex)
  8332. End Try
  8333. End Sub
  8334. Private Sub SearchForMissingEpisodesToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SearchForMissingEpisodesToolStripMenuItem.Click
  8335. Try
  8336. If Not Bckgrndfindmissingepisodes.IsBusy And bckgroundscanepisodes.IsBusy = False Then
  8337. Pref.displayMissingEpisodes = SearchForMissingEpisodesToolStripMenuItem.Checked
  8338. Pref.ConfigSave()
  8339. If Pref.displayMissingEpisodes = False
  8340. RefreshMissingEpisodesToolStripMenuItem.Enabled = False
  8341. rbTvListAll.Checked = True
  8342. rbTvMissingEpisodes.Enabled = False
  8343. rbTvMissingAiredEp.Enabled = False
  8344. RefreshMissingEpisodesToolStripMenuItem.ToolTipText = Nothing
  8345. tv_CacheRefresh
  8346. Return
  8347. End If
  8348. RefreshMissingEpisodesToolStripMenuItem.Enabled = True
  8349. RefreshMissingEpisodesToolStripMenuItem.ToolTipText = "Last Refresh: " & Pref.lastrefreshmissingdate
  8350. rbTvMissingEpisodes.Enabled = True
  8351. rbTvMissingAiredEp.Enabled = True
  8352. Pref.DlMissingEpData = False
  8353. tv_EpisodesMissingLoad(False)
  8354. ElseIf Bckgrndfindmissingepisodes.IsBusy Then
  8355. MsgBox("Process is already running")
  8356. Else
  8357. MsgBox("Missing episode search cannot be performed" & vbCrLf & " when the episode scraper is running")
  8358. End If
  8359. Catch ex As Exception
  8360. ExceptionHandler.LogError(ex)
  8361. End Try
  8362. End Sub
  8363. Private Sub RefreshMissingEpisodesToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RefreshMissingEpisodesToolStripMenuItem.Click
  8364. Pref.DlMissingEpData = True
  8365. Pref.lastrefreshmissingdate = DateTime.Now.ToString("yyyy-MM-dd")
  8366. ClearMissingFolder()
  8367. tv_EpisodesMissingLoad(True)
  8368. End Sub
  8369. Private Sub RefreshThisShowToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Tv_TreeViewContext_RefreshShow.Click
  8370. Try
  8371. Dim Show As TvShow = tv_ShowSelectedCurrently(TvTreeview)
  8372. Dim selectednode As Integer = TvTreeview.SelectedNode.Index
  8373. If Show IsNot Nothing Then
  8374. Call tv_CacheRefreshSelected(Show)
  8375. Else
  8376. MsgBox("No Show Selected")
  8377. End If
  8378. TvTreeview.SelectedNode = TvTreeview.Nodes(selectednode)
  8379. Catch ex As Exception
  8380. ExceptionHandler.LogError(ex)
  8381. End Try
  8382. End Sub
  8383. Private Sub Tv_TreeViewContext_ShowMissEps_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Tv_TreeViewContext_ShowMissEps.Click
  8384. Try
  8385. Dim Show As TvShow = tv_ShowSelectedCurrently(TvTreeview)
  8386. If Not Bckgrndfindmissingepisodes.IsBusy Then
  8387. Dim tempstring As String = ""
  8388. For Each sho In Cache.TvCache.Shows
  8389. If sho.NfoFilePath = TvTreeview.SelectedNode.Name Then
  8390. tempstring = "Checking """ & sho.Title.Value & """ for missing episodes"
  8391. Exit For
  8392. End If
  8393. Next
  8394. If tempstring = "" Then tempstring = "Checking for missing episodes"
  8395. messbox = New frmMessageBox(tempstring, "", "Please Wait")
  8396. messbox.Show()
  8397. messbox.Refresh()
  8398. Application.DoEvents()
  8399. Dim ShowList As New List(Of TvShow)
  8400. ShowList.Add(Show)
  8401. Bckgrndfindmissingepisodes.RunWorkerAsync(ShowList)
  8402. messbox.Close()
  8403. Else
  8404. MsgBox("The missing episode thread is already running")
  8405. End If
  8406. Catch ex As Exception
  8407. ExceptionHandler.LogError(ex)
  8408. End Try
  8409. End Sub
  8410. Private Sub LockAllToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LockAllToolStripMenuItem.Click
  8411. Try
  8412. Dim Show As Media_Companion.TvShow
  8413. For Each Show In Cache.TvCache.Shows
  8414. Show = nfoFunction.tvshow_NfoLoad(Show.NfoFilePath) '.Load()
  8415. Show.State = Media_Companion.ShowState.Locked
  8416. nfoFunction.tvshow_NfoSave(Show, True)
  8417. 'Show.Save()
  8418. Tv_CacheSave()
  8419. Next
  8420. tv_CacheLoad()
  8421. Catch ex As Exception
  8422. ExceptionHandler.LogError(ex)
  8423. End Try
  8424. End Sub
  8425. Private Sub UnlockAllToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles UnlockAllToolStripMenuItem.Click
  8426. Try
  8427. Dim Show As Media_Companion.TvShow
  8428. For Each Show In Cache.TvCache.Shows
  8429. Show = nfoFunction.tvshow_NfoLoad(Show.NfoFilePath) '.Load()
  8430. Show.State = Media_Companion.ShowState.Open
  8431. nfoFunction.tvshow_NfoSave(Show, True)
  8432. 'Show.Save()
  8433. Tv_CacheSave()
  8434. Next
  8435. tv_CacheLoad()
  8436. Catch ex As Exception
  8437. ExceptionHandler.LogError(ex)
  8438. End Try
  8439. End Sub
  8440. Private Sub TV_BatchRescrapeWizardToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TV_BatchRescrapeWizardToolStripMenuItem.Click
  8441. Try
  8442. If Not tvbckrescrapewizard.IsBusy Then
  8443. tvBatchList.Reset()
  8444. Dim displaywizard As New tv_batch_wizard
  8445. If Pref.MultiMonitoEnabled Then
  8446. displaywizard.Bounds = screen.AllScreens(CurrentScreen).Bounds
  8447. displaywizard.StartPosition = FormStartPosition.Manual
  8448. End If
  8449. displaywizard.ShowDialog()
  8450. If tvBatchList.activate = True Then
  8451. Statusstrip_Enable()
  8452. ToolStripStatusLabel8.Text = "Starting TV Batch Scrape"
  8453. ToolStripStatusLabel8.Visible = True
  8454. ToolStripProgressBar7.Value = 0
  8455. ToolStripProgressBar7.Visible = True
  8456. tvbckrescrapewizard.RunWorkerAsync()
  8457. End If
  8458. Else
  8459. MsgBox("The update Wizard is Already Running")
  8460. End If
  8461. Catch ex As Exception
  8462. ExceptionHandler.LogError(ex)
  8463. End Try
  8464. End Sub
  8465. Private Sub tsmiMov_ExportMovies_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tsmiMov_ExportMovies.Click
  8466. Try
  8467. listoffilestomove.Clear()
  8468. If DataGridViewMovies.SelectedRows.Count > 0 Then
  8469. For Each sRow As DataGridViewRow In DataGridViewMovies.SelectedRows
  8470. Dim playlist As New List(Of String)
  8471. Dim tempstring As String = Utilities.GetFileName(DataGridViewMovies.SelectedCells(NFO_INDEX).Value.ToString)
  8472. playlist = Utilities.GetMediaList(tempstring)
  8473. If playlist.Count > 0 Then
  8474. For Each File In playlist
  8475. If Not listoffilestomove.Contains(File) Then listoffilestomove.Add(File)
  8476. Next
  8477. Dim fullpathandfilename As String = sRow.Cells("fullpathandfilename").Value.ToString
  8478. listoffilestomove.Add(fullpathandfilename)
  8479. If IO.File.Exists(Pref.GetFanartPath(fullpathandfilename)) Then listoffilestomove.Add(Pref.GetFanartPath(fullpathandfilename))
  8480. If IO.File.Exists(Pref.GetPosterPath(fullpathandfilename)) Then listoffilestomove.Add(Pref.GetPosterPath(fullpathandfilename))
  8481. Dim di As DirectoryInfo = New DirectoryInfo(fullpathandfilename.Replace(IO.Path.GetFileName(fullpathandfilename), ""))
  8482. Dim filenama As String = IO.Path.GetFileNameWithoutExtension(fullpathandfilename)
  8483. Dim fils As IO.FileInfo() = di.GetFiles(filenama & ".*")
  8484. For Each fiNext In fils
  8485. If Not listoffilestomove.Contains(fiNext.FullName) Then
  8486. listoffilestomove.Add(fiNext.FullName)
  8487. End If
  8488. Next
  8489. Dim trailerpath As String = Pref.ActualTrailerPath(fullpathandfilename) 'fullpathandfilename.Replace(IO.Path.GetExtension(fullpathandfilename), "-trailer.flv")
  8490. Dim filenama2 As String = IO.Path.GetFileNameWithoutExtension(trailerpath)
  8491. Dim fils2 As IO.FileInfo() = di.GetFiles(filenama2 & ".*")
  8492. For Each fiNext In fils2
  8493. If Not listoffilestomove.Contains(fiNext.FullName) Then
  8494. listoffilestomove.Add(fiNext.FullName)
  8495. End If
  8496. Next
  8497. End If
  8498. Next
  8499. totalfilesize = 0
  8500. For Each item In listoffilestomove
  8501. totalfilesize = totalfilesize + Utilities.GetFileSize(item)
  8502. Next
  8503. With FolderBrowserDialog1
  8504. .ShowNewFolderButton = True
  8505. .Description = "Select destination for file copy"
  8506. End With
  8507. Dim drive As String = ""
  8508. Dim savepath As String = ""
  8509. Dim frm As New frmCopyProgress
  8510. If Pref.MultiMonitoEnabled Then
  8511. frm.Bounds = screen.AllScreens(CurrentScreen).Bounds
  8512. frm.StartPosition = FormStartPosition.Manual
  8513. End If
  8514. frm.ShowDialog()
  8515. End If
  8516. Catch ex As Exception
  8517. ExceptionHandler.LogError(ex)
  8518. End Try
  8519. End Sub
  8520. Private Sub frm_ExportTabSetup()
  8521. If TextBox45.Text = "" Then
  8522. Dim tempstring2 As String = workingProfile.config.Replace(IO.Path.GetFileName(workingProfile.config), "pathsubstitution.xml")
  8523. If IO.File.Exists(tempstring2) Then
  8524. relativeFolderList.Clear()
  8525. Dim prefs As New XmlDocument
  8526. Try
  8527. prefs.Load(tempstring2)
  8528. Catch ex As Exception
  8529. End Try
  8530. Dim thisresult As XmlNode = Nothing
  8531. For Each thisresult In prefs("relativepaths")
  8532. Select Case thisresult.Name
  8533. Case "folder"
  8534. Dim mc As New str_RelativeFileList(SetDefaults)
  8535. Dim it2 As XmlNode
  8536. For Each it2 In thisresult.ChildNodes
  8537. Select Case it2.Name
  8538. Case "mc"
  8539. mc.mc = it2.InnerText
  8540. Case "xbmc"
  8541. mc.xbmc = it2.InnerText
  8542. relativeFolderList.Add(mc)
  8543. End Select
  8544. Next
  8545. End Select
  8546. Next
  8547. For Each item In relativeFolderList
  8548. TextBox45.Text += "<folder>" & vbCrLf
  8549. TextBox45.Text += " <mc>" & item.mc & "</mc>" & vbCrLf
  8550. TextBox45.Text += " <xbmc>" & item.xbmc & "</xbmc>" & vbCrLf
  8551. TextBox45.Text += "</folder>" & vbCrLf & vbCrLf
  8552. Next
  8553. End If
  8554. If TextBox45.Text = "" Then
  8555. For Each pat In movieFolders
  8556. If Not pat.selected Then Continue For
  8557. TextBox45.Text += "<folder>" & vbCrLf
  8558. TextBox45.Text += " <mc>" & pat.rpath & "</mc>" & vbCrLf
  8559. TextBox45.Text += " <xbmc>" & pat.rpath & "</xbmc>" & vbCrLf
  8560. TextBox45.Text += "</folder>" & vbCrLf & vbCrLf
  8561. Next
  8562. For Each pat In Pref.offlinefolders
  8563. TextBox45.Text += "<folder>" & vbCrLf
  8564. TextBox45.Text += " <mc>" & pat & "</mc>" & vbCrLf
  8565. TextBox45.Text += " <xbmc>" & pat & "</xbmc>" & vbCrLf
  8566. TextBox45.Text += "</folder>" & vbCrLf & vbCrLf
  8567. Next
  8568. For Each pat In tvRootFolders
  8569. TextBox45.Text += "<folder>" & vbCrLf
  8570. TextBox45.Text += " <mc>" & pat.rpath & "</mc>" & vbCrLf
  8571. TextBox45.Text += " <xbmc>" & pat.rpath & "</xbmc>" & vbCrLf
  8572. TextBox45.Text += "</folder>" & vbCrLf & vbCrLf
  8573. Next
  8574. End If
  8575. End If
  8576. End Sub
  8577. Private Sub Button109_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button109.Click
  8578. Try
  8579. relativeFolderList.Clear()
  8580. Dim tempstring2 As String = workingProfile.config.Replace(IO.Path.GetFileName(workingProfile.config), "pathsubstitution.xml")
  8581. Dim temptext As String = ""
  8582. temptext = "<relativepaths>" & TextBox45.Text & "</relativepaths>"
  8583. Dim doc As New XmlDocument
  8584. doc.LoadXml(temptext)
  8585. Dim thisresult As XmlElement
  8586. For Each thisresult In doc("relativepaths")
  8587. Dim newfo As New str_RelativeFileList(SetDefaults)
  8588. For Each innerresult In thisresult
  8589. Select Case innerresult.Name
  8590. Case "mc"
  8591. newfo.mc = innerresult.InnerText
  8592. Case "xbmc"
  8593. newfo.xbmc = innerresult.InnerText
  8594. End Select
  8595. Next
  8596. If Not String.IsNullOrEmpty(newfo.mc) AndAlso Not String.IsNullOrEmpty(newfo.xbmc) Then relativeFolderList.Add(newfo)
  8597. Next
  8598. If relativeFolderList.Count > 0 Then
  8599. Dim docs As New XmlDocument
  8600. Dim thispref As XmlNode = Nothing
  8601. Dim xmlproc As XmlDeclaration
  8602. xmlproc = docs.CreateXmlDeclaration("1.0", "UTF-8", "yes")
  8603. docs.AppendChild(xmlproc)
  8604. Dim root As XmlElement
  8605. Dim child As XmlElement
  8606. Dim childchild As XmlElement
  8607. root = doc.CreateElement("relativepaths")
  8608. For Each item In relativeFolderList
  8609. child = doc.CreateElement("folder")
  8610. childchild = doc.CreateElement("mc")
  8611. childchild.InnerText = item.mc
  8612. child.AppendChild(childchild)
  8613. childchild = doc.CreateElement("xbmc")
  8614. childchild.InnerText = item.xbmc
  8615. child.AppendChild(childchild)
  8616. root.AppendChild(child)
  8617. Next
  8618. Dim output As New XmlTextWriter(tempstring2, System.Text.Encoding.UTF8)
  8619. output.Formatting = Formatting.Indented
  8620. doc.WriteTo(output)
  8621. output.Close()
  8622. End If
  8623. Catch ex As Exception
  8624. ExceptionHandler.LogError(ex)
  8625. End Try
  8626. End Sub
  8627. Private Sub SplitContainer1_SplitterMoved(ByVal sender As System.Object, ByVal e As System.Windows.Forms.SplitterEventArgs) Handles SplitContainer1.SplitterMoved
  8628. Mc.clsGridViewMovie.SetFirstColumnWidth(DataGridViewMovies)
  8629. End Sub
  8630. Private Sub SplitContainer5_SplitterMoved(ByVal sender As System.Object, ByVal e As System.Windows.Forms.SplitterEventArgs) Handles SplitContainer5.SplitterMoved
  8631. ResizeBottomLHSPanel()
  8632. Try
  8633. DebugSplitter5PosLabel.Text = SplitContainer5.SplitterDistance
  8634. Catch ex As Exception
  8635. ExceptionHandler.LogError(ex)
  8636. End Try
  8637. End Sub
  8638. Private Sub MediaCompanionCodeplexSiteToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MediaCompanionCodeplexSiteToolStripMenuItem.Click
  8639. Try
  8640. Dim webAddress As String = "http://mediacompanion.codeplex.com/"
  8641. OpenUrl(webAddress)
  8642. Catch ex As Exception
  8643. ExceptionHandler.LogError(ex)
  8644. End Try
  8645. End Sub
  8646. Private Sub CheckBoxDebugShowXML_CheckedChanged(sender As System.Object, e As System.EventArgs) Handles CheckBoxDebugShowXML.CheckedChanged
  8647. Try
  8648. If CheckBoxDebugShowXML.Checked = False Then
  8649. TabLevel1.TabPages.Remove(Me.TabConfigXML)
  8650. TabLevel1.TabPages.Remove(Me.TabMovieCacheXML)
  8651. TabLevel1.TabPages.Remove(Me.TabTVCacheXML)
  8652. TabLevel1.TabPages.Remove(Me.TabProfile)
  8653. TabLevel1.TabPages.Remove(Me.TabActorCache)
  8654. TabLevel1.TabPages.Remove(Me.TabRegex)
  8655. Else
  8656. TabLevel1.TabPages.Add(Me.TabConfigXML)
  8657. TabLevel1.TabPages.Add(Me.TabMovieCacheXML)
  8658. TabLevel1.TabPages.Add(Me.TabTVCacheXML)
  8659. TabLevel1.TabPages.Add(Me.TabProfile)
  8660. TabLevel1.TabPages.Add(Me.TabActorCache)
  8661. TabLevel1.TabPages.Add(Me.TabRegex)
  8662. End If
  8663. Catch ex As Exception
  8664. ExceptionHandler.LogError(ex)
  8665. End Try
  8666. End Sub
  8667. Public Sub util_ConfigLoad(ByVal Optional prefs As Boolean = False)
  8668. Pref.SetUpPreferences()
  8669. Pref.ConfigLoad()
  8670. Pref.MultiMonitoEnabled = convert.ToBoolean(multimonitor)
  8671. DataGridViewMovies.DataSource = Nothing
  8672. Me.SearchForMissingEpisodesToolStripMenuItem.Checked = Pref.displayMissingEpisodes
  8673. Me.RefreshMissingEpisodesToolStripMenuItem.Enabled = Pref.displayMissingEpisodes
  8674. If Pref.displayMissingEpisodes Then
  8675. Me.RefreshMissingEpisodesToolStripMenuItem.ToolTipText = "Last Refresh: " & Pref.lastrefreshmissingdate
  8676. End If
  8677. Me.rbTvMissingEpisodes.Enabled = Pref.displayMissingEpisodes
  8678. Me.rbTvMissingAiredEp.Enabled = Pref.displayMissingEpisodes
  8679. Renamer.setRenamePref(Pref.tv_RegexRename.Item(Pref.tvrename), Pref.tv_RegexScraper)
  8680. XBMCTMDBConfigSave()
  8681. XBMCTVDBConfigSave()
  8682. '----------------------------------------------------------
  8683. mScraperManager = New ScraperManager(IO.Path.Combine(My.Application.Info.DirectoryPath, "Assets\scrapers"))
  8684. '----------------------------------------------------------
  8685. Dim loadinginfo As String = ""
  8686. If Not IO.File.Exists(workingProfile.moviecache) Or Pref.startupCache = False Then
  8687. loadinginfo = "Status :- Building Movie caches"
  8688. frmSplash.Label3.Text = loadinginfo
  8689. frmSplash.Label3.Refresh()
  8690. mov_RebuildMovieCaches()
  8691. Else
  8692. loadinginfo = "Status :- Loading Movie Database"
  8693. frmSplash.Label3.Text = loadinginfo
  8694. frmSplash.Label3.Refresh()
  8695. mov_CacheLoad()
  8696. End If
  8697. If IO.File.Exists(workingProfile.Genres) Then
  8698. loadinginfo = "Status :- Loading Genre List"
  8699. frmSplash.Label3.Text = loadinginfo
  8700. frmSplash.Label3.Refresh()
  8701. Call util_GenreLoad()
  8702. End If
  8703. If IO.File.Exists(workingProfile.homemoviecache) Then
  8704. loadinginfo = "Status :- Loading Home Movie Database"
  8705. frmSplash.Label3.Text = loadinginfo
  8706. frmSplash.Label3.Refresh()
  8707. Call homemovieCacheLoad()
  8708. End If
  8709. If IO.File.Exists(workingProfile.MusicVideoCache) Then
  8710. loadinginfo = "Status :- Loading Music Video Database"
  8711. frmSplash.Label3.Text = loadinginfo
  8712. frmSplash.Label3.Refresh()
  8713. UcMusicVideo1.cmbxMVSort.SelectedIndex = 0
  8714. Call UcMusicVideo1.MVCacheLoad()
  8715. End If
  8716. If Not prefs then
  8717. If Not IO.File.Exists(workingProfile.tvcache) Or Pref.startupCache = False Then
  8718. loadinginfo = "Status :- Building TV Database"
  8719. frmSplash.Label3.Text = loadinginfo
  8720. frmSplash.Label3.Refresh()
  8721. Call tv_CacheRefresh()
  8722. Else
  8723. loadinginfo = "Status :- Loading TV Database"
  8724. frmSplash.Label3.Text = loadinginfo
  8725. frmSplash.Label3.Refresh()
  8726. Call tv_CacheLoad()
  8727. End If
  8728. Call tv_Filter()
  8729. End If
  8730. If Pref.homemoviefolders.Count > 0 Then
  8731. AuthorizeCheck = True
  8732. clbx_HMMovieFolders.Items.Clear()
  8733. For Each folder In homemoviefolders
  8734. clbx_HMMovieFolders.Items.Add(folder.rpath, folder.selected)
  8735. Next
  8736. AuthorizeCheck = False
  8737. End If
  8738. cbBtnLink.Checked = Pref.XBMC_Link
  8739. SetcbBtnLink
  8740. If Pref.XbmcLinkReady Then
  8741. XbmcControllerQ.Write(XbmcController.E.ConnectReq, PriorityQueue.Priorities.low)
  8742. End If
  8743. End Sub
  8744. Private Sub MediaCompanionHelpFileToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles MediaCompanionHelpFileToolStripMenuItem.Click
  8745. Try
  8746. Process.Start(applicationPath & "\Media_Companion.chm")
  8747. Catch ex As Exception
  8748. ExceptionHandler.LogError(ex)
  8749. End Try
  8750. End Sub
  8751. Private Sub Tv_TreeViewContext_DispByAiredDate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Tv_TreeViewContext_DispByAiredDate.Click
  8752. 'This function displays in a Form with a fullscreen textbox, a list off all of a TvShows episodes in 'date aired' order, separated by calendar year.
  8753. 'It can be called from a TVShow, Season or Episode context menu
  8754. 'It handles the following errors - no aired date, episodes on the same aired date, episodes on same date with same series & same episode i.e. a duplicate....
  8755. Try
  8756. Dim WorkingTvShow As TvShow = tv_ShowSelectedCurrently(TvTreeview)
  8757. Dim NoDateCountUp As Integer = 0
  8758. Dim Abort As Boolean = True 'this is used to verify that we actually have episodes to process
  8759. Dim mySortedList As New SortedList() 'this is our sorted list, we add to the list a key (aired date) & the associated data (episode name), then we sort it & then we read out the data
  8760. Dim childNodeLevel1 As TreeNode
  8761. Select Case TvTreeview.SelectedNode.Level
  8762. Case Is = 0
  8763. childNodeLevel1 = TvTreeview.SelectedNode
  8764. Case Is = 1
  8765. childNodeLevel1 = TvTreeview.SelectedNode.Parent
  8766. Case Is = 2
  8767. childNodeLevel1 = TvTreeview.SelectedNode.Parent.Parent
  8768. Case Else
  8769. MsgBox("Unsupported TvTreeviewlevel in Aired Date Function", MsgBoxStyle.Exclamation, "Error!")
  8770. Exit Sub
  8771. End Select
  8772. 'this section steps down through the tree to get from the tvshow to each episode
  8773. For Each childNodeLevel2 As TreeNode In childNodeLevel1.Nodes
  8774. For Each childNodeLevel3 As TreeNode In childNodeLevel2.Nodes
  8775. Abort = False 'if we get here then there is at least 1 episode
  8776. Dim episode As New TvEpisode
  8777. episode.Load(childNodeLevel3.Name)
  8778. Dim EpAired As String = episode.Aired.Value 'this holds the 'aired' value
  8779. If EpAired Is Nothing Then
  8780. EpAired = "9999-" & Utilities.PadNumber(NoDateCountUp, 5) 'if the aired date is nothing then we add it as 9999-xxxxx where x increments
  8781. NoDateCountUp += 1
  8782. End If
  8783. 'Convert episode to 2 digits for formatting
  8784. Dim episode2digit As New List(Of String)
  8785. episode2digit.Clear()
  8786. episode2digit.Add(childNodeLevel3.Tag.Episode.Value)
  8787. If episode2digit(0).Length = 1 Then episode2digit(0) = "0" & episode2digit(0)
  8788. 'Convert season to 2 digits for formatting
  8789. Dim season2digit As String = childNodeLevel3.Tag.Season.Value
  8790. If season2digit.Length = 1 Then season2digit = "0" & season2digit
  8791. 'here we add our data in the order that it is read in the tree - the sorted list will sort it for us
  8792. 'using the key value .aired (date format is yyyy-mm-dd so simple alphabetical sort is all that is required)
  8793. 'FormatTVFilename formats the show title,episode tile, season no & episode no as per the users preferences
  8794. Dim SameDateLoop As Boolean = True
  8795. Dim Key As String
  8796. Key = EpAired & season2digit & episode2digit(0) 'the key index (which is the string used to sort by) is the date+season+episode - this should be unique!
  8797. Do Until SameDateLoop = False
  8798. If mySortedList.ContainsKey(Key) Then
  8799. Key += "^" 'we add an aditional ^ to the key if its still not unique.....
  8800. Else
  8801. SameDateLoop = False
  8802. End If
  8803. Loop
  8804. mySortedList.Add(Key, EpAired & " " & Renamer.setTVFilename(WorkingTvShow.Title.Value, childNodeLevel3.Tag.title.value, episode2digit, season2digit))
  8805. Next
  8806. Next
  8807. If Not Abort Then 'i.e. we have episodes in this show....
  8808. Dim textstring As String = "!!! " & WorkingTvShow.Title.Value & " Seasons: " & WorkingTvShow.Seasons.Count & " Episodes: " & WorkingTvShow.Episodes.Count & vbCrLf 'start our text with the show title
  8809. textstring += "!!! " & StrDup(textstring.Length - 2, "-") & vbCrLf 'add an underline of the same length
  8810. Dim prevkey As String = mySortedList.GetKey(0).Substring(0, 4) 'load with first year value first four digits of aired date
  8811. For Line = 0 To mySortedList.Count - 1 'read the data from the sorted list
  8812. If mySortedList.GetKey(Line).Substring(0, 4) <> prevkey Then textstring += "!!! ----------" & vbCrLf 'line break between years...
  8813. prevkey = mySortedList.GetKey(Line).Substring(0, 4) 'set so that we can compare with next iteration
  8814. textstring += "!!! " & mySortedList.GetByIndex(Line) & vbCrLf ' "!!! " allows this to be shown in either brief or Full log modes
  8815. Next
  8816. textstring += "!!! " & vbCrLf & "!!! 9999 episodes have no valid aired date stored" & vbCrLf
  8817. ' 'Show Final Listing Screen
  8818. Dim MyFormObject As New frmoutputlog(textstring, True) 'create the log form & modify it to suit our needs
  8819. MyFormObject.TextBox1.Font = New System.Drawing.Font("Courier New", 10.2!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) 'constant width font
  8820. MyFormObject.btn_savelog.AutoSize = True 'change button size to text will fit automatically
  8821. MyFormObject.btn_savelog.Text = "Save Details..." 'change the button text
  8822. MyFormObject.Text = "Episodes in Aired Order for " & WorkingTvShow.Title.Value 'change the form title text
  8823. MyFormObject.ShowDialog() 'show the form
  8824. Else 'we get here if abort still = true, i.e. no episodes
  8825. MsgBox("There are no Epsiodes or Missing Episodes for this show.", MsgBoxStyle.OkOnly, "No Episodes")
  8826. End If
  8827. Catch ex As Exception
  8828. ExceptionHandler.LogError(ex)
  8829. End Try
  8830. End Sub
  8831. Private Sub util_FixSeasonEpisode() 'atleast try... if season or episode is -1, but title contains a regexable name to retreive season & episode
  8832. Dim textstring As String = "!!! Season Episode -1 fix..." & vbCrLf
  8833. Dim correctionsfound As Integer = 0
  8834. Dim correctionsfixed As Integer = 0
  8835. Dim childNodeLevel1 As TreeNode
  8836. Dim originallabeltext = Label148.Text
  8837. For Each childNodeLevel1 In TvTreeview.Nodes 'step thru each tvshow/season/episode in the treeview
  8838. For Each childNodeLevel2 As TreeNode In childNodeLevel1.Nodes
  8839. Label148.Text = childNodeLevel1.Text & " - " & childNodeLevel2.Text 'display some sort of progress using the text label associated with the fix
  8840. Label148.Invalidate()
  8841. Windows.Forms.Application.DoEvents() 'this refreshes the label whilst we are still in this sub
  8842. For Each childNodeLevel3 As TreeNode In childNodeLevel2.Nodes
  8843. Dim episode As New TvEpisode
  8844. episode.Load(childNodeLevel3.Name) 'load the episode from the nfo using the path stored in the treeview
  8845. If episode.Season.Value <> -1 AndAlso episode.Episode.Value <> -1 Then Continue For ' check if we have the issue
  8846. textstring += "!!! " & childNodeLevel1.Text & " - " & childNodeLevel3.Name 'add details to the log"
  8847. correctionsfound += 1 'increment the found issues counter
  8848. For Each regexp In Pref.tv_RegexScraper
  8849. Dim M As Match
  8850. Dim sourcetext As String = ""
  8851. If RadioButton_Fix_Filename.Checked Then
  8852. sourcetext = childNodeLevel3.Name 'use nfo filename to retrieve season/episode
  8853. Else
  8854. sourcetext = episode.Title.Value 'use 'title' node in nfo to retieve season/episode
  8855. End If
  8856. M = Regex.Match(episode.Title.Value, regexp)
  8857. If Not M.Success Then Continue For 'we found a valid regex match
  8858. Try
  8859. episode.Season.Value = M.Groups(1).Value.ToString 'set new values
  8860. episode.Episode.Value = M.Groups(2).Value.ToString
  8861. correctionsfixed += 1
  8862. episode.Save(childNodeLevel3.Name) 'save episode
  8863. textstring += " - Corrected - S" & episode.Season.Value & "E" & episode.Episode.Value
  8864. Exit For
  8865. Catch
  8866. textstring += vbCrLf & "**** exception created during nfo save **** - " & childNodeLevel3.Name
  8867. End Try
  8868. Next
  8869. textstring += vbCrLf
  8870. Next
  8871. Next
  8872. Next
  8873. Label148.Text = originallabeltext 'return the label text back after we have used it to diplay progress
  8874. Dim MyFormObject As New frmoutputlog(textstring, True) 'create the log form & modify it to suit our needs
  8875. MyFormObject.TextBox1.Font = New System.Drawing.Font("Courier New", 10.2!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) 'constant width font
  8876. MyFormObject.btn_savelog.AutoSize = True 'change button size to text will fit automatically
  8877. MyFormObject.btn_savelog.Text = "Save Details..." 'change the button text
  8878. MyFormObject.Font = New System.Drawing.Font("Courier New", 10.2!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
  8879. MyFormObject.Text = "Corrections" & vbCrLf & "Found: " & correctionsfound & vbCrLf & " Fixed: " & correctionsfixed 'change the form title text
  8880. MyFormObject.ShowDialog() 'show the form
  8881. If MsgBox("Corrections" & vbCrLf & "Found: " & correctionsfound & vbCrLf & "Fixed: " & correctionsfixed & vbCrLf & vbCrLf & "Do you want to perform a refresh to reload the corrected nfo's?", MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then
  8882. tv_CacheRefresh() 'ask to do a refresh or not, user may want to try both methods before do a refresh.
  8883. End If
  8884. End Sub
  8885. Private Sub tsmiTvDelShowNfoArt_Click(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles tsmiTvDelShowNfoArt.MouseDown
  8886. Dim NoDelArt As Boolean = (e.Button = MouseButtons.Right)
  8887. TVContextMenu.Close()
  8888. Dim Sh As TvShow = tv_ShowSelectedCurrently(TvTreeview)
  8889. TvDelShowNfoArt(Sh, False, NoDelArt)
  8890. End Sub
  8891. Private Sub tsmiTvDelShowEpNfoArt_Click(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles tsmiTvDelShowEpNfoArt.MouseDown
  8892. Dim NoDelArt As Boolean = (e.Button = MouseButtons.Right)
  8893. TVContextMenu.Close()
  8894. Dim msgstring As String = "Warning: This will Remove all nfo's" & If(Not NoDelArt, " and artwork", "") & " for this Show and Episodes"
  8895. msgstring &= vbcrlf & "and remove the show's folder from MC's ""List Of Separate Folders""." & vbCrLf
  8896. msgstring &= vbCrLf & "To Rescrape this show, use ""Check Roots for New TV Shows"" or "
  8897. msgstring &= vbCrLf & "Add this show's folder again to your ""List Of Separate Folders""." & vbCrLf
  8898. msgstring &= vbCrLf & "Are your sure you wish to continue?"
  8899. Dim x = MsgBox(msgstring, MsgBoxStyle.OkCancel, "Delete Show and Episode's nfo's" & If(Not NoDelArt, " and artwork", ""))
  8900. If x = MsgBoxResult.Cancel Then Exit Sub
  8901. Dim Sh As TvShow = tv_ShowSelectedCurrently(TvTreeview)
  8902. Dim seas As TvSeason = tv_SeasonSelectedCurrently(TvTreeview)
  8903. Dim ep As TvEpisode = ep_SelectedCurrently(TvTreeview)
  8904. TvDelEpNfoAst(Sh, seas, ep, True, NoDelArt)
  8905. TvDelShowNfoArt(Sh, True, NoDelArt)
  8906. End Sub
  8907. Private Sub tsmiTvDelEpNfoArt_Click(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles tsmiTvDelEpNfoArt.MouseDown
  8908. Dim NoDelArt As Boolean = (e.Button = MouseButtons.Right)
  8909. TVContextMenu.Close()
  8910. Dim Sh As TvShow = tv_ShowSelectedCurrently(TvTreeview)
  8911. Dim seas As TvSeason = tv_SeasonSelectedCurrently(TvTreeview)
  8912. Dim ep As TvEpisode = ep_SelectedCurrently(TvTreeview)
  8913. TvDelEpNfoAst(Sh, seas, ep, False, NoDelArt)
  8914. End Sub
  8915. Private Sub Tv_TreeViewContext_RescrapeShowOrEpisode_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Tv_TreeViewContext_RescrapeShowOrEpisode.Click
  8916. tv_Rescrape()
  8917. End Sub
  8918. Private Sub Tv_TreeViewContext_WatchedShowOrEpisode_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Tv_TreeViewContext_WatchedShowOrEpisode.Click
  8919. Tv_MarkAs_Watched_UnWatched("1")
  8920. End Sub
  8921. Private Sub Tv_TreeViewContext_UnWatchedShowOrEpisode_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Tv_TreeViewContext_UnWatchedShowOrEpisode.Click
  8922. Tv_MarkAs_Watched_UnWatched("0")
  8923. End Sub
  8924. Private Sub Tv_TreeViewContext_Play_Episode_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Tv_TreeViewContext_Play_Episode.Click
  8925. Try
  8926. Dim ep As TvEpisode = ep_SelectedCurrently(TvTreeview)
  8927. If ep.IsMissing Then Exit Sub
  8928. Dim tempstring As String = ep.VideoFilePath 'DirectCast(TvTreeview.SelectedNode.Tag, Media_Companion.TvEpisode).VideoFilePath
  8929. StartVideo(tempstring)
  8930. 'If Pref.videomode = 1 Then Call util_VideoMode1(tempstring)
  8931. 'If Pref.videomode = 2 Then Call util_VideoMode2(tempstring)
  8932. 'If Pref.videomode = 3 Then
  8933. ' Pref.videomode = 2
  8934. ' Call util_VideoMode2(tempstring)
  8935. 'End If
  8936. 'If Pref.videomode >= 4 Then
  8937. ' If Pref.selectedvideoplayer <> Nothing Then
  8938. ' Call util_VideoMode4(tempstring)
  8939. ' Else
  8940. ' Call util_VideoMode1(tempstring)
  8941. ' End If
  8942. 'End If
  8943. Catch ex As Exception
  8944. ExceptionHandler.LogError(ex)
  8945. End Try
  8946. End Sub
  8947. Private Sub Tv_TreeViewContext_ViewNfo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Tv_TreeViewContext_ViewNfo.Click
  8948. Try
  8949. If TvTreeview.SelectedNode Is Nothing Then Exit Sub
  8950. If TypeOf TvTreeview.SelectedNode.Tag Is Media_Companion.TvShow Then
  8951. Utilities.NfoNotepadDisplay(DirectCast(TvTreeview.SelectedNode.Tag, Media_Companion.TvShow).NfoFilePath, Pref.altnfoeditor)
  8952. ElseIf TypeOf TvTreeview.SelectedNode.Tag Is Media_Companion.TvSeason Then
  8953. MsgBox("A Season NFO is invalid so it can't be shown")
  8954. ElseIf TypeOf TvTreeview.SelectedNode.Tag Is Media_Companion.TvEpisode Then
  8955. Utilities.NfoNotepadDisplay(DirectCast(TvTreeview.SelectedNode.Tag, Media_Companion.TvEpisode).NfoFilePath, Pref.altnfoeditor)
  8956. Else
  8957. MsgBox("None")
  8958. End If
  8959. Catch ex As Exception
  8960. ExceptionHandler.LogError(ex)
  8961. End Try
  8962. Debug.Print(Me.Controls.Count)
  8963. End Sub
  8964. Private Sub TvDelShowNfoArt(Show As TvShow, ByVal Ignore As Boolean, Optional ByVal NoDelArt As Boolean = False)
  8965. Try
  8966. If Not Ignore Then
  8967. Dim msgstring As String = "Warning: This will Remove the selected Tv Show's nfo" & If(Not NoDelArt, " and artwork", "")
  8968. msgstring &= vbcrlf & "and remove the show's folder from MC's ""List Of Separate Folders""." & vbCrLf
  8969. msgstring &= vbCrLf & "To Rescrape this show, use ""Check Roots for New TV Shows"" or "
  8970. msgstring &= vbCrLf & "Add this show's folder again to your ""List Of Separate Folders""." & vbCrLf
  8971. msgstring &= vbCrLf & "Are your sure you wish to continue?"
  8972. Dim x = MsgBox(msgstring, MsgBoxStyle.OkCancel, "Delete Show's nfo's" & If(Not NoDelArt, " and artwork", ""))
  8973. If x = MsgBoxResult.Cancel Then Exit Sub
  8974. End If
  8975. If Not NoDelArt Then TvDeleteShowArt(show)
  8976. Dim showpath As String = Show.FolderPath
  8977. Utilities.SafeDeleteFile(showpath & "tvshow.nfo")
  8978. showpath = showpath.Substring(0, showpath.Length-1)
  8979. If ListBox6.items.Contains(showpath) Then ListBox6.Items.Remove(showpath)
  8980. If Pref.tvFolders.Contains(showpath) Then Pref.tvFolders.Remove(showpath)
  8981. TvTreeview.Nodes.Remove(show.ShowNode)
  8982. Cache.TvCache.Remove(show)
  8983. Tv_CacheSave()
  8984. TvTreeviewRebuild()
  8985. Show.UpdateTreenode()
  8986. Catch ex As Exception
  8987. ExceptionHandler.LogError(ex)
  8988. End Try
  8989. End Sub
  8990. Private Sub TvDelEpNfoAst(Show As TvShow, season As TvSeason, ep As TvEpisode, ByVal Ignore As Boolean, Optional ByVal NoDelArt As Boolean = False)
  8991. Try
  8992. If Not Ignore Then
  8993. Dim msgstring As String = "Warning, This operation will delete all Episode nfo's" & If(Not NoDelArt, " and artwork", "")
  8994. msgstring &= vbCrLf & "!! Note: will not delete missing episodes." & vbCrLf
  8995. msgstring &= vbCrLf & "Are your sure you wish to continue?"
  8996. Dim res As MsgBoxResult = MsgBox(msgstring, MsgBoxStyle.YesNoCancel, "Delete episode nfo(s)" & If(Not NoDelArt, " and artwork", ""))
  8997. If res = MsgBoxResult.No OrElse res = MsgBoxResult.Cancel Then Exit Sub
  8998. End If
  8999. Dim TheseEpisodes As New List(Of Media_Companion.TvEpisode)
  9000. If Not IsNothing(ep) Then
  9001. For Each epis In season.Episodes
  9002. If epis.NfoFilePath = ep.NfoFilePath Then TheseEpisodes.Add(epis)
  9003. Next
  9004. Else
  9005. TheseEpisodes.AddRange(Show.Episodes)
  9006. End If
  9007. For Each episode In TheseEpisodes
  9008. If IsNothing(season) OrElse episode.Season.Value = season.SeasonNumber.ToString Then
  9009. If Not episode.IsMissing Then
  9010. If episode.FolderPath <> Show.FolderPath AndAlso File.Exists(episode.FolderPath & "folder.jpg") Then
  9011. Utilities.SafeDeleteFile(episode.FolderPath & "folder.jpg")
  9012. End If
  9013. Dim eppath As String = episode.NfoFilePath
  9014. Utilities.SafeDeleteFile(eppath)
  9015. If Not NoDelArt Then
  9016. Utilities.SafeDeleteFile(eppath.Replace(".nfo", ".tbn"))
  9017. Utilities.SafeDeleteFile(eppath.Replace(".nfo", "-thumb.jpg"))
  9018. End If
  9019. End If
  9020. Cache.TvCache.Remove(episode)
  9021. TvTreeview.Nodes.Remove(episode.EpisodeNode)
  9022. If Not IsNothing(season) Then season.Episodes.Remove(episode)
  9023. End If
  9024. Next
  9025. Dim listofnodes As New List(Of TreeNode)
  9026. For Each n As TreeNode In TvTreeview.Nodes
  9027. listofnodes.Add(n)
  9028. For Each chn As TreeNode in n.nodes
  9029. listofnodes.Add(chn)
  9030. Next
  9031. Next
  9032. For Each n In listofnodes
  9033. If n.FullPath.Contains(Show.Title.Value) AndAlso n.FullPath.ToLower.Contains("season") AndAlso n.GetNodeCount(False) = 0 Then
  9034. TvTreeview.Nodes.Remove(n)
  9035. End If
  9036. Next
  9037. Tv_CacheSave()
  9038. TvTreeviewRebuild()
  9039. Show.UpdateTreenode()
  9040. Catch ex As Exception
  9041. ExceptionHandler.LogError(ex)
  9042. End Try
  9043. End Sub
  9044. Private Sub Tv_TreeViewContext_FindMissArt_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Tv_TreeViewContext_FindMissArt.Click
  9045. Try
  9046. tv_MissingArtDownload(tv_ShowSelectedCurrently(TvTreeview))
  9047. Catch ex As Exception
  9048. ExceptionHandler.LogError(ex)
  9049. End Try
  9050. End Sub
  9051. Private Sub MovieContextMenu_Opening(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MovieContextMenu.Opening
  9052. Try
  9053. If DataGridViewMovies.SelectedRows.Count = 0 Then
  9054. e.Cancel = True
  9055. End If
  9056. tsmiRescrapeRenameFiles.Enabled = Not Pref.usefoldernames AndAlso Not Pref.basicsavemode And Pref.MovieRenameEnable
  9057. tsmiMov_OpenInMkvmergeGUI .Enabled = (Pref.MkvMergeGuiPath <> "")
  9058. tsmiRescrapeFrodo_Poster_Thumbs .Enabled = Pref.FrodoEnabled
  9059. tsmiRescrapeFrodo_Fanart_Thumbs .Enabled = Pref.FrodoEnabled
  9060. Catch ex As Exception
  9061. ExceptionHandler.LogError(ex)
  9062. End Try
  9063. End Sub
  9064. Private Sub TVContextMenu_Opening(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles TVContextMenu.Opening
  9065. Try
  9066. If (TvTreeview.SelectedNode Is Nothing) Then
  9067. e.Cancel = True
  9068. End If
  9069. Catch ex As Exception
  9070. ExceptionHandler.LogError(ex)
  9071. End Try
  9072. End Sub
  9073. Private Sub SaveSelectedFanartAsToolStripMenuItem_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles SaveSelectedFanartAsToolStripMenuItem.Click
  9074. Try
  9075. messbox = New frmMessageBox("Please wait,", "", "Downloading Fanart")
  9076. System.Windows.Forms.Cursor.Current = Cursors.WaitCursor
  9077. messbox.Show()
  9078. Me.Refresh()
  9079. messbox.Refresh()
  9080. Me.Refresh()
  9081. Application.DoEvents()
  9082. Dim tempstring As String
  9083. Dim tempint As Integer = 0
  9084. Dim tempstring2 As String = String.Empty
  9085. Dim allok As Boolean = False
  9086. For Each button As Control In Me.Panel2.Controls
  9087. If button.Name.IndexOf("checkbox") <> -1 Then
  9088. Dim b1 As RadioButton = CType(button, RadioButton)
  9089. If b1.Checked = True Then
  9090. tempstring = b1.Name
  9091. tempstring = tempstring.Replace("moviefanartcheckbox", "")
  9092. tempint = Convert.ToDecimal(tempstring)
  9093. tempstring2 = fanartArray(tempint).hdUrl
  9094. allok = True
  9095. Exit For
  9096. End If
  9097. End If
  9098. Next
  9099. If allok = False Then
  9100. MsgBox("No Fanart Is Selected")
  9101. Else
  9102. Try
  9103. Panel1.Controls.Remove(Label1)
  9104. With SaveFileDialog1
  9105. .AddExtension = True
  9106. .DefaultExt = "jpg"
  9107. .Filter = "Jpg Pictures (*.jpg)|*.jpg"
  9108. .Title = "Save Hi-Res Fanart as"
  9109. .OverwritePrompt = True
  9110. .CheckPathExists = True
  9111. .InitialDirectory = workingMovieDetails.fileinfo.path
  9112. End With
  9113. If SaveFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
  9114. Movie.SaveFanartImageToCacheAndPath(tempstring2, SaveFileDialog1.FileName)
  9115. End If
  9116. Catch ex As WebException
  9117. MsgBox(ex.Message)
  9118. End Try
  9119. End If
  9120. Catch ex As Exception
  9121. ExceptionHandler.LogError(ex)
  9122. Finally
  9123. messbox.Close()
  9124. End Try
  9125. End Sub
  9126. Private Sub TasksDontShowCompleted_CheckedChanged(sender As System.Object, e As System.EventArgs) Handles TasksDontShowCompleted.CheckedChanged
  9127. Me.TasksOnlyIncompleteTasks = TasksDontShowCompleted.Checked
  9128. End Sub
  9129. Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click
  9130. util_FixSeasonEpisode()
  9131. End Sub
  9132. Private Sub mov_DisplayFanart()
  9133. If workingMovieDetails Is Nothing Then Exit Sub
  9134. If workingMovieDetails.fileinfo.fanartpath <> Nothing Then
  9135. Try
  9136. Dim fanartpath = mov_FanartORExtrathumbPath()
  9137. If IO.File.Exists(fanartpath) Then
  9138. util_ImageLoad(PictureBox2, fanartpath, Utilities.DefaultFanartPath)
  9139. lblMovFanartWidth.Text = PictureBox2.Image.Width
  9140. lblMovFanartHeight.Text = PictureBox2.Image.Height
  9141. Else
  9142. util_ImageLoad(PictureBox2, Utilities.DefaultFanartPath, Utilities.DefaultFanartPath)
  9143. lblMovFanartWidth.Text = ""
  9144. lblMovFanartHeight.Text = ""
  9145. End If
  9146. Catch ex As Exception
  9147. #If SilentErrorScream Then
  9148. Throw ex
  9149. #End If
  9150. End Try
  9151. End If
  9152. End Sub
  9153. Private Function mov_FanartORExtrathumbPath() As String
  9154. Dim fanarttype As String = ""
  9155. For Each rb As RadioButton In GroupBoxFanartExtrathumbs.Controls
  9156. If rb.Checked Then
  9157. fanarttype = rb.Text.ToLower
  9158. Exit For
  9159. End If
  9160. Next
  9161. Dim workingfanartpath As String = workingMovieDetails.fileinfo.fanartpath
  9162. If fanarttype = "fanart" Then
  9163. Return workingfanartpath
  9164. Else
  9165. Return Strings.Left(workingfanartpath, workingfanartpath.LastIndexOf("\")) & "\extrathumbs\" & fanarttype & ".jpg"
  9166. End If
  9167. End Function
  9168. Private Sub tpMovMain_Enter(sender As Object, e As System.EventArgs) Handles tpMovMain.Enter
  9169. mov_SplitContainerAutoPosition()
  9170. End Sub
  9171. Private Sub tpTvMainBrowser_Enter(sender As Object, e As System.EventArgs) Handles tpTvMainBrowser.Enter
  9172. tv_SplitContainerAutoPosition()
  9173. End Sub
  9174. Private Sub plottxt_DoubleClick(sender As System.Object, e As System.EventArgs) Handles plottxt.DoubleClick
  9175. ShowBigMovieText()
  9176. End Sub
  9177. Private Sub plottxt_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles plottxt.KeyPress
  9178. If e.KeyChar = Convert.ToChar(1) Then
  9179. DirectCast(sender, TextBox).SelectAll()
  9180. e.Handled = True
  9181. End If
  9182. End Sub
  9183. Private Sub outlinetxt_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles outlinetxt.KeyPress
  9184. If e.KeyChar = Convert.ToChar(1) Then
  9185. DirectCast(sender, TextBox).SelectAll()
  9186. e.Handled = True
  9187. End If
  9188. End Sub
  9189. Private Sub ShowBigMovieText()
  9190. Dim frm As New frmBigMovieText
  9191. If Pref.MultiMonitoEnabled Then
  9192. frm.Bounds = screen.AllScreens(CurrentScreen).Bounds
  9193. frm.StartPosition = FormStartPosition.Manual
  9194. End If
  9195. frm.ShowDialog(
  9196. titletxt.Text,
  9197. directortxt.Text,
  9198. votestxt.Text,
  9199. ratingtxt.Text,
  9200. runtimetxt.Text,
  9201. genretxt.Text,
  9202. txtStars.Text,
  9203. certtxt.Text,
  9204. plottxt.Text
  9205. )
  9206. End Sub
  9207. 'Private Function GetActorThumb(ByRef currentUri As String)
  9208. ' Dim actorthumb As String = currentUri
  9209. ' If Pref.actorsave Then
  9210. ' Dim uri As Uri
  9211. ' uri = New Uri(actorthumb)
  9212. ' If Len(Pref.actornetworkpath) > 0 AndAlso Len(Pref.actorsavepath) > 0 Then
  9213. ' Dim actorThumbFileName As String
  9214. ' Dim localActorThumbFileName As String
  9215. ' actorThumbFileName = System.IO.Path.Combine(Pref.actornetworkpath, uri.Segments(uri.Segments.GetLength(0) - 1))
  9216. ' localActorThumbFileName = System.IO.Path.Combine(Pref.actorsavepath, uri.Segments(uri.Segments.GetLength(0) - 1))
  9217. ' Movie.SaveActorImageToCacheAndPath(uri.OriginalString, localActorThumbFileName)
  9218. ' actorthumb = actorThumbFileName
  9219. ' End If
  9220. ' End If
  9221. ' Return actorthumb
  9222. 'End Function
  9223. Private Sub mov_RescrapeAllSelected()
  9224. _rescrapeList.Field = Nothing
  9225. _rescrapeList.FullPathAndFilenames.Clear()
  9226. For Each row In DataGridViewMovies.SelectedRows
  9227. Dim fullpath As String = row.Cells("fullpathandfilename").Value.ToString
  9228. If Not File.Exists(fullpath) Then Continue For
  9229. _rescrapeList.FullPathAndFilenames.Add(fullpath)
  9230. Next
  9231. RunBackgroundMovieScrape("RescrapeAll")
  9232. End Sub
  9233. Public Sub mov_VideoSourcePopulate()
  9234. Try
  9235. cbMovieDisplay_Source.Items.Clear()
  9236. cbMovieDisplay_Source.Items.Add("")
  9237. For Each mset In Pref.releaseformat
  9238. cbMovieDisplay_Source.Items.Add(mset)
  9239. Next
  9240. cbFilterSource.UpdateItems( Pref.releaseformat.ToList )
  9241. cbMovieDisplay_Source.SelectedIndex = 0
  9242. If IsNothing(workingMovieDetails) = False Then
  9243. If workingMovieDetails.fullmoviebody.source <> "" Then
  9244. For te = 0 To cbMovieDisplay_Source.Items.Count - 1
  9245. If cbMovieDisplay_Source.Items(te) = workingMovieDetails.fullmoviebody.source Then
  9246. cbMovieDisplay_Source.SelectedIndex = te
  9247. Exit For
  9248. End If
  9249. Next
  9250. End If
  9251. End If
  9252. Catch ex As Exception
  9253. #If SilentErrorScream Then
  9254. Throw ex
  9255. #End If
  9256. End Try
  9257. End Sub
  9258. 'AnotherPhil bug fix - If the default browser is <goz> IE <goz/> then not stating the exe throws an exception
  9259. Public Sub OpenUrl(ByVal url As String)
  9260. 'Dim testprocess As New Process
  9261. 'testprocess.Start("notepad.exe")
  9262. Try
  9263. If Pref.selectedBrowser <> "" Then
  9264. 'testprocess.Start(Pref.selectedBrowser, Uri.EscapeUriString(url))
  9265. Process.Start(Pref.selectedBrowser, Uri.EscapeUriString(url))
  9266. Else
  9267. Try
  9268. 'testprocess.Start(url)
  9269. Process.Start(url)
  9270. Catch ex As Exception
  9271. MessageBox.Show("An error occurred while trying to launch the default browser - Under 'General Preferences' check 'Use external Browser...' and then locate your browser to fix this error", "", MessageBoxButtons.OK)
  9272. End Try
  9273. End If
  9274. Catch ex As Exception
  9275. ExceptionHandler.LogError(ex)
  9276. End Try
  9277. 'testprocess.Close()
  9278. 'testprocess.Dispose()
  9279. End Sub
  9280. Private Sub ZoomActorPictureBox(pictureBox As PictureBox)
  9281. If IsNothing(pictureBox.Tag) orElse pictureBox.Tag.ToString = Utilities.DefaultActorPath Then Exit Sub
  9282. Me.ControlBox = False
  9283. MenuStrip1.Enabled = False
  9284. Try
  9285. util_ZoomImage(pictureBox.Tag.ToString)
  9286. Catch
  9287. Dim wc As New WebClient()
  9288. Dim ImageInBytes() As Byte = wc.DownloadData(pictureBox.Tag)
  9289. Dim ImageStream As New IO.MemoryStream(ImageInBytes)
  9290. Dim cachefile As String = Utilities.Download2Cache(pictureBox.Tag.ToString)
  9291. util_ZoomImage(cachefile)
  9292. End Try
  9293. End Sub
  9294. Private Sub Mov_RemoveMovie()
  9295. For Each row As DataGridViewRow In DataGridViewMovies.SelectedRows
  9296. oMovies.RemoveMovieFromCache(row.Cells("fullpathandfilename").Value.ToString)
  9297. DataGridViewMovies.Rows.RemoveAt(row.Index)
  9298. Next
  9299. DataGridViewMovies.ClearSelection
  9300. oMovies.SaveMovieCache
  9301. UpdateFilteredList
  9302. End Sub
  9303. Private Sub Mov_DeleteNfoArtwork(Optional ByVal DelArtwork As Boolean = True)
  9304. Dim msgstr As String = " Are you sure you wish to delete" & vbCrLf
  9305. msgstr &= ".nfo" & If(DelArtwork, ", Fanart, Poster and Actors", " only") & " for" & vbCrLf
  9306. msgstr &= "Selected Movie(s)?"
  9307. If MsgBox(msgstr, MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then
  9308. Dim movielist As New List(Of String)
  9309. Pref.MovieDeleteNfoArtwork = True
  9310. For Each row As DataGridViewRow In DataGridViewMovies.SelectedRows
  9311. movielist.Add(row.Cells(NFO_INDEX).Value.ToString)
  9312. oMovies.DeleteScrapedFiles(row.Cells(NFO_INDEX).Value.ToString, DelArtwork)
  9313. Next
  9314. 'Last remove from dataGridViewMovies and update cache.
  9315. Mov_RemoveMovie()
  9316. Pref.MovieDeleteNfoArtwork = False
  9317. Else
  9318. MsgBox(" Deletion of .nfo, artwork and Actors " &vbCrLf & "has been Cancelled")
  9319. End If
  9320. End Sub
  9321. Private Sub TabLevel1_SelectedIndexChanged(sender As System.Object, e As System.EventArgs) Handles TabLevel1.SelectedIndexChanged
  9322. Select Case TabLevel1.SelectedTab.Text.ToLower
  9323. Case "config.xml"
  9324. RichTextBoxTabConfigXML.Text = Utilities.LoadFullText(workingProfile.config) ' applicationPath & "\Settings\config.xml"
  9325. Case "moviecache"
  9326. RichTextBoxTabMovieCache.Text = Utilities.LoadFullText(workingProfile.moviecache) ' applicationPath & "\Settings\moviecache.xml"
  9327. Case = "tvcache"
  9328. RichTextBoxTabTVCache.Text = Utilities.LoadFullText(workingProfile.tvcache) ' applicationPath & "\Settings\tvcache.xml"
  9329. Case = "actorcache"
  9330. RichTextBoxTabActorCache.Text = Utilities.LoadFullText(workingProfile.actorcache) ' applicationPath & "\Settings\actorcache.xml"
  9331. Case = "profile"
  9332. RichTextBoxTabProfile.Text = Utilities.LoadFullText(applicationPath & "\Settings\profile.xml") ' applicationPath & "\Settings\profile.xml"
  9333. Case = "regex"
  9334. RichTextBoxTabRegex.Text = Utilities.LoadFullText(workingProfile.regexlist) ' applicationPath & "\Settings\regex.xml"
  9335. Case "export"
  9336. frm_ExportTabSetup()
  9337. Case "movies"
  9338. If Not MoviesFiltersResizeCalled Then
  9339. MoviesFiltersResizeCalled = True
  9340. Pref.movie_filters.SetMovieFiltersVisibility
  9341. UpdateMovieFiltersPanel
  9342. End If
  9343. Case "music videos"
  9344. UcMusicVideo1.mv_FiltersAndSortApply(True)
  9345. End Select
  9346. End Sub
  9347. Sub HandleMovieList_DisplayChange(DisplayField As String)
  9348. Mc.clsGridViewMovie.GridFieldToDisplay1 = DisplayField
  9349. If rbTitleAndYear.Checked Then Pref.moviedefaultlist = 0
  9350. If rbFileName .Checked Then Pref.moviedefaultlist = 1
  9351. If rbFolder .Checked Then Pref.moviedefaultlist = 2
  9352. Mc.clsGridViewMovie.GridviewMovieDesign(Me)
  9353. If MainFormLoadedStatus Then
  9354. DisplayMovie()
  9355. End If
  9356. End Sub
  9357. Private Sub cbFilterChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbFilterGeneral.SelectedValueChanged, cbFilterSource.TextChanged,
  9358. cbFilterGenre.TextChanged, cbFilterCertificate.TextChanged,
  9359. cbFilterSet.TextChanged, cbFilterResolution.TextChanged,
  9360. cbFilterAudioCodecs.TextChanged, cbFilterAudioChannels.TextChanged,
  9361. cbFilterAudioBitrates.TextChanged, cbFilterNumAudioTracks.TextChanged,
  9362. cbFilterAudioLanguages.TextChanged, cbFilterActor.TextChanged, cbFilterTag.TextChanged,
  9363. cbFilterDirector.TextChanged, cbFilterVideoCodec.TextChanged, cbFilterSubTitleLang.TextChanged,
  9364. cbFilterAudioDefaultLanguages.TextChanged, cbFilterCountries.TextChanged,
  9365. cbFilterStudios.TextChanged, cbFilterRootFolder.TextChanged,
  9366. cbFilterUserRated.TextChanged
  9367. If TypeName(sender) = "TriStateCheckedComboBox" Then
  9368. Dim x As MC_UserControls.TriStateCheckedComboBox = sender
  9369. If x.opState <> 0 Then
  9370. Return
  9371. End If
  9372. End If
  9373. ApplyMovieFilters()
  9374. End Sub
  9375. Private Sub cbFilterRatingChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbFilterRating.SelectionChanged, cbFilterVotes.SelectionChanged,
  9376. cbFilterRuntime.SelectionChanged, cbFilterFolderSizes.SelectionChanged,
  9377. cbFilterYear.SelectionChanged
  9378. ApplyMovieFilters
  9379. End Sub
  9380. 'Private Sub cbFilterVotesChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbFilterVotes.SelectionChanged
  9381. ' ApplyMovieFilters
  9382. 'End Sub
  9383. 'Private Sub cbFilterRuntimeChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbFilterRuntime.SelectionChanged
  9384. ' ApplyMovieFilters
  9385. 'End Sub
  9386. 'Private Sub cbFilterFolderSizesChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbFilterFolderSizes.SelectionChanged
  9387. ' ApplyMovieFilters
  9388. 'End Sub
  9389. 'Private Sub cbFilterYearChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbFilterYear.SelectionChanged
  9390. ' ApplyMovieFilters
  9391. 'End Sub
  9392. Private Sub cbFilterBeginSliding(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbFilterRuntime.BeginSliding, cbFilterYear.BeginSliding, cbFilterVotes.BeginSliding, cbFilterRating.BeginSliding, cbFilterFolderSizes.BeginSliding
  9393. SplitContainer5.Panel2.ContextMenuStrip = Nothing
  9394. End Sub
  9395. Private Sub cbFilterEndSliding(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbFilterRuntime.EndSliding, cbFilterYear.EndSliding, cbFilterVotes.EndSliding, cbFilterRating.EndSliding, cbFilterFolderSizes.EndSliding
  9396. SplitContainer5.Panel2.ContextMenuStrip = cmsConfigureMovieFilters
  9397. End Sub
  9398. Private Sub ApplyMovieFilters
  9399. tsmiMov_ConvertToFrodo.Enabled = (cbFilterGeneral.Text.RemoveAfterMatch="Pre-Frodo poster only") or (cbFilterGeneral.Text.RemoveAfterMatch="Both poster formats")
  9400. If ProgState = ProgramState.Other Then
  9401. Mc.clsGridViewMovie.mov_FiltersAndSortApply(Me)
  9402. DisplayMovie
  9403. End If
  9404. End Sub
  9405. Sub HandleMovieFilter_SelectedValueChanged(cbFilter As ComboBox, ByRef filterValue As String, Optional replaceUnknown As Boolean = False)
  9406. If ProgState = ProgramState.Other Then
  9407. If cbFilter.Text = "All" Then
  9408. filterValue = ""
  9409. Else
  9410. filterValue = cbFilter.Text.RemoveAfterMatch
  9411. If replaceUnknown Then filterValue = filterValue.Replace("Unknown","-1")
  9412. End If
  9413. ApplyMovieFilters
  9414. End If
  9415. End Sub
  9416. Private Sub TimerToolTip_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TimerToolTip.Tick
  9417. TimerToolTip.Enabled = False
  9418. TooltipGridViewMovies1.Visible = Pref.ShowMovieGridToolTip
  9419. End Sub
  9420. #Region "Movie scraping stuff"
  9421. Sub RunBackgroundMovieScrape(action As String)
  9422. If Not BckWrkScnMovies.IsBusy Then
  9423. scraperLog = ""
  9424. tsStatusLabel.Text = ""
  9425. tsMultiMovieProgressBar.Value = tsMultiMovieProgressBar.Minimum
  9426. tsMultiMovieProgressBar.Visible = Get_MultiMovieProgressBar_Visiblity(action)
  9427. tsStatusLabel.Visible = True
  9428. tsLabelEscCancel.Visible = True
  9429. Statusstrip_Enable()
  9430. 'StatusStrip1.BackColor = Color.Honeydew
  9431. 'StatusStrip1.Visible = True
  9432. 'tsStatusLabel1.Visible = False
  9433. ssFileDownload.Visible = False
  9434. tsProgressBarFileDownload_Resize()
  9435. EnableDisableByTag("M", False) 'Disable all UI options that can't be run while scraper is running
  9436. ScraperErrorDetected = False
  9437. BckWrkScnMovies.RunWorkerAsync(action)
  9438. While BckWrkScnMovies.IsBusy
  9439. Application.DoEvents()
  9440. End While
  9441. If Not Pref.MusicVidScrape Then oMovies.SaveCaches
  9442. Else
  9443. MsgBox("The " & If(Pref.MusicVidScrape, "MusicVideo", "Movie") & " Scraper is Already Running")
  9444. End If
  9445. End Sub
  9446. Private cbBtnLink_Checked As Boolean
  9447. Sub EnableDisableByTag(tagQualifier As String, _state As Boolean)
  9448. If Not _state Then
  9449. StateBefore = ProgState
  9450. cbBtnLink_Checked = cbBtnLink.Checked
  9451. ProgState = ProgramState.MovieControlsDisabled
  9452. Else
  9453. cbBtnLink.Checked = cbBtnLink_Checked
  9454. ProgState = StateBefore
  9455. End If
  9456. If IsNothing(ControlsToDisableDuringMovieScrape) Then
  9457. ControlsToDisableDuringMovieScrape = (From c As Control In GetAllMatchingControls("M")).ToList
  9458. End If
  9459. For Each c In ControlsToDisableDuringMovieScrape
  9460. c.Enabled = _state
  9461. Next
  9462. 'Not picked up for some unknown reason...
  9463. MoviesToolStripMenuItem.Enabled = _state
  9464. End Sub
  9465. Function GetAllMatchingControls(tagQualifier As String) As List(Of Control)
  9466. Dim allControls As New List(Of Control)
  9467. GetAllMatchingControls(tagQualifier, Me, allControls)
  9468. Return allControls
  9469. End Function
  9470. Sub GetAllMatchingControls(tagQualifier As String, parent As Control, allControls As List(Of Control))
  9471. Dim query = From c As Control In parent.Controls
  9472. For Each c As Control In query
  9473. Try
  9474. If Not IsNothing(c) AndAlso Not IsNothing(c.Tag) AndAlso TypeName(c.Tag).ToLower = "string" AndAlso c.Tag = tagQualifier Then allControls.Add(c)
  9475. Catch ex As Exception
  9476. End Try
  9477. GetAllMatchingControls(tagQualifier, c, allControls)
  9478. Next
  9479. End Sub
  9480. #Region "MC Scraper Calls"
  9481. Function Get_MultiMovieProgressBar_Visiblity(action As String)
  9482. Select Case action
  9483. Case "BatchRescrape" : Return _rescrapeList.FullPathAndFilenames.Count>1 ' filteredList.Count > 1
  9484. Case "ChangeMovie" : Return False
  9485. Case "RescrapeAll" : Return _rescrapeList.FullPathAndFilenames.Count>1
  9486. Case