Dependency checking
This commit is contained in:
parent
bbb7f5e26c
commit
574d128cb6
29
Installer/Dexif_Installer/Helper.cs
Normal file
29
Installer/Dexif_Installer/Helper.cs
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Dexif_Installer {
|
||||||
|
class Helper {
|
||||||
|
// https://stackoverflow.com/a/3856090/4708786
|
||||||
|
public static bool ExistsOnPath(string fileName) {
|
||||||
|
return GetFullPath(fileName) != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string GetFullPath(string fileName) {
|
||||||
|
if (File.Exists(fileName)) {
|
||||||
|
return Path.GetFullPath(fileName);
|
||||||
|
}
|
||||||
|
var values = Environment.GetEnvironmentVariable("PATH");
|
||||||
|
foreach (var path in values.Split(Path.PathSeparator)) {
|
||||||
|
var fullPath = Path.Combine(path, fileName);
|
||||||
|
if (File.Exists(fullPath)) {
|
||||||
|
return fullPath;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -6,6 +6,8 @@
|
|||||||
xmlns:fa="http://schemas.fontawesome.io/icons/"
|
xmlns:fa="http://schemas.fontawesome.io/icons/"
|
||||||
xmlns:local="clr-namespace:Dexif_Installer"
|
xmlns:local="clr-namespace:Dexif_Installer"
|
||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
|
WindowStartupLocation="CenterScreen"
|
||||||
|
Loaded="WindowLoaded"
|
||||||
Title="DEXIF Installer" Height="300" Width="510" >
|
Title="DEXIF Installer" Height="300" Width="510" >
|
||||||
<Grid Background="{DynamicResource PolarNight_0_Brush}">
|
<Grid Background="{DynamicResource PolarNight_0_Brush}">
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
|
@ -21,6 +21,7 @@ using System.Windows.Shapes;
|
|||||||
* - Install Exec
|
* - Install Exec
|
||||||
* - Install Reg Keys
|
* - Install Reg Keys
|
||||||
* - Add to "Installed Programs"
|
* - Add to "Installed Programs"
|
||||||
|
* - Add uninstall functionality
|
||||||
*
|
*
|
||||||
* (Very Very Future TODO)
|
* (Very Very Future TODO)
|
||||||
* - Recursion Support for Directories
|
* - Recursion Support for Directories
|
||||||
@ -28,16 +29,53 @@ using System.Windows.Shapes;
|
|||||||
* - Configurable Suffix / Etc. Opts
|
* - Configurable Suffix / Etc. Opts
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Dexif_Installer
|
namespace Dexif_Installer {
|
||||||
{
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Interaction logic for MainWindow.xaml
|
/// Interaction logic for MainWindow.xaml
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class MainWindow : Window
|
public partial class MainWindow : Window {
|
||||||
{
|
public MainWindow() {
|
||||||
public MainWindow()
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void WindowLoaded(object sender, RoutedEventArgs e) {
|
||||||
|
EnsureChocolatey();
|
||||||
|
EnsureExiftool();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void EnsureChocolatey() {
|
||||||
|
String ChocolateyExecutable = "choco.exe";
|
||||||
|
String DefaultInstallPath = "C:\\ProgramData\\chocolatey\\bin\\";
|
||||||
|
if (Helper.ExistsOnPath(DefaultInstallPath + ChocolateyExecutable)) {
|
||||||
|
Status_Chocolatey.Icon = FontAwesome.WPF.FontAwesomeIcon.CheckCircleOutline;
|
||||||
|
Locate_Chocolatey.Content = "Change";
|
||||||
|
Status_Chocolatey.ToolTip = DefaultInstallPath + ChocolateyExecutable;
|
||||||
|
} else if (Helper.ExistsOnPath(ChocolateyExecutable)) {
|
||||||
|
Status_Chocolatey.Icon = FontAwesome.WPF.FontAwesomeIcon.CheckCircleOutline;
|
||||||
|
Locate_Chocolatey.Content = "Change";
|
||||||
|
Status_Chocolatey.ToolTip = Helper.GetFullPath(ChocolateyExecutable);
|
||||||
|
} else {
|
||||||
|
Status_Chocolatey.Icon = FontAwesome.WPF.FontAwesomeIcon.TimesCircleOutline;
|
||||||
|
Status_Chocolatey.ToolTip = "Chocolatey not found.";
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
private void EnsureExiftool() {
|
||||||
|
String ExiftoolExecutable = "exiftool.exe";
|
||||||
|
String DefaultInstallPath = " C:\\ProgramData\\chocolatey\\bin\\";
|
||||||
|
if (Helper.ExistsOnPath(DefaultInstallPath + ExiftoolExecutable)) {
|
||||||
|
Status_Exiftool.Icon = FontAwesome.WPF.FontAwesomeIcon.CheckCircleOutline;
|
||||||
|
Locate_Exiftool.Content = "Change";
|
||||||
|
Status_Exiftool.ToolTip = DefaultInstallPath + ExiftoolExecutable;
|
||||||
|
} else if (Helper.ExistsOnPath(ExiftoolExecutable)) {
|
||||||
|
Status_Exiftool.Icon = FontAwesome.WPF.FontAwesomeIcon.CheckCircleOutline;
|
||||||
|
Locate_Exiftool.Content = "Change";
|
||||||
|
Status_Exiftool.ToolTip = Helper.GetFullPath(ExiftoolExecutable);
|
||||||
|
} else {
|
||||||
|
Status_Exiftool.Icon = FontAwesome.WPF.FontAwesomeIcon.TimesCircleOutline;
|
||||||
|
Status_Exiftool.ToolTip = "Exiftool not found.";
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user