update
This commit is contained in:
@@ -425,7 +425,7 @@ public partial class MainForm : RadForm, IMainApi
|
||||
if (sender is RadMenuItem item && item.Tag is WorkspaceFeature feature)
|
||||
{
|
||||
var ws = wsInfo?.Workspace;
|
||||
if (feature.Configure(ref ws))
|
||||
if (feature.Configure(ws))
|
||||
await LoadNewWorkspace(ws, feature);
|
||||
}
|
||||
}
|
||||
@@ -441,7 +441,7 @@ public partial class MainForm : RadForm, IMainApi
|
||||
if (wsInfo != null)
|
||||
{
|
||||
var ws = wsInfo.Workspace;
|
||||
if (wsInfo.Feature.Configure(ref ws))
|
||||
if (wsInfo.Feature.Configure(ws))
|
||||
await LoadNewWorkspace(ws, wsInfo.Feature);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
<Window xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||
x:Class="ModpackUpdater.Apps.Manager.Ui.MainWindow"
|
||||
Title="MainWindow">
|
||||
Welcome to Avalonia!
|
||||
</Window>
|
||||
<Window
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||
x:Class="ModpackUpdater.Apps.Manager.Ui.MainWindow"
|
||||
Title="Minecraft Modpack Manager"
|
||||
Padding="3">
|
||||
|
||||
|
||||
</Window>
|
||||
@@ -1,268 +0,0 @@
|
||||
namespace ModpackUpdater.Apps.Manager.Ui;
|
||||
|
||||
partial class UpdatesCollectorUi
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
var listViewDetailColumn1 = new Telerik.WinControls.UI.ListViewDetailColumn("Column 0", "Name");
|
||||
var listViewDetailColumn2 = new Telerik.WinControls.UI.ListViewDetailColumn("Column 1", "Current version");
|
||||
var listViewDetailColumn3 = new Telerik.WinControls.UI.ListViewDetailColumn("Column 2", "New version");
|
||||
var listViewDetailColumn4 = new Telerik.WinControls.UI.ListViewDetailColumn("Column 0", "Release");
|
||||
var listViewDetailColumn5 = new Telerik.WinControls.UI.ListViewDetailColumn("Column 1", "Tag");
|
||||
var resources = new System.ComponentModel.ComponentResourceManager(typeof(UpdatesCollectorUi));
|
||||
tableLayoutPanel1 = new TableLayoutPanel();
|
||||
radButton_Continue = new Telerik.WinControls.UI.RadButton();
|
||||
radProgressBar1 = new Telerik.WinControls.UI.RadProgressBar();
|
||||
radSplitContainer1 = new Telerik.WinControls.UI.RadSplitContainer();
|
||||
splitPanel1 = new Telerik.WinControls.UI.SplitPanel();
|
||||
tableLayoutPanel2 = new TableLayoutPanel();
|
||||
radListView_Updates = new Telerik.WinControls.UI.RadListView();
|
||||
splitPanel2 = new Telerik.WinControls.UI.SplitPanel();
|
||||
tableLayoutPanel3 = new TableLayoutPanel();
|
||||
radListView_VersionTags = new Telerik.WinControls.UI.RadListView();
|
||||
radWaitingBar1 = new Telerik.WinControls.UI.RadWaitingBar();
|
||||
dotsSpinnerWaitingBarIndicatorElement1 = new Telerik.WinControls.UI.DotsSpinnerWaitingBarIndicatorElement();
|
||||
tableLayoutPanel1.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)radButton_Continue).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)radProgressBar1).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)radSplitContainer1).BeginInit();
|
||||
radSplitContainer1.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)splitPanel1).BeginInit();
|
||||
splitPanel1.SuspendLayout();
|
||||
tableLayoutPanel2.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)radListView_Updates).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)splitPanel2).BeginInit();
|
||||
splitPanel2.SuspendLayout();
|
||||
tableLayoutPanel3.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)radListView_VersionTags).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)radWaitingBar1).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)this).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// tableLayoutPanel1
|
||||
//
|
||||
tableLayoutPanel1.AutoSize = true;
|
||||
tableLayoutPanel1.ColumnCount = 3;
|
||||
tableLayoutPanel1.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 200F));
|
||||
tableLayoutPanel1.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100F));
|
||||
tableLayoutPanel1.ColumnStyles.Add(new ColumnStyle());
|
||||
tableLayoutPanel1.Controls.Add(radButton_Continue, 2, 0);
|
||||
tableLayoutPanel1.Controls.Add(radProgressBar1, 0, 0);
|
||||
tableLayoutPanel1.Dock = DockStyle.Bottom;
|
||||
tableLayoutPanel1.Location = new Point(0, 419);
|
||||
tableLayoutPanel1.Name = "tableLayoutPanel1";
|
||||
tableLayoutPanel1.RowCount = 1;
|
||||
tableLayoutPanel1.RowStyles.Add(new RowStyle());
|
||||
tableLayoutPanel1.Size = new Size(800, 30);
|
||||
tableLayoutPanel1.TabIndex = 0;
|
||||
//
|
||||
// radButton_Continue
|
||||
//
|
||||
radButton_Continue.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||
radButton_Continue.DialogResult = DialogResult.OK;
|
||||
radButton_Continue.ImageAlignment = ContentAlignment.MiddleRight;
|
||||
radButton_Continue.Location = new Point(647, 3);
|
||||
radButton_Continue.Name = "radButton_Continue";
|
||||
radButton_Continue.Size = new Size(150, 24);
|
||||
radButton_Continue.TabIndex = 0;
|
||||
radButton_Continue.Text = "Continue";
|
||||
radButton_Continue.TextAlignment = ContentAlignment.MiddleLeft;
|
||||
radButton_Continue.TextImageRelation = TextImageRelation.ImageBeforeText;
|
||||
//
|
||||
// radProgressBar1
|
||||
//
|
||||
radProgressBar1.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
|
||||
radProgressBar1.Location = new Point(3, 3);
|
||||
radProgressBar1.Name = "radProgressBar1";
|
||||
radProgressBar1.Size = new Size(194, 24);
|
||||
radProgressBar1.TabIndex = 2;
|
||||
radProgressBar1.Visible = false;
|
||||
//
|
||||
// radSplitContainer1
|
||||
//
|
||||
radSplitContainer1.Controls.Add(splitPanel1);
|
||||
radSplitContainer1.Controls.Add(splitPanel2);
|
||||
radSplitContainer1.Dock = DockStyle.Fill;
|
||||
radSplitContainer1.Location = new Point(0, 0);
|
||||
radSplitContainer1.Name = "radSplitContainer1";
|
||||
radSplitContainer1.Size = new Size(800, 419);
|
||||
radSplitContainer1.TabIndex = 1;
|
||||
radSplitContainer1.TabStop = false;
|
||||
//
|
||||
// splitPanel1
|
||||
//
|
||||
splitPanel1.Controls.Add(tableLayoutPanel2);
|
||||
splitPanel1.Location = new Point(0, 0);
|
||||
splitPanel1.Name = "splitPanel1";
|
||||
splitPanel1.Size = new Size(516, 419);
|
||||
splitPanel1.SizeInfo.AutoSizeScale = new SizeF(0.148241222F, 0F);
|
||||
splitPanel1.SizeInfo.SplitterCorrection = new Size(118, 0);
|
||||
splitPanel1.TabIndex = 0;
|
||||
splitPanel1.TabStop = false;
|
||||
splitPanel1.Text = "splitPanel1";
|
||||
//
|
||||
// tableLayoutPanel2
|
||||
//
|
||||
tableLayoutPanel2.ColumnCount = 1;
|
||||
tableLayoutPanel2.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100F));
|
||||
tableLayoutPanel2.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 20F));
|
||||
tableLayoutPanel2.Controls.Add(radListView_Updates, 0, 0);
|
||||
tableLayoutPanel2.Dock = DockStyle.Fill;
|
||||
tableLayoutPanel2.Location = new Point(0, 0);
|
||||
tableLayoutPanel2.Name = "tableLayoutPanel2";
|
||||
tableLayoutPanel2.RowCount = 1;
|
||||
tableLayoutPanel2.RowStyles.Add(new RowStyle(SizeType.Percent, 100F));
|
||||
tableLayoutPanel2.RowStyles.Add(new RowStyle(SizeType.Absolute, 20F));
|
||||
tableLayoutPanel2.Size = new Size(516, 419);
|
||||
tableLayoutPanel2.TabIndex = 1;
|
||||
//
|
||||
// radListView_Updates
|
||||
//
|
||||
radListView_Updates.AllowEdit = false;
|
||||
radListView_Updates.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
|
||||
listViewDetailColumn1.HeaderText = "Name";
|
||||
listViewDetailColumn2.HeaderText = "Current version";
|
||||
listViewDetailColumn2.Width = 120F;
|
||||
listViewDetailColumn3.HeaderText = "New version";
|
||||
listViewDetailColumn3.Width = 120F;
|
||||
radListView_Updates.Columns.AddRange(new Telerik.WinControls.UI.ListViewDetailColumn[] { listViewDetailColumn1, listViewDetailColumn2, listViewDetailColumn3 });
|
||||
radListView_Updates.ItemSpacing = -1;
|
||||
radListView_Updates.Location = new Point(3, 3);
|
||||
radListView_Updates.Name = "radListView_Updates";
|
||||
radListView_Updates.Size = new Size(510, 413);
|
||||
radListView_Updates.TabIndex = 0;
|
||||
radListView_Updates.ViewType = Telerik.WinControls.UI.ListViewType.DetailsView;
|
||||
radListView_Updates.SelectedItemChanged += RadListView_Updates_SelectedItemChanged;
|
||||
radListView_Updates.ItemRemoved += RadListView_Updates_ItemRemoved;
|
||||
//
|
||||
// splitPanel2
|
||||
//
|
||||
splitPanel2.Controls.Add(tableLayoutPanel3);
|
||||
splitPanel2.Location = new Point(520, 0);
|
||||
splitPanel2.Name = "splitPanel2";
|
||||
splitPanel2.Size = new Size(280, 419);
|
||||
splitPanel2.SizeInfo.AutoSizeScale = new SizeF(-0.148241192F, 0F);
|
||||
splitPanel2.SizeInfo.SplitterCorrection = new Size(-118, 0);
|
||||
splitPanel2.TabIndex = 1;
|
||||
splitPanel2.TabStop = false;
|
||||
splitPanel2.Text = "splitPanel2";
|
||||
//
|
||||
// tableLayoutPanel3
|
||||
//
|
||||
tableLayoutPanel3.ColumnCount = 1;
|
||||
tableLayoutPanel3.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100F));
|
||||
tableLayoutPanel3.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 20F));
|
||||
tableLayoutPanel3.Controls.Add(radListView_VersionTags, 0, 0);
|
||||
tableLayoutPanel3.Dock = DockStyle.Fill;
|
||||
tableLayoutPanel3.Location = new Point(0, 0);
|
||||
tableLayoutPanel3.Name = "tableLayoutPanel3";
|
||||
tableLayoutPanel3.RowCount = 1;
|
||||
tableLayoutPanel3.RowStyles.Add(new RowStyle(SizeType.Percent, 100F));
|
||||
tableLayoutPanel3.RowStyles.Add(new RowStyle(SizeType.Absolute, 20F));
|
||||
tableLayoutPanel3.Size = new Size(280, 419);
|
||||
tableLayoutPanel3.TabIndex = 0;
|
||||
//
|
||||
// radListView_VersionTags
|
||||
//
|
||||
radListView_VersionTags.AllowEdit = false;
|
||||
radListView_VersionTags.AllowRemove = false;
|
||||
radListView_VersionTags.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
|
||||
listViewDetailColumn4.HeaderText = "Release";
|
||||
listViewDetailColumn5.HeaderText = "Tag";
|
||||
radListView_VersionTags.Columns.AddRange(new Telerik.WinControls.UI.ListViewDetailColumn[] { listViewDetailColumn4, listViewDetailColumn5 });
|
||||
radListView_VersionTags.ItemSpacing = -1;
|
||||
radListView_VersionTags.Location = new Point(3, 3);
|
||||
radListView_VersionTags.Name = "radListView_VersionTags";
|
||||
radListView_VersionTags.Size = new Size(274, 413);
|
||||
radListView_VersionTags.TabIndex = 0;
|
||||
radListView_VersionTags.ViewType = Telerik.WinControls.UI.ListViewType.DetailsView;
|
||||
radListView_VersionTags.SelectedIndexChanged += RadListView_VersionTags_SelectedIndexChanged;
|
||||
//
|
||||
// radWaitingBar1
|
||||
//
|
||||
radWaitingBar1.AssociatedControl = radListView_Updates;
|
||||
radWaitingBar1.Location = new Point(220, 171);
|
||||
radWaitingBar1.Name = "radWaitingBar1";
|
||||
radWaitingBar1.Size = new Size(70, 70);
|
||||
radWaitingBar1.TabIndex = 2;
|
||||
radWaitingBar1.Text = "radWaitingBar1";
|
||||
radWaitingBar1.WaitingIndicators.Add(dotsSpinnerWaitingBarIndicatorElement1);
|
||||
radWaitingBar1.WaitingIndicatorSize = new Size(100, 14);
|
||||
radWaitingBar1.WaitingSpeed = 100;
|
||||
radWaitingBar1.WaitingStyle = Telerik.WinControls.Enumerations.WaitingBarStyles.DotsSpinner;
|
||||
//
|
||||
// dotsSpinnerWaitingBarIndicatorElement1
|
||||
//
|
||||
dotsSpinnerWaitingBarIndicatorElement1.Name = "dotsSpinnerWaitingBarIndicatorElement1";
|
||||
//
|
||||
// UpdatesCollectorUi
|
||||
//
|
||||
AutoScaleBaseSize = new Size(7, 15);
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(800, 449);
|
||||
Controls.Add(radSplitContainer1);
|
||||
Controls.Add(tableLayoutPanel1);
|
||||
Icon = (Icon)resources.GetObject("$this.Icon");
|
||||
Name = "UpdatesCollectorUi";
|
||||
StartPosition = FormStartPosition.CenterParent;
|
||||
Text = "Find updates";
|
||||
Shown += UpdatesCollectorUi_Shown;
|
||||
tableLayoutPanel1.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)radButton_Continue).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)radProgressBar1).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)radSplitContainer1).EndInit();
|
||||
radSplitContainer1.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)splitPanel1).EndInit();
|
||||
splitPanel1.ResumeLayout(false);
|
||||
tableLayoutPanel2.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)radListView_Updates).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)splitPanel2).EndInit();
|
||||
splitPanel2.ResumeLayout(false);
|
||||
tableLayoutPanel3.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)radListView_VersionTags).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)radWaitingBar1).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)this).EndInit();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private TableLayoutPanel tableLayoutPanel1;
|
||||
private Telerik.WinControls.UI.RadButton radButton_Continue;
|
||||
private Telerik.WinControls.UI.RadSplitContainer radSplitContainer1;
|
||||
private Telerik.WinControls.UI.SplitPanel splitPanel1;
|
||||
private TableLayoutPanel tableLayoutPanel2;
|
||||
private Telerik.WinControls.UI.SplitPanel splitPanel2;
|
||||
private TableLayoutPanel tableLayoutPanel3;
|
||||
private Telerik.WinControls.UI.RadListView radListView_Updates;
|
||||
private Telerik.WinControls.UI.RadWaitingBar radWaitingBar1;
|
||||
private Telerik.WinControls.UI.RadListView radListView_VersionTags;
|
||||
private Telerik.WinControls.UI.RadProgressBar radProgressBar1;
|
||||
private Telerik.WinControls.UI.DotsSpinnerWaitingBarIndicatorElement dotsSpinnerWaitingBarIndicatorElement1;
|
||||
}
|
||||
@@ -1,136 +0,0 @@
|
||||
using ModpackUpdater.Apps.Manager.Api.Model;
|
||||
using ModpackUpdater.Manager;
|
||||
|
||||
namespace ModpackUpdater.Apps.Manager.Ui;
|
||||
|
||||
public partial class UpdatesCollectorUi : RadForm
|
||||
{
|
||||
public record ModUpdateInfo(KeyValuePair<string, string>[] AvailableVersions, InstallAction Origin)
|
||||
{
|
||||
public int NewVersion { get; set; } = 0;
|
||||
}
|
||||
|
||||
public record ModUpdates(List<ModUpdateInfo> List);
|
||||
|
||||
private readonly IWorkspace workspace;
|
||||
private readonly ModpackFactory factory = new();
|
||||
private readonly InstallAction[] actions;
|
||||
|
||||
public ModUpdates? CurrentUpdates { get; private set; }
|
||||
public ModUpdateInfo? SelectedUpdate => radListView_Updates.SelectedItem?.Value as ModUpdateInfo;
|
||||
public int SelectedVersion => radListView_VersionTags.SelectedIndex;
|
||||
|
||||
public UpdatesCollectorUi(IWorkspace workspace, params InstallAction[] actions)
|
||||
{
|
||||
this.workspace = workspace;
|
||||
this.actions = actions;
|
||||
|
||||
InitializeComponent();
|
||||
|
||||
radListView_Updates.AutoSizeColumnsMode = ListViewAutoSizeColumnsMode.Fill;
|
||||
radListView_VersionTags.AutoSizeColumnsMode = ListViewAutoSizeColumnsMode.Fill;
|
||||
}
|
||||
|
||||
private async Task<ModUpdates> FindUpdates()
|
||||
{
|
||||
var list = new List<ModUpdateInfo>();
|
||||
|
||||
foreach (var action in actions)
|
||||
{
|
||||
var updates = await factory.FindUpdates(action, workspace.ModpackConfig?.MinecraftVersion, workspace.ModpackConfig?.ModLoader ?? ModLoader.Any);
|
||||
|
||||
BeginInvoke(() =>
|
||||
{
|
||||
radProgressBar1.Value1 += 1;
|
||||
radProgressBar1.Text = $"{radProgressBar1.Value1} / {radProgressBar1.Maximum}";
|
||||
});
|
||||
|
||||
if (updates == null || updates.Length == 0 || updates[0].Value == action.SourceTag)
|
||||
continue;
|
||||
|
||||
list.Add(new(updates, action));
|
||||
}
|
||||
|
||||
return new ModUpdates(list);
|
||||
}
|
||||
|
||||
private void LoadUpdates(ModUpdates updates)
|
||||
{
|
||||
radListView_Updates.BeginUpdate();
|
||||
radListView_Updates.Items.Clear();
|
||||
|
||||
foreach (var update in updates.List)
|
||||
{
|
||||
var item = new ListViewDataItem(update);
|
||||
UpdateUpdatesItem(item);
|
||||
radListView_Updates.Items.Add(item);
|
||||
}
|
||||
|
||||
radListView_Updates.EndUpdate();
|
||||
}
|
||||
|
||||
private static void UpdateUpdatesItem(ListViewDataItem? item)
|
||||
{
|
||||
if (item?.Value is not ModUpdateInfo updates)
|
||||
return;
|
||||
|
||||
item[0] = updates.Origin.Name;
|
||||
item[1] = updates.Origin.SourceTag;
|
||||
item[2] = updates.AvailableVersions[updates.NewVersion].Value;
|
||||
}
|
||||
|
||||
private void LoadVersions(ModUpdateInfo updates)
|
||||
{
|
||||
radListView_VersionTags.BeginUpdate();
|
||||
radListView_VersionTags.Items.Clear();
|
||||
|
||||
foreach (var kvp in updates.AvailableVersions)
|
||||
{
|
||||
var item = new ListViewDataItem();
|
||||
item[0] = kvp.Key;
|
||||
item[1] = kvp.Value;
|
||||
radListView_VersionTags.Items.Add(item);
|
||||
}
|
||||
|
||||
radListView_VersionTags.SelectedIndex = updates.NewVersion;
|
||||
radListView_VersionTags.EndUpdate();
|
||||
}
|
||||
|
||||
private async void UpdatesCollectorUi_Shown(object sender, EventArgs e)
|
||||
{
|
||||
radWaitingBar1.StartWaiting();
|
||||
radProgressBar1.Value1 = 0;
|
||||
radProgressBar1.Maximum = actions.Length;
|
||||
radProgressBar1.Text = null;
|
||||
radProgressBar1.Visible = true;
|
||||
|
||||
CurrentUpdates = await FindUpdates();
|
||||
LoadUpdates(CurrentUpdates);
|
||||
|
||||
radProgressBar1.Visible = false;
|
||||
radWaitingBar1.StopWaiting();
|
||||
}
|
||||
|
||||
private void RadListView_Updates_SelectedItemChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (SelectedUpdate is ModUpdateInfo updates)
|
||||
LoadVersions(updates);
|
||||
}
|
||||
|
||||
private void RadListView_VersionTags_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
var newIndex = SelectedVersion;
|
||||
|
||||
if (newIndex != -1 && SelectedUpdate is ModUpdateInfo updates)
|
||||
{
|
||||
updates.NewVersion = newIndex;
|
||||
UpdateUpdatesItem(radListView_Updates.SelectedItem);
|
||||
}
|
||||
}
|
||||
|
||||
private void RadListView_Updates_ItemRemoved(object sender, ListViewItemEventArgs e)
|
||||
{
|
||||
if (e.Item?.Value is ModUpdateInfo update && CurrentUpdates is not null && CurrentUpdates.List.Contains(update))
|
||||
CurrentUpdates.List.Remove(update);
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
101
ModpackUpdater.Apps.Manager/Ui/UpdatesCollectorView.axaml
Normal file
101
ModpackUpdater.Apps.Manager/Ui/UpdatesCollectorView.axaml
Normal file
@@ -0,0 +1,101 @@
|
||||
<dialogs:AvaloniaFlyoutBase
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:dialogs="https://git.pilzinsel64.de/pilz-framework/pilz"
|
||||
xmlns:local="clr-namespace:ModpackUpdater.Apps.Manager.Ui"
|
||||
mc:Ignorable="d"
|
||||
d:DesignWidth="600"
|
||||
d:DesignHeight="450"
|
||||
Width="1000"
|
||||
Height="800"
|
||||
x:Class="ModpackUpdater.Apps.Manager.Ui.UpdatesCollectorView"
|
||||
Title="UpdatesCollectorWindow"
|
||||
Loaded="Me_OnLoaded">
|
||||
|
||||
<!-- Main -->
|
||||
<dialogs:AvaloniaFlyoutBase.MainContent>
|
||||
<Grid
|
||||
RowDefinitions="Auto,*"
|
||||
RowSpacing="6"
|
||||
VerticalAlignment="Stretch">
|
||||
|
||||
<!-- TextBox: Search -->
|
||||
<TextBox
|
||||
x:Name="TextBoxSearch"
|
||||
Grid.Row="0"
|
||||
Watermark="Search"
|
||||
TextChanged="TextBoxSearch_OnTextChanged"/>
|
||||
|
||||
<!-- ScrollViewer: Updates -->
|
||||
<ScrollViewer
|
||||
Grid.Row="1">
|
||||
|
||||
<ItemsControl
|
||||
x:Name="ItemsControlUpdates">
|
||||
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate
|
||||
DataType="{x:Type local:UpdatesCollectorView+ModUpdateInfo}">
|
||||
|
||||
<Grid
|
||||
ColumnDefinitions="20*,20*,20*,Auto"
|
||||
ColumnSpacing="6"
|
||||
RowSpacing="6"
|
||||
Margin="3">
|
||||
|
||||
<!-- Label: Name -->
|
||||
<TextBlock
|
||||
Grid.Column="0"
|
||||
VerticalAlignment="Center"
|
||||
Text="{Binding Origin.Name}"/>
|
||||
|
||||
<!-- Label: Version (old) -->
|
||||
<TextBlock
|
||||
Grid.Column="1"
|
||||
VerticalAlignment="Center"
|
||||
Text="{Binding Origin.SourceTag}"/>
|
||||
|
||||
<!-- ComboBox: Version (new) -->
|
||||
<ComboBox
|
||||
HorizontalAlignment="Stretch"
|
||||
Grid.Column="2"
|
||||
ItemsSource="{Binding DisplayVersions}"
|
||||
SelectedIndex="{Binding NewVersion}"/>
|
||||
|
||||
<!-- Button: RemoveUpdate -->
|
||||
<dialogs:ImageButton
|
||||
Grid.Column="3"
|
||||
VerticalAlignment="Center"
|
||||
HorizontalAlignment="Center"
|
||||
Content="Remove"
|
||||
Click="ButtonRemoveUpdate_Click"/>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
</ScrollViewer>
|
||||
</Grid>
|
||||
</dialogs:AvaloniaFlyoutBase.MainContent>
|
||||
|
||||
<!-- Footer -->
|
||||
<dialogs:AvaloniaFlyoutBase.FooterContent>
|
||||
<Panel
|
||||
HorizontalAlignment="Stretch"
|
||||
VerticalAlignment="Stretch">
|
||||
|
||||
<!-- ProgressBar: Status -->
|
||||
<ProgressBar
|
||||
x:Name="ProgressBarStatus"
|
||||
HorizontalAlignment="Stretch"
|
||||
VerticalAlignment="Stretch"/>
|
||||
|
||||
<!-- TextBox: Status -->
|
||||
<TextBlock
|
||||
x:Name="TextBlockStatus"
|
||||
HorizontalAlignment="Stretch"
|
||||
VerticalAlignment="Stretch"/>
|
||||
</Panel>
|
||||
</dialogs:AvaloniaFlyoutBase.FooterContent>
|
||||
</dialogs:AvaloniaFlyoutBase>
|
||||
94
ModpackUpdater.Apps.Manager/Ui/UpdatesCollectorView.axaml.cs
Normal file
94
ModpackUpdater.Apps.Manager/Ui/UpdatesCollectorView.axaml.cs
Normal file
@@ -0,0 +1,94 @@
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Interactivity;
|
||||
using ModpackUpdater.Apps.Manager.Api.Model;
|
||||
using ModpackUpdater.Manager;
|
||||
using Pilz.UI.AvaloniaUI.Dialogs;
|
||||
|
||||
namespace ModpackUpdater.Apps.Manager.Ui;
|
||||
|
||||
public partial class UpdatesCollectorView : AvaloniaFlyoutBase
|
||||
{
|
||||
public record ModUpdateInfo(KeyValuePair<string, string>[] AvailableVersions, InstallAction Origin)
|
||||
{
|
||||
public int NewVersion { get; set; }
|
||||
public IEnumerable<string> DisplayVersions { get; } = AvailableVersions.Select(n =>
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(n.Value) || n.Value == n.Key)
|
||||
return n.Key;
|
||||
return $"{n.Value} ({n.Value})";
|
||||
});
|
||||
}
|
||||
|
||||
public record ModUpdates(IList<ModUpdateInfo> List);
|
||||
|
||||
private readonly IWorkspace workspace;
|
||||
private readonly ModpackFactory factory = new();
|
||||
private readonly InstallAction[] actions;
|
||||
|
||||
public ModUpdates? CurrentUpdates { get; private set; }
|
||||
|
||||
public UpdatesCollectorView(IWorkspace workspace, params InstallAction[] actions)
|
||||
{
|
||||
this.workspace = workspace;
|
||||
this.actions = actions;
|
||||
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private async Task<ModUpdates> FindUpdates()
|
||||
{
|
||||
var list = new ObservableCollection<ModUpdateInfo>();
|
||||
|
||||
ProgressBarStatus.Maximum = actions.Length;
|
||||
|
||||
foreach (var action in actions)
|
||||
{
|
||||
var updates = await factory.FindUpdates(action, workspace.ModpackConfig?.MinecraftVersion, workspace.ModpackConfig?.ModLoader ?? ModLoader.Any);
|
||||
|
||||
ProgressBarStatus.Value += 1;
|
||||
TextBlockStatus.Text = $"{Math.Round(ProgressBarStatus.Value / ProgressBarStatus.Maximum * 100)}";
|
||||
|
||||
if (updates == null || updates.Length == 0 || updates[0].Value == action.SourceTag)
|
||||
continue;
|
||||
|
||||
list.Add(new(updates, action));
|
||||
}
|
||||
|
||||
return new ModUpdates(list);
|
||||
}
|
||||
|
||||
protected override void OnLoadData(DoWorkEventArgs e)
|
||||
{
|
||||
e.Result = Task.Run(FindUpdates).Result;
|
||||
}
|
||||
|
||||
protected override void OnLoadDataCompleted(RunWorkerCompletedEventArgs e)
|
||||
{
|
||||
if (e.Result is ModUpdates updates)
|
||||
ItemsControlUpdates.ItemsSource = (CurrentUpdates = updates).List;
|
||||
}
|
||||
|
||||
private void Me_OnLoaded(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
|
||||
private void TextBoxSearch_OnTextChanged(object? sender, TextChangedEventArgs e)
|
||||
{
|
||||
var searchString = TextBoxSearch.Text?.Trim().ToLowerInvariant();
|
||||
var hasNoSearch = string.IsNullOrWhiteSpace(searchString);
|
||||
|
||||
foreach (var item in ItemsControlUpdates.Items.OfType<Grid>())
|
||||
{
|
||||
item.IsVisible = hasNoSearch || (item.Name != null && item.Name.Contains(searchString!, StringComparison.InvariantCultureIgnoreCase));
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonRemoveUpdate_Click(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
if (sender is Button button && button.DataContext is ModUpdateInfo update)
|
||||
CurrentUpdates?.List.Remove(update);
|
||||
}
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
<Window xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
mc:Ignorable="d" d:DesignWidth="600" d:DesignHeight="450"
|
||||
Width="600" Height="600"
|
||||
x:Class="ModpackUpdater.Apps.Manager.Ui.UpdatesCollectorWindow"
|
||||
Title="UpdatesCollectorWindow">
|
||||
|
||||
</Window>
|
||||
@@ -1,33 +0,0 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using ModpackUpdater.Apps.Manager.Api.Model;
|
||||
using ModpackUpdater.Manager;
|
||||
|
||||
namespace ModpackUpdater.Apps.Manager.Ui;
|
||||
|
||||
public partial class UpdatesCollectorWindow : Window
|
||||
{
|
||||
public record ModUpdateInfo(KeyValuePair<string, string>[] AvailableVersions, InstallAction Origin)
|
||||
{
|
||||
public int NewVersion { get; set; } = 0;
|
||||
}
|
||||
|
||||
public record ModUpdates(List<ModUpdateInfo> List);
|
||||
|
||||
private readonly IWorkspace workspace;
|
||||
private readonly ModpackFactory factory = new();
|
||||
private readonly InstallAction[] actions;
|
||||
|
||||
public ModUpdates? CurrentUpdates { get; private set; }
|
||||
public ModUpdateInfo? SelectedUpdate => radListView_Updates.SelectedItem?.Value as ModUpdateInfo;
|
||||
public int SelectedVersion => radListView_VersionTags.SelectedIndex;
|
||||
|
||||
public UpdatesCollectorWindow(IWorkspace workspace, params InstallAction[] actions)
|
||||
{
|
||||
this.workspace = workspace;
|
||||
this.actions = actions;
|
||||
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user