PageRenderTime 72ms CodeModel.GetById 28ms 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

Large files files are truncated, but you can click here to view the full file

  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(chi

Large files files are truncated, but you can click here to view the full file