Add button interactions
This commit is contained in:
@@ -29,7 +29,6 @@
|
||||
|
||||
<!--Working Directory-->
|
||||
<TextBlock Grid.Column="0" Grid.Row="2" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="5" Text="Working Directory:" />
|
||||
<TextBox Grid.Column="1" Grid.Row="2" Margin="5" VerticalContentAlignment="Center" Text="{Binding ApplicationWorkingDirectory}" />
|
||||
<Button Grid.Column="2" Grid.Row="2" Margin="5" Padding="5,2" Content="Browse" Click="Button_WorkingDirectory" />
|
||||
<TextBox Grid.Column="1" Grid.Row="2" Grid.ColumnSpan="2" Margin="5" VerticalContentAlignment="Center" Text="{Binding ApplicationWorkingDirectory}" />
|
||||
</Grid>
|
||||
</UserControl>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
@@ -11,7 +12,7 @@ using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
using Microsoft.Win32;
|
||||
|
||||
namespace ExeLauncher.GUI
|
||||
{
|
||||
@@ -59,12 +60,20 @@ namespace ExeLauncher.GUI
|
||||
|
||||
private void Button_Path(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var dialog = new OpenFileDialog()
|
||||
{
|
||||
AddExtension = true,
|
||||
DefaultExt = ".exe",
|
||||
FileName = "Run.exe",
|
||||
Filter = "Executable|*.exe"
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
private void Button_WorkingDirectory(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (dialog.ShowDialog() == true)
|
||||
{
|
||||
ApplicationPath = dialog.FileName;
|
||||
|
||||
ApplicationWorkingDirectory = Path.GetDirectoryName(ApplicationPath) ?? "";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
@@ -19,10 +21,41 @@ namespace ExeLauncher.GUI
|
||||
/// <summary>
|
||||
/// Interaction logic for MainWindow.xaml
|
||||
/// </summary>
|
||||
public partial class MainWindow : Window
|
||||
public partial class MainWindow : Window, INotifyPropertyChanged
|
||||
{
|
||||
public string ApplicationName { get; set; } = "";
|
||||
public string ApplicationIconPath { get; set; } = "";
|
||||
public event PropertyChangedEventHandler? PropertyChanged;
|
||||
|
||||
private string _appName = "";
|
||||
|
||||
public string ApplicationName
|
||||
{
|
||||
get => _appName;
|
||||
set
|
||||
{
|
||||
if (_appName != value)
|
||||
{
|
||||
_appName = value;
|
||||
|
||||
NotifyPropertyChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private string _applicationIconPath = "";
|
||||
|
||||
public string ApplicationIconPath
|
||||
{
|
||||
get => _applicationIconPath;
|
||||
set
|
||||
{
|
||||
if (_applicationIconPath != value)
|
||||
{
|
||||
_applicationIconPath = value;
|
||||
|
||||
NotifyPropertyChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public ObservableCollection<ApplicationModel> Applications { get; set; }
|
||||
|
||||
@@ -38,7 +71,7 @@ namespace ExeLauncher.GUI
|
||||
|
||||
private void Button_Icon(object sender, RoutedEventArgs e)
|
||||
{
|
||||
|
||||
ApplicationIconPath = Program.GetIcon();
|
||||
}
|
||||
|
||||
private void Button_Add(object sender, RoutedEventArgs e)
|
||||
@@ -53,5 +86,10 @@ namespace ExeLauncher.GUI
|
||||
Applications.RemoveAt(Applications.Count - 1);
|
||||
}
|
||||
}
|
||||
|
||||
private void NotifyPropertyChanged([CallerMemberName] string propertyName = "")
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ using System.Windows.Forms;
|
||||
|
||||
namespace ExeLauncher
|
||||
{
|
||||
class Program
|
||||
public class Program
|
||||
{
|
||||
const string Paths = "%Paths%";
|
||||
const string Arguments = "%Arguments%";
|
||||
@@ -62,7 +62,7 @@ namespace ExeLauncher
|
||||
Console.ReadKey(true);
|
||||
}
|
||||
|
||||
private static void CreateExecutable(string location, string paths, string arguments, string workingDirectories, string icon)
|
||||
public static void CreateExecutable(string location, string paths, string arguments, string workingDirectories, string icon)
|
||||
{
|
||||
code = code.Replace(Paths, paths);
|
||||
code = code.Replace(Arguments, arguments);
|
||||
@@ -92,7 +92,7 @@ namespace ExeLauncher
|
||||
}
|
||||
}
|
||||
|
||||
private static string GetIcon()
|
||||
public static string GetIcon()
|
||||
{
|
||||
var dialog = new OpenFileDialog()
|
||||
{
|
||||
@@ -108,7 +108,7 @@ namespace ExeLauncher
|
||||
return "";
|
||||
}
|
||||
|
||||
private static string GetLocation()
|
||||
public static string GetLocation()
|
||||
{
|
||||
var dialog = new SaveFileDialog()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user