Skip to content

Commit

Permalink
All in-one installer(auto download dependencies) + multi-lang texts i…
Browse files Browse the repository at this point in the history
…n scan procedure
  • Loading branch information
LordKBX committed May 10, 2020
1 parent 95c226f commit 07abffd
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 38 deletions.
73 changes: 40 additions & 33 deletions AnotherMusicPlayer/Medias.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public partial class MainWindow : Window
private FileSystemWatcher MediatequeWatcher = null;
private double MediatequeTotalScanedSize = 0;
private double MediatequeTotalScanedDuration = 0;
private bool Scanning = false;

Dictionary<string, Dictionary<string, object>> MediatequeBddFiles = new Dictionary<string, Dictionary<string, object>>();
List<string> MediatequeScanedFiles = new List<string>();
Expand All @@ -64,41 +65,10 @@ private async void MediatequeScan(bool DoClean = false)
{
if (System.IO.Directory.Exists(Settings.LibFolder))
{
Scanning = true;
Dispatcher.BeginInvoke(new Action(() => {
LibNavigationPathContener.Children.Clear();
LibNavigationContent.Children.Clear();

TextBlock tb2 = new TextBlock();
tb2.Text = "<< Scan en cours >>, Fichiers trouvés: ";
tb2.FontSize = 8;
LibNavigationPathContener.Children.Add(tb2);

TextBlock tb3 = new TextBlock();
tb3.Text = "" + MediatequeScanedFiles.Count;
tb3.FontSize = 8;
LibNavigationPathContener.Children.Add(tb3);

TextBlock tb4 = new TextBlock();
tb4.Text = ", Taille Totale: ";
tb4.FontSize = 8;
LibNavigationPathContener.Children.Add(tb4);

TextBlock tb5 = new TextBlock();
tb5.Text = "" + MediatequeTotalScanedSize;
tb5.FontSize = 8;
LibNavigationPathContener.Children.Add(tb5);

TextBlock tb6 = new TextBlock();
tb6.Text = ", Durée Totale: ";
tb6.FontSize = 8;
LibNavigationPathContener.Children.Add(tb6);

TextBlock tb7 = new TextBlock();
tb7.Text = "" + MediatequeTotalScanedDuration;
tb7.FontSize = 8;
LibNavigationPathContener.Children.Add(tb7);

LibNavigationContent.Orientation = Orientation.Vertical;
MediatequeBuildNavigationScan();
}));
if (DoClean) {
MediatequeCurrentFolder = null; MediatequeWatcher = null;
Expand Down Expand Up @@ -134,6 +104,7 @@ private async void MediatequeScan(bool DoClean = false)
MediatequeBuildNavigationPath(MediatequeCurrentFolder ?? MediatequeRefFolder);
MediatequeBuildNavigationContent(MediatequeCurrentFolder ?? MediatequeRefFolder);
}));
Scanning = false;
}
}
}
Expand Down Expand Up @@ -294,6 +265,42 @@ private ContextMenu LibMediaCreateContextMenu()
return ct;
}

private void MediatequeBuildNavigationScan()
{
LibNavigationPathContener.Children.Clear();
TextBlock tb2 = new TextBlock();
tb2.Text = "<< " + GetTaductionString("LibMediaScanning") + " >>, " + GetTaductionString("LibMediaFiles") + ": ";
tb2.FontSize = 8;
LibNavigationPathContener.Children.Add(tb2);

TextBlock tb3 = new TextBlock();
tb3.Text = "" + MediatequeScanedFiles.Count;
tb3.FontSize = 8;
LibNavigationPathContener.Children.Add(tb3);

TextBlock tb4 = new TextBlock();
tb4.Text = ", " + GetTaductionString("LibMediaTotalSize") + ": ";
tb4.FontSize = 8;
LibNavigationPathContener.Children.Add(tb4);

TextBlock tb5 = new TextBlock();
tb5.Text = "" + MediatequeTotalScanedSize;
tb5.FontSize = 8;
LibNavigationPathContener.Children.Add(tb5);

TextBlock tb6 = new TextBlock();
tb6.Text = ", " + GetTaductionString("LibMediaTotalDuration") + ": ";
tb6.FontSize = 8;
LibNavigationPathContener.Children.Add(tb6);

TextBlock tb7 = new TextBlock();
tb7.Text = "" + MediatequeTotalScanedDuration;
tb7.FontSize = 8;
LibNavigationPathContener.Children.Add(tb7);

LibNavigationContent.Orientation = Orientation.Vertical;
}

private void MediatequeBuildNavigationPath(Folder fold) {
LibNavigationPathContener.Children.Clear();
MediatequeCurrentFolder = fold;
Expand Down
1 change: 1 addition & 0 deletions AnotherMusicPlayer/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ private void ParamsLanguageVals_SelectionChanged(object sender, SelectionChanged
Settings.Lang = (string)item.Tag;
Settings.SaveSettings();
Traduction();
if (Scanning) { MediatequeBuildNavigationScan(); }
}

private void ParamsConvKeepVals_SelectionChanged(object sender, SelectionChangedEventArgs e)
Expand Down
5 changes: 5 additions & 0 deletions AnotherMusicPlayer/Traduction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,10 @@ private void Traduction()
Resources.MergedDictionaries[1].Clear();
Resources.MergedDictionaries[1] = new ResourceDictionary { Source = new Uri(BaseDir + "Traductions" + Path.DirectorySeparatorChar + end + ".xaml", UriKind.Absolute) };
}

private string GetTaductionString(string reference) {
try { return (string)Resources.MergedDictionaries[1][reference]; }
catch { return ""; }
}
}
}
5 changes: 5 additions & 0 deletions AnotherMusicPlayer/Traductions/en.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,9 @@
<sys:String x:Key="ParamsLibFolderSelectorBlockerTitle">Directory</sys:String>

<sys:String x:Key="ParamsLibItemContextMenuItem1">Add to PlayList</sys:String>

<sys:String x:Key="LibMediaScanning">Scanning</sys:String>
<sys:String x:Key="LibMediaFiles">Files</sys:String>
<sys:String x:Key="LibMediaTotalSize">Total Size</sys:String>
<sys:String x:Key="LibMediaTotalDuration">Total Duration</sys:String>
</ResourceDictionary>
5 changes: 5 additions & 0 deletions AnotherMusicPlayer/Traductions/fr.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,9 @@
<sys:String x:Key="ParamsLibFolderSelectorBlockerTitle">Dossier</sys:String>

<sys:String x:Key="ParamsLibItemContextMenuItem1">Ajouter à la liste de lecture</sys:String>

<sys:String x:Key="LibMediaScanning">Scan en cours</sys:String>
<sys:String x:Key="LibMediaFiles">Fichiers trouvés</sys:String>
<sys:String x:Key="LibMediaTotalSize">Taille Totale</sys:String>
<sys:String x:Key="LibMediaTotalDuration">Durée Totale</sys:String>
</ResourceDictionary>
30 changes: 25 additions & 5 deletions build.iss
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!

#define MyAppName "Another Music Player"
#define MyAppVersion "0.1.2"
#define MyAppVersion "0.1.2.1"
#define MyAppPublisher "LordKBX WorkShop"
#define MyAppURL "https://github.com/LordKBX/Another-Music-Player"
#define MyAppExeName "AnotherMusicPlayer.exe"
#define RunTimeName "Install Runtime .NET CORE 3.1.3"

[Setup]
; NOTE: The value of AppId uniquely identifies this application. Do not use the same AppId value in installers for other applications.
Expand Down Expand Up @@ -35,7 +36,9 @@ WizardStyle=modern

[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"
Name: "french"; MessagesFile: "compiler:Languages\French.isl"
Name: "french"; MessagesFile: "compiler:Languages\French.isl"

#include ReadReg(HKEY_LOCAL_MACHINE,'Software\Sherlock Software\InnoTools\Downloader','ScriptPath','');

[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
Expand All @@ -51,18 +54,35 @@ Name: "{autoprograms}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
Name: "{autodesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon
Name: "{userappdata}\Microsoft\Internet Explorer\Quick Launch\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: quicklaunchicon

[Run]
[Run]
Filename: "{tmp}\setup-runtime.exe"; Description: "Run installer .NET Core 3.1.3(do not skip if download additional elements page was show)"; Parameters: "/install /quiet"; Flags: skipifdoesntexist shellexec waituntilterminated
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent

[Code]
procedure InitializeWizard();
begin
{ Welcome page }
{ Hide the labels }
WizardForm.WelcomeLabel1.Visible := True;
WizardForm.WelcomeLabel1.Visible := True;
WizardForm.WelcomeLabel2.Visible := True;
{
WizardForm.WelcomeLabel2.Font.Color := clRed;
WizardForm.WelcomeLabel2.Font.Size := 10;
WizardForm.WelcomeLabel2.Caption := 'This application require the framework ".NET CORE 3.1", Go to'
+ #13#10 + ' https://dotnet.microsoft.com/download/dotnet-core/3.1'
+ #13#10 + ' Section "Desktop Runtime"';
end;
}
if not RegKeyExists(HKEY_LOCAL_MACHINE, 'SOFTWARE\\Classes\\Installer\\Dependencies\\dotnet_apphost_pack_24.76.28628_x64_x86') then
begin
itd_init;
{ if IsWin64 then
else }
itd_addfile('http://download.visualstudio.microsoft.com/download/pr/7cd5c874-5d11-4e72-81f0-4a005d956708/0eb310169770c893407169fc3abaac4f/windowsdesktop-runtime-3.1.3-win-x86.exe',expandconstant('{tmp}\setup-runtime.exe'))
{ ; }
//Start the download after the "Ready to install" screen is shown
itd_downloadafter(wpReady);
end;
end;

0 comments on commit 07abffd

Please sign in to comment.