Skip to content

Commit

Permalink
Refectorization, cleaned code.
Browse files Browse the repository at this point in the history
  • Loading branch information
DineshSolanki committed Aug 10, 2021
1 parent 21da016 commit b403866
Show file tree
Hide file tree
Showing 12 changed files with 20 additions and 35 deletions.
1 change: 0 additions & 1 deletion FoliCon/Modules/ClickBehavior.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using System.Windows.Input;
using System.Windows.Threading;
using Microsoft.Xaml.Behaviors;
using Prism.Commands;

namespace FoliCon.Modules
{
Expand Down
2 changes: 1 addition & 1 deletion FoliCon/Modules/IGDBClass.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public void ResultPicked(Game result, string fullFolderPath, string rating = "")
var year = result.FirstReleaseDate != null ? result.FirstReleaseDate.Value.Year.ToString(CultureInfo.InvariantCulture) : "";
var posterUrl = ImageHelper.GetImageUrl(result.Cover.Value.ImageId, ImageSize.HD720);
Util.AddToPickedListDataTable(_listDataTable, localPosterPath, result.Name, rating, fullFolderPath, folderName,
year, (int)(result.Id ?? 0));
year);
if (result.Id != null) Util.SaveMediaInfo((int)result.Id, "Game", fullFolderPath);
var tempImage = new ImageToDownload
{
Expand Down
1 change: 1 addition & 0 deletions FoliCon/Modules/LangProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Windows;
using System.Windows.Data;
using HandyControl.Tools;
// ReSharper disable InconsistentNaming

namespace FoliCon.Properties.Langs
{
Expand Down
17 changes: 9 additions & 8 deletions FoliCon/Modules/TMDB.cs
Original file line number Diff line number Diff line change
Expand Up @@ -187,13 +187,15 @@ public static ObservableCollection<ListItem> ExtractTvDetailsIntoListItem(Search

return items;
}

/// <summary>
/// Prepares the Selected Result for Download And final List View
/// </summary>
/// <param name="result">Search Response</param>
/// <param name="resultType">Type of search Response.</param>
/// <param name="fullFolderPath">Full Path to the current Media Folder</param>
/// <param name="rating">Rating for media</param>
/// <param name="isPickedById"> identifies if Title was picked by media ID.</param>
/// TODO: Merge parameter response and resultType.
public void ResultPicked(dynamic result, string resultType, string fullFolderPath, string rating = "",bool isPickedById = false)
{
Expand All @@ -218,22 +220,22 @@ public void ResultPicked(dynamic result, string resultType, string fullFolderPat
var year = pickedResult.FirstAirDate != null ? pickedResult.FirstAirDate.Year.ToString(CultureInfo.InvariantCulture) : "";
Util.AddToPickedListDataTable(_listDataTable, localPosterPath, pickedResult.Name,
rating, fullFolderPath, folderName,
year, pickedResult.Id);
year);
id = pickedResult.Id;
}
else if (resultType == MediaTypes.Movie)
{
dynamic pickedResult = isPickedById ? (Movie)result : (SearchMovie)result;
var year = pickedResult.ReleaseDate != null ? pickedResult.ReleaseDate.Year.ToString(CultureInfo.InvariantCulture) : "";
Util.AddToPickedListDataTable(_listDataTable, localPosterPath, pickedResult.Title,
rating, fullFolderPath, folderName, year, pickedResult.Id);
rating, fullFolderPath, folderName, year);
id = pickedResult.Id;
}
else if (resultType == MediaTypes.Collection)
{
dynamic pickedResult = isPickedById ? (Collection)result : (SearchCollection)result;
Util.AddToPickedListDataTable(_listDataTable, localPosterPath, pickedResult.Name, rating, fullFolderPath,
folderName, "", pickedResult.Id);
folderName, "");
id = pickedResult.Id;
}
else if (resultType == MediaTypes.Mtv)
Expand All @@ -250,7 +252,7 @@ public void ResultPicked(dynamic result, string resultType, string fullFolderPat
: "";
Util.AddToPickedListDataTable(_listDataTable, localPosterPath, pickedResult.Name,
rating, fullFolderPath, folderName,
year, pickedResult.Id);
year);
id = pickedResult.Id;
break;
}
Expand All @@ -263,7 +265,7 @@ public void ResultPicked(dynamic result, string resultType, string fullFolderPat
: "";
Util.AddToPickedListDataTable(_listDataTable, localPosterPath, pickedResult.Title,
rating, fullFolderPath, folderName,
year, pickedResult.Id);
year);
id = pickedResult.Id;
break;
}
Expand Down Expand Up @@ -323,11 +325,10 @@ public async Task<ResultResponse> SearchAsync(string query, string searchMode)
};
return response;
}

/// <summary>
/// Searches TMDB for a query in Specified search mode
/// Searches TMDB media by ID as per media Type.
/// </summary>
/// <param name="query">Title to search</param>
/// <param name="mediaTypee">Search Mode such as Movie,TV</param>
/// <returns>Returns Search result with its Media Type</returns>
public ResultResponse SearchByIdAsync(int id, string mediaType)
{
Expand Down
5 changes: 3 additions & 2 deletions FoliCon/Modules/Util.cs
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ public static VistaFolderBrowserDialog NewFolderBrowserDialog(string description
/// <param name="folderName">Short Folder Name</param>
/// <param name="year">Media Year</param>
public static void AddToPickedListDataTable(DataTable dataTable, string poster, string title, string rating,
string fullFolderPath, string folderName, string year = "", int id = 0)
string fullFolderPath, string folderName, string year = "")
{
if (rating == "0")
{
Expand Down Expand Up @@ -449,7 +449,8 @@ public static int MakeIco(string iconMode, string selectedFolder, DataTable pick
/// <param name="rating"> if Wants to Include rating on Icon</param>
/// <param name="ratingVisibility">Show rating or NOT</param>
/// <param name="mockupVisibility">Is Cover Mockup visible. </param>
public static void BuildFolderIco(string iconMode, string filmFolderPath, string rating,
/// <param name="mediaTitle">Title of the media.</param>
private static void BuildFolderIco(string iconMode, string filmFolderPath, string rating,
string ratingVisibility, string mockupVisibility, string mediaTitle)
{
if (!File.Exists(filmFolderPath))
Expand Down
1 change: 0 additions & 1 deletion FoliCon/Views/AboutBox.xaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<UserControl x:Class="FoliCon.Views.AboutBox"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
xmlns:hc="https://handyorg.github.io/handycontrol"
xmlns:prism="http://prismlibrary.com/"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
Expand Down
3 changes: 1 addition & 2 deletions FoliCon/Views/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,7 @@
</hc:EventTrigger>
</hc:Interaction.Triggers>
<TextBlock Text="{Binding SelectedFolder}" HorizontalAlignment="Center" VerticalAlignment="Top"
FontStyle="Italic" Foreground="Black">
</TextBlock>
FontStyle="Italic" Foreground="Black" />
</ContentControl>

<Grid Grid.Column="0" Grid.Row="2" Grid.IsSharedSizeScope="True" Background="WhiteSmoke">
Expand Down
2 changes: 0 additions & 2 deletions FoliCon/Views/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
using FoliCon.Modules;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Globalization;
using System.Threading;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using FoliCon.Models;
using FoliCon.Properties.Langs;
using HandyControl.Tools;
using Vanara.PInvoke;

namespace FoliCon.Views
Expand Down
12 changes: 1 addition & 11 deletions FoliCon/Views/PosterIconLiaher.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,19 +1,9 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace FoliCon.Views
{
Expand Down
6 changes: 3 additions & 3 deletions FoliCon/Views/ProSearchResult.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/// </summary>
public partial class ProSearchResult
{
private bool AutoScroll = true;
private bool _autoScroll = true;

public ProSearchResult()
{
Expand All @@ -17,11 +17,11 @@ private void ScrollViewer_ScrollChanged(object sender, System.Windows.Controls.S
if (e.ExtentHeightChange == 0)
{

AutoScroll = scrollViewer.VerticalOffset == scrollViewer.ScrollableHeight;
_autoScroll = scrollViewer.VerticalOffset == scrollViewer.ScrollableHeight;
}


if (AutoScroll && e.ExtentHeightChange != 0)
if (_autoScroll && e.ExtentHeightChange != 0)
{
scrollViewer.ScrollToVerticalOffset(scrollViewer.ExtentHeight);
}
Expand Down
2 changes: 0 additions & 2 deletions FoliCon/Views/SearchResult.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Input;
using FoliCon.Models;

namespace FoliCon.Views
{
Expand Down
3 changes: 1 addition & 2 deletions FoliCon/Views/posterIconConfig.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:prism="http://prismlibrary.com/"
xmlns:hc="https://handyorg.github.io/handycontrol"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:modules="clr-namespace:FoliCon.ViewModels"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
Expand All @@ -20,7 +19,7 @@
<prism:Dialog.WindowStyle>
<Style TargetType="Window">
<Setter Property="Height" Value="300" />
<Setter Property="MaxHeight" Value="300"></Setter>
<Setter Property="MaxHeight" Value="300" />
<Setter Property="Width" Value="1066" />
<!--<Setter Property="ResizeMode" Value="NoResize" />-->
<Setter Property="WindowStyle" Value="ThreeDBorderWindow" />
Expand Down

0 comments on commit b403866

Please sign in to comment.