Skip to content

Commit

Permalink
added option to delete media info files(info.folicon)
Browse files Browse the repository at this point in the history
translation related to mediaInfo feature added.
  • Loading branch information
DineshSolanki committed Aug 6, 2021
1 parent 6592404 commit 5d55ce8
Show file tree
Hide file tree
Showing 12 changed files with 156 additions and 6 deletions.
2 changes: 2 additions & 0 deletions FoliCon/Models/GlobalVariables.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,7 @@ internal static class GlobalVariables
"Alternate" => IconOverlay.Alternate,
_ => IconOverlay.Alternate
};

public static string MediaInfoFile = "info.folicon";
}
}
14 changes: 12 additions & 2 deletions FoliCon/Modules/LangProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,10 @@ private void UpdateLangs()
OnPropertyChanged(nameof(UsePosterOverlay));
OnPropertyChanged(nameof(Version));
OnPropertyChanged(nameof(Year));
OnPropertyChanged(nameof(ExceptionOccurred));
OnPropertyChanged(nameof(DeleteMediaInfo));
OnPropertyChanged(nameof(DeleteMediaInfoTooltip));
OnPropertyChanged(nameof(DeleteMediaInfoConfirmation));
OnPropertyChanged(nameof(ConfirmMediaInfoDeletion));
}

public string About => Lang.About;
Expand Down Expand Up @@ -412,6 +415,10 @@ private void UpdateLangs()

public string Year => Lang.Year;
public string ExceptionOccurred => Lang.ExceptionOccurred;
public string ConfirmMediaInfoDeletion => Lang.ConfirmMediaInfoDeletion;
public string DeleteMediaInfoConfirmation => Lang.DeleteMediaInfoConfirmation;
public string DeleteMediaInfoTooltip => Lang.DeleteMediaInfoTooltip;
public string DeleteMediaInfo => Lang.DeleteMediaInfo;


public event PropertyChangedEventHandler PropertyChanged;
Expand Down Expand Up @@ -671,6 +678,9 @@ public class LangKeys
public static string Year = nameof(Year);

public static string ExceptionOccurred = nameof(ExceptionOccurred);

public static string ConfirmMediaInfoDeletion = nameof(ConfirmMediaInfoDeletion);
public static string DeleteMediaInfoConfirmation = nameof(DeleteMediaInfoConfirmation);
public static string DeleteMediaInfoTooltip = nameof(DeleteMediaInfoTooltip);
public static string DeleteMediaInfo = nameof(DeleteMediaInfo);
}
}
17 changes: 13 additions & 4 deletions FoliCon/Modules/Util.cs
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,15 @@ public static void DeleteIconsFromFolder(string folderPath)
File.Delete(icoFile);
File.Delete(iniFile);
}

public static void DeleteMediaInfoFromSubfolders(string folderPath)
{
foreach (var folder in Directory.EnumerateDirectories(folderPath))
{
var icoFile = Path.Combine(folder, GlobalVariables.MediaInfoFile);
File.Delete(icoFile);
}
}
/// <summary>
/// Checks if Web is accessible from This System
/// </summary>
Expand Down Expand Up @@ -578,15 +587,15 @@ public static CultureInfo GetCultureInfoByLanguage(Languages language)

public static void SaveMediaInfo(int id, string mediaType, string folderPath)
{
var filePath = $@"{folderPath}\folicon.folicon";
InIHelper.AddValue("ID", id.ToString(),null,filePath);
var filePath = Path.Combine(folderPath, GlobalVariables.MediaInfoFile);
InIHelper.AddValue("ID", id.ToString(CultureInfo.InvariantCulture),null,filePath);
InIHelper.AddValue("MediaType", mediaType,null,filePath);
Util.HideFile(filePath);
HideFile(filePath);
}

