bounds cleanup

This commit is contained in:
pointfeev 2022-08-25 23:37:44 -04:00
parent c7bc55ac43
commit 50fd708017
2 changed files with 30 additions and 14 deletions

View file

@ -188,20 +188,27 @@ internal class CustomTreeView : TreeView
Refresh(); Refresh();
Point clickPoint = PointToClient(e.Location); Point clickPoint = PointToClient(e.Location);
SelectForm selectForm = (form ??= FindForm()) as SelectForm; SelectForm selectForm = (form ??= FindForm()) as SelectForm;
foreach (KeyValuePair<TreeNode, Rectangle> pair in selectionBounds) foreach (KeyValuePair<TreeNode, Rectangle> pair in selectionBounds.ToList())
if (pair.Key.IsVisible && pair.Value.Contains(clickPoint)) {
if (pair.Key.TreeView is null)
_ = selectionBounds.Remove(pair.Key);
else if (pair.Key.IsVisible && pair.Value.Contains(clickPoint))
{ {
SelectedNode = pair.Key; SelectedNode = pair.Key;
if (e.Button is MouseButtons.Right && selectForm is not null) if (e.Button is MouseButtons.Right && selectForm is not null)
selectForm.OnNodeRightClick(pair.Key, e.Location); selectForm.OnNodeRightClick(pair.Key, e.Location);
break; break;
} }
}
if (e.Button is MouseButtons.Left) if (e.Button is MouseButtons.Left)
{ {
bool invalidate = false; bool invalidate = false;
if (comboBoxBounds.Any() && selectForm is not null) if (comboBoxBounds.Any() && selectForm is not null)
foreach (KeyValuePair<ProgramSelection, Rectangle> pair in comboBoxBounds) foreach (KeyValuePair<ProgramSelection, Rectangle> pair in comboBoxBounds.ToList())
if (pair.Value.Contains(clickPoint)) {
if (!ProgramSelection.All.Contains(pair.Key))
_ = comboBoxBounds.Remove(pair.Key);
else if (pair.Value.Contains(clickPoint))
{ {
List<string> proxies = Resources.Resources.EmbeddedResources.FindAll(r => r.StartsWith("Koaloader")); List<string> proxies = Resources.Resources.EmbeddedResources.FindAll(r => r.StartsWith("Koaloader"));
comboBoxDropDown ??= new(); comboBoxDropDown ??= new();
@ -215,15 +222,18 @@ internal class CustomTreeView : TreeView
string text = proxy.GetKoaloaderProxyDisplay(); string text = proxy.GetKoaloaderProxyDisplay();
if (text.Contains("32-bit")) if (text.Contains("32-bit"))
{ {
_ = comboBoxDropDown.Items.Add(new ToolStripButton(text, null, new EventHandler((sender, e) => { _ = comboBoxDropDown.Items.Add(new ToolStripButton(text, null, new EventHandler((sender, e) =>
{
pair.Key.KoaloaderProxy = proxy; pair.Key.KoaloaderProxy = proxy;
ProgramData.UpdateKoaloaderProxyChoices(); ProgramData.UpdateKoaloaderProxyChoices();
Invalidate(); Invalidate();
})) { Font = comboBoxFont }); }))
{ Font = comboBoxFont });
} }
} }
comboBoxDropDown.Show(new(comboBoxDropDown.Left, comboBoxDropDown.Top)); comboBoxDropDown.Show(new(comboBoxDropDown.Left, comboBoxDropDown.Top));
}) { Font = comboBoxFont }); })
{ Font = comboBoxFont });
_ = comboBoxDropDown.Items.Add(new ToolStripButton("64-bit", null, (s, e) => _ = comboBoxDropDown.Items.Add(new ToolStripButton("64-bit", null, (s, e) =>
{ {
comboBoxDropDown.Items.Clear(); comboBoxDropDown.Items.Clear();
@ -232,28 +242,36 @@ internal class CustomTreeView : TreeView
string text = proxy.GetKoaloaderProxyDisplay(); string text = proxy.GetKoaloaderProxyDisplay();
if (text.Contains("64-bit")) if (text.Contains("64-bit"))
{ {
_ = comboBoxDropDown.Items.Add(new ToolStripButton(text, null, new EventHandler((sender, e) => { _ = comboBoxDropDown.Items.Add(new ToolStripButton(text, null, new EventHandler((sender, e) =>
{
pair.Key.KoaloaderProxy = proxy; pair.Key.KoaloaderProxy = proxy;
ProgramData.UpdateKoaloaderProxyChoices(); ProgramData.UpdateKoaloaderProxyChoices();
Invalidate(); Invalidate();
})) { Font = comboBoxFont }); }))
{ Font = comboBoxFont });
} }
} }
comboBoxDropDown.Show(new(comboBoxDropDown.Left, comboBoxDropDown.Top)); comboBoxDropDown.Show(new(comboBoxDropDown.Left, comboBoxDropDown.Top));
}) { Font = comboBoxFont }); })
{ Font = comboBoxFont });
comboBoxDropDown.Show(this, PointToScreen(new(pair.Value.Left, pair.Value.Bottom - 1))); comboBoxDropDown.Show(this, PointToScreen(new(pair.Value.Left, pair.Value.Bottom - 1)));
invalidate = true; invalidate = true;
break; break;
} }
}
if (!invalidate) if (!invalidate)
{ {
foreach (KeyValuePair<ProgramSelection, Rectangle> pair in checkBoxBounds) foreach (KeyValuePair<ProgramSelection, Rectangle> pair in checkBoxBounds.ToList())
if (pair.Value.Contains(clickPoint)) {
if (!ProgramSelection.All.Contains(pair.Key))
_ = checkBoxBounds.Remove(pair.Key);
else if (pair.Value.Contains(clickPoint))
{ {
pair.Key.Koaloader = !pair.Key.Koaloader; pair.Key.Koaloader = !pair.Key.Koaloader;
invalidate = true; invalidate = true;
break; break;
} }
}
if (invalidate && selectForm is not null) if (invalidate && selectForm is not null)
{ {
CheckBox koaloaderAllCheckBox = selectForm.KoaloaderAllCheckBox(); CheckBox koaloaderAllCheckBox = selectForm.KoaloaderAllCheckBox();

View file

@ -8,8 +8,6 @@ using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows.Forms; using System.Windows.Forms;
using Windows.Foundation.Metadata;
namespace CreamInstaller.Utility; namespace CreamInstaller.Utility;
internal static class ProgramData internal static class ProgramData