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 { /// /// Logique d'interaction pour AppControl.xaml /// 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) ?? ""; } } } }