From 43e8b6434971914dfd0c084d5dabfafd3284a6e1 Mon Sep 17 00:00:00 2001 From: pointfeev Date: Tue, 30 Nov 2021 11:45:09 -0500 Subject: [PATCH] move from indexing based on names to appids, increase size of forms --- CreamInstaller/Classes/ProgramSelection.cs | 10 +-- CreamInstaller/Forms/InstallForm.Designer.cs | 22 +++--- CreamInstaller/Forms/MainForm.cs | 4 +- CreamInstaller/Forms/SelectForm.Designer.cs | 36 ++++----- CreamInstaller/Forms/SelectForm.cs | 79 +++++++++++++------- CreamInstaller/Program.cs | 8 ++ 6 files changed, 98 insertions(+), 61 deletions(-) diff --git a/CreamInstaller/Classes/ProgramSelection.cs b/CreamInstaller/Classes/ProgramSelection.cs index 6f10530..b0166fd 100644 --- a/CreamInstaller/Classes/ProgramSelection.cs +++ b/CreamInstaller/Classes/ProgramSelection.cs @@ -36,11 +36,11 @@ namespace CreamInstaller private void Toggle(KeyValuePair dlcApp, bool enabled) => SelectedSteamDlc[dlcApp.Key] = enabled ? dlcApp.Value : null; - public void ToggleDlc(string dlcName, bool enabled) + public void ToggleDlc(int dlcAppId, bool enabled) { foreach (KeyValuePair dlcApp in AllSteamDlc) { - if (dlcApp.Value == dlcName) + if (dlcApp.Key == dlcAppId) { Toggle(dlcApp, enabled); break; @@ -64,13 +64,13 @@ namespace CreamInstaller public static List AllSafeEnabled => AllSafe.FindAll(s => s.Enabled); - public static ProgramSelection FromName(string displayName) => AllSafe.Find(s => s.Name == displayName); + public static ProgramSelection FromAppId(int appId) => AllSafe.Find(s => s.SteamAppId == appId); - public static KeyValuePair? GetDlc(string displayName) + public static KeyValuePair? GetAllSteamDlc(int appId) { foreach (ProgramSelection selection in AllSafe) foreach (KeyValuePair app in selection.AllSteamDlc) - if (app.Value == displayName) return app; + if (app.Key == appId) return app; return null; } } diff --git a/CreamInstaller/Forms/InstallForm.Designer.cs b/CreamInstaller/Forms/InstallForm.Designer.cs index 1b60138..80db4ac 100644 --- a/CreamInstaller/Forms/InstallForm.Designer.cs +++ b/CreamInstaller/Forms/InstallForm.Designer.cs @@ -44,7 +44,7 @@ namespace CreamInstaller | System.Windows.Forms.AnchorStyles.Right))); this.userProgressBar.Location = new System.Drawing.Point(12, 27); this.userProgressBar.Name = "userProgressBar"; - this.userProgressBar.Size = new System.Drawing.Size(500, 23); + this.userProgressBar.Size = new System.Drawing.Size(760, 23); this.userProgressBar.TabIndex = 1; // // userInfoLabel @@ -53,7 +53,7 @@ namespace CreamInstaller | System.Windows.Forms.AnchorStyles.Right))); this.userInfoLabel.Location = new System.Drawing.Point(12, 9); this.userInfoLabel.Name = "userInfoLabel"; - this.userInfoLabel.Size = new System.Drawing.Size(500, 15); + this.userInfoLabel.Size = new System.Drawing.Size(760, 15); this.userInfoLabel.TabIndex = 2; this.userInfoLabel.Text = "Loading . . . "; // @@ -61,7 +61,7 @@ namespace CreamInstaller // this.acceptButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.acceptButton.Enabled = false; - this.acceptButton.Location = new System.Drawing.Point(437, 286); + this.acceptButton.Location = new System.Drawing.Point(697, 526); this.acceptButton.Name = "acceptButton"; this.acceptButton.Size = new System.Drawing.Size(75, 23); this.acceptButton.TabIndex = 4; @@ -73,7 +73,7 @@ namespace CreamInstaller // this.retryButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.retryButton.Enabled = false; - this.retryButton.Location = new System.Drawing.Point(356, 286); + this.retryButton.Location = new System.Drawing.Point(616, 526); this.retryButton.Name = "retryButton"; this.retryButton.Size = new System.Drawing.Size(75, 23); this.retryButton.TabIndex = 3; @@ -84,7 +84,7 @@ namespace CreamInstaller // cancelButton // this.cancelButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.cancelButton.Location = new System.Drawing.Point(12, 286); + this.cancelButton.Location = new System.Drawing.Point(12, 526); this.cancelButton.Name = "cancelButton"; this.cancelButton.Size = new System.Drawing.Size(75, 23); this.cancelButton.TabIndex = 1; @@ -102,17 +102,17 @@ namespace CreamInstaller this.logTextBox.Name = "logTextBox"; this.logTextBox.ReadOnly = true; this.logTextBox.ScrollBars = System.Windows.Forms.RichTextBoxScrollBars.ForcedBoth; - this.logTextBox.Size = new System.Drawing.Size(500, 224); + this.logTextBox.Size = new System.Drawing.Size(760, 464); this.logTextBox.TabIndex = 4; this.logTextBox.TabStop = false; this.logTextBox.Text = ""; // // reselectButton // - this.reselectButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.reselectButton.Location = new System.Drawing.Point(135, 286); + this.reselectButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.reselectButton.Location = new System.Drawing.Point(410, 526); this.reselectButton.Name = "reselectButton"; - this.reselectButton.Size = new System.Drawing.Size(175, 23); + this.reselectButton.Size = new System.Drawing.Size(200, 23); this.reselectButton.TabIndex = 2; this.reselectButton.Text = "Reselect Programs / Games"; this.reselectButton.UseVisualStyleBackColor = true; @@ -122,7 +122,7 @@ namespace CreamInstaller // this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(524, 321); + this.ClientSize = new System.Drawing.Size(784, 561); this.Controls.Add(this.reselectButton); this.Controls.Add(this.logTextBox); this.Controls.Add(this.cancelButton); @@ -133,7 +133,7 @@ namespace CreamInstaller this.DoubleBuffered = true; this.MaximizeBox = false; this.MinimizeBox = false; - this.MinimumSize = new System.Drawing.Size(540, 360); + this.MinimumSize = new System.Drawing.Size(600, 400); this.Name = "InstallForm"; this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Show; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; diff --git a/CreamInstaller/Forms/MainForm.cs b/CreamInstaller/Forms/MainForm.cs index b87ed5c..c3655b3 100644 --- a/CreamInstaller/Forms/MainForm.cs +++ b/CreamInstaller/Forms/MainForm.cs @@ -146,7 +146,8 @@ namespace CreamInstaller "\n\nThis will cause unwanted behavior when updating the program!", "Ignore", "Abort") == DialogResult.Cancel) { - Environment.Exit(0); + Application.Exit(); + return; } } OnLoad(); @@ -194,6 +195,7 @@ namespace CreamInstaller { updateManager.LaunchUpdater(latestVersion); Application.Exit(); + return; } else { diff --git a/CreamInstaller/Forms/SelectForm.Designer.cs b/CreamInstaller/Forms/SelectForm.Designer.cs index 53e81ab..113334e 100644 --- a/CreamInstaller/Forms/SelectForm.Designer.cs +++ b/CreamInstaller/Forms/SelectForm.Designer.cs @@ -48,10 +48,10 @@ namespace CreamInstaller // this.acceptButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.acceptButton.Enabled = false; - this.acceptButton.Location = new System.Drawing.Point(322, 254); + this.acceptButton.Location = new System.Drawing.Point(422, 326); this.acceptButton.Name = "acceptButton"; this.acceptButton.Size = new System.Drawing.Size(150, 23); - this.acceptButton.TabIndex = 102; + this.acceptButton.TabIndex = 10002; this.acceptButton.Text = "Generate and Install"; this.acceptButton.UseVisualStyleBackColor = true; this.acceptButton.Click += new System.EventHandler(this.OnAccept); @@ -59,10 +59,10 @@ namespace CreamInstaller // cancelButton // this.cancelButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.cancelButton.Location = new System.Drawing.Point(12, 254); + this.cancelButton.Location = new System.Drawing.Point(12, 326); this.cancelButton.Name = "cancelButton"; this.cancelButton.Size = new System.Drawing.Size(75, 23); - this.cancelButton.TabIndex = 100; + this.cancelButton.TabIndex = 10000; this.cancelButton.Text = "Cancel"; this.cancelButton.UseVisualStyleBackColor = true; this.cancelButton.Click += new System.EventHandler(this.OnCancel); @@ -84,7 +84,7 @@ namespace CreamInstaller this.groupBox1.Controls.Add(this.allCheckBox); this.groupBox1.Location = new System.Drawing.Point(12, 12); this.groupBox1.Name = "groupBox1"; - this.groupBox1.Size = new System.Drawing.Size(460, 236); + this.groupBox1.Size = new System.Drawing.Size(560, 308); this.groupBox1.TabIndex = 8; this.groupBox1.TabStop = false; this.groupBox1.Text = "Programs / Games"; @@ -96,7 +96,7 @@ namespace CreamInstaller | System.Windows.Forms.AnchorStyles.Right))); this.noneFoundLabel.Location = new System.Drawing.Point(6, 22); this.noneFoundLabel.Name = "noneFoundLabel"; - this.noneFoundLabel.Size = new System.Drawing.Size(448, 208); + this.noneFoundLabel.Size = new System.Drawing.Size(548, 280); this.noneFoundLabel.TabIndex = 1002; this.noneFoundLabel.Text = "No CreamAPI-applicable programs were found on your computer!"; this.noneFoundLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; @@ -115,7 +115,7 @@ namespace CreamInstaller this.treeView1.HotTracking = true; this.treeView1.Location = new System.Drawing.Point(6, 22); this.treeView1.Name = "treeView1"; - this.treeView1.Size = new System.Drawing.Size(448, 208); + this.treeView1.Size = new System.Drawing.Size(548, 280); this.treeView1.TabIndex = 1001; // // allCheckBox @@ -123,7 +123,7 @@ namespace CreamInstaller this.allCheckBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.allCheckBox.AutoSize = true; this.allCheckBox.Enabled = false; - this.allCheckBox.Location = new System.Drawing.Point(414, 0); + this.allCheckBox.Location = new System.Drawing.Point(514, 0); this.allCheckBox.Name = "allCheckBox"; this.allCheckBox.Size = new System.Drawing.Size(40, 19); this.allCheckBox.TabIndex = 1; @@ -135,18 +135,18 @@ namespace CreamInstaller // this.progressBar1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); - this.progressBar1.Location = new System.Drawing.Point(12, 225); + this.progressBar1.Location = new System.Drawing.Point(12, 297); this.progressBar1.Name = "progressBar1"; - this.progressBar1.Size = new System.Drawing.Size(460, 23); + this.progressBar1.Size = new System.Drawing.Size(560, 23); this.progressBar1.TabIndex = 9; // // label2 // this.label2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); - this.label2.Location = new System.Drawing.Point(12, 207); + this.label2.Location = new System.Drawing.Point(12, 279); this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(460, 15); + this.label2.Size = new System.Drawing.Size(760, 15); this.label2.TabIndex = 10; this.label2.Text = "Loading . . ."; // @@ -154,11 +154,11 @@ namespace CreamInstaller // this.scanButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.scanButton.Enabled = false; - this.scanButton.Location = new System.Drawing.Point(110, 254); + this.scanButton.Location = new System.Drawing.Point(236, 326); this.scanButton.Name = "scanButton"; - this.scanButton.Size = new System.Drawing.Size(190, 23); - this.scanButton.TabIndex = 101; - this.scanButton.Text = "Rescan for Programs / Games"; + this.scanButton.Size = new System.Drawing.Size(180, 23); + this.scanButton.TabIndex = 10001; + this.scanButton.Text = "Rescan Programs / Games"; this.scanButton.UseVisualStyleBackColor = true; this.scanButton.Click += new System.EventHandler(this.OnScan); // @@ -166,7 +166,7 @@ namespace CreamInstaller // this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(484, 289); + this.ClientSize = new System.Drawing.Size(584, 361); this.Controls.Add(this.scanButton); this.Controls.Add(this.groupBox1); this.Controls.Add(this.progressBar1); @@ -177,7 +177,7 @@ namespace CreamInstaller this.DoubleBuffered = true; this.MaximizeBox = false; this.MinimizeBox = false; - this.MinimumSize = new System.Drawing.Size(500, 328); + this.MinimumSize = new System.Drawing.Size(600, 400); this.Name = "SelectForm"; this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Show; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; diff --git a/CreamInstaller/Forms/SelectForm.cs b/CreamInstaller/Forms/SelectForm.cs index 57697f6..a9fe39e 100644 --- a/CreamInstaller/Forms/SelectForm.cs +++ b/CreamInstaller/Forms/SelectForm.cs @@ -9,6 +9,7 @@ using System.Diagnostics; using System.Drawing; using System.IO; using System.Linq; +using System.Runtime.InteropServices; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; @@ -150,7 +151,7 @@ namespace CreamInstaller { if (Program.Canceled || !GetDllDirectoriesFromGameDirectory(directory, out List dllDirectories)) return; VProperty appInfo = null; - if (Program.Canceled || (name != "Paradox Launcher" && !SteamCMD.GetAppInfo(appId, out appInfo, branch, buildId))) return; + if (Program.Canceled || (appId > 0 && !SteamCMD.GetAppInfo(appId, out appInfo, branch, buildId))) return; if (Program.Canceled) return; ConcurrentDictionary dlc = new(); List dlcTasks = new(); @@ -166,8 +167,8 @@ namespace CreamInstaller string dlcName = null; if (SteamCMD.GetAppInfo(id, out VProperty dlcAppInfo)) dlcName = dlcAppInfo?.Value?["common"]?["name"]?.ToString(); if (Program.Canceled) return; - if (string.IsNullOrWhiteSpace(dlcName)) return; - dlc[id] = dlcName; + if (string.IsNullOrWhiteSpace(dlcName)) return; //dlcName = "Unknown DLC"; + dlc[id] = /*$"[{id}] " +*/ dlcName; progress.Report(++cur); }); dlcTasks.Add(task); @@ -175,13 +176,13 @@ namespace CreamInstaller } progress.Report(-RunningTasks.Count); } - else if (name != "Paradox Launcher") return; + else if (appId > 0) return; if (Program.Canceled) return; if (string.IsNullOrWhiteSpace(name)) return; if (Program.Canceled) return; - ProgramSelection selection = ProgramSelection.FromName(name) ?? new(); + ProgramSelection selection = ProgramSelection.FromAppId(appId) ?? new(); selection.Name = name; selection.RootDirectory = directory; selection.SteamAppId = appId; @@ -197,22 +198,22 @@ namespace CreamInstaller treeView1.Invoke((MethodInvoker)delegate { if (Program.Canceled) return; - TreeNode programNode = treeNodes.Find(s => s.Text == name) ?? new(); + TreeNode programNode = treeNodes.Find(s => s.Name == "" + appId) ?? new(); programNode.Name = "" + appId; - programNode.Text = name; + programNode.Text = /*(appId > 0 ? $"[{appId}] " : "") +*/ name; programNode.Checked = selection.Enabled; programNode.Remove(); treeView1.Nodes.Add(programNode); treeNodes.Remove(programNode); treeNodes.Add(programNode); - if (name == "Paradox Launcher") + if (appId == 0) // paradox launcher { // maybe add game and/or dlc choice here? } else foreach (KeyValuePair dlcApp in dlc.ToList()) { if (Program.Canceled || programNode is null) return; - TreeNode dlcNode = treeNodes.Find(s => s.Text == dlcApp.Value) ?? new(); + TreeNode dlcNode = treeNodes.Find(s => s.Name == "" + dlcApp.Key) ?? new(); dlcNode.Name = "" + dlcApp.Key; dlcNode.Text = dlcApp.Value; dlcNode.Checked = selection.SelectedSteamDlc.Contains(dlcApp); @@ -235,6 +236,11 @@ namespace CreamInstaller task.Wait(); } progress.Report(RunningTasks.Count); + ProgramSelection.All.ForEach(selection => selection.SteamApiDllDirectories.RemoveAll(directory => !Directory.Exists(directory))); + ProgramSelection.All.RemoveAll(selection => !Directory.Exists(selection.RootDirectory) || !selection.SteamApiDllDirectories.Any()); + foreach (TreeNode treeNode in treeNodes) + if (treeNode.Parent is null && ProgramSelection.FromAppId(int.Parse(treeNode.Name)) is null) + treeNode.Remove(); } private async void OnLoad() @@ -283,13 +289,7 @@ namespace CreamInstaller setup = false; label2.Text = "Gathering and caching your applicable games and their DLCs . . . "; await Task.Run(() => GetCreamApiApplicablePrograms(iProgress)); - treeView1.Sort(); - - ProgramSelection.All.ForEach(selection => selection.SteamApiDllDirectories.RemoveAll(directory => !Directory.Exists(directory))); - ProgramSelection.All.RemoveAll(selection => !Directory.Exists(selection.RootDirectory) || !selection.SteamApiDllDirectories.Any()); - foreach (TreeNode treeNode in treeNodes) - if (treeNode.Parent is null && ProgramSelection.FromName(treeNode.Text) is null) - treeNode.Remove(); + //SetMinimumSizeFromTreeView(); progressBar1.Value = 100; groupBox1.Size = new(groupBox1.Size.Width, groupBox1.Size.Height + 44); @@ -305,13 +305,42 @@ namespace CreamInstaller scanButton.Enabled = true; } + /*private const int GWL_STYLE = -16; + private const int WS_VSCROLL = 0x00200000; + private const int WS_HSCROLL = 0x00100000; + + [DllImport("user32.dll", ExactSpelling = false, CharSet = CharSet.Auto)] + private static extern int GetWindowLong(IntPtr hWnd, int nIndex); + + private const int MINIMUM_SIZE_INCREMENT = 8; + private void SetMinimumSizeFromTreeView() + { + Dictionary expansionState = new(); + foreach (TreeNode node in treeView1.Nodes) expansionState[node] = node.IsExpanded; + treeView1.ExpandAll(); + Size minimumSize = MinimumSize; + Point point; + int style = GetWindowLong(treeView1.Handle, GWL_STYLE); + while ((style & WS_HSCROLL) != 0) + { + minimumSize.Width += MINIMUM_SIZE_INCREMENT; + point = Location; + point.X -= MINIMUM_SIZE_INCREMENT / 2; + Location = point; + MinimumSize = minimumSize; + style = GetWindowLong(treeView1.Handle, GWL_STYLE); + Update(); + } + foreach (TreeNode node in treeView1.Nodes) if (!expansionState[node]) node.Collapse(); + }*/ + private void OnTreeViewNodeCheckedChanged(object sender, TreeViewEventArgs e) { if (e.Action == TreeViewAction.Unknown) return; - ProgramSelection selection = ProgramSelection.FromName(e.Node.Text); + ProgramSelection selection = ProgramSelection.FromAppId(int.Parse(e.Node.Name)); if (selection is null) { - ProgramSelection.FromName(e.Node.Parent.Text).ToggleDlc(e.Node.Text, e.Node.Checked); + ProgramSelection.FromAppId(int.Parse(e.Node.Parent.Name)).ToggleDlc(int.Parse(e.Node.Name), e.Node.Checked); e.Node.Parent.Checked = e.Node.Parent.Nodes.Cast().ToList().Any(treeNode => treeNode.Checked); } else @@ -347,8 +376,8 @@ namespace CreamInstaller { if (e.Button == MouseButtons.Right) { - ProgramSelection selection = ProgramSelection.FromName(e.Node.Text); - KeyValuePair? dlc = ProgramSelection.GetDlc(e.Node.Text); + ProgramSelection selection = ProgramSelection.FromAppId(int.Parse(e.Node.Name)); + KeyValuePair? dlc = ProgramSelection.GetAllSteamDlc(int.Parse(e.Node.Name)); int appId = selection?.SteamAppId ?? dlc?.Key ?? 0; if (appId > 0) Process.Start(new ProcessStartInfo { @@ -371,7 +400,7 @@ namespace CreamInstaller private static void PopulateParadoxLauncherDlc(ProgramSelection paradoxLauncher = null) { - paradoxLauncher ??= ProgramSelection.FromName("Paradox Launcher"); + paradoxLauncher ??= ProgramSelection.FromAppId(0); if (!(paradoxLauncher is null)) { paradoxLauncher.ExtraSteamAppIdDlc.Clear(); @@ -395,7 +424,7 @@ namespace CreamInstaller private static bool ParadoxLauncherDlcDialog(Form form) { - ProgramSelection paradoxLauncher = ProgramSelection.FromName("Paradox Launcher"); + ProgramSelection paradoxLauncher = ProgramSelection.FromAppId(0); if (!(paradoxLauncher is null) && paradoxLauncher.Enabled) { PopulateParadoxLauncherDlc(paradoxLauncher); @@ -427,11 +456,9 @@ namespace CreamInstaller if (installForm.Reselecting) { foreach (TreeNode treeNode in treeNodes) - if (!(treeNode.Parent is null) || treeNode.Text == "Paradox Launcher") + if (!(treeNode.Parent is null) || int.Parse(treeNode.Name) == 0) OnTreeViewNodeCheckedChanged(null, new(treeNode, TreeViewAction.ByMouse)); - int X = installForm.Location.X + installForm.Size.Width / 2 - Size.Width / 2; - int Y = installForm.Location.Y + installForm.Size.Height / 2 - Size.Height / 2; - Location = new(X, Y); + this.InheritLocation(installForm); Show(); } else diff --git a/CreamInstaller/Program.cs b/CreamInstaller/Program.cs index c665a95..6cb3e3f 100644 --- a/CreamInstaller/Program.cs +++ b/CreamInstaller/Program.cs @@ -37,6 +37,7 @@ namespace CreamInstaller { if (ExceptionHandler.OutputException(e)) goto retry; Application.Exit(); + return; } } mutex.Close(); @@ -90,5 +91,12 @@ namespace CreamInstaller } private static void OnApplicationExit(object s, EventArgs e) => Cleanup(); + + internal static void InheritLocation(this Form form, Form fromForm) + { + int X = fromForm.Location.X + fromForm.Size.Width / 2 - form.Size.Width / 2; + int Y = fromForm.Location.Y + fromForm.Size.Height / 2 - form.Size.Height / 2; + form.Location = new(X, Y); + } } } \ No newline at end of file