- Forms now use automatic sizing
- Fixed version info being duplicated after update cancellation
This commit is contained in:
pointfeev 2022-06-10 19:38:32 -05:00
parent 851e4ccaf5
commit ca72e9adf5
7 changed files with 55 additions and 45 deletions

View file

@ -14,6 +14,7 @@ internal class CustomForm : Form
Owner = (owner as Form) ?? ActiveForm; Owner = (owner as Form) ?? ActiveForm;
KeyPreview = true; KeyPreview = true;
KeyPress += OnKeyPress; KeyPress += OnKeyPress;
ResizeRedraw = true;
} }
protected override CreateParams CreateParams // Double buffering for all controls protected override CreateParams CreateParams // Double buffering for all controls

View file

@ -5,7 +5,7 @@
<UseWindowsForms>True</UseWindowsForms> <UseWindowsForms>True</UseWindowsForms>
<ApplicationIcon>Resources\ini.ico</ApplicationIcon> <ApplicationIcon>Resources\ini.ico</ApplicationIcon>
<IncludeAllContentForSelfExtract>true</IncludeAllContentForSelfExtract> <IncludeAllContentForSelfExtract>true</IncludeAllContentForSelfExtract>
<Version>3.5.1.0</Version> <Version>3.5.2.0</Version>
<PackageIcon>Resources\ini.ico</PackageIcon> <PackageIcon>Resources\ini.ico</PackageIcon>
<PackageLicenseFile>LICENSE</PackageLicenseFile> <PackageLicenseFile>LICENSE</PackageLicenseFile>
<Copyright>2021, pointfeev (https://github.com/pointfeev)</Copyright> <Copyright>2021, pointfeev (https://github.com/pointfeev)</Copyright>

View file

@ -128,6 +128,8 @@ namespace CreamInstaller
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 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.ClientSize = new System.Drawing.Size(784, 561);
this.Controls.Add(this.reselectButton); this.Controls.Add(this.reselectButton);
this.Controls.Add(this.logTextBox); this.Controls.Add(this.logTextBox);
@ -137,11 +139,10 @@ namespace CreamInstaller
this.Controls.Add(this.userProgressBar); this.Controls.Add(this.userProgressBar);
this.Controls.Add(this.userInfoLabel); this.Controls.Add(this.userInfoLabel);
this.DoubleBuffered = true; this.DoubleBuffered = true;
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.MaximizeBox = false; this.MaximizeBox = false;
this.MinimizeBox = false; this.MinimizeBox = false;
this.MinimumSize = new System.Drawing.Size(600, 400);
this.Name = "InstallForm"; this.Name = "InstallForm";
this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Show;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "InstallForm"; this.Text = "InstallForm";
this.Load += new System.EventHandler(this.OnLoad); this.Load += new System.EventHandler(this.OnLoad);

View file

@ -21,21 +21,21 @@ namespace CreamInstaller
/// </summary> /// </summary>
private void InitializeComponent() 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.updateButton = new System.Windows.Forms.Button();
this.ignoreButton = 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.changelogTreeView = new CustomTreeView();
this.SuspendLayout(); this.SuspendLayout();
// //
// label1 // progressLabel
// //
this.label1.FlatStyle = System.Windows.Forms.FlatStyle.System; this.progressLabel.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.label1.Location = new System.Drawing.Point(12, 16); this.progressLabel.Location = new System.Drawing.Point(12, 16);
this.label1.Name = "label1"; this.progressLabel.Name = "progressLabel";
this.label1.Size = new System.Drawing.Size(218, 15); this.progressLabel.Size = new System.Drawing.Size(218, 15);
this.label1.TabIndex = 0; this.progressLabel.TabIndex = 0;
this.label1.Text = "Checking for updates . . ."; this.progressLabel.Text = "Checking for updates . . .";
// //
// updateButton // updateButton
// //
@ -62,38 +62,41 @@ namespace CreamInstaller
this.ignoreButton.UseVisualStyleBackColor = true; this.ignoreButton.UseVisualStyleBackColor = true;
this.ignoreButton.Click += new System.EventHandler(this.OnIgnore); this.ignoreButton.Click += new System.EventHandler(this.OnIgnore);
// //
// progressBar1 // progressBar
// //
this.progressBar1.Location = new System.Drawing.Point(12, 41); this.progressBar.Location = new System.Drawing.Point(12, 41);
this.progressBar1.Name = "progressBar1"; this.progressBar.Name = "progressBar";
this.progressBar1.Size = new System.Drawing.Size(380, 23); this.progressBar.Size = new System.Drawing.Size(380, 23);
this.progressBar1.TabIndex = 4; this.progressBar.TabIndex = 4;
this.progressBar1.Visible = false; this.progressBar.Visible = false;
// //
// changelogTreeView // changelogTreeView
// //
this.changelogTreeView.DrawMode = System.Windows.Forms.TreeViewDrawMode.OwnerDrawAll;
this.changelogTreeView.Location = new System.Drawing.Point(12, 70); 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.Name = "changelogTreeView";
this.changelogTreeView.Size = new System.Drawing.Size(380, 179); this.changelogTreeView.Size = new System.Drawing.Size(380, 179);
this.changelogTreeView.Sorted = true;
this.changelogTreeView.TabIndex = 5; this.changelogTreeView.TabIndex = 5;
// //
// MainForm // MainForm
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 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.ClientSize = new System.Drawing.Size(404, 261);
this.Controls.Add(this.changelogTreeView); this.Controls.Add(this.changelogTreeView);
this.Controls.Add(this.progressBar1); this.Controls.Add(this.progressBar);
this.Controls.Add(this.ignoreButton); this.Controls.Add(this.ignoreButton);
this.Controls.Add(this.updateButton); this.Controls.Add(this.updateButton);
this.Controls.Add(this.label1); this.Controls.Add(this.progressLabel);
this.DoubleBuffered = true; this.DoubleBuffered = true;
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.MaximizeBox = false; this.MaximizeBox = false;
this.MaximumSize = new System.Drawing.Size(420, 300);
this.MinimizeBox = false; this.MinimizeBox = false;
this.Name = "MainForm"; this.Name = "MainForm";
this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "MainForm"; this.Text = "MainForm";
this.Load += new System.EventHandler(this.OnLoad); this.Load += new System.EventHandler(this.OnLoad);
@ -103,10 +106,10 @@ namespace CreamInstaller
#endregion #endregion
private Label label1; private Label progressLabel;
private Button updateButton; private Button updateButton;
private Button ignoreButton; private Button ignoreButton;
private ProgressBar progressBar1; private ProgressBar progressBar;
private CustomTreeView changelogTreeView; private CustomTreeView changelogTreeView;
} }
} }

View file

@ -49,15 +49,14 @@ internal partial class MainForm : CustomForm
private async void OnLoad() private async void OnLoad()
{ {
Size = new(420, 85); progressBar.Visible = false;
progressBar1.Visible = false;
ignoreButton.Visible = true; ignoreButton.Visible = true;
updateButton.Text = "Update"; updateButton.Text = "Update";
updateButton.Click -= OnUpdateCancel; updateButton.Click -= OnUpdateCancel;
label1.Text = "Checking for updates . . ."; progressLabel.Text = "Checking for updates . . .";
changelogTreeView.Visible = false; changelogTreeView.Visible = false;
changelogTreeView.Location = new(12, 41); changelogTreeView.Location = new(progressLabel.Location.X, progressLabel.Location.Y + progressLabel.Size.Height + 13);
changelogTreeView.Size = new(380, 208); Refresh();
GithubPackageResolver resolver = new("pointfeev", "CreamInstaller", "CreamInstaller.zip"); GithubPackageResolver resolver = new("pointfeev", "CreamInstaller", "CreamInstaller.zip");
ZipPackageExtractor extractor = new(); ZipPackageExtractor extractor = new();
@ -87,8 +86,7 @@ internal partial class MainForm : CustomForm
} }
else else
{ {
Size = new(420, 300); progressLabel.Text = $"An update is available: v{latestVersion}";
label1.Text = $"An update is available: v{latestVersion}";
ignoreButton.Enabled = true; ignoreButton.Enabled = true;
updateButton.Enabled = true; updateButton.Enabled = true;
updateButton.Click += new(OnUpdate); updateButton.Click += new(OnUpdate);
@ -96,8 +94,10 @@ internal partial class MainForm : CustomForm
Version currentVersion = new(Application.ProductVersion); Version currentVersion = new(Application.ProductVersion);
foreach (Version version in versions.Where(v => v > currentVersion && !changelogTreeView.Nodes.ContainsKey(v.ToString()))) foreach (Version version in versions.Where(v => v > currentVersion && !changelogTreeView.Nodes.ContainsKey(v.ToString())))
{ {
TreeNode root = new($"v{version}"); TreeNode root = new($"v{version}")
root.Name = root.Text; {
Name = version.ToString()
};
changelogTreeView.Nodes.Add(root); changelogTreeView.Nodes.Add(root);
if (changelogTreeView.Nodes.Count > 0) changelogTreeView.Nodes[0].EnsureVisible(); if (changelogTreeView.Nodes.Count > 0) changelogTreeView.Nodes[0].EnsureVisible();
_ = Task.Run(async () => _ = Task.Run(async () =>
@ -155,22 +155,22 @@ internal partial class MainForm : CustomForm
private async void OnUpdate(object sender, EventArgs e) private async void OnUpdate(object sender, EventArgs e)
{ {
progressBar1.Visible = true; progressBar.Visible = true;
ignoreButton.Visible = false; ignoreButton.Visible = false;
updateButton.Text = "Cancel"; updateButton.Text = "Cancel";
updateButton.Click -= OnUpdate; updateButton.Click -= OnUpdate;
updateButton.Click += new(OnUpdateCancel); updateButton.Click += new(OnUpdateCancel);
changelogTreeView.Location = new(12, 70); changelogTreeView.Location = new(progressBar.Location.X, progressBar.Location.Y + progressBar.Size.Height + 6);
changelogTreeView.Size = new(380, 179); Refresh();
Progress<double> progress = new(); Progress<double> progress = new();
progress.ProgressChanged += new(delegate (object sender, double _progress) progress.ProgressChanged += new(delegate (object sender, double _progress)
{ {
label1.Text = $"Updating . . . {(int)_progress}%"; progressLabel.Text = $"Updating . . . {(int)_progress}%";
progressBar1.Value = (int)_progress; progressBar.Value = (int)_progress;
}); });
label1.Text = "Updating . . . "; progressLabel.Text = "Updating . . . ";
cancellationTokenSource = new(); cancellationTokenSource = new();
try try
{ {
@ -180,6 +180,8 @@ internal partial class MainForm : CustomForm
} }
catch { } catch { }
await Task.Run(() => Thread.Sleep(3000));
if (updateManager is not null && updateManager.IsUpdatePrepared(latestVersion)) if (updateManager is not null && updateManager.IsUpdatePrepared(latestVersion))
{ {
updateManager.LaunchUpdater(latestVersion); updateManager.LaunchUpdater(latestVersion);
@ -191,15 +193,15 @@ internal partial class MainForm : CustomForm
private void OnUpdateCancel(object sender, EventArgs e) private void OnUpdateCancel(object sender, EventArgs e)
{ {
cancellationTokenSource.Cancel(); cancellationTokenSource?.Cancel();
updateManager.Dispose(); updateManager?.Dispose();
updateManager = null; updateManager = null;
} }
protected override void Dispose(bool disposing) protected override void Dispose(bool disposing)
{ {
if (disposing && components is not null) if (disposing)
components.Dispose(); components?.Dispose();
base.Dispose(disposing); base.Dispose(disposing);
cancellationTokenSource?.Dispose(); cancellationTokenSource?.Dispose();
updateManager?.Dispose(); updateManager?.Dispose();

View file

@ -163,6 +163,8 @@ namespace CreamInstaller
this.AcceptButton = this.acceptButton; this.AcceptButton = this.acceptButton;
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 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.ClientSize = new System.Drawing.Size(433, 279);
this.Controls.Add(this.saveButton); this.Controls.Add(this.saveButton);
this.Controls.Add(this.loadButton); this.Controls.Add(this.loadButton);

View file

@ -270,6 +270,8 @@ namespace CreamInstaller
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 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.ClientSize = new System.Drawing.Size(584, 361);
this.Controls.Add(this.progressLabelDLCs); this.Controls.Add(this.progressLabelDLCs);
this.Controls.Add(this.progressLabelGames); this.Controls.Add(this.progressLabelGames);
@ -282,11 +284,10 @@ namespace CreamInstaller
this.Controls.Add(this.installButton); this.Controls.Add(this.installButton);
this.Controls.Add(this.progressLabel); this.Controls.Add(this.progressLabel);
this.DoubleBuffered = true; this.DoubleBuffered = true;
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.MaximizeBox = false; this.MaximizeBox = false;
this.MinimizeBox = false; this.MinimizeBox = false;
this.MinimumSize = new System.Drawing.Size(600, 400);
this.Name = "SelectForm"; this.Name = "SelectForm";
this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Show;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "SelectForm"; this.Text = "SelectForm";
this.Load += new System.EventHandler(this.OnLoad); this.Load += new System.EventHandler(this.OnLoad);