1
0
mirror of synced 2024-09-24 11:38:22 +02:00

Improve updater

This commit is contained in:
KillzXGaming 2019-05-13 21:21:51 -04:00
parent a043f96b11
commit f590b9d834
7 changed files with 72 additions and 23 deletions

Binary file not shown.

View File

@ -33,38 +33,47 @@
this.listViewCustom1 = new Switch_Toolbox.Library.Forms.ListViewCustom();
this.columnHeader1 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.columnHeader2 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.stTextBox1 = new Switch_Toolbox.Library.Forms.STTextBox();
this.stLabel1 = new Switch_Toolbox.Library.Forms.STLabel();
this.stLabel2 = new Switch_Toolbox.Library.Forms.STLabel();
this.contentContainer.SuspendLayout();
this.SuspendLayout();
//
// contentContainer
//
this.contentContainer.Controls.Add(this.stLabel2);
this.contentContainer.Controls.Add(this.stLabel1);
this.contentContainer.Controls.Add(this.stTextBox1);
this.contentContainer.Controls.Add(this.listViewCustom1);
this.contentContainer.Controls.Add(this.stButton2);
this.contentContainer.Controls.Add(this.stButton1);
this.contentContainer.Controls.SetChildIndex(this.stButton1, 0);
this.contentContainer.Controls.SetChildIndex(this.stButton2, 0);
this.contentContainer.Controls.SetChildIndex(this.listViewCustom1, 0);
this.contentContainer.Controls.SetChildIndex(this.stTextBox1, 0);
this.contentContainer.Controls.SetChildIndex(this.stLabel1, 0);
this.contentContainer.Controls.SetChildIndex(this.stLabel2, 0);
//
// stButton1
//
this.stButton1.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.stButton1.DialogResult = System.Windows.Forms.DialogResult.No;
this.stButton1.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.stButton1.Location = new System.Drawing.Point(459, 361);
this.stButton1.Name = "stButton1";
this.stButton1.Size = new System.Drawing.Size(75, 23);
this.stButton1.TabIndex = 11;
this.stButton1.Text = "Cancel";
this.stButton1.Text = "No";
this.stButton1.UseVisualStyleBackColor = false;
//
// stButton2
//
this.stButton2.DialogResult = System.Windows.Forms.DialogResult.OK;
this.stButton2.DialogResult = System.Windows.Forms.DialogResult.Yes;
this.stButton2.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.stButton2.Location = new System.Drawing.Point(378, 361);
this.stButton2.Name = "stButton2";
this.stButton2.Size = new System.Drawing.Size(75, 23);
this.stButton2.TabIndex = 12;
this.stButton2.Text = "Ok";
this.stButton2.Text = "Yes";
this.stButton2.UseVisualStyleBackColor = false;
//
// listViewCustom1
@ -74,13 +83,14 @@
this.columnHeader1,
this.columnHeader2});
this.listViewCustom1.FullRowSelect = true;
this.listViewCustom1.Location = new System.Drawing.Point(3, 31);
this.listViewCustom1.Location = new System.Drawing.Point(3, 58);
this.listViewCustom1.Name = "listViewCustom1";
this.listViewCustom1.OwnerDraw = true;
this.listViewCustom1.Size = new System.Drawing.Size(540, 324);
this.listViewCustom1.Size = new System.Drawing.Size(540, 201);
this.listViewCustom1.TabIndex = 13;
this.listViewCustom1.UseCompatibleStateImageBehavior = false;
this.listViewCustom1.View = System.Windows.Forms.View.Details;
this.listViewCustom1.SelectedIndexChanged += new System.EventHandler(this.listViewCustom1_SelectedIndexChanged);
//
// columnHeader1
//
@ -90,6 +100,34 @@
// columnHeader2
//
this.columnHeader2.Text = "Date";
this.columnHeader2.Width = 368;
//
// stTextBox1
//
this.stTextBox1.BorderStyle = System.Windows.Forms.BorderStyle.None;
this.stTextBox1.Location = new System.Drawing.Point(5, 280);
this.stTextBox1.Multiline = true;
this.stTextBox1.Name = "stTextBox1";
this.stTextBox1.Size = new System.Drawing.Size(529, 75);
this.stTextBox1.TabIndex = 14;
//
// stLabel1
//
this.stLabel1.AutoSize = true;
this.stLabel1.Location = new System.Drawing.Point(6, 34);
this.stLabel1.Name = "stLabel1";
this.stLabel1.Size = new System.Drawing.Size(283, 13);
this.stLabel1.TabIndex = 15;
this.stLabel1.Text = "Updates are found! Would you like to update to the latest?";
//
// stLabel2
//
this.stLabel2.AutoSize = true;
this.stLabel2.Location = new System.Drawing.Point(6, 262);
this.stLabel2.Name = "stLabel2";
this.stLabel2.Size = new System.Drawing.Size(39, 13);
this.stLabel2.TabIndex = 16;
this.stLabel2.Text = "Details";
//
// GithubUpdateDialog
//
@ -99,6 +137,7 @@
this.Name = "GithubUpdateDialog";
this.Text = "Github Update";
this.contentContainer.ResumeLayout(false);
this.contentContainer.PerformLayout();
this.ResumeLayout(false);
}
@ -110,5 +149,8 @@
private Switch_Toolbox.Library.Forms.ListViewCustom listViewCustom1;
private System.Windows.Forms.ColumnHeader columnHeader1;
private System.Windows.Forms.ColumnHeader columnHeader2;
private Switch_Toolbox.Library.Forms.STLabel stLabel2;
private Switch_Toolbox.Library.Forms.STLabel stLabel1;
private Switch_Toolbox.Library.Forms.STTextBox stTextBox1;
}
}

View File

@ -19,12 +19,23 @@ namespace Toolbox
InitializeComponent();
}
private List<GitHubCommit> ActiveCommitList;
public void LoadCommits(List<GitHubCommit> Commits)
{
ActiveCommitList = Commits;
foreach (var commit in Commits)
{
listViewCustom1.Items.Add(commit.Commit.Message).SubItems.Add(commit.Commit.Author.Date.DateTime.ToString());
}
}
private void listViewCustom1_SelectedIndexChanged(object sender, EventArgs e)
{
if (listViewCustom1.SelectedIndices.Count > 0)
{
int index = listViewCustom1.SelectedIndices[0];
stTextBox1.Text = ActiveCommitList[index].Commit.Message;
}
}
}
}

View File

@ -71,6 +71,7 @@ namespace Toolbox
//Use for files opened with program
public List<string> openedFiles = new List<string>();
private VersionCheck VersionCheck;
private void Form1_Load(object sender, EventArgs e)
{
VersionCheck version = new VersionCheck();
@ -154,7 +155,8 @@ namespace Toolbox
bool UsePrompt = true;
private void Application_Idle(object sender, EventArgs e)
{
if (UpdateProgram.CanUpdate && Runtime.EnableVersionCheck && UsePrompt)
if (UpdateProgram.CanUpdate && Runtime.EnableVersionCheck && UsePrompt &&
UpdateProgram.CommitList.Count > 0)
{
updateToolstrip.Enabled = true;
}
@ -162,21 +164,12 @@ namespace Toolbox
private void UpdateNotifcationClick()
{
/* var dialog = new GithubUpdateDialog();
if (UpdateProgram.CommitList.Count <= 0)
return;
var dialog = new GithubUpdateDialog();
dialog.LoadCommits(UpdateProgram.CommitList);
if (dialog.ShowDialog() == DialogResult.OK)
{
}*/
//Prompt once for the user to update the tool.
DialogResult result;
using (DialogCenteringService centeringService = new DialogCenteringService(this)) // center message box
{
result = MessageBox.Show($"A new update is available {UpdateProgram.LatestRelease.TagName} \n\n{UpdateProgram.LatestRelease.Body}!" +
$" Would you like to install it?", "Updater", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1);
}
if (result == DialogResult.Yes)
if (dialog.ShowDialog() == DialogResult.Yes)
{
UpdateApplication();
}

View File

@ -51,13 +51,16 @@ namespace Toolbox
{
var options = new ApiOptions
{
PageSize = 5,
PageSize = 20,
PageCount = 1
};
foreach (GitHubCommit c in await client.Repository.Commit.GetAll("KillzXGaming", "Switch-Toolbox", options))
{
CommitList.Add(c);
if (!Runtime.CompileDate.Contains(c.Commit.Author.Date.DateTime.ToString()))
CommitList.Add(c);
else
break;
}
}