public static (string ID, string MediaType) ReadMediaInfo(string folderPath)
{
var filePath = $@"{folderPath}\folicon.folicon";
var filePath = Path.Combine(folderPath, GlobalVariables.MediaInfoFile);
var id = File.Exists(filePath) ? InIHelper.ReadValue("ID", null, filePath) : null;
var mediaType = File.Exists(filePath) ? InIHelper.ReadValue("MediaType", null, filePath) : null;
var mediaInfo = (ID:id, MediaType:mediaType);
Expand Down
37 changes: 37 additions & 0 deletions FoliCon/Properties/Langs/Lang.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions FoliCon/Properties/Langs/Lang.ar.resx
Original file line number Diff line number Diff line change
Expand Up @@ -499,4 +499,17 @@
<data name="ExceptionOccurred" xml:space="preserve">
<value>حدث استثناء</value>
</data>
<data name="ConfirmMediaInfoDeletion" xml:space="preserve">
<value>تأكيد حذف ملفات معلومات الوسائط</value>
</data>
<data name="DeleteMediaInfo" xml:space="preserve">
<value>حذف معلومات الوسائط</value>
</data>
<data name="DeleteMediaInfoConfirmation" xml:space="preserve">
<value>هل أنت متأكد أنك تريد حذف ملفات معلومات وسائط فوليكون؟</value>
</data>
<data name="DeleteMediaInfoTooltip" xml:space="preserve">
<value>سيؤدي هذا إلى حذف ملفات معلومات الوسائط التي يستخدمها فوليكون لتخزين معرف الوسائط بعد تحديد العنوان لأول مرة.
يساعد هذا فوليكون في التعرف على الوسائط دون الحاجة إلى الاختيار من بين العناوين الغامضة.</value>
</data>
</root>
13 changes: 13 additions & 0 deletions FoliCon/Properties/Langs/Lang.es.resx
Original file line number Diff line number Diff line change
Expand Up @@ -499,4 +499,17 @@ y puede buscar "Juegos, películas y programas" y casi cualquier ícono de carpe
<data name="ExceptionOccurred" xml:space="preserve">
<value>Ocurrió una excepción</value>
</data>
<data name="ConfirmMediaInfoDeletion" xml:space="preserve">
<value>Confirmar la eliminación de archivos de información multimedia</value>
</data>
<data name="DeleteMediaInfo" xml:space="preserve">
<value>Eliminar información multimedia</value>
</data>
<data name="DeleteMediaInfoConfirmation" xml:space="preserve">
<value>¿Está seguro de que desea eliminar los archivos de información de medios de folicon?</value>
</data>
<data name="DeleteMediaInfoTooltip" xml:space="preserve">
<value>Esto eliminará los archivos de información de medios utilizados por folicon para almacenar la identificación de medios después de seleccionar un título por primera vez.
Esto ayuda a folicon a identificar los medios sin tener que elegir entre títulos ambiguos.</value>
</data>
</root>
16 changes: 16 additions & 0 deletions FoliCon/Properties/Langs/Lang.hi.resx
Original file line number Diff line number Diff line change
Expand Up @@ -496,4 +496,20 @@
<data name="Version" xml:space="preserve">
<value>संस्करण :</value>
</data>
<data name="ConfirmMediaInfoDeletion" xml:space="preserve">
<value>मीडिया इन्फो फ़ाइलों को हटाने की पुष्टि करें</value>
</data>
<data name="DeleteMediaInfo" xml:space="preserve">
<value>मीडिया जानकारी हटाएं</value>
</data>
<data name="DeleteMediaInfoConfirmation" xml:space="preserve">
<value>क्या आप वाकई फ़ॉलिकॉन मीडिया जानकारी फ़ाइलें हटाना चाहते हैं?</value>
</data>
<data name="DeleteMediaInfoTooltip" xml:space="preserve">
<value>यह पहली बार किसी शीर्षक के चयन के बाद मीडिया आईडी को स्टोर करने के लिए फॉलिकॉन द्वारा उपयोग की जाने वाली मीडिया जानकारी फ़ाइलों को हटा देगा।
यह अस्पष्ट शीर्षकों में से चुने बिना फॉलिकॉन को मीडिया की पहचान करने में मदद करता है।</value>
</data>
<data name="ExceptionOccurred" xml:space="preserve">
<value>त्रुटी</value>
</data>
</root>
13 changes: 13 additions & 0 deletions FoliCon/Properties/Langs/Lang.resx
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,9 @@
<data name="ConfirmIconDeletion" xml:space="preserve">
<value>Confirm Icon Deletion</value>
</data>
<data name="ConfirmMediaInfoDeletion" xml:space="preserve">
<value>Confirm Media Info files deletion</value>
</data>
<data name="ConfirmToOpenFolder" xml:space="preserve">
<value>Click "Confirm" to open folder.</value>
</data>
Expand All @@ -210,6 +213,16 @@
<data name="DeleteIconsTooltip" xml:space="preserve">
<value>This will delete existing icons from all subFolders.</value>
</data>
<data name="DeleteMediaInfo" xml:space="preserve">
<value>Delete media info</value>
</data>
<data name="DeleteMediaInfoConfirmation" xml:space="preserve">
<value>Are you sure you want to delete folicon media info files ?</value>
</data>
<data name="DeleteMediaInfoTooltip" xml:space="preserve">
<value>This will delete media info files used by folicon to store media id after a title is selected for the first time.
This helps folicon identify media without having to chose from ambigous titles.</value>
</data>
<data name="DevelopedByDinesh" xml:space="preserve">
<value>Developed By Dinesh Solanki.</value>
</data>
Expand Down
13 changes: 13 additions & 0 deletions FoliCon/Properties/Langs/Lang.ru.resx
Original file line number Diff line number Diff line change
Expand Up @@ -499,4 +499,17 @@
<data name="ExceptionOccurred" xml:space="preserve">
<value>Произошло исключение</value>
</data>
<data name="ConfirmMediaInfoDeletion" xml:space="preserve">
<value>Подтвердите удаление файлов Media Info</value>
</data>
<data name="DeleteMediaInfo" xml:space="preserve">
<value>Удалить информацию о мультимедиа</value>
</data>
<data name="DeleteMediaInfoConfirmation" xml:space="preserve">
<value>Вы уверены, что хотите удалить информационные файлы мультимедиа Folicon?</value>
</data>
<data name="DeleteMediaInfoTooltip" xml:space="preserve">
<value>Это приведет к удалению файлов информации о мультимедиа, используемых folicon для хранения идентификатора мультимедиа после выбора заголовка в первый раз.
Это помогает фоликону идентифицировать носители без необходимости выбирать из двусмысленных названий.</value>
</data>
</root>
19 changes: 19 additions & 0 deletions FoliCon/ViewModels/MainWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ public Languages AppLanguage

public DelegateCommand CustomIconsCommand { get; private set; }
public DelegateCommand DeleteIconsCommand { get; private set; }
public DelegateCommand DeleteMediaInfoCommand { get; private set; }

public DelegateCommand HelpCommand { get; } = new(() =>
Util.StartProcess("https://github.com/DineshSolanki/FoliCon"));
Expand Down Expand Up @@ -437,6 +438,7 @@ private void InitializeDelegates()
PosterIconConfigCommand = new DelegateCommand(delegate { _dialogService.ShowPosterIconConfig(_ => { }); });
AboutCommand = new DelegateCommand(AboutMethod);
DeleteIconsCommand = new DelegateCommand(DeleteIconsMethod);
DeleteMediaInfoCommand = new DelegateCommand(DeleteMediaInfo);
CustomIconsCommand = new DelegateCommand(delegate
{
_dialogService.ShowCustomIconWindow(
Expand Down Expand Up @@ -466,6 +468,23 @@ private void InitializeDelegates()
});
}

private void DeleteMediaInfo()
{
if (Directory.Exists(SelectedFolder))
{
if (MessageBox.Show(CustomMessageBox.Ask(LangProvider.GetLang("DeleteMediaInfoConfirmation"),
LangProvider.GetLang("ConfirmMediaInfoDeletion"))) == System.Windows.MessageBoxResult.Yes)
{
Util.DeleteMediaInfoFromSubfolders(SelectedFolder);
}
}
else
{
MessageBox.Show(CustomMessageBox.Error(LangProvider.GetLang("DirectoryIsEmpty"),
LangProvider.GetLang("EmptyDirectory")));
}
}

private void InitializeProperties()
{
Fnames = new List<string>();
Expand Down
3 changes: 3 additions & 0 deletions FoliCon/Views/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@
<MenuItem x:Name="MenuDeleteIconsbtn" Header="{ex:Lang Key={x:Static langs:LangKeys.DeleteIcons}}"
ToolTip="{ex:Lang Key={x:Static langs:LangKeys.DeleteIconsTooltip}}"
Command="{Binding DeleteIconsCommand}" />
<MenuItem x:Name="MenuDeleteMediaInfoBtn" Header="{ex:Lang Key={x:Static langs:LangKeys.DeleteMediaInfo}}"
ToolTip="{ex:Lang Key={x:Static langs:LangKeys.DeleteMediaInfoTooltip}}"
Command="{Binding DeleteMediaInfoCommand}" />
<MenuItem x:Name="MenuCustomIconsbtn" Header="{ex:Lang Key={x:Static langs:LangKeys.HaveIcons}}"
ToolTip="{ex:Lang Key={x:Static langs:LangKeys.HaveIconsTooltip}}"
Command="{Binding CustomIconsCommand}" />
Expand Down
2 changes: 2 additions & 0 deletions Folicon.sln.DotSettings
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:Boolean x:Key="/Default/UserDictionary/Words/=langs/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>

0 comments on commit 5d55ce8

Please sign in to comment.