Implemented UI

This commit is contained in:
2021-12-04 13:01:52 +01:00
parent 3795774023
commit 0d2f2a6653
3 changed files with 59 additions and 34 deletions

View File

@@ -6,7 +6,7 @@ using System.Threading.Tasks;
namespace ExeLauncher.GUI namespace ExeLauncher.GUI
{ {
internal record ApplicationModel public record ApplicationModel
{ {
public int Number { get; set; } = 1; public int Number { get; set; } = 1;
public string Path { get; set; } = ""; public string Path { get; set; } = "";

View File

@@ -6,7 +6,7 @@
xmlns:local="clr-namespace:ExeLauncher.GUI" xmlns:local="clr-namespace:ExeLauncher.GUI"
mc:Ignorable="d" mc:Ignorable="d"
DataContext="{Binding RelativeSource={RelativeSource Self}}" DataContext="{Binding RelativeSource={RelativeSource Self}}"
Title="MainWindow" Height="450" Width="800"> Title="ExeLauncher" MinHeight="335" Height="480" Width="800">
<DockPanel LastChildFill="True"> <DockPanel LastChildFill="True">
<!--Controls--> <!--Controls-->
<Grid DockPanel.Dock="Bottom" Background="#F5F5F5"> <Grid DockPanel.Dock="Bottom" Background="#F5F5F5">
@@ -16,9 +16,8 @@
</StackPanel> </StackPanel>
</Grid> </Grid>
<!--Apps--> <!--Apps-->
<ScrollViewer> <DockPanel LastChildFill="True" Margin="10">
<StackPanel Margin="10"> <GroupBox DockPanel.Dock="Top" Header="Application Info">
<GroupBox Header="Application Info">
<Grid> <Grid>
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" /> <ColumnDefinition Width="Auto" />
@@ -39,13 +38,28 @@
<Button Grid.Column="2" Grid.Row="1" Margin="5" Padding="5,2" Content="Browse" Click="Button_Icon" /> <Button Grid.Column="2" Grid.Row="1" Margin="5" Padding="5,2" Content="Browse" Click="Button_Icon" />
</Grid> </Grid>
</GroupBox> </GroupBox>
<GroupBox Header="Application 1"> <ListView HorizontalContentAlignment="Stretch" ItemsSource="{Binding Applications}" BorderThickness="0">
<local:AppControl ApplicationPath="C:\Test.exe" /> <ListView.ItemContainerStyle>
<Style TargetType="ListViewItem">
<Setter Property="Focusable" Value="false"/>
<Setter Property="Background" Value="Transparent" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ListViewItem}">
<ContentPresenter />
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ListView.ItemContainerStyle>
<ListView.ItemTemplate>
<DataTemplate>
<GroupBox Header="{Binding Number}" HeaderStringFormat="Application {0}">
<local:AppControl ApplicationPath="{Binding Path}" ApplicationArguments="{Binding Arguments}" ApplicationWorkingDirectory="{Binding WorkingDirectory}" />
</GroupBox> </GroupBox>
<GroupBox Header="Application 2"> </DataTemplate>
<local:AppControl ApplicationPath="C:\Test.exe" /> </ListView.ItemTemplate>
</GroupBox> </ListView>
</StackPanel> </DockPanel>
</ScrollViewer>
</DockPanel> </DockPanel>
</Window> </Window>

View File

@@ -1,5 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
@@ -23,8 +24,15 @@ namespace ExeLauncher.GUI
public string ApplicationName { get; set; } = ""; public string ApplicationName { get; set; } = "";
public string ApplicationIconPath { get; set; } = ""; public string ApplicationIconPath { get; set; } = "";
public ObservableCollection<ApplicationModel> Applications { get; set; }
public MainWindow() public MainWindow()
{ {
Applications = new()
{
new ApplicationModel()
};
InitializeComponent(); InitializeComponent();
} }
@@ -35,12 +43,15 @@ namespace ExeLauncher.GUI
private void Button_Add(object sender, RoutedEventArgs e) private void Button_Add(object sender, RoutedEventArgs e)
{ {
Applications.Add(new ApplicationModel() { Number = Applications.Count + 1 });
} }
private void Button_Remove(object sender, RoutedEventArgs e) private void Button_Remove(object sender, RoutedEventArgs e)
{ {
if (Applications.Count > 1)
{
Applications.RemoveAt(Applications.Count - 1);
}
} }
} }
} }