update
This commit is contained in:
@@ -6,8 +6,10 @@
|
||||
xmlns:modpackUpdater="clr-namespace:ModpackUpdater;assembly=ModpackUpdater"
|
||||
xmlns:local="clr-namespace:ModpackUpdater.Apps.Manager.Ui"
|
||||
xmlns:manager="clr-namespace:ModpackUpdater.Apps.Manager"
|
||||
xmlns:vm="clr-namespace:ModpackUpdater.Apps.Manager.Ui.Models"
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||
x:Class="ModpackUpdater.Apps.Manager.Ui.MainWindow"
|
||||
x:DataType="vm:MainWindowViewModel"
|
||||
Title="Minecraft Modpack Manager"
|
||||
Padding="3">
|
||||
|
||||
@@ -47,19 +49,51 @@
|
||||
Grid.Column="0"
|
||||
Margin="3"/>
|
||||
|
||||
<!-- ... -->
|
||||
<DataGrid
|
||||
x:Name="DataGridActions"
|
||||
Grid.Column="1"
|
||||
Margin="3"
|
||||
ItemsSource="{Binding Actions}"
|
||||
SelectedItem="{Binding SelectedAction}">
|
||||
|
||||
<DataGrid.Columns>
|
||||
<DataGridTextColumn
|
||||
Header="Id"
|
||||
Binding="{Binding InheritedId}"/>
|
||||
|
||||
<DataGridTextColumn
|
||||
Header="Side"
|
||||
Binding="{Binding InheritedSide}"/>
|
||||
|
||||
<DataGridTextColumn
|
||||
Header="Update type"
|
||||
Binding="{Binding InheritedUpdateType}"
|
||||
IsVisible="{Binding IsUpdate}"/>
|
||||
|
||||
<DataGridTextColumn
|
||||
Header="Source type"
|
||||
Binding="{Binding InheritedSourceType}"/>
|
||||
|
||||
<DataGridTextColumn
|
||||
Header="Dest path"
|
||||
Binding="{Binding InheritedDestPath}"/>
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
|
||||
<ScrollViewer
|
||||
x:Name="ScrollViewerInstallAction"
|
||||
Grid.Column="2"
|
||||
Margin="3"
|
||||
DataContext="{Binding SelectedAction}"
|
||||
VerticalScrollBarVisibility="Auto">
|
||||
|
||||
<StackPanel>
|
||||
<StackPanel
|
||||
Spacing="6">
|
||||
|
||||
<!-- Update -->
|
||||
<StackPanel
|
||||
x:Name="StackPanelUpdate"
|
||||
Margin="3"
|
||||
Spacing="6">
|
||||
Spacing="6"
|
||||
IsVisible="{Binding IsUpdate}">
|
||||
|
||||
<!-- Header -->
|
||||
<StackPanel Orientation="Horizontal" Spacing="6">
|
||||
@@ -69,7 +103,9 @@
|
||||
|
||||
<!-- Inherit from -->
|
||||
<Label Content="Inherit from" Target="TextBoxUpdateActionInheritFrom"/>
|
||||
<TextBox x:Name="TextBoxUpdateActionInheritFrom" Text="{Binding InheritFrom, DataType=modpackUpdater:UpdateAction}"/>
|
||||
<TextBox
|
||||
x:Name="TextBoxUpdateActionInheritFrom"
|
||||
Text="{Binding InheritFrom}"/>
|
||||
|
||||
<!-- Source type -->
|
||||
<Label Content="Source type" Target="ComboBoxUpdateActionSourceType"/>
|
||||
@@ -78,18 +114,17 @@
|
||||
ItemsSource="{x:Static local:MainWindow.UpdateActionTypes}"
|
||||
DisplayMemberBinding="{Binding Value}"
|
||||
SelectedValueBinding="{Binding Key}"
|
||||
SelectedValue="{Binding Type, DataType=modpackUpdater:UpdateAction}"/>
|
||||
SelectedValue="{Binding Type}"/>
|
||||
|
||||
<!-- Is Directory -->
|
||||
<CheckBox
|
||||
x:Name="CheckBoxUpdateActionIsDir"
|
||||
Content="Is Directory"
|
||||
IsChecked="{Binding IsDirectory, DataType=modpackUpdater:UpdateAction}"/>
|
||||
IsChecked="{Binding IsDirectory}"/>
|
||||
</StackPanel>
|
||||
|
||||
<!-- General -->
|
||||
<StackPanel
|
||||
Margin="3"
|
||||
Spacing="6">
|
||||
|
||||
<!-- Header -->
|
||||
@@ -100,11 +135,15 @@
|
||||
|
||||
<!-- Id -->
|
||||
<Label Content="Id" Target="TextBoxInstallActionId"/>
|
||||
<TextBox x:Name="TextBoxInstallActionId" Text="{Binding Id, DataType=modpackUpdater:InstallAction}"/>
|
||||
<TextBox
|
||||
x:Name="TextBoxInstallActionId"
|
||||
Text="{Binding Id}"/>
|
||||
|
||||
<!-- Name -->
|
||||
<Label Content="Name" Target="TextBoxInstallActionName"/>
|
||||
<TextBox x:Name="TextBoxInstallActionName" Text="{Binding Name, DataType=modpackUpdater:InstallAction}"/>
|
||||
<TextBox
|
||||
x:Name="TextBoxInstallActionName"
|
||||
Text="{Binding Name}"/>
|
||||
|
||||
<!-- Side -->
|
||||
<Label Content="Side" Target="ComboBoxInstallActionSide"/>
|
||||
@@ -113,18 +152,17 @@
|
||||
ItemsSource="{x:Static local:MainWindow.Sides}"
|
||||
DisplayMemberBinding="{Binding Value}"
|
||||
SelectedValueBinding="{Binding Key}"
|
||||
SelectedValue="{Binding Side, DataType=modpackUpdater:InstallAction}"/>
|
||||
SelectedValue="{Binding Side}"/>
|
||||
|
||||
<!-- Is Extra -->
|
||||
<CheckBox
|
||||
x:Name="CheckBoxInstallActionIsExtra"
|
||||
Content="Is Extra"
|
||||
IsChecked="{Binding IsExtra, DataType=modpackUpdater:InstallAction}"/>
|
||||
IsChecked="{Binding IsExtra}"/>
|
||||
</StackPanel>
|
||||
|
||||
<!-- Destination -->
|
||||
<StackPanel
|
||||
Margin="3"
|
||||
Spacing="6">
|
||||
|
||||
<!-- Header -->
|
||||
@@ -134,12 +172,13 @@
|
||||
</StackPanel>
|
||||
|
||||
<!-- Destination path -->
|
||||
<TextBox x:Name="TextBoxInstallDestPath" Text="{Binding DestPath, DataType=modpackUpdater:InstallAction}"/>
|
||||
<TextBox
|
||||
x:Name="TextBoxInstallDestPath"
|
||||
Text="{Binding DestPath}"/>
|
||||
</StackPanel>
|
||||
|
||||
<!-- Source -->
|
||||
<StackPanel
|
||||
Margin="3"
|
||||
Spacing="6">
|
||||
|
||||
<!-- Header -->
|
||||
@@ -155,37 +194,48 @@
|
||||
ItemsSource="{x:Static local:MainWindow.SourceTypes}"
|
||||
DisplayMemberBinding="{Binding Value}"
|
||||
SelectedValueBinding="{Binding Key}"
|
||||
SelectedValue="{Binding SourceType, DataType=modpackUpdater:InstallAction}"/>
|
||||
SelectedValue="{Binding SourceType}"/>
|
||||
|
||||
<!-- Is Zip -->
|
||||
<CheckBox
|
||||
x:Name="CheckBoxInstallActionIsZip"
|
||||
Content="Is Zip archive"
|
||||
IsChecked="{Binding IsZip, DataType=modpackUpdater:InstallAction}"/>
|
||||
IsChecked="{Binding IsZip}"/>
|
||||
|
||||
<!-- Source owner -->
|
||||
<Label Content="Source owner" Target="TextBoxInstallActionSourceOwner"/>
|
||||
<TextBox x:Name="TextBoxInstallActionSourceOwner" Text="{Binding SourceOwner, DataType=modpackUpdater:InstallAction}"/>
|
||||
<TextBox
|
||||
x:Name="TextBoxInstallActionSourceOwner"
|
||||
Text="{Binding SourceOwner}"/>
|
||||
|
||||
<!-- Source name -->
|
||||
<Label Content="Source name" Target="TextBoxInstallActionSourceName"/>
|
||||
<TextBox x:Name="TextBoxInstallActionSourceName" Text="{Binding SourceName, DataType=modpackUpdater:InstallAction}"/>
|
||||
<TextBox
|
||||
x:Name="TextBoxInstallActionSourceName"
|
||||
Text="{Binding SourceName}"/>
|
||||
|
||||
<!-- Source RegEx -->
|
||||
<Label Content="Source RegEx" Target="TextBoxInstallActionSourceRegEx"/>
|
||||
<TextBox x:Name="TextBoxInstallActionSourceRegEx" Text="{Binding SourceRegex, DataType=modpackUpdater:InstallAction}"/>
|
||||
<TextBox
|
||||
x:Name="TextBoxInstallActionSourceRegEx"
|
||||
Text="{Binding SourceRegex}"/>
|
||||
|
||||
<!-- Source url -->
|
||||
<Label Content="Source URL" Target="TextBoxInstallActionSourceUrl"/>
|
||||
<TextBox x:Name="TextBoxInstallActionSourceUrl" Text="{Binding SourceUrl, DataType=modpackUpdater:InstallAction}"/>
|
||||
<TextBox
|
||||
x:Name="TextBoxInstallActionSourceUrl" Text="{Binding SourceUrl}"/>
|
||||
|
||||
<!-- Zip archive path -->
|
||||
<Label Content="ZIP archive path" Target="TextBoxInstallActionZipArchivePath"/>
|
||||
<TextBox x:Name="TextBoxInstallActionZipArchivePath" Text="{Binding SourceUrl, DataType=modpackUpdater:InstallAction}"/>
|
||||
<TextBox
|
||||
x:Name="TextBoxInstallActionZipArchivePath"
|
||||
Text="{Binding SourceUrl}"/>
|
||||
|
||||
<!-- Source path -->
|
||||
<Label Content="Source path" Target="TextBoxInstallActionSourcePath"/>
|
||||
<TextBox x:Name="TextBoxInstallActionSourcePath" Text="{Binding SrcPath, DataType=modpackUpdater:UpdateAction}"/>
|
||||
<TextBox
|
||||
x:Name="TextBoxInstallActionSourcePath"
|
||||
Text="{Binding SrcPath}"/>
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel
|
||||
@@ -200,7 +250,9 @@
|
||||
|
||||
<!-- Website -->
|
||||
<Label Content="Website" Target="TextBoxInstallActionWebsite"/>
|
||||
<TextBox x:Name="TextBoxInstallActionWebsite" Text="{Binding Website, DataType=modpackUpdater:InstallAction}"/>
|
||||
<TextBox
|
||||
x:Name="TextBoxInstallActionWebsite"
|
||||
Text="{Binding Website}"/>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</ScrollViewer>
|
||||
|
||||
180
ModpackUpdater.Apps.Manager/Ui/Models/InstallActionViewModel.cs
Normal file
180
ModpackUpdater.Apps.Manager/Ui/Models/InstallActionViewModel.cs
Normal file
@@ -0,0 +1,180 @@
|
||||
using System.ComponentModel;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace ModpackUpdater.Apps.Manager.Ui.Models;
|
||||
|
||||
public class InstallActionViewModel(InstallAction action, IActionSet baseActions) : INotifyPropertyChanged
|
||||
{
|
||||
#region Implementation of INotifyPropertyChanged
|
||||
|
||||
public event PropertyChangedEventHandler? PropertyChanged;
|
||||
|
||||
protected virtual void OnPropertyChanged([CallerMemberName] string? propertyName = null)
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
|
||||
#endregion Implementation of INotifyPropertyChanged
|
||||
|
||||
public static Dictionary<SourceType, string> SourceTypes { get; } = Enum.GetValues<SourceType>().ToDictionary(n => n, n => Enum.GetName(n)!);
|
||||
public static Dictionary<Side, string> Sides { get; } = Enum.GetValues<Side>().ToDictionary(n => n, n => Enum.GetName(n)!);
|
||||
public static Dictionary<UpdateActionType, string> UpdateActionTypes { get; } = Enum.GetValues<UpdateActionType>().ToDictionary(n => n, n => Enum.GetName(n)!);
|
||||
|
||||
public InstallAction Action => action;
|
||||
private InstallAction? Base => action is UpdateAction ua ? baseActions.Actions.FirstOrDefault(n => n.Id == ua.InheritFrom) : null;
|
||||
private InstallAction Inherited => Base ?? action;
|
||||
|
||||
public bool IsUpdate => action is UpdateAction;
|
||||
|
||||
public string InheritedId => action is UpdateAction ua && !string.IsNullOrWhiteSpace(ua.InheritFrom) ? ua.InheritFrom : action.Id;
|
||||
public string InheritedSide => Sides[Inherited.Side];
|
||||
public string InheritedUpdateType => action is UpdateAction ua ? UpdateActionTypes[ua.Type] : string.Empty;
|
||||
public string InheritedSourceType => SourceTypes[Inherited.SourceType];
|
||||
public string InheritedDestPath => Inherited.DestPath;
|
||||
|
||||
public string Id
|
||||
{
|
||||
get => action.Id;
|
||||
set
|
||||
{
|
||||
action.Id = value;
|
||||
OnPropertyChanged();
|
||||
OnPropertyChanged(nameof(InheritedId));
|
||||
}
|
||||
}
|
||||
|
||||
public string Name
|
||||
{
|
||||
get => action.Name;
|
||||
set => action.Name = value;
|
||||
}
|
||||
|
||||
public string Website
|
||||
{
|
||||
get => action.Website;
|
||||
set => action.Website = value;
|
||||
}
|
||||
|
||||
public bool IsZip
|
||||
{
|
||||
get => action.IsZip;
|
||||
set => action.IsZip = value;
|
||||
}
|
||||
|
||||
public string ZipPath
|
||||
{
|
||||
get => action.ZipPath;
|
||||
set => action.ZipPath = value;
|
||||
}
|
||||
|
||||
public string DestPath
|
||||
{
|
||||
get => action.DestPath;
|
||||
set
|
||||
{
|
||||
action.DestPath = value;
|
||||
OnPropertyChanged();
|
||||
OnPropertyChanged(nameof(InheritedDestPath));
|
||||
}
|
||||
}
|
||||
|
||||
public string SourceUrl
|
||||
{
|
||||
get => action.SourceUrl;
|
||||
set => action.SourceUrl = value;
|
||||
}
|
||||
|
||||
public SourceType SourceType
|
||||
{
|
||||
get => action.SourceType;
|
||||
set
|
||||
{
|
||||
action.SourceType = value;
|
||||
OnPropertyChanged();
|
||||
OnPropertyChanged(nameof(InheritedSourceType));
|
||||
}
|
||||
}
|
||||
|
||||
public string SourceOwner
|
||||
{
|
||||
get => action.SourceOwner;
|
||||
set => action.SourceOwner = value;
|
||||
}
|
||||
|
||||
public string SourceName
|
||||
{
|
||||
get => action.SourceName;
|
||||
set => action.SourceName = value;
|
||||
}
|
||||
|
||||
public string SourceRegex
|
||||
{
|
||||
get => action.SourceRegex;
|
||||
set => action.SourceRegex = value;
|
||||
}
|
||||
|
||||
public string SourceTag
|
||||
{
|
||||
get => action.SourceTag;
|
||||
set => action.SourceTag = value;
|
||||
}
|
||||
|
||||
public Side Side
|
||||
{
|
||||
get => action.Side;
|
||||
set
|
||||
{
|
||||
action.Side = value;
|
||||
OnPropertyChanged();
|
||||
OnPropertyChanged(nameof(InheritedSide));
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsExtra
|
||||
{
|
||||
get => action.IsExtra;
|
||||
set => action.IsExtra = value;
|
||||
}
|
||||
|
||||
public UpdateActionType Type
|
||||
{
|
||||
get => action is UpdateAction ua ? ua.Type : default;
|
||||
set
|
||||
{
|
||||
if (action is UpdateAction ua)
|
||||
ua.Type = value;
|
||||
}
|
||||
}
|
||||
|
||||
public string SrcPath
|
||||
{
|
||||
get => action is UpdateAction ua ? ua.SrcPath : string.Empty;
|
||||
set
|
||||
{
|
||||
if (action is UpdateAction ua)
|
||||
ua.SrcPath = value;
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsDirectory
|
||||
{
|
||||
get => action is UpdateAction ua && ua.IsDirectory;
|
||||
set
|
||||
{
|
||||
if (action is UpdateAction ua)
|
||||
ua.IsDirectory = value;
|
||||
}
|
||||
}
|
||||
|
||||
public string InheritFrom
|
||||
{
|
||||
get => action is UpdateAction ua ? ua.InheritFrom : string.Empty;
|
||||
set
|
||||
{
|
||||
if (action is UpdateAction ua)
|
||||
ua.InheritFrom = value;
|
||||
OnPropertyChanged();
|
||||
OnPropertyChanged(nameof(InheritedId));
|
||||
}
|
||||
}
|
||||
}
|
||||
24
ModpackUpdater.Apps.Manager/Ui/Models/MainWindowViewModel.cs
Normal file
24
ModpackUpdater.Apps.Manager/Ui/Models/MainWindowViewModel.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using System.ComponentModel;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace ModpackUpdater.Apps.Manager.Ui.Models;
|
||||
|
||||
public class MainWindowViewModel : INotifyPropertyChanged
|
||||
{
|
||||
#region Implementation of INotifyPropertyChanged
|
||||
|
||||
public event PropertyChangedEventHandler? PropertyChanged;
|
||||
|
||||
protected virtual void OnPropertyChanged([CallerMemberName] string? propertyName = null)
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
|
||||
#endregion Implementation of INotifyPropertyChanged
|
||||
|
||||
public bool IsUpdate { get; set; }
|
||||
|
||||
public List<InstallActionViewModel> Actions { get; } = [];
|
||||
|
||||
public InstallActionViewModel? SelectedAction { get; set; }
|
||||
}
|
||||
Reference in New Issue
Block a user