Permalink
Find file
Fetching contributors…
Cannot retrieve contributors at this time
261 lines (213 sloc) 12.3 KB
' ################################################################################
' # EMBER MEDIA MANAGER #
' ################################################################################
' ################################################################################
' # This file is part of Ember Media Manager. #
' # #
' # Ember Media Manager is free software: you can redistribute it and/or modify #
' # it under the terms of the GNU General Public License as published by #
' # the Free Software Foundation, either version 3 of the License, or #
' # (at your option) any later version. #
' # #
' # Ember Media Manager is distributed in the hope that it will be useful, #
' # but WITHOUT ANY WARRANTY; without even the implied warranty of #
' # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
' # GNU General Public License for more details. #
' # #
' # You should have received a copy of the GNU General Public License #
' # along with Ember Media Manager. If not, see <http://www.gnu.org/licenses/>. #
' ################################################################################
Imports System.IO
Imports EmberAPI
Public Class dlgEditSeason
#Region "Fields"
Private Fanart As New Images With {.IsEdit = True}
Private Poster As New Images With {.IsEdit = True}
#End Region 'Fields
#Region "Methods"
Private Sub btnRemoveFanart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRemoveFanart.Click
Me.pbFanart.Image = Nothing
Me.Fanart.Image = Nothing
End Sub
Private Sub btnRemovePoster_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRemovePoster.Click
Me.pbPoster.Image = Nothing
Me.Poster.Image = Nothing
End Sub
Private Sub btnSetFanartDL_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSetFanartDL.Click
Try
Using dImgManual As New dlgImgManual
If dImgManual.ShowDialog(Enums.ImageType.Fanart) = DialogResult.OK Then
Fanart.FromFile(Path.Combine(Master.TempPath, "fanart.jpg"))
pbFanart.Image = Fanart.Image
Me.lblFanartSize.Text = String.Format(Master.eLang.GetString(269, "Size: {0}x{1}"), Me.pbFanart.Image.Width, Me.pbFanart.Image.Height)
Me.lblFanartSize.Visible = True
End If
End Using
Catch ex As Exception
Master.eLog.WriteToErrorLog(ex.Message, ex.StackTrace, "Error")
End Try
End Sub
Private Sub btnSetFanartScrape_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSetFanartScrape.Click
Dim tImage As Image = ModulesManager.Instance.TVSingleImageOnly(Master.currShow.TVShow.Title, Convert.ToInt32(Master.currShow.ShowID), Master.currShow.TVShow.ID, Enums.TVImageType.SeasonFanart, Master.currShow.TVEp.Season, 0, Master.currShow.ShowLanguage, Master.currShow.Ordering, Me.pbFanart.Image)
If Not IsNothing(tImage) Then
Me.Fanart.Image = New Bitmap(tImage)
Me.pbFanart.Image = tImage
Me.lblFanartSize.Text = String.Format(Master.eLang.GetString(269, "Size: {0}x{1}"), Me.pbFanart.Image.Width, Me.pbFanart.Image.Height)
Me.lblFanartSize.Visible = True
End If
End Sub
Private Sub btnSetFanart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSetFanart.Click
Try
With ofdImage
.InitialDirectory = Master.currShow.ShowPath
.Filter = "JPEGs|*.jpg"
.FilterIndex = 4
End With
If ofdImage.ShowDialog() = DialogResult.OK Then
Fanart.FromFile(ofdImage.FileName)
pbFanart.Image = Fanart.Image
Me.lblFanartSize.Text = String.Format(Master.eLang.GetString(269, "Size: {0}x{1}"), Me.pbFanart.Image.Width, Me.pbFanart.Image.Height)
Me.lblFanartSize.Visible = True
End If
Catch ex As Exception
Master.eLog.WriteToErrorLog(ex.Message, ex.StackTrace, "Error")
End Try
End Sub
Private Sub btnSetPosterDL_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSetPosterDL.Click
Try
Using dImgManual As New dlgImgManual
If dImgManual.ShowDialog(Enums.ImageType.Posters) = DialogResult.OK Then
Poster.FromFile(Path.Combine(Master.TempPath, "poster.jpg"))
pbPoster.Image = Poster.Image
Me.lblPosterSize.Text = String.Format(Master.eLang.GetString(269, "Size: {0}x{1}"), Me.pbPoster.Image.Width, Me.pbPoster.Image.Height)
Me.lblPosterSize.Visible = True
End If
End Using
Catch ex As Exception
Master.eLog.WriteToErrorLog(ex.Message, ex.StackTrace, "Error")
End Try
End Sub
Private Sub btnSetPosterScrape_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSetPosterScrape.Click
Dim tImage As Image = ModulesManager.Instance.TVSingleImageOnly(Master.currShow.TVShow.Title, Convert.ToInt32(Master.currShow.ShowID), Master.currShow.TVShow.ID, Enums.TVImageType.SeasonPoster, Master.currShow.TVEp.Season, 0, Master.currShow.ShowLanguage, Master.currShow.Ordering, Me.pbPoster.Image)
If Not IsNothing(tImage) Then
Me.Poster.Image = New Bitmap(tImage)
Me.pbPoster.Image = tImage
Me.lblPosterSize.Text = String.Format(Master.eLang.GetString(269, "Size: {0}x{1}"), Me.pbPoster.Image.Width, Me.pbPoster.Image.Height)
Me.lblPosterSize.Visible = True
End If
End Sub
Private Sub btnSetPoster_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSetPoster.Click
Try
With ofdImage
.InitialDirectory = Master.currShow.ShowPath
.Filter = "Supported Images(*.jpg, *.jpeg, *.tbn)|*.jpg;*.jpeg;*.tbn|jpeg (*.jpg, *.jpeg)|*.jpg;*.jpeg|tbn (*.tbn)|*.tbn"
.FilterIndex = 0
End With
If ofdImage.ShowDialog() = DialogResult.OK Then
Poster.FromFile(ofdImage.FileName)
pbPoster.Image = Poster.Image
Me.lblPosterSize.Text = String.Format(Master.eLang.GetString(269, "Size: {0}x{1}"), Me.pbPoster.Image.Width, Me.pbPoster.Image.Height)
Me.lblPosterSize.Visible = True
End If
Catch ex As Exception
Master.eLog.WriteToErrorLog(ex.Message, ex.StackTrace, "Error")
End Try
End Sub
Private Sub Cancel_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel_Button.Click
Me.DialogResult = System.Windows.Forms.DialogResult.Cancel
Me.Close()
End Sub
Private Sub CleanUp()
Try
If File.Exists(Path.Combine(Master.TempPath, "poster.jpg")) Then
File.Delete(Path.Combine(Master.TempPath, "poster.jpg"))
End If
If File.Exists(Path.Combine(Master.TempPath, "fanart.jpg")) Then
File.Delete(Path.Combine(Master.TempPath, "fanart.jpg"))
End If
Catch ex As Exception
Master.eLog.WriteToErrorLog(ex.Message, ex.StackTrace, "Error")
End Try
End Sub
Private Sub dlgEditSeason_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not Master.eSettings.SeasonFanartEnabled AndAlso Not String.IsNullOrEmpty(Functions.GetSeasonDirectoryFromShowPath(Master.currShow.ShowPath, Master.currShow.TVEp.Season)) Then TabControl1.TabPages.Remove(TabPage3)
Me.SetUp()
Dim iBackground As New Bitmap(Me.pnlTop.Width, Me.pnlTop.Height)
Using g As Graphics = Graphics.FromImage(iBackground)
g.FillRectangle(New Drawing2D.LinearGradientBrush(Me.pnlTop.ClientRectangle, Color.SteelBlue, Color.LightSteelBlue, Drawing2D.LinearGradientMode.Horizontal), pnlTop.ClientRectangle)
Me.pnlTop.BackgroundImage = iBackground
End Using
Me.FillInfo()
End Sub
Private Sub FillInfo()
With Me
If Master.eSettings.SeasonFanartEnabled AndAlso Not String.IsNullOrEmpty(Functions.GetSeasonDirectoryFromShowPath(Master.currShow.ShowPath, Master.currShow.TVEp.Season)) Then
Fanart.FromFile(Master.currShow.SeasonFanartPath)
If Not IsNothing(Fanart.Image) Then
.pbFanart.Image = Fanart.Image
.lblFanartSize.Text = String.Format(Master.eLang.GetString(269, "Size: {0}x{1}"), .pbFanart.Image.Width, .pbFanart.Image.Height)
.lblFanartSize.Visible = True
End If
End If
Poster.FromFile(Master.currShow.SeasonPosterPath)
If Not IsNothing(Poster.Image) Then
.pbPoster.Image = Poster.Image
.lblPosterSize.Text = String.Format(Master.eLang.GetString(269, "Size: {0}x{1}"), .pbPoster.Image.Width, .pbPoster.Image.Height)
.lblPosterSize.Visible = True
End If
End With
End Sub
Private Sub OK_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK_Button.Click
Try
Me.SetInfo()
Master.DB.SaveTVSeasonToDB(Master.currShow, False)
Me.CleanUp()
Catch ex As Exception
Master.eLog.WriteToErrorLog(ex.Message, ex.StackTrace, "Error")
End Try
Me.DialogResult = System.Windows.Forms.DialogResult.OK
Me.Close()
End Sub
Private Sub SetInfo()
Try
With Me
If Master.eSettings.SeasonFanartEnabled AndAlso Not String.IsNullOrEmpty(Functions.GetSeasonDirectoryFromShowPath(Master.currShow.ShowPath, Master.currShow.TVEp.Season)) Then
If Not IsNothing(.Fanart.Image) Then
Dim fPath As String = .Fanart.SaveAsSeasonFanart(Master.currShow)
Master.currShow.SeasonFanartPath = fPath
Else
.Fanart.DeleteSeasonFanart(Master.currShow)
Master.currShow.SeasonFanartPath = String.Empty
End If
End If
If Not IsNothing(.Poster.Image) Then
Dim pPath As String = .Poster.SaveAsSeasonPoster(Master.currShow)
Master.currShow.SeasonPosterPath = pPath
Else
.Poster.DeleteSeasonPosters(Master.currShow)
Master.currShow.SeasonPosterPath = String.Empty
End If
End With
Catch ex As Exception
Master.eLog.WriteToErrorLog(ex.Message, ex.StackTrace, "Error")
End Try
End Sub
Private Sub SetUp()
Me.Text = Master.eLang.GetString(769, "Edit Season")
Me.OK_Button.Text = Master.eLang.GetString(179, "OK")
Me.Cancel_Button.Text = Master.eLang.GetString(167, "Cancel")
Me.Label2.Text = Master.eLang.GetString(830, "Edit the details for the selected season.")
Me.Label1.Text = Me.Text
Me.TabPage2.Text = Master.eLang.GetString(148, "Poster")
Me.btnRemovePoster.Text = Master.eLang.GetString(247, "Remove Poster")
Me.btnSetPosterScrape.Text = Master.eLang.GetString(248, "Change Poster (Scrape)")
Me.btnSetPoster.Text = Master.eLang.GetString(249, "Change Poster (Local)")
Me.TabPage3.Text = Master.eLang.GetString(149, "Fanart")
Me.btnRemoveFanart.Text = Master.eLang.GetString(250, "Remove Fanart")
Me.btnSetFanartScrape.Text = Master.eLang.GetString(251, "Change Fanart (Scrape)")
Me.btnSetFanart.Text = Master.eLang.GetString(252, "Change Fanart (Local)")
Me.btnSetPosterDL.Text = Master.eLang.GetString(265, "Change Poster (Download)")
Me.btnSetFanartDL.Text = Master.eLang.GetString(266, "Change Fanart (Download)")
End Sub
#End Region 'Methods
End Class