diff --git a/CreamInstaller/Components/CustomForm.cs b/CreamInstaller/Components/CustomForm.cs index 17b2825..f1f8034 100644 --- a/CreamInstaller/Components/CustomForm.cs +++ b/CreamInstaller/Components/CustomForm.cs @@ -14,6 +14,7 @@ internal class CustomForm : Form Owner = (owner as Form) ?? ActiveForm; KeyPreview = true; KeyPress += OnKeyPress; + ResizeRedraw = true; } protected override CreateParams CreateParams // Double buffering for all controls diff --git a/CreamInstaller/CreamInstaller.csproj b/CreamInstaller/CreamInstaller.csproj index 3878619..0be31fa 100644 --- a/CreamInstaller/CreamInstaller.csproj +++ b/CreamInstaller/CreamInstaller.csproj @@ -5,7 +5,7 @@ True Resources\ini.ico true - 3.5.1.0 + 3.5.2.0 Resources\ini.ico LICENSE 2021, pointfeev (https://github.com/pointfeev) diff --git a/CreamInstaller/Forms/InstallForm.Designer.cs b/CreamInstaller/Forms/InstallForm.Designer.cs index fb70fee..3983c57 100644 --- a/CreamInstaller/Forms/InstallForm.Designer.cs +++ b/CreamInstaller/Forms/InstallForm.Designer.cs @@ -128,6 +128,8 @@ namespace CreamInstaller // this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.AutoSize = true; + this.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; this.ClientSize = new System.Drawing.Size(784, 561); this.Controls.Add(this.reselectButton); this.Controls.Add(this.logTextBox); @@ -137,11 +139,10 @@ namespace CreamInstaller this.Controls.Add(this.userProgressBar); this.Controls.Add(this.userInfoLabel); this.DoubleBuffered = true; + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; this.MaximizeBox = false; this.MinimizeBox = false; - 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; this.Text = "InstallForm"; this.Load += new System.EventHandler(this.OnLoad); diff --git a/CreamInstaller/Forms/MainForm.Designer.cs b/CreamInstaller/Forms/MainForm.Designer.cs index d43cd45..8d3e142 100644 --- a/CreamInstaller/Forms/MainForm.Designer.cs +++ b/CreamInstaller/Forms/MainForm.Designer.cs @@ -21,21 +21,21 @@ namespace CreamInstaller /// private void InitializeComponent() { - this.label1 = new System.Windows.Forms.Label(); + this.progressLabel = new System.Windows.Forms.Label(); this.updateButton = new System.Windows.Forms.Button(); this.ignoreButton = new System.Windows.Forms.Button(); - this.progressBar1 = new System.Windows.Forms.ProgressBar(); + this.progressBar = new System.Windows.Forms.ProgressBar(); this.changelogTreeView = new CustomTreeView(); this.SuspendLayout(); // - // label1 + // progressLabel // - this.label1.FlatStyle = System.Windows.Forms.FlatStyle.System; - this.label1.Location = new System.Drawing.Point(12, 16); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(218, 15); - this.label1.TabIndex = 0; - this.label1.Text = "Checking for updates . . ."; + this.progressLabel.FlatStyle = System.Windows.Forms.FlatStyle.System; + this.progressLabel.Location = new System.Drawing.Point(12, 16); + this.progressLabel.Name = "progressLabel"; + this.progressLabel.Size = new System.Drawing.Size(218, 15); + this.progressLabel.TabIndex = 0; + this.progressLabel.Text = "Checking for updates . . ."; // // updateButton // @@ -62,38 +62,41 @@ namespace CreamInstaller this.ignoreButton.UseVisualStyleBackColor = true; this.ignoreButton.Click += new System.EventHandler(this.OnIgnore); // - // progressBar1 + // progressBar // - this.progressBar1.Location = new System.Drawing.Point(12, 41); - this.progressBar1.Name = "progressBar1"; - this.progressBar1.Size = new System.Drawing.Size(380, 23); - this.progressBar1.TabIndex = 4; - this.progressBar1.Visible = false; + this.progressBar.Location = new System.Drawing.Point(12, 41); + this.progressBar.Name = "progressBar"; + this.progressBar.Size = new System.Drawing.Size(380, 23); + this.progressBar.TabIndex = 4; + this.progressBar.Visible = false; // // changelogTreeView // + this.changelogTreeView.DrawMode = System.Windows.Forms.TreeViewDrawMode.OwnerDrawAll; this.changelogTreeView.Location = new System.Drawing.Point(12, 70); + this.changelogTreeView.Margin = new System.Windows.Forms.Padding(0, 0, 0, 12); this.changelogTreeView.Name = "changelogTreeView"; this.changelogTreeView.Size = new System.Drawing.Size(380, 179); + this.changelogTreeView.Sorted = true; this.changelogTreeView.TabIndex = 5; // // MainForm // this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.AutoSize = true; + this.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; this.ClientSize = new System.Drawing.Size(404, 261); this.Controls.Add(this.changelogTreeView); - this.Controls.Add(this.progressBar1); + this.Controls.Add(this.progressBar); this.Controls.Add(this.ignoreButton); this.Controls.Add(this.updateButton); - this.Controls.Add(this.label1); + this.Controls.Add(this.progressLabel); this.DoubleBuffered = true; this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; this.MaximizeBox = false; - this.MaximumSize = new System.Drawing.Size(420, 300); this.MinimizeBox = false; this.Name = "MainForm"; - this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "MainForm"; this.Load += new System.EventHandler(this.OnLoad); @@ -103,10 +106,10 @@ namespace CreamInstaller #endregion - private Label label1; + private Label progressLabel; private Button updateButton; private Button ignoreButton; - private ProgressBar progressBar1; + private ProgressBar progressBar; private CustomTreeView changelogTreeView; } } diff --git a/CreamInstaller/Forms/MainForm.cs b/CreamInstaller/Forms/MainForm.cs index 7b9ec46..2ebe9a3 100644 --- a/CreamInstaller/Forms/MainForm.cs +++ b/CreamInstaller/Forms/MainForm.cs @@ -49,15 +49,14 @@ internal partial class MainForm : CustomForm private async void OnLoad() { - Size = new(420, 85); - progressBar1.Visible = false; + progressBar.Visible = false; ignoreButton.Visible = true; updateButton.Text = "Update"; updateButton.Click -= OnUpdateCancel; - label1.Text = "Checking for updates . . ."; + progressLabel.Text = "Checking for updates . . ."; changelogTreeView.Visible = false; - changelogTreeView.Location = new(12, 41); - changelogTreeView.Size = new(380, 208); + changelogTreeView.Location = new(progressLabel.Location.X, progressLabel.Location.Y + progressLabel.Size.Height + 13); + Refresh(); GithubPackageResolver resolver = new("pointfeev", "CreamInstaller", "CreamInstaller.zip"); ZipPackageExtractor extractor = new(); @@ -87,8 +86,7 @@ internal partial class MainForm : CustomForm } else { - Size = new(420, 300); - label1.Text = $"An update is available: v{latestVersion}"; + progressLabel.Text = $"An update is available: v{latestVersion}"; ignoreButton.Enabled = true; updateButton.Enabled = true; updateButton.Click += new(OnUpdate); @@ -96,8 +94,10 @@ internal partial class MainForm : CustomForm Version currentVersion = new(Application.ProductVersion); foreach (Version version in versions.Where(v => v > currentVersion && !changelogTreeView.Nodes.ContainsKey(v.ToString()))) { - TreeNode root = new($"v{version}"); - root.Name = root.Text; + TreeNode root = new($"v{version}") + { + Name = version.ToString() + }; changelogTreeView.Nodes.Add(root); if (changelogTreeView.Nodes.Count > 0) changelogTreeView.Nodes[0].EnsureVisible(); _ = Task.Run(async () => @@ -155,22 +155,22 @@ internal partial class MainForm : CustomForm private async void OnUpdate(object sender, EventArgs e) { - progressBar1.Visible = true; + progressBar.Visible = true; ignoreButton.Visible = false; updateButton.Text = "Cancel"; updateButton.Click -= OnUpdate; updateButton.Click += new(OnUpdateCancel); - changelogTreeView.Location = new(12, 70); - changelogTreeView.Size = new(380, 179); + changelogTreeView.Location = new(progressBar.Location.X, progressBar.Location.Y + progressBar.Size.Height + 6); + Refresh(); Progress progress = new(); progress.ProgressChanged += new(delegate (object sender, double _progress) { - label1.Text = $"Updating . . . {(int)_progress}%"; - progressBar1.Value = (int)_progress; + progressLabel.Text = $"Updating . . . {(int)_progress}%"; + progressBar.Value = (int)_progress; }); - label1.Text = "Updating . . . "; + progressLabel.Text = "Updating . . . "; cancellationTokenSource = new(); try { @@ -180,6 +180,8 @@ internal partial class MainForm : CustomForm } catch { } + await Task.Run(() => Thread.Sleep(3000)); + if (updateManager is not null && updateManager.IsUpdatePrepared(latestVersion)) { updateManager.LaunchUpdater(latestVersion); @@ -191,15 +193,15 @@ internal partial class MainForm : CustomForm private void OnUpdateCancel(object sender, EventArgs e) { - cancellationTokenSource.Cancel(); - updateManager.Dispose(); + cancellationTokenSource?.Cancel(); + updateManager?.Dispose(); updateManager = null; } protected override void Dispose(bool disposing) { - if (disposing && components is not null) - components.Dispose(); + if (disposing) + components?.Dispose(); base.Dispose(disposing); cancellationTokenSource?.Dispose(); updateManager?.Dispose(); diff --git a/CreamInstaller/Forms/SelectDialogForm.Designer.cs b/CreamInstaller/Forms/SelectDialogForm.Designer.cs index b29585f..d1ddd59 100644 --- a/CreamInstaller/Forms/SelectDialogForm.Designer.cs +++ b/CreamInstaller/Forms/SelectDialogForm.Designer.cs @@ -163,6 +163,8 @@ namespace CreamInstaller this.AcceptButton = this.acceptButton; this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.AutoSize = true; + this.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; this.ClientSize = new System.Drawing.Size(433, 279); this.Controls.Add(this.saveButton); this.Controls.Add(this.loadButton); diff --git a/CreamInstaller/Forms/SelectForm.Designer.cs b/CreamInstaller/Forms/SelectForm.Designer.cs index f1043fe..afc5f63 100644 --- a/CreamInstaller/Forms/SelectForm.Designer.cs +++ b/CreamInstaller/Forms/SelectForm.Designer.cs @@ -270,6 +270,8 @@ namespace CreamInstaller // this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.AutoSize = true; + this.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; this.ClientSize = new System.Drawing.Size(584, 361); this.Controls.Add(this.progressLabelDLCs); this.Controls.Add(this.progressLabelGames); @@ -282,11 +284,10 @@ namespace CreamInstaller this.Controls.Add(this.installButton); this.Controls.Add(this.progressLabel); this.DoubleBuffered = true; + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; this.MaximizeBox = false; this.MinimizeBox = false; - 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; this.Text = "SelectForm"; this.Load += new System.EventHandler(this.OnLoad);