Files
ExeLauncher/ExeLauncher.GUI/AppControl.xaml.cs
2021-12-04 14:54:21 +01:00

78 lines
2.8 KiB
C#

using System;
using System.Collections.Generic;
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 Microsoft.Win32;
namespace ExeLauncher.GUI
{
/// <summary>
/// Logique d'interaction pour AppControl.xaml
/// </summary>
public partial class AppControl : UserControl
{
public string ApplicationPath
{
get { return (string)GetValue(ApplicationPathProperty); }
set { SetValue(ApplicationPathProperty, value); }
}
// Using a DependencyProperty as the backing store for ApplicationPath. This enables animation, styling, binding, etc...
public static readonly DependencyProperty ApplicationPathProperty =
DependencyProperty.Register("ApplicationPath", typeof(string), typeof(AppControl), new PropertyMetadata(""));
public string ApplicationArguments
{
get { return (string)GetValue(ApplicationArgumentsProperty); }
set { SetValue(ApplicationArgumentsProperty, value); }
}
// Using a DependencyProperty as the backing store for ApplicationArguments. This enables animation, styling, binding, etc...
public static readonly DependencyProperty ApplicationArgumentsProperty =
DependencyProperty.Register("ApplicationArguments", typeof(string), typeof(AppControl), new PropertyMetadata(""));
public string ApplicationWorkingDirectory
{
get { return (string)GetValue(ApplicationWorkingDirectoryProperty); }
set { SetValue(ApplicationWorkingDirectoryProperty, value); }
}
// Using a DependencyProperty as the backing store for ApplicationWorkingDirectory. This enables animation, styling, binding, etc...
public static readonly DependencyProperty ApplicationWorkingDirectoryProperty =
DependencyProperty.Register("ApplicationWorkingDirectory", typeof(string), typeof(AppControl), new PropertyMetadata(""));
public AppControl()
{
InitializeComponent();
}
private void Button_Path(object sender, RoutedEventArgs e)
{
var dialog = new OpenFileDialog()
{
AddExtension = true,
DefaultExt = ".exe",
FileName = "Run.exe",
Filter = "Executable|*.exe"
};
if (dialog.ShowDialog() == true)
{
ApplicationPath = dialog.FileName;
ApplicationWorkingDirectory = Path.GetDirectoryName(ApplicationPath) ?? "";
}
}
}
}