From a2e2b20a62161914a18fdebc6a1c442a7837dd89 Mon Sep 17 00:00:00 2001 From: Paul Hebble Date: Wed, 14 Feb 2024 22:32:25 -0600 Subject: [PATCH] Ability to clear auto-installed flag from changeset tab --- GUI/Controls/Changeset.Designer.cs | 133 ++++++++++----- GUI/Controls/Changeset.cs | 178 ++++++++++++-------- GUI/Controls/Changeset.resx | 7 +- GUI/Controls/ManageMods.cs | 52 +++++- GUI/Dialogs/YesNoDialog.Designer.cs | 2 +- GUI/Dialogs/YesNoDialog.cs | 1 + GUI/Localization/de-DE/Changeset.de-DE.resx | 4 +- GUI/Localization/fr-FR/Changeset.fr-FR.resx | 6 +- GUI/Localization/it-IT/Changeset.it-IT.resx | 6 +- GUI/Localization/ja-JP/Changeset.ja-JP.resx | 6 +- GUI/Localization/ko-KR/Changeset.ko-KR.resx | 6 +- GUI/Localization/nl-NL/Changeset.nl-NL.resx | 6 +- GUI/Localization/pl-PL/Changeset.pl-PL.resx | 6 +- GUI/Localization/pt-BR/Changeset.pt-BR.resx | 6 +- GUI/Localization/ru-RU/Changeset.ru-RU.resx | 6 +- GUI/Localization/tr-TR/Changeset.tr-TR.resx | 6 +- GUI/Localization/zh-CN/Changeset.zh-CN.resx | 6 +- GUI/Main/Main.Designer.cs | 1 + GUI/Main/Main.cs | 13 +- GUI/Main/MainChangeset.cs | 8 +- GUI/Model/ModChange.cs | 22 ++- GUI/Properties/Resources.resx | 11 ++ 22 files changed, 321 insertions(+), 171 deletions(-) diff --git a/GUI/Controls/Changeset.Designer.cs b/GUI/Controls/Changeset.Designer.cs index ace396195c..4b0093a16d 100644 --- a/GUI/Controls/Changeset.Designer.cs +++ b/GUI/Controls/Changeset.Designer.cs @@ -30,10 +30,11 @@ private void InitializeComponent() { this.components = new System.ComponentModel.Container(); System.ComponentModel.ComponentResourceManager resources = new SingleAssemblyComponentResourceManager(typeof(Changeset)); - this.ChangesListView = new ThemedListView(); - this.Mod = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.ChangeType = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.Reason = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.ChangesGrid = new System.Windows.Forms.DataGridView(); + this.ModColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.ChangeTypeColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.ReasonsColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.DeleteColumn = new System.Windows.Forms.DataGridViewImageColumn(); this.CloseTheGameLabel = new System.Windows.Forms.Label(); this.BottomButtonPanel = new CKAN.GUI.LeftRightRowPanel(); this.ConfirmChangesButton = new System.Windows.Forms.Button(); @@ -42,39 +43,78 @@ private void InitializeComponent() this.BottomButtonPanel.SuspendLayout(); this.SuspendLayout(); // - // ChangesListView - // - this.ChangesListView.Dock = System.Windows.Forms.DockStyle.Fill; - this.ChangesListView.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.ChangesListView.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { - this.Mod, - this.ChangeType, - this.Reason}); - this.ChangesListView.FullRowSelect = true; - this.ChangesListView.Location = new System.Drawing.Point(-2, 0); - this.ChangesListView.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); - this.ChangesListView.Name = "ChangesListView"; - this.ChangesListView.Size = new System.Drawing.Size(1532, 886); - this.ChangesListView.ShowItemToolTips = true; - this.ChangesListView.TabIndex = 0; - this.ChangesListView.UseCompatibleStateImageBehavior = false; - this.ChangesListView.View = System.Windows.Forms.View.Details; - this.ChangesListView.SelectedIndexChanged += new System.EventHandler(ChangesListView_SelectedIndexChanged); - // - // Mod - // - this.Mod.Width = 332; - resources.ApplyResources(this.Mod, "Mod"); - // - // ChangeType - // - this.ChangeType.Width = 111; - resources.ApplyResources(this.ChangeType, "ChangeType"); - // - // Reason - // - this.Reason.Width = 606; - resources.ApplyResources(this.Reason, "Reason"); + // ChangesGrid + // + this.ChangesGrid.AllowUserToResizeColumns = true; + this.ChangesGrid.AllowUserToOrderColumns = true; + this.ChangesGrid.AllowUserToResizeRows = false; + this.ChangesGrid.AutoGenerateColumns = false; + this.ChangesGrid.BackgroundColor = System.Drawing.SystemColors.Window; + this.ChangesGrid.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; + this.ChangesGrid.Dock = System.Windows.Forms.DockStyle.Fill; + this.ChangesGrid.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { + this.ModColumn, + this.ChangeTypeColumn, + this.ReasonsColumn, + this.DeleteColumn}); + this.ChangesGrid.ColumnHeadersDefaultCellStyle.Padding = new System.Windows.Forms.Padding(1, 3, 1, 3); + this.ChangesGrid.ColumnHeadersDefaultCellStyle.BackColor = System.Drawing.SystemColors.Control; + this.ChangesGrid.ColumnHeadersDefaultCellStyle.ForeColor = System.Drawing.SystemColors.ControlText; + this.ChangesGrid.ColumnHeadersDefaultCellStyle.SelectionBackColor = System.Drawing.SystemColors.Control; + this.ChangesGrid.ColumnHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.Raised; + this.ChangesGrid.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.ChangesGrid.CellBorderStyle = System.Windows.Forms.DataGridViewCellBorderStyle.None; + this.ChangesGrid.DefaultCellStyle.ForeColor = System.Drawing.SystemColors.WindowText; + this.ChangesGrid.EnableHeadersVisualStyles = false; + this.ChangesGrid.Location = new System.Drawing.Point(-2, 0); + this.ChangesGrid.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + this.ChangesGrid.MultiSelect = false; + this.ChangesGrid.Name = "ChangesGrid"; + this.ChangesGrid.RowHeadersVisible = false; + this.ChangesGrid.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; + this.ChangesGrid.ShowCellToolTips = true; + this.ChangesGrid.Size = new System.Drawing.Size(1532, 886); + this.ChangesGrid.TabIndex = 0; + this.ChangesGrid.TabStop = false; + this.ChangesGrid.SelectionChanged += new System.EventHandler(this.ChangesGrid_SelectionChanged); + this.ChangesGrid.DataBindingComplete += new System.Windows.Forms.DataGridViewBindingCompleteEventHandler(this.ChangesGrid_DataBindingComplete); + this.ChangesGrid.CellClick += this.ChangesGrid_CellClick; + // + // ModColumn + // + this.ModColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells; + this.ModColumn.Width = 332; + this.ModColumn.ValueType = typeof(string); + this.ModColumn.DataPropertyName = "Mod"; + this.ModColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable; + resources.ApplyResources(this.ModColumn, "ModColumn"); + // + // ChangeTypeColumn + // + this.ReasonsColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells; + this.ChangeTypeColumn.Width = 111; + this.ChangeTypeColumn.ValueType = typeof(string); + this.ChangeTypeColumn.DataPropertyName = "ChangeType"; + this.ChangeTypeColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable; + resources.ApplyResources(this.ChangeTypeColumn, "ChangeTypeColumn"); + // + // ReasonsColumn + // + this.ReasonsColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; + this.ReasonsColumn.Width = 606; + this.ReasonsColumn.ValueType = typeof(string); + this.ReasonsColumn.DataPropertyName = "Reasons"; + this.ReasonsColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable; + resources.ApplyResources(this.ReasonsColumn, "ReasonsColumn"); + // + // DeleteColumn + // + this.DeleteColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells; + this.DeleteColumn.Width = 200; + this.DeleteColumn.ValueType = typeof(System.Drawing.Bitmap); + this.DeleteColumn.DataPropertyName = "DeleteImage"; + this.DeleteColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable; + resources.ApplyResources(this.DeleteColumn, "DeleteColumn"); // // CloseTheGameLabel // @@ -88,9 +128,9 @@ private void InitializeComponent() this.CloseTheGameLabel.TabIndex = 0; this.CloseTheGameLabel.TextAlign = System.Drawing.ContentAlignment.MiddleRight; resources.ApplyResources(this.CloseTheGameLabel, "CloseTheGameLabel"); - // + // // BottomButtonPanel - // + // this.BottomButtonPanel.RightControls.Add(this.ConfirmChangesButton); this.BottomButtonPanel.RightControls.Add(this.CancelChangesButton); this.BottomButtonPanel.RightControls.Add(this.BackButton); @@ -132,11 +172,11 @@ private void InitializeComponent() this.ConfirmChangesButton.TabIndex = 2; this.ConfirmChangesButton.Click += new System.EventHandler(this.ConfirmChangesButton_Click); resources.ApplyResources(this.ConfirmChangesButton, "ConfirmChangesButton"); - // + // // Changeset - // + // this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None; - this.Controls.Add(this.ChangesListView); + this.Controls.Add(this.ChangesGrid); this.Controls.Add(this.CloseTheGameLabel); this.Controls.Add(this.BottomButtonPanel); this.Margin = new System.Windows.Forms.Padding(0, 0, 0, 0); @@ -152,10 +192,11 @@ private void InitializeComponent() #endregion - private System.Windows.Forms.ListView ChangesListView; - private System.Windows.Forms.ColumnHeader Mod; - private System.Windows.Forms.ColumnHeader ChangeType; - private System.Windows.Forms.ColumnHeader Reason; + private System.Windows.Forms.DataGridView ChangesGrid; + private System.Windows.Forms.DataGridViewTextBoxColumn ModColumn; + private System.Windows.Forms.DataGridViewTextBoxColumn ChangeTypeColumn; + private System.Windows.Forms.DataGridViewTextBoxColumn ReasonsColumn; + private System.Windows.Forms.DataGridViewImageColumn DeleteColumn; private System.Windows.Forms.Label CloseTheGameLabel; private CKAN.GUI.LeftRightRowPanel BottomButtonPanel; private System.Windows.Forms.Button BackButton; diff --git a/GUI/Controls/Changeset.cs b/GUI/Controls/Changeset.cs index edf0203646..a5514f40de 100644 --- a/GUI/Controls/Changeset.cs +++ b/GUI/Controls/Changeset.cs @@ -3,6 +3,8 @@ using System.Drawing; using System.Collections.Generic; using System.Windows.Forms; +using System.ComponentModel; +using System.Reflection; #if NET5_0_OR_GREATER using System.Runtime.Versioning; #endif @@ -19,66 +21,66 @@ public partial class Changeset : UserControl public Changeset() { InitializeComponent(); + // Reduce the grid's flickering + ChangesGrid.GetType() + .GetProperty("DoubleBuffered", + BindingFlags.Instance | BindingFlags.NonPublic) + .SetValue(ChangesGrid, true, null); } - public void LoadChangeset( - List changes, - List AlertLabels, - Dictionary conflicts) + public void LoadChangeset(List changes, + List AlertLabels, + Dictionary conflicts) { - changeset = changes; - alertLabels = AlertLabels; - this.conflicts = conflicts; + changeset = changes; ConfirmChangesButton.Enabled = conflicts == null || !conflicts.Any(); - CloseTheGameLabel.Visible = changeset != null - && changeset.Any(ch => DeletingChanges.Contains(ch.ChangeType)); + CloseTheGameLabel.Visible = changes?.Any(ch => DeletingChanges.Contains(ch.ChangeType)) + ?? false; + ChangesGrid.DataSource = new BindingList( + changes?.Select(ch => new ChangesetRow(ch, AlertLabels, conflicts)) + .ToList() + ?? new List()); + ChangesGrid.AutoResizeColumns(); } - private static readonly HashSet DeletingChanges = new HashSet - { - GUIModChangeType.Remove, - GUIModChangeType.Update, - GUIModChangeType.Replace, - }; - - protected override void OnVisibleChanged(EventArgs e) - { - base.OnVisibleChanged(e); - if (Visible) - { - // Update list on each refresh in case caching changed - UpdateList(); - } - } - - public ListView.SelectedListViewItemCollection SelectedItems - => ChangesListView.SelectedItems; + public CkanModule SelectedItem => SelectedRow?.Change.Mod; - public event Action OnSelectedItemsChanged; + public event Action OnSelectedItemsChanged; + public event Action OnRemoveItem; public event Action> OnConfirmChanges; - public event Action OnCancelChanges; + public event Action OnCancelChanges; - private void UpdateList() + private void ChangesGrid_DataBindingComplete(object sender, DataGridViewBindingCompleteEventArgs e) { - ChangesListView.BeginUpdate(); - ChangesListView.Items.Clear(); - if (changeset != null) + ChangesGrid.ClearSelection(); + foreach (var row in ChangesGrid.Rows.OfType()) { - // Changeset sorting is handled upstream in the resolver - ChangesListView.Items.AddRange(changeset - .Where(ch => ch.ChangeType != GUIModChangeType.None) - .Select(ch => MakeItem(ch, conflicts)) - .ToArray()); - ChangesListView.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent); - ChangesListView.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize); + var obj = row.DataBoundItem as ChangesetRow; + row.DefaultCellStyle.ForeColor = obj?.WarningLabel != null + ? Color.Red : SystemColors.WindowText; + row.DefaultCellStyle.BackColor = obj?.Conflict != null + ? Color.LightCoral : Color.Empty; + if (obj?.Change.IsRemovable ?? false) + { + foreach (var icon in row.Cells.OfType()) + { + icon.ToolTipText = string.Format(Properties.Resources.ChangesetDeleteTooltip, + obj.ChangeType, obj.Change.Mod); + } + } } - ChangesListView.EndUpdate(); } - private void ChangesListView_SelectedIndexChanged(object sender, EventArgs e) + private void ChangesGrid_CellClick(object sender, DataGridViewCellEventArgs e) { - OnSelectedItemsChanged?.Invoke(ChangesListView.SelectedItems); + if (ChangesGrid.CurrentCell?.OwningColumn == DeleteColumn + && ChangesGrid.CurrentRow?.DataBoundItem is ChangesetRow row + && row.Change.IsRemovable + && row.ConfirmUncheck()) + { + OnRemoveItem?.Invoke(row.Change); + } } private void ConfirmChangesButton_Click(object sender, EventArgs e) @@ -97,35 +99,75 @@ private void BackButton_Click(object sender, EventArgs e) OnCancelChanges?.Invoke(false); } - private ListViewItem MakeItem(ModChange change, Dictionary conflicts) + private void ChangesGrid_SelectionChanged(object sender, EventArgs e) { - var descr = change.Description; - CkanModule m = change.Mod; - ModuleLabel warnLbl = alertLabels?.FirstOrDefault(l => - l.ContainsModule(Main.Instance.CurrentInstance.game, m.identifier)); - return new ListViewItem(new string[] + // Don't pop up mod info when they click the X icons + if (ChangesGrid.CurrentCell?.OwningColumn is DataGridViewTextBoxColumn) { - change.NameAndStatus, - change.ChangeType.Localize(), - conflicts != null && conflicts.TryGetValue(m, out string confDescr) - ? string.Format("{0} ({1})", confDescr, descr) - : warnLbl != null + OnSelectedItemsChanged?.Invoke(SelectedRow?.Change.Mod); + } + } + + private static readonly HashSet DeletingChanges = new HashSet + { + GUIModChangeType.Remove, + GUIModChangeType.Update, + GUIModChangeType.Replace, + }; + + private ChangesetRow SelectedRow + => ChangesGrid.SelectedRows + .OfType() + .FirstOrDefault() + ?.DataBoundItem as ChangesetRow; + + private List changeset; + } + + #if NET5_0_OR_GREATER + [SupportedOSPlatform("windows")] + #endif + public class ChangesetRow + { + public ChangesetRow(ModChange change, + List alertLabels, + Dictionary conflicts) + { + Change = change; + WarningLabel = alertLabels?.FirstOrDefault(l => + l.ContainsModule(Main.Instance.CurrentInstance.game, + Change.Mod.identifier)); + conflicts?.TryGetValue(Change.Mod, out Conflict); + Reasons = Conflict != null + ? string.Format("{0} ({1})", Conflict, Change.Description) + : WarningLabel != null ? string.Format( Properties.Resources.MainChangesetWarningInstallingModuleWithLabel, - warnLbl.Name, - descr) - : descr - }) - { - Tag = m, - ForeColor = warnLbl != null ? Color.Red : SystemColors.WindowText, - BackColor = conflicts != null && conflicts.ContainsKey(m) ? Color.LightCoral : Color.Empty, - ToolTipText = descr, - }; + WarningLabel.Name, Change.Description) + : Change.Description; } - private List changeset; - private List alertLabels; - private Dictionary conflicts; + public readonly ModChange Change; + public readonly ModuleLabel WarningLabel = null; + public readonly string Conflict = null; + + public string Mod => Change.NameAndStatus; + public string ChangeType => Change.ChangeType.Localize(); + public string Reasons { get; private set; } + public Bitmap DeleteImage => Change.IsRemovable ? EmbeddedImages.textClear + : EmptyBitmap; + + public bool ConfirmUncheck() + => Change.IsAutoRemoval + ? Main.Instance.YesNoDialog( + string.Format(Properties.Resources.ChangesetConfirmRemoveAutoRemoval, Change.Mod), + Properties.Resources.ChangesetConfirmRemoveAutoRemovalYes, + Properties.Resources.ChangesetConfirmRemoveAutoRemovalNo) + : Main.Instance.YesNoDialog( + string.Format(Properties.Resources.ChangesetConfirmRemoveUserRequested, ChangeType, Change.Mod), + Properties.Resources.ChangesetConfirmRemoveUserRequestedYes, + Properties.Resources.ChangesetConfirmRemoveUserRequestedNo); + + private static readonly Bitmap EmptyBitmap = new Bitmap(1, 1); } } diff --git a/GUI/Controls/Changeset.resx b/GUI/Controls/Changeset.resx index df61fcad04..9165fecdb8 100644 --- a/GUI/Controls/Changeset.resx +++ b/GUI/Controls/Changeset.resx @@ -117,9 +117,10 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - Mod - Change - Reasons for action + Mod + Change + Reasons for action + Skip? Note: To apply these changes, CKAN must overwrite or delete files. If the game is running, close it before continuing! Back Clear diff --git a/GUI/Controls/ManageMods.cs b/GUI/Controls/ManageMods.cs index 1a393cdd52..8efffeccff 100644 --- a/GUI/Controls/ManageMods.cs +++ b/GUI/Controls/ManageMods.cs @@ -905,6 +905,42 @@ private void ModGrid_CellValueChanged(object sender, DataGridViewCellEventArgs e } } + public void RemoveChangesetItem(ModChange change) + { + if (change.IsRemovable + && mainModList.full_list_of_mod_rows.TryGetValue(change.Mod.identifier, + out DataGridViewRow row) + && row.Tag is GUIMod guiMod) + { + if (change.IsAutoRemoval) + { + guiMod.SetAutoInstallChecked(row, AutoInstalled, false); + OnRegistryChanged?.Invoke(); + } + else if (change.IsUserRequested) + { + switch (change.ChangeType) + { + case GUIModChangeType.Install: + guiMod.SetInstallChecked(row, Installed, false); + break; + case GUIModChangeType.Remove: + guiMod.SetInstallChecked(row, Installed, true); + break; + case GUIModChangeType.Update: + guiMod.SetUpgradeChecked(row, UpdateCol, false); + break; + case GUIModChangeType.Replace: + guiMod.SetReplaceChecked(row, ReplaceCol, false); + break; + } + } + var inst = Main.Instance.CurrentInstance; + UpdateChangeSetAndConflicts( + inst, RegistryManager.Instance(inst, repoData).registry); + } + } + private void ModGrid_GotFocus(object sender, EventArgs e) { Util.Invoke(this, () => @@ -975,12 +1011,16 @@ public void ClearChangeSet() } mod.SetUpgradeChecked(row, UpdateCol, false); mod.SetReplaceChecked(row, ReplaceCol, false); - // Marking a mod as AutoInstalled can immediately queue it for removal if there is no dependent mod. - // Reset the state of the AutoInstalled checkbox for these by deducing it from the changeset. - if (mod.InstalledMod != null && - ChangeSet.Contains(new ModChange(mod.InstalledMod?.Module, GUIModChangeType.Remove, - new SelectionReason.NoLongerUsed())) - ) + } + // Marking a mod as AutoInstalled can immediately queue it for removal if there is no dependent mod. + // Reset the state of the AutoInstalled checkbox for these by deducing it from the changeset. + foreach (DataGridViewRow row in mainModList.full_list_of_mod_rows.Values) + { + GUIMod mod = row.Tag as GUIMod; + if (mod.InstalledMod != null + && ChangeSet.Contains(new ModChange(mod.InstalledMod?.Module, + GUIModChangeType.Remove, + new SelectionReason.NoLongerUsed()))) { mod.SetAutoInstallChecked(row, AutoInstalled, false); } diff --git a/GUI/Dialogs/YesNoDialog.Designer.cs b/GUI/Dialogs/YesNoDialog.Designer.cs index 6040b0d53e..f138f08f5d 100644 --- a/GUI/Dialogs/YesNoDialog.Designer.cs +++ b/GUI/Dialogs/YesNoDialog.Designer.cs @@ -126,7 +126,7 @@ private void InitializeComponent() this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.SizableToolWindow; this.Icon = EmbeddedImages.AppIcon; this.Name = "YesNoDialog"; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; resources.ApplyResources(this, "$this"); this.panel1.ResumeLayout(false); this.BottomButtonPanel.ResumeLayout(false); diff --git a/GUI/Dialogs/YesNoDialog.cs b/GUI/Dialogs/YesNoDialog.cs index 8b87047302..1414b4485d 100644 --- a/GUI/Dialogs/YesNoDialog.cs +++ b/GUI/Dialogs/YesNoDialog.cs @@ -67,6 +67,7 @@ private void Setup(string text, string yesText, string noText) ClientSize.Width, Math.Min(maxHeight, height) ); + ActiveControl = YesButton; } private void SetupSuppressable(string text, string yesText, string noText, string suppressText) diff --git a/GUI/Localization/de-DE/Changeset.de-DE.resx b/GUI/Localization/de-DE/Changeset.de-DE.resx index 677af9e5da..1aecbc30ec 100644 --- a/GUI/Localization/de-DE/Changeset.de-DE.resx +++ b/GUI/Localization/de-DE/Changeset.de-DE.resx @@ -117,8 +117,8 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - Änderung - Grund + Änderung + Grund Zurück Löschen Annehmen diff --git a/GUI/Localization/fr-FR/Changeset.fr-FR.resx b/GUI/Localization/fr-FR/Changeset.fr-FR.resx index c72d882198..d108346c49 100644 --- a/GUI/Localization/fr-FR/Changeset.fr-FR.resx +++ b/GUI/Localization/fr-FR/Changeset.fr-FR.resx @@ -117,13 +117,13 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + Mod - + Changement - + Raison de l'action diff --git a/GUI/Localization/it-IT/Changeset.it-IT.resx b/GUI/Localization/it-IT/Changeset.it-IT.resx index 9e292ab65a..53903665f6 100644 --- a/GUI/Localization/it-IT/Changeset.it-IT.resx +++ b/GUI/Localization/it-IT/Changeset.it-IT.resx @@ -117,13 +117,13 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + Mod - + Modifica - + Motivi dell’azione diff --git a/GUI/Localization/ja-JP/Changeset.ja-JP.resx b/GUI/Localization/ja-JP/Changeset.ja-JP.resx index f80ef3d20f..a831a13419 100644 --- a/GUI/Localization/ja-JP/Changeset.ja-JP.resx +++ b/GUI/Localization/ja-JP/Changeset.ja-JP.resx @@ -117,9 +117,9 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - Mod - 変更 - 変更の理由 + Mod + 変更 + 変更の理由 戻る 取消 適用 diff --git a/GUI/Localization/ko-KR/Changeset.ko-KR.resx b/GUI/Localization/ko-KR/Changeset.ko-KR.resx index 2f41c4f4a2..0d596036c0 100644 --- a/GUI/Localization/ko-KR/Changeset.ko-KR.resx +++ b/GUI/Localization/ko-KR/Changeset.ko-KR.resx @@ -117,13 +117,13 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + 모드 - + 변경 - + 변경 이유 diff --git a/GUI/Localization/nl-NL/Changeset.nl-NL.resx b/GUI/Localization/nl-NL/Changeset.nl-NL.resx index 914e2ce6b8..afee672c1e 100644 --- a/GUI/Localization/nl-NL/Changeset.nl-NL.resx +++ b/GUI/Localization/nl-NL/Changeset.nl-NL.resx @@ -117,13 +117,13 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + Mod - + Wijziging - + Redenen voor actie diff --git a/GUI/Localization/pl-PL/Changeset.pl-PL.resx b/GUI/Localization/pl-PL/Changeset.pl-PL.resx index 7987058a3a..f8b02e0cb8 100644 --- a/GUI/Localization/pl-PL/Changeset.pl-PL.resx +++ b/GUI/Localization/pl-PL/Changeset.pl-PL.resx @@ -117,13 +117,13 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + Mod - + Zmień - + Powód działania diff --git a/GUI/Localization/pt-BR/Changeset.pt-BR.resx b/GUI/Localization/pt-BR/Changeset.pt-BR.resx index 885d3c97fe..307e9d8274 100644 --- a/GUI/Localization/pt-BR/Changeset.pt-BR.resx +++ b/GUI/Localization/pt-BR/Changeset.pt-BR.resx @@ -117,13 +117,13 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + Mod - + Mudança - + Razão para a ação diff --git a/GUI/Localization/ru-RU/Changeset.ru-RU.resx b/GUI/Localization/ru-RU/Changeset.ru-RU.resx index d12cb8e6f7..a41b68865d 100644 --- a/GUI/Localization/ru-RU/Changeset.ru-RU.resx +++ b/GUI/Localization/ru-RU/Changeset.ru-RU.resx @@ -117,13 +117,13 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + Модификация - + Действие - + Причина действия diff --git a/GUI/Localization/tr-TR/Changeset.tr-TR.resx b/GUI/Localization/tr-TR/Changeset.tr-TR.resx index 71c30fd041..72f9744c44 100644 --- a/GUI/Localization/tr-TR/Changeset.tr-TR.resx +++ b/GUI/Localization/tr-TR/Changeset.tr-TR.resx @@ -117,13 +117,13 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + Mod - + Değişim - + İşlem için sebepler diff --git a/GUI/Localization/zh-CN/Changeset.zh-CN.resx b/GUI/Localization/zh-CN/Changeset.zh-CN.resx index 7a6a7aac93..a3eb0cd3d3 100644 --- a/GUI/Localization/zh-CN/Changeset.zh-CN.resx +++ b/GUI/Localization/zh-CN/Changeset.zh-CN.resx @@ -117,9 +117,9 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - Mod - 更改 - 操作理由 + Mod + 更改 + 操作理由 返回 取消更改 应用 diff --git a/GUI/Main/Main.Designer.cs b/GUI/Main/Main.Designer.cs index 8bf05c4aa8..f88f7ba4e5 100644 --- a/GUI/Main/Main.Designer.cs +++ b/GUI/Main/Main.Designer.cs @@ -508,6 +508,7 @@ private void InitializeComponent() this.Changeset.Size = new System.Drawing.Size(500, 500); this.Changeset.TabIndex = 32; this.Changeset.OnSelectedItemsChanged += this.Changeset_OnSelectedItemsChanged; + this.Changeset.OnRemoveItem += ManageMods.RemoveChangesetItem; this.Changeset.OnConfirmChanges += this.Changeset_OnConfirmChanges; this.Changeset.OnCancelChanges += this.Changeset_OnCancelChanges; // diff --git a/GUI/Main/Main.cs b/GUI/Main/Main.cs index 2eaebd38ec..832c112ec3 100644 --- a/GUI/Main/Main.cs +++ b/GUI/Main/Main.cs @@ -826,10 +826,8 @@ private GUIMod ActiveModInfo } } - private void ShowSelectionModInfo(ListView.SelectedListViewItemCollection selection) + private void ShowSelectionModInfo(CkanModule module) { - CkanModule module = (CkanModule)selection?.Cast().FirstOrDefault()?.Tag; - ActiveModInfo = module == null ? null : new GUIMod( module, repoData, @@ -840,6 +838,11 @@ private void ShowSelectionModInfo(ListView.SelectedListViewItemCollection select configuration.HideV); } + private void ShowSelectionModInfo(ListView.SelectedListViewItemCollection selection) + { + ShowSelectionModInfo(selection?.Cast().FirstOrDefault()?.Tag as CkanModule); + } + private void ManageMods_OnChangeSetChanged(List changeset, Dictionary conflicts) { if (changeset != null && changeset.Any()) @@ -888,7 +891,7 @@ private void MainTabControl_OnSelectedIndexChanged(object sender, EventArgs e) break; case "ChangesetTabPage": - ShowSelectionModInfo(Changeset.SelectedItems); + ShowSelectionModInfo(Changeset.SelectedItem); break; case "ChooseRecommendedModsTabPage": @@ -900,7 +903,7 @@ private void MainTabControl_OnSelectedIndexChanged(object sender, EventArgs e) break; default: - ShowSelectionModInfo(null); + ShowSelectionModInfo((CkanModule)null); break; } } diff --git a/GUI/Main/MainChangeset.cs b/GUI/Main/MainChangeset.cs index 0f472d2776..a5d1a3de84 100644 --- a/GUI/Main/MainChangeset.cs +++ b/GUI/Main/MainChangeset.cs @@ -1,7 +1,6 @@ using System; using System.Linq; using System.Collections.Generic; -using System.Windows.Forms; // Don't warn if we use our own obsolete properties #pragma warning disable 0618 @@ -20,9 +19,12 @@ private void UpdateChangesDialog(List changeset, Dictionary - /// For changes involving another version in addition to the main one, - /// this is that other version. - /// When upgrading, the target version. - /// Otherwise not used. - /// public GUIModChangeType ChangeType { get; private set; } public SelectionReason[] Reasons { get; private set; } @@ -58,6 +52,16 @@ public class ModChange /// public readonly bool IsAutoRemoval; + /// + /// true if this change is user requested and no other changes depend on it, false otherwise. + /// + public readonly bool IsUserRequested; + + /// + /// true if this change can be removed from a changeset, false otherwise + /// + public bool IsRemovable => IsAutoRemoval || IsUserRequested; + // If we don't have a Reason, the user probably wanted to install it public ModChange(CkanModule mod, GUIModChangeType changeType) : this(mod, changeType, new SelectionReason.UserRequested()) @@ -74,7 +78,8 @@ public ModChange(CkanModule mod, GUIModChangeType changeType, IEnumerable