diff --git a/CreamInstaller/Components/CustomTreeView.cs b/CreamInstaller/Components/CustomTreeView.cs index d729102..73ee453 100644 --- a/CreamInstaller/Components/CustomTreeView.cs +++ b/CreamInstaller/Components/CustomTreeView.cs @@ -24,10 +24,10 @@ internal sealed class CustomTreeView : TreeView private static readonly Color C7 = ColorTranslator.FromHtml("#006900"); private static readonly Color C8 = ColorTranslator.FromHtml("#69AA69"); - private readonly Dictionary checkBoxBounds = new(); - private readonly Dictionary comboBoxBounds = new(); + private readonly Dictionary checkBoxBounds = []; + private readonly Dictionary comboBoxBounds = []; - private readonly Dictionary selectionBounds = new(); + private readonly Dictionary selectionBounds = []; private SolidBrush backBrush; private ToolStripDropDown comboBoxDropDown; private Font comboBoxFont; @@ -36,6 +36,7 @@ internal sealed class CustomTreeView : TreeView internal CustomTreeView() { DrawMode = TreeViewDrawMode.OwnerDrawAll; + Invalidated += OnInvalidated; DrawNode += DrawTreeNode; Disposed += OnDisposed; } @@ -59,6 +60,13 @@ internal sealed class CustomTreeView : TreeView comboBoxDropDown = null; } + private void OnInvalidated(object sender, EventArgs e) + { + checkBoxBounds.Clear(); + comboBoxBounds.Clear(); + selectionBounds.Clear(); + } + private void DrawTreeNode(object sender, DrawTreeNodeEventArgs e) { e.DrawDefault = true; @@ -205,7 +213,7 @@ internal sealed class CustomTreeView : TreeView return; if (comboBoxBounds.Count > 0 && selectForm is not null) foreach (KeyValuePair pair in comboBoxBounds) - if (!Selection.All.ContainsKey(pair.Key)) + if (!Selection.All.ContainsKey(pair.Key) || !pair.Key.CanUseProxy) _ = comboBoxBounds.Remove(pair.Key); else if (pair.Value.Contains(clickPoint)) { @@ -243,7 +251,7 @@ internal sealed class CustomTreeView : TreeView } foreach (KeyValuePair pair in checkBoxBounds) - if (!Selection.All.ContainsKey(pair.Key)) + if (!Selection.All.ContainsKey(pair.Key) || !pair.Key.CanUseProxy) _ = checkBoxBounds.Remove(pair.Key); else if (pair.Value.Contains(clickPoint)) { diff --git a/CreamInstaller/Forms/SelectForm.Designer.cs b/CreamInstaller/Forms/SelectForm.Designer.cs index 3677bf8..6f018d1 100644 --- a/CreamInstaller/Forms/SelectForm.Designer.cs +++ b/CreamInstaller/Forms/SelectForm.Designer.cs @@ -40,11 +40,13 @@ namespace CreamInstaller.Forms saveButton = new Button(); loadButton = new Button(); resetButton = new Button(); + saveFlowPanel = new FlowLayoutPanel(); selectionTreeView = new CustomTreeView(); programsGroupBox.SuspendLayout(); proxyFlowPanel.SuspendLayout(); blockedGamesFlowPanel.SuspendLayout(); allCheckBoxLayoutPanel.SuspendLayout(); + saveFlowPanel.SuspendLayout(); SuspendLayout(); // // installButton @@ -53,10 +55,10 @@ namespace CreamInstaller.Forms installButton.AutoSize = true; installButton.AutoSizeMode = AutoSizeMode.GrowAndShrink; installButton.Enabled = false; - installButton.Location = new System.Drawing.Point(427, 326); + installButton.Location = new System.Drawing.Point(495, 376); installButton.Name = "installButton"; - installButton.Padding = new Padding(12, 0, 12, 0); - installButton.Size = new System.Drawing.Size(145, 25); + installButton.Padding = new Padding(3, 0, 3, 0); + installButton.Size = new System.Drawing.Size(127, 25); installButton.TabIndex = 10000; installButton.Text = "Generate and Install"; installButton.UseVisualStyleBackColor = true; @@ -67,10 +69,10 @@ namespace CreamInstaller.Forms cancelButton.Anchor = AnchorStyles.Bottom | AnchorStyles.Left; cancelButton.AutoSize = true; cancelButton.AutoSizeMode = AutoSizeMode.GrowAndShrink; - cancelButton.Location = new System.Drawing.Point(12, 326); + cancelButton.Location = new System.Drawing.Point(12, 376); cancelButton.Name = "cancelButton"; - cancelButton.Padding = new Padding(12, 0, 12, 0); - cancelButton.Size = new System.Drawing.Size(77, 25); + cancelButton.Padding = new Padding(3, 0, 3, 0); + cancelButton.Size = new System.Drawing.Size(59, 25); cancelButton.TabIndex = 10004; cancelButton.Text = "Cancel"; cancelButton.UseVisualStyleBackColor = true; @@ -86,7 +88,7 @@ namespace CreamInstaller.Forms programsGroupBox.Controls.Add(selectionTreeView); programsGroupBox.Location = new System.Drawing.Point(12, 12); programsGroupBox.Name = "programsGroupBox"; - programsGroupBox.Size = new System.Drawing.Size(560, 209); + programsGroupBox.Size = new System.Drawing.Size(610, 287); programsGroupBox.TabIndex = 8; programsGroupBox.TabStop = false; programsGroupBox.Text = "Programs / Games"; @@ -97,10 +99,10 @@ namespace CreamInstaller.Forms proxyFlowPanel.AutoSize = true; proxyFlowPanel.AutoSizeMode = AutoSizeMode.GrowAndShrink; proxyFlowPanel.Controls.Add(proxyAllCheckBox); - proxyFlowPanel.Location = new System.Drawing.Point(422, -1); + proxyFlowPanel.Location = new System.Drawing.Point(478, -1); proxyFlowPanel.Margin = new Padding(0); proxyFlowPanel.Name = "proxyFlowPanel"; - proxyFlowPanel.Size = new System.Drawing.Size(81, 19); + proxyFlowPanel.Size = new System.Drawing.Size(75, 19); proxyFlowPanel.TabIndex = 10005; proxyFlowPanel.WrapContents = false; // @@ -108,13 +110,11 @@ namespace CreamInstaller.Forms // proxyAllCheckBox.Anchor = AnchorStyles.Top | AnchorStyles.Right; proxyAllCheckBox.AutoSize = true; - proxyAllCheckBox.Checked = false; - proxyAllCheckBox.CheckState = CheckState.Checked; proxyAllCheckBox.Enabled = false; proxyAllCheckBox.Location = new System.Drawing.Point(2, 0); proxyAllCheckBox.Margin = new Padding(2, 0, 0, 0); proxyAllCheckBox.Name = "proxyAllCheckBox"; - proxyAllCheckBox.Size = new System.Drawing.Size(79, 19); + proxyAllCheckBox.Size = new System.Drawing.Size(73, 19); proxyAllCheckBox.TabIndex = 4; proxyAllCheckBox.Text = "Proxy All"; proxyAllCheckBox.CheckedChanged += OnProxyAllCheckBoxChanged; @@ -124,7 +124,7 @@ namespace CreamInstaller.Forms noneFoundLabel.Dock = DockStyle.Fill; noneFoundLabel.Location = new System.Drawing.Point(3, 19); noneFoundLabel.Name = "noneFoundLabel"; - noneFoundLabel.Size = new System.Drawing.Size(554, 187); + noneFoundLabel.Size = new System.Drawing.Size(604, 265); noneFoundLabel.TabIndex = 1002; noneFoundLabel.Text = "No applicable programs nor games were found on your computer!"; noneFoundLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; @@ -137,7 +137,7 @@ namespace CreamInstaller.Forms blockedGamesFlowPanel.AutoSizeMode = AutoSizeMode.GrowAndShrink; blockedGamesFlowPanel.Controls.Add(blockedGamesCheckBox); blockedGamesFlowPanel.Controls.Add(blockProtectedHelpButton); - blockedGamesFlowPanel.Location = new System.Drawing.Point(125, -1); + blockedGamesFlowPanel.Location = new System.Drawing.Point(150, -1); blockedGamesFlowPanel.Margin = new Padding(0); blockedGamesFlowPanel.Name = "blockedGamesFlowPanel"; blockedGamesFlowPanel.Size = new System.Drawing.Size(170, 19); @@ -162,7 +162,7 @@ namespace CreamInstaller.Forms // blockProtectedHelpButton // blockProtectedHelpButton.Enabled = false; - blockProtectedHelpButton.Font = new System.Drawing.Font("Segoe UI", 7F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); + blockProtectedHelpButton.Font = new System.Drawing.Font("Segoe UI", 7F); blockProtectedHelpButton.Location = new System.Drawing.Point(150, 0); blockProtectedHelpButton.Margin = new Padding(0, 0, 1, 0); blockProtectedHelpButton.Name = "blockProtectedHelpButton"; @@ -172,26 +172,13 @@ namespace CreamInstaller.Forms blockProtectedHelpButton.UseVisualStyleBackColor = true; blockProtectedHelpButton.Click += OnBlockProtectedGamesHelpButtonClicked; // - // selectionTreeView - // - selectionTreeView.BackColor = System.Drawing.SystemColors.Control; - selectionTreeView.BorderStyle = System.Windows.Forms.BorderStyle.None; - selectionTreeView.CheckBoxes = true; - selectionTreeView.Dock = System.Windows.Forms.DockStyle.Fill; - selectionTreeView.Enabled = false; - selectionTreeView.FullRowSelect = true; - selectionTreeView.Location = new System.Drawing.Point(3, 19); - selectionTreeView.Name = "selectionTreeView"; - selectionTreeView.Size = new System.Drawing.Size(554, 187); - selectionTreeView.TabIndex = 1001; - // // allCheckBoxLayoutPanel // allCheckBoxLayoutPanel.Anchor = AnchorStyles.Top | AnchorStyles.Right; allCheckBoxLayoutPanel.AutoSize = true; allCheckBoxLayoutPanel.AutoSizeMode = AutoSizeMode.GrowAndShrink; allCheckBoxLayoutPanel.Controls.Add(allCheckBox); - allCheckBoxLayoutPanel.Location = new System.Drawing.Point(512, -1); + allCheckBoxLayoutPanel.Location = new System.Drawing.Point(562, -1); allCheckBoxLayoutPanel.Margin = new Padding(0); allCheckBoxLayoutPanel.Name = "allCheckBoxLayoutPanel"; allCheckBoxLayoutPanel.Size = new System.Drawing.Size(42, 19); @@ -213,20 +200,34 @@ namespace CreamInstaller.Forms allCheckBox.Text = "All"; allCheckBox.CheckedChanged += OnAllCheckBoxChanged; // + // selectionTreeView + // + selectionTreeView.BackColor = System.Drawing.SystemColors.Control; + selectionTreeView.BorderStyle = BorderStyle.None; + selectionTreeView.CheckBoxes = true; + selectionTreeView.Dock = DockStyle.Fill; + selectionTreeView.DrawMode = TreeViewDrawMode.OwnerDrawAll; + selectionTreeView.Enabled = false; + selectionTreeView.FullRowSelect = true; + selectionTreeView.Location = new System.Drawing.Point(3, 19); + selectionTreeView.Name = "selectionTreeView"; + selectionTreeView.Size = new System.Drawing.Size(604, 265); + selectionTreeView.TabIndex = 1001; + // // progressBar // progressBar.Anchor = AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right; - progressBar.Location = new System.Drawing.Point(12, 266); + progressBar.Location = new System.Drawing.Point(12, 344); progressBar.Name = "progressBar"; - progressBar.Size = new System.Drawing.Size(560, 23); + progressBar.Size = new System.Drawing.Size(610, 23); progressBar.TabIndex = 9; // // progressLabel // progressLabel.Anchor = AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right; - progressLabel.Location = new System.Drawing.Point(12, 224); + progressLabel.Location = new System.Drawing.Point(12, 302); progressLabel.Name = "progressLabel"; - progressLabel.Size = new System.Drawing.Size(560, 15); + progressLabel.Size = new System.Drawing.Size(610, 15); progressLabel.TabIndex = 10; progressLabel.Text = "Gathering and caching your applicable games and their DLCs . . . 0%"; // @@ -236,10 +237,10 @@ namespace CreamInstaller.Forms scanButton.AutoSize = true; scanButton.AutoSizeMode = AutoSizeMode.GrowAndShrink; scanButton.Enabled = false; - scanButton.Location = new System.Drawing.Point(250, 326); + scanButton.Location = new System.Drawing.Point(186, 376); scanButton.Name = "scanButton"; - scanButton.Padding = new Padding(12, 0, 12, 0); - scanButton.Size = new System.Drawing.Size(78, 25); + scanButton.Padding = new Padding(3, 0, 3, 0); + scanButton.Size = new System.Drawing.Size(60, 25); scanButton.TabIndex = 10002; scanButton.Text = "Rescan"; scanButton.UseVisualStyleBackColor = true; @@ -251,10 +252,10 @@ namespace CreamInstaller.Forms uninstallButton.AutoSize = true; uninstallButton.AutoSizeMode = AutoSizeMode.GrowAndShrink; uninstallButton.Enabled = false; - uninstallButton.Location = new System.Drawing.Point(334, 326); + uninstallButton.Location = new System.Drawing.Point(420, 376); uninstallButton.Name = "uninstallButton"; - uninstallButton.Padding = new Padding(12, 0, 12, 0); - uninstallButton.Size = new System.Drawing.Size(87, 25); + uninstallButton.Padding = new Padding(3, 0, 3, 0); + uninstallButton.Size = new System.Drawing.Size(69, 25); uninstallButton.TabIndex = 10001; uninstallButton.Text = "Uninstall"; uninstallButton.UseVisualStyleBackColor = true; @@ -263,20 +264,20 @@ namespace CreamInstaller.Forms // progressLabelGames // progressLabelGames.Anchor = AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right; - progressLabelGames.Font = new System.Drawing.Font("Segoe UI", 7F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); - progressLabelGames.Location = new System.Drawing.Point(12, 239); + progressLabelGames.Font = new System.Drawing.Font("Segoe UI", 7F); + progressLabelGames.Location = new System.Drawing.Point(12, 317); progressLabelGames.Name = "progressLabelGames"; - progressLabelGames.Size = new System.Drawing.Size(560, 12); + progressLabelGames.Size = new System.Drawing.Size(610, 12); progressLabelGames.TabIndex = 11; progressLabelGames.Text = "Remaining games (2): Game 1, Game 2"; // // progressLabelDLCs // progressLabelDLCs.Anchor = AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right; - progressLabelDLCs.Font = new System.Drawing.Font("Segoe UI", 7F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); - progressLabelDLCs.Location = new System.Drawing.Point(12, 251); + progressLabelDLCs.Font = new System.Drawing.Font("Segoe UI", 7F); + progressLabelDLCs.Location = new System.Drawing.Point(12, 329); progressLabelDLCs.Name = "progressLabelDLCs"; - progressLabelDLCs.Size = new System.Drawing.Size(560, 12); + progressLabelDLCs.Size = new System.Drawing.Size(610, 12); progressLabelDLCs.TabIndex = 12; progressLabelDLCs.Text = "Remaining DLC (2): 123456, 654321"; // @@ -284,7 +285,7 @@ namespace CreamInstaller.Forms // sortCheckBox.Anchor = AnchorStyles.Bottom | AnchorStyles.Left; sortCheckBox.AutoSize = true; - sortCheckBox.Location = new System.Drawing.Point(125, 330); + sortCheckBox.Location = new System.Drawing.Point(84, 380); sortCheckBox.Margin = new Padding(3, 0, 0, 0); sortCheckBox.Name = "sortCheckBox"; sortCheckBox.Size = new System.Drawing.Size(98, 19); @@ -298,9 +299,10 @@ namespace CreamInstaller.Forms saveButton.AutoSize = true; saveButton.AutoSizeMode = AutoSizeMode.GrowAndShrink; saveButton.Enabled = false; - saveButton.Location = new System.Drawing.Point(432, 295); + saveButton.Location = new System.Drawing.Point(51, 0); + saveButton.Margin = new Padding(6, 0, 6, 0); saveButton.Name = "saveButton"; - saveButton.Size = new System.Drawing.Size(66, 25); + saveButton.Size = new System.Drawing.Size(41, 25); saveButton.TabIndex = 10006; saveButton.Text = "Save"; saveButton.UseVisualStyleBackColor = true; @@ -312,9 +314,10 @@ namespace CreamInstaller.Forms loadButton.AutoSize = true; loadButton.AutoSizeMode = AutoSizeMode.GrowAndShrink; loadButton.Enabled = false; - loadButton.Location = new System.Drawing.Point(504, 295); + loadButton.Location = new System.Drawing.Point(98, 0); + loadButton.Margin = new Padding(0); loadButton.Name = "loadButton"; - loadButton.Size = new System.Drawing.Size(68, 25); + loadButton.Size = new System.Drawing.Size(43, 25); loadButton.TabIndex = 10005; loadButton.Text = "Load"; loadButton.UseVisualStyleBackColor = true; @@ -326,24 +329,36 @@ namespace CreamInstaller.Forms resetButton.AutoSize = true; resetButton.AutoSizeMode = AutoSizeMode.GrowAndShrink; resetButton.Enabled = false; - resetButton.Location = new System.Drawing.Point(356, 295); + resetButton.Location = new System.Drawing.Point(0, 0); + resetButton.Margin = new Padding(0); resetButton.Name = "resetButton"; - resetButton.Size = new System.Drawing.Size(70, 25); + resetButton.Size = new System.Drawing.Size(45, 25); resetButton.TabIndex = 10007; resetButton.Text = "Reset"; resetButton.UseVisualStyleBackColor = true; resetButton.Click += OnResetSelections; // + // saveFlowPanel + // + saveFlowPanel.Anchor = AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right; + saveFlowPanel.AutoSize = true; + saveFlowPanel.AutoSizeMode = AutoSizeMode.GrowAndShrink; + saveFlowPanel.Controls.Add(resetButton); + saveFlowPanel.Controls.Add(saveButton); + saveFlowPanel.Controls.Add(loadButton); + saveFlowPanel.Location = new System.Drawing.Point(263, 376); + saveFlowPanel.Name = "saveFlowPanel"; + saveFlowPanel.Size = new System.Drawing.Size(141, 25); + saveFlowPanel.TabIndex = 10008; + saveFlowPanel.WrapContents = false; + // // SelectForm // AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); AutoScaleMode = AutoScaleMode.Font; - AutoSize = true; AutoSizeMode = AutoSizeMode.GrowAndShrink; - ClientSize = new System.Drawing.Size(584, 361); - Controls.Add(resetButton); - Controls.Add(loadButton); - Controls.Add(saveButton); + ClientSize = new System.Drawing.Size(634, 411); + Controls.Add(saveFlowPanel); Controls.Add(sortCheckBox); Controls.Add(progressLabelDLCs); Controls.Add(progressLabelGames); @@ -370,6 +385,8 @@ namespace CreamInstaller.Forms blockedGamesFlowPanel.PerformLayout(); allCheckBoxLayoutPanel.ResumeLayout(false); allCheckBoxLayoutPanel.PerformLayout(); + saveFlowPanel.ResumeLayout(false); + saveFlowPanel.PerformLayout(); ResumeLayout(false); PerformLayout(); } @@ -398,6 +415,7 @@ namespace CreamInstaller.Forms private Button saveButton; private Button loadButton; private Button resetButton; + private FlowLayoutPanel saveFlowPanel; } } diff --git a/CreamInstaller/Forms/SelectForm.cs b/CreamInstaller/Forms/SelectForm.cs index 09249c6..7dd2e3e 100644 --- a/CreamInstaller/Forms/SelectForm.cs +++ b/CreamInstaller/Forms/SelectForm.cs @@ -762,9 +762,8 @@ internal sealed partial class SelectForm : CustomForm progressBar.Visible = true; programsGroupBox.Size = programsGroupBox.Size with { - Height = programsGroupBox.Size.Height - 3 - progressLabel.Size.Height - progressLabelGames.Size.Height - - progressLabelDLCs.Size.Height - - progressBar.Size.Height + Height = programsGroupBox.Size.Height - progressLabel.Size.Height - progressLabelGames.Size.Height - + progressLabelDLCs.Size.Height - progressBar.Size.Height - 6 }; } @@ -777,9 +776,8 @@ internal sealed partial class SelectForm : CustomForm progressBar.Visible = false; programsGroupBox.Size = programsGroupBox.Size with { - Height = programsGroupBox.Size.Height + 3 + progressLabel.Size.Height + progressLabelGames.Size.Height + - progressLabelDLCs.Size.Height - + progressBar.Size.Height + Height = programsGroupBox.Size.Height + progressLabel.Size.Height + progressLabelGames.Size.Height + + progressLabelDLCs.Size.Height + progressBar.Size.Height + 6 }; } @@ -1041,6 +1039,7 @@ internal sealed partial class SelectForm : CustomForm proxyAllCheckBox.Checked = shouldEnable; proxyAllCheckBox.CheckedChanged += OnProxyAllCheckBoxChanged; resetButton.Enabled = CanResetSelections(); + saveButton.Enabled = CanSaveSelections(); } private bool AreSelectionsDefault()