Skip to content

Commit

Permalink
Poster can now be seen in Poster Mode result screen for clicked item.
Browse files Browse the repository at this point in the history
  • Loading branch information
DineshSolanki committed Jun 22, 2020
1 parent 12ab0e1 commit 0d84b54
Show file tree
Hide file tree
Showing 8 changed files with 102 additions and 68 deletions.
4 changes: 3 additions & 1 deletion Folicon_Native/Classes/ListItem.vb
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ Public Class ListItem
Public Property Rating() As String
Public Property Folder() As String
Public Property Overview() As String
Public Sub New(ByVal _title As String, ByVal _year As String, ByVal _rating As String, ByVal Optional _overview As String = Nothing, Optional ByVal _folder As String = "")
Public Property Poster() As String
Public Sub New(ByVal _title As String, ByVal _year As String, ByVal _rating As String, ByVal Optional _overview As String = Nothing, Optional _poster As String = Nothing, Optional ByVal _folder As String = "")
Title = _title
Year = _year
Rating = _rating
Overview = _overview
Poster = _poster
Folder = _folder
End Sub

Expand Down
4 changes: 4 additions & 0 deletions Folicon_Native/Folicon.vbproj
Original file line number Diff line number Diff line change
Expand Up @@ -254,5 +254,9 @@
<ItemGroup>
<Resource Include="Model\folicon Icon.ico" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\LoadingPosterImage.png" />
<Resource Include="Resources\NoPosterAvailable.png" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.VisualBasic.targets" />
</Project>
10 changes: 6 additions & 4 deletions Folicon_Native/Modules/IGDB.vb
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ Namespace Modules
Dim folderPath = SelectedFolderPath & "\" & Fnames(FolderNameIndex)
Dim folderName = Fnames(FolderNameIndex)
Dim year=If(result.FirstReleaseDate IsNot Nothing,result.FirstReleaseDate.Value.Year,"")
Dim posterUrl= IGDB.ImageHelper.GetImageUrl(result.Cover.Value.ImageId,ImageSize.HD720)
AddToPickedListDataTable(localPosterPath,result.Name,"",folderPath,folderName,year)
Dim posterUrl = ImageHelper.GetImageUrl(result.Cover.Value.ImageId, ImageSize.HD720)
AddToPickedListDataTable(localPosterPath,result.Name,"",folderPath,folderName,year)
FolderProcessedCount += 1
Dim tempImage As New ImageToDownload() With{
.LocalPath=localPosterPath,
Expand All @@ -35,13 +35,15 @@ Namespace Modules
dim mediaName as String
dim year As String
Dim rating as String
Dim overview as String
Dim overview As String
Dim poster As String
For Each item In result
mediaName = item.Name
year = If(item.FirstReleaseDate Isnot Nothing, item.FirstReleaseDate.Value.Year, "")
'rating = If(item.TotalRating Isnot Nothing, item.TotalRating,"")
overview = item.Summary
items.Add(new ListItem(mediaName, year, "", overview))
poster = If(item.Cover IsNot Nothing, "https://" & ImageHelper.GetImageUrl(item.Cover.Value.ImageId, ImageSize.HD720).Substring(2), Nothing)
items.Add(New ListItem(mediaName, year, "", overview, poster))
Next
Return items
End Function
Expand Down
117 changes: 64 additions & 53 deletions Folicon_Native/Modules/TMDB.vb
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,33 @@ Imports System.Threading
Namespace Modules

Module TMDB
public class ResultResponse
public Property Result As Object
public Property MediaType As string
Dim posterBase As String = "https://image.tmdb.org/t/p/w200"
Public Class ResultResponse
Public Property Result As Object
Public Property MediaType As String
End Class

public Async Function SearchIt(query As string, serviceClient As ServiceClient) As Task(Of ResultResponse)
Public Async Function SearchIt(query As String, serviceClient As ServiceClient) As Task(Of ResultResponse)
Dim r
Dim mt As string
If SearchMod = "Movie"
If query.ToLower.Contains("collection")
r = Await serviceClient.Collections.SearchAsync(query, "en-US", 1, CancellationToken.none)
Dim mt As String
If SearchMod = "Movie" Then

If query.ToLower.Contains("collection") Then
r = Await serviceClient.Collections.SearchAsync(query, "en-US", 1, CancellationToken.None)
mt = "Collection"
Else
r =
Await _
serviceClient.Movies.SearchAsync(query, "en-US", false, Nothing, True, 1, CancellationToken.none)
serviceClient.Movies.SearchAsync(query, "en-US", False, Nothing, True, 1, CancellationToken.None)
mt = "Movie"
End If
ElseIf SearchMod = "TV"
ElseIf SearchMod = "TV" Then
r = Await serviceClient.Shows.SearchAsync(query, "en-US", Nothing, True, 1, CancellationToken.None)
mt = "TV"
ElseIf SearchMod = "Auto (Movies & TV Shows)"
ElseIf SearchMod = "Auto (Movies & TV Shows)" Then
' TODO: Write logic to search for all
Dim iop As Net.TMDb.Resources
r = await serviceClient.SearchAsync(query, "en-US", False, 1, CancellationToken.none)
r = Await serviceClient.SearchAsync(query, "en-US", False, 1, CancellationToken.None)
mt = "Auto (Movies & TV Shows)"
End If
Searchresultob = r
Expand All @@ -39,131 +41,140 @@ Namespace Modules
End Function


Public Sub ResultPicked(result As Object, resultType As String, pickIndex As integer)
If result.Results(pickIndex).Poster Is nothing
throw New Exception("NoPoster")
Public Sub ResultPicked(result As Object, resultType As String, pickIndex As Integer)
If result.Results(pickIndex).Poster Is Nothing Then
Throw New Exception("NoPoster")
End If
Dim localPosterPath = SelectedFolderPath & "\" & Fnames(FolderNameIndex) & "\" & Fnames(FolderNameIndex) &
".png"
Dim folderPath = SelectedFolderPath & "\" & Fnames(FolderNameIndex)
Dim folderName = Fnames(FolderNameIndex)
Dim posterUrl = String.Concat("http://image.tmdb.org/t/p/original", result.Results(pickIndex).Poster)
'If Not String.IsNullOrEmpty(posterUrl)
If resultType = "TV"
If resultType = "TV" Then
Dim searchResult = DirectCast(result, Shows)
Dim pickedResult = searchResult.Results(pickIndex)
AddToPickedListDataTable(localPosterPath,
pickedResult.Name, pickedResult.VoteAverage,
folderPath,
folderName, pickedResult.FirstAirDate.Value.Year)
ElseIf resultType = "Movie"
ElseIf resultType = "Movie" Then
Dim searchResult = DirectCast(result, Movies)
Dim pickedResult = searchResult.Results(pickIndex)

AddToPickedListDataTable(localPosterPath,
pickedResult.Title, pickedResult.VoteAverage,
folderPath, folderName, pickedResult.ReleaseDate.Value.Year)
ElseIf resultType = "Collection"
ElseIf resultType = "Collection" Then

Dim searchResult = DirectCast(result, Collections)
Dim pickedResult = searchResult.Results(pickIndex)
AddToPickedListDataTable(localPosterPath,
pickedResult.Name, "",
folderPath, folderName)
ElseIf resultType = "Auto (Movies & TV Shows)"
ElseIf resultType = "Auto (Movies & TV Shows)" Then
Dim mediaType = result.Results(pickIndex).GetType()
If mediaType.Name = "Show"
Dim pickedResult = DirectCast(result.Results(pickIndex), show)
If mediaType.Name = "Show" Then
Dim pickedResult = DirectCast(result.Results(pickIndex), Show)
AddToPickedListDataTable(localPosterPath,
pickedResult.Name, pickedResult.VoteAverage,
folderPath,
folderName, pickedResult.FirstAirDate.Value.Year)
Elseif mediaType.name = "Movie"
ElseIf mediaType.Name = "Movie" Then
Dim pickedResult = DirectCast(result.Results(pickIndex), Movie)
AddToPickedListDataTable(localPosterPath,
pickedResult.Title, pickedResult.VoteAverage,
folderPath, folderName, pickedResult.ReleaseDate.Value.Year)
End If
End If
FolderProcessedCount += 1
Dim tempImage As New ImageToDownload() With{
.LocalPath=localPosterPath,
.RemotePath=posterUrl}
Dim tempImage As New ImageToDownload() With {
.LocalPath = localPosterPath,
.RemotePath = posterUrl}
ImgDownloadList.Add(tempImage)
'End If
End Sub

public Function ExtractTvDetailsIntoListItem(result As shows) As ObservableCollection(Of ListItem)
Public Function ExtractTvDetailsIntoListItem(result As Shows) As ObservableCollection(Of ListItem)
Dim items As New ObservableCollection(Of ListItem)()
dim mediaName as String
dim year As String
Dim rating as String
Dim overview as String
Dim mediaName As String
Dim year As String
Dim rating As String
Dim overview As String
Dim poster As String
For Each item In result.Results
mediaName = item.Name
year = If(item.FirstAirDate Isnot Nothing, item.FirstAirDate.Value.Year, "")
year = If(item.FirstAirDate IsNot Nothing, item.FirstAirDate.Value.Year, "")
rating = item.VoteAverage
overview = item.Overview
items.Add(new ListItem(mediaName, year, rating, overview))
poster = If(item.Poster IsNot Nothing, posterBase & item.Poster, Nothing)
items.Add(New ListItem(mediaName, year, rating, overview, poster))
Next
Return items
End Function

public Function ExtractMoviesDetailsIntoListItem(result As Movies) As ObservableCollection(Of ListItem)
Public Function ExtractMoviesDetailsIntoListItem(result As Movies) As ObservableCollection(Of ListItem)
Dim items As New ObservableCollection(Of ListItem)()
dim mediaName as String
dim year As String
Dim rating as String
Dim overview as String
Dim mediaName As String
Dim year As String
Dim rating As String
Dim overview As String
Dim poster As String
For Each item In result.Results
mediaName = item.Title
year = If(item.ReleaseDate Isnot Nothing, item.ReleaseDate.Value.Year, "")
year = If(item.ReleaseDate IsNot Nothing, item.ReleaseDate.Value.Year, "")
rating = item.VoteAverage
overview = item.Overview
items.Add(new ListItem(mediaName, year, rating, overview))
poster = If(item.Poster IsNot Nothing, posterBase & item.Poster, Nothing)
items.Add(New ListItem(mediaName, year, rating, overview, poster))
Next
Return items
End Function

public Function ExtractResourceDetailsIntoListItem(result As Resources) As ObservableCollection(Of ListItem)
Public Function ExtractResourceDetailsIntoListItem(result As Resources) As ObservableCollection(Of ListItem)
Dim items As New ObservableCollection(Of ListItem)()
dim mediaName = ""
dim year = ""
Dim mediaName = ""
Dim year = ""
Dim rating = ""
Dim overview = ""
Dim poster = Nothing
For Each item In result.Results
Dim mediaType = item.GetType()
If mediaType.Name = "Show"
If mediaType.Name = "Show" Then
Dim res As Show = item
mediaName = res.Name
year = If(res.FirstAirDate Isnot Nothing, res.FirstAirDate.Value.Year, "")
year = If(res.FirstAirDate IsNot Nothing, res.FirstAirDate.Value.Year, "")
rating = res.VoteAverage
overview = res.Overview
ElseIf mediaType.Name = "Movie"
poster = If(res.Poster IsNot Nothing, posterBase & res.Poster, Nothing)
ElseIf mediaType.Name = "Movie" Then
Dim res As Movie = item
mediaName = res.Title
year = If(res.ReleaseDate Isnot Nothing, res.ReleaseDate.Value.Year, "")
year = If(res.ReleaseDate IsNot Nothing, res.ReleaseDate.Value.Year, "")
rating = res.VoteAverage
overview = res.Overview
poster = If(res.Poster IsNot Nothing, posterBase & res.Poster, Nothing)
End If

items.Add(new ListItem(mediaName, year, rating, overview))
items.Add(New ListItem(mediaName, year, rating, overview, poster))
Next
Return items
End Function

public Function ExtractCollectionDetailsIntoListItem(result As Collections) As ObservableCollection(Of ListItem)
Public Function ExtractCollectionDetailsIntoListItem(result As Collections) As ObservableCollection(Of ListItem)
Dim items As New ObservableCollection(Of ListItem)()
dim mediaName as String
dim year As String
Dim rating as String
Dim overview as String
Dim mediaName As String
Dim year As String
Dim rating As String
Dim overview As String
Dim poster As String
For Each item In result.Results
mediaName = item.Name
year = ""
rating = ""
overview = ""
items.Add(new ListItem(mediaName, year, rating, overview))
poster = If(item.Poster IsNot Nothing, posterBase & item.Poster, Nothing)
items.Add(New ListItem(mediaName, year, rating, overview, poster))
Next
Return items
End Function
Expand Down
Binary file added Folicon_Native/Resources/LoadingPosterImage.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Folicon_Native/Resources/NoPosterAvailable.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 10 additions & 4 deletions Folicon_Native/SearchResult.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
mc:Ignorable="d"
Title="Search Result" Height="514.5" Width="861.5" ResizeMode="NoResize" Loaded="Window_Loaded" >
<!--<Window.DataContext>
<local:ListItem/>
</Window.DataContext>-->
<Window.Resources>
<BitmapImage x:Key="NoPoster" UriSource="/Resources/NoPosterAvailable.png"/>
<BitmapImage x:Key="LoadingPoster" UriSource="/Resources/LoadingPosterImage.png"/>
</Window.Resources>

<xctk:BusyIndicator x:Name="BusyIndicator1" BusyContent="Searching..." >
<Grid>
Expand Down Expand Up @@ -39,8 +40,13 @@
<Label Content="~OR~" HorizontalAlignment="Left" Margin="178,223,0,0" Grid.Row="1" VerticalAlignment="Top" Width="54" FontSize="16"/>
<TextBox x:Name="SearchTxt" HorizontalAlignment="Left" Height="23" Margin="21,270,0,0" Grid.Row="1" TextWrapping="Wrap" Text="{x:Null}" VerticalAlignment="Top" Width="313"/>
<Button x:Name="SearchAgainbtn" Content="Search Again" HorizontalAlignment="Left" Margin="349,270,0,0" VerticalAlignment="Top" Width="98" Grid.Row="1"/>
<TextBox x:Name="OverviewText" HorizontalAlignment="Left" Height="385" Margin="473,76,0,0" Grid.RowSpan="2" TextWrapping="Wrap" Text="{Binding SelectedItem.Overview, ElementName=ListView1}" VerticalAlignment="Top" Width="358" IsReadOnly="True" FontSize="15"/>
<TextBox x:Name="OverviewText" HorizontalAlignment="Left" Height="189" Margin="465,103,0,0" TextWrapping="Wrap" Text="{Binding SelectedItem.Overview, ElementName=ListView1}" VerticalAlignment="Top" Width="366" IsReadOnly="True" FontSize="15" Grid.Row="1"/>
<Slider x:Name="FontSlider" HorizontalAlignment="Left" Margin="526,43,0,0" VerticalAlignment="Top" Width="260" Maximum="25" ValueChanged="Slider_ValueChanged" Minimum="12" Value="15"/>
<Image x:Name="imgTitlePoster" Source="{Binding SelectedItem.Poster, ElementName=ListView1, FallbackValue={StaticResource LoadingPoster}, TargetNullValue={StaticResource NoPoster}}" HorizontalAlignment="Left" Height="198" Margin="569,66,0,0" Grid.RowSpan="2" VerticalAlignment="Top" Width="158" Stretch="Fill">
<Image.Effect>
<DropShadowEffect/>
</Image.Effect>
</Image>
</Grid>
</xctk:BusyIndicator>

Expand Down
21 changes: 15 additions & 6 deletions Folicon_Native/SearchResult.xaml.vb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Public Class SearchResult
MovieTitle.Content = SearchTitle
If Searchresultob IsNot Nothing AndAlso if(searchMod="Game",Searchresultob.Length ,Searchresultob.TotalCount) IsNot Nothing Then
FetchAndAddDetailsToListView(ListView1, Searchresultob, SearchTitle)
ListView1.Focus()

Else
SearchTxt.Focus()
End If
Expand Down Expand Up @@ -76,13 +76,22 @@ Public Class SearchResult
If SearchMod = "TV"
Dim ob = DirectCast(result, Shows)
source = ExtractTvDetailsIntoListItem(ob)
ElseIf SearchMod = "Movie"
If query.ToLower.Contains("collection")
ElseIf SearchMod = "Movie" Then

If query.ToLower.Contains("collection") Then
Dim ob = DirectCast(result, collections)
source = ExtractCollectionDetailsIntoListItem(ob)
Else
Dim ob = DirectCast(result, Movies)
source = ExtractMoviesDetailsIntoListItem(ob)
Dim ob
Try
ob = DirectCast(result, Movies)
source = ExtractMoviesDetailsIntoListItem(ob)
Catch ex As Exception
ob = DirectCast(result, Collections)
source = ExtractCollectionDetailsIntoListItem(ob)
End Try


End If
ElseIf SearchMod = "Auto (Movies & TV Shows)"
Dim ob = DirectCast(result, Resources)
Expand Down Expand Up @@ -139,6 +148,6 @@ Public Class SearchResult
End Sub

Private Sub ListView1_MouseDoubleClick(sender As Object, e As MouseButtonEventArgs) Handles ListView1.MouseDoubleClick
Pickbtn_Click(Nothing,nothing)
Pickbtn_Click(Nothing, Nothing)
End Sub
End Class

0 comments on commit 0d84b54

Please sign in to comment.