Stage changes
This commit is contained in:
parent
daca8d5b9a
commit
c186afa8b4
|
@ -29,8 +29,7 @@
|
|||
private void InitializeComponent()
|
||||
{
|
||||
this.components = new System.ComponentModel.Container();
|
||||
System.ComponentModel.ComponentResourceManager resources =
|
||||
new System.ComponentModel.ComponentResourceManager(typeof(UpTool2.MainForm));
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm));
|
||||
this.sidebarPanel = new System.Windows.Forms.FlowLayoutPanel();
|
||||
this.infoPanel = new System.Windows.Forms.Panel();
|
||||
this.action_run = new System.Windows.Forms.Button();
|
||||
|
@ -47,21 +46,32 @@
|
|||
this.controls_settings = new System.Windows.Forms.Button();
|
||||
this.controls_reload = new System.Windows.Forms.Button();
|
||||
this.toolTip = new System.Windows.Forms.ToolTip(this.components);
|
||||
this.changesButton = new System.Windows.Forms.Button();
|
||||
this.searchPackageDialog = new System.Windows.Forms.OpenFileDialog();
|
||||
this.changesPanel = new System.Windows.Forms.Panel();
|
||||
this.progressBar1 = new System.Windows.Forms.ProgressBar();
|
||||
this.changesLabel = new System.Windows.Forms.Label();
|
||||
this.infoPanel.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize) (this.splitContainer)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.splitContainer)).BeginInit();
|
||||
this.splitContainer.Panel1.SuspendLayout();
|
||||
this.splitContainer.Panel2.SuspendLayout();
|
||||
this.splitContainer.SuspendLayout();
|
||||
this.optionsPanel.SuspendLayout();
|
||||
this.changesPanel.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// sidebarPanel
|
||||
//
|
||||
this.sidebarPanel.AutoScroll = true;
|
||||
this.sidebarPanel.BackColor = System.Drawing.SystemColors.ControlLight;
|
||||
this.sidebarPanel.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.sidebarPanel.Location = new System.Drawing.Point(0, 68);
|
||||
this.sidebarPanel.Name = "sidebarPanel";
|
||||
this.sidebarPanel.Size = new System.Drawing.Size(312, 451);
|
||||
this.sidebarPanel.Size = new System.Drawing.Size(312, 425);
|
||||
this.sidebarPanel.TabIndex = 0;
|
||||
//
|
||||
// infoPanel
|
||||
//
|
||||
this.infoPanel.Controls.Add(this.action_run);
|
||||
this.infoPanel.Controls.Add(this.action_remove);
|
||||
this.infoPanel.Controls.Add(this.action_update);
|
||||
|
@ -71,11 +81,12 @@
|
|||
this.infoPanel.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.infoPanel.Location = new System.Drawing.Point(0, 0);
|
||||
this.infoPanel.Name = "infoPanel";
|
||||
this.infoPanel.Size = new System.Drawing.Size(616, 519);
|
||||
this.infoPanel.Size = new System.Drawing.Size(616, 493);
|
||||
this.infoPanel.TabIndex = 1;
|
||||
this.action_run.Anchor =
|
||||
((System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Top |
|
||||
System.Windows.Forms.AnchorStyles.Right)));
|
||||
//
|
||||
// action_run
|
||||
//
|
||||
this.action_run.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.action_run.Location = new System.Drawing.Point(491, 6);
|
||||
this.action_run.Name = "action_run";
|
||||
this.action_run.Size = new System.Drawing.Size(27, 27);
|
||||
|
@ -83,9 +94,10 @@
|
|||
this.action_run.Text = "↗";
|
||||
this.action_run.UseVisualStyleBackColor = true;
|
||||
this.action_run.Click += new System.EventHandler(this.Action_run_Click);
|
||||
this.action_remove.Anchor =
|
||||
((System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Top |
|
||||
System.Windows.Forms.AnchorStyles.Right)));
|
||||
//
|
||||
// action_remove
|
||||
//
|
||||
this.action_remove.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.action_remove.Enabled = false;
|
||||
this.action_remove.Location = new System.Drawing.Point(523, 6);
|
||||
this.action_remove.Name = "action_remove";
|
||||
|
@ -94,9 +106,10 @@
|
|||
this.action_remove.Text = "🗑";
|
||||
this.action_remove.UseVisualStyleBackColor = true;
|
||||
this.action_remove.Click += new System.EventHandler(this.Action_remove_Click);
|
||||
this.action_update.Anchor =
|
||||
((System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Top |
|
||||
System.Windows.Forms.AnchorStyles.Right)));
|
||||
//
|
||||
// action_update
|
||||
//
|
||||
this.action_update.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.action_update.Enabled = false;
|
||||
this.action_update.Location = new System.Drawing.Point(554, 6);
|
||||
this.action_update.Name = "action_update";
|
||||
|
@ -105,9 +118,10 @@
|
|||
this.action_update.Text = "⭱";
|
||||
this.action_update.UseVisualStyleBackColor = true;
|
||||
this.action_update.Click += new System.EventHandler(this.Action_update_Click);
|
||||
this.action_install.Anchor =
|
||||
((System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Top |
|
||||
System.Windows.Forms.AnchorStyles.Right)));
|
||||
//
|
||||
// action_install
|
||||
//
|
||||
this.action_install.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.action_install.Enabled = false;
|
||||
this.action_install.Location = new System.Drawing.Point(586, 6);
|
||||
this.action_install.Name = "action_install";
|
||||
|
@ -116,30 +130,50 @@
|
|||
this.action_install.Text = "⭳";
|
||||
this.action_install.UseVisualStyleBackColor = true;
|
||||
this.action_install.Click += new System.EventHandler(this.Action_install_Click);
|
||||
//
|
||||
// infoPanel_Description
|
||||
//
|
||||
this.infoPanel_Description.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.infoPanel_Description.Location = new System.Drawing.Point(3, 51);
|
||||
this.infoPanel_Description.Name = "infoPanel_Description";
|
||||
this.infoPanel_Description.Size = new System.Drawing.Size(611, 458);
|
||||
this.infoPanel_Description.Size = new System.Drawing.Size(611, 439);
|
||||
this.infoPanel_Description.TabIndex = 1;
|
||||
//
|
||||
// infoPanel_Title
|
||||
//
|
||||
this.infoPanel_Title.AutoSize = true;
|
||||
this.infoPanel_Title.Font = new System.Drawing.Font("Microsoft Sans Serif", 20.25F,
|
||||
System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
||||
this.infoPanel_Title.Font = new System.Drawing.Font("Microsoft Sans Serif", 20.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
||||
this.infoPanel_Title.Location = new System.Drawing.Point(2, 1);
|
||||
this.infoPanel_Title.Name = "infoPanel_Title";
|
||||
this.infoPanel_Title.Size = new System.Drawing.Size(0, 31);
|
||||
this.infoPanel_Title.TabIndex = 0;
|
||||
//
|
||||
// splitContainer
|
||||
//
|
||||
this.splitContainer.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.splitContainer.Location = new System.Drawing.Point(0, 0);
|
||||
this.splitContainer.Name = "splitContainer";
|
||||
//
|
||||
// splitContainer.Panel1
|
||||
//
|
||||
this.splitContainer.Panel1.Controls.Add(this.sidebarPanel);
|
||||
this.splitContainer.Panel1.Controls.Add(this.optionsPanel);
|
||||
this.splitContainer.Panel1MinSize = 160;
|
||||
//
|
||||
// splitContainer.Panel2
|
||||
//
|
||||
this.splitContainer.Panel2.Controls.Add(this.infoPanel);
|
||||
this.splitContainer.Panel2MinSize = 160;
|
||||
this.splitContainer.Size = new System.Drawing.Size(933, 519);
|
||||
this.splitContainer.Size = new System.Drawing.Size(933, 493);
|
||||
this.splitContainer.SplitterDistance = 312;
|
||||
this.splitContainer.SplitterWidth = 5;
|
||||
this.splitContainer.TabIndex = 0;
|
||||
this.splitContainer.TabStop = false;
|
||||
//
|
||||
// optionsPanel
|
||||
//
|
||||
this.optionsPanel.Controls.Add(this.controls_upload);
|
||||
this.optionsPanel.Controls.Add(this.filterBox);
|
||||
this.optionsPanel.Controls.Add(this.searchBox);
|
||||
|
@ -150,9 +184,10 @@
|
|||
this.optionsPanel.Name = "optionsPanel";
|
||||
this.optionsPanel.Size = new System.Drawing.Size(312, 68);
|
||||
this.optionsPanel.TabIndex = 0;
|
||||
this.controls_upload.Anchor =
|
||||
((System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Top |
|
||||
System.Windows.Forms.AnchorStyles.Right)));
|
||||
//
|
||||
// controls_upload
|
||||
//
|
||||
this.controls_upload.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.controls_upload.Location = new System.Drawing.Point(284, 6);
|
||||
this.controls_upload.Name = "controls_upload";
|
||||
this.controls_upload.Size = new System.Drawing.Size(27, 27);
|
||||
|
@ -160,10 +195,11 @@
|
|||
this.controls_upload.Text = "↑";
|
||||
this.controls_upload.UseVisualStyleBackColor = true;
|
||||
this.controls_upload.Click += new System.EventHandler(this.controls_upload_Click);
|
||||
this.filterBox.Anchor =
|
||||
((System.Windows.Forms.AnchorStyles) (((System.Windows.Forms.AnchorStyles.Top |
|
||||
System.Windows.Forms.AnchorStyles.Left) |
|
||||
System.Windows.Forms.AnchorStyles.Right)));
|
||||
//
|
||||
// filterBox
|
||||
//
|
||||
this.filterBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.filterBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.filterBox.FormattingEnabled = true;
|
||||
this.filterBox.Location = new System.Drawing.Point(68, 7);
|
||||
|
@ -171,15 +207,19 @@
|
|||
this.filterBox.Size = new System.Drawing.Size(209, 23);
|
||||
this.filterBox.TabIndex = 3;
|
||||
this.filterBox.SelectedIndexChanged += new System.EventHandler(this.UpdateSidebarV);
|
||||
this.searchBox.Anchor =
|
||||
((System.Windows.Forms.AnchorStyles) (((System.Windows.Forms.AnchorStyles.Bottom |
|
||||
System.Windows.Forms.AnchorStyles.Left) |
|
||||
System.Windows.Forms.AnchorStyles.Right)));
|
||||
//
|
||||
// searchBox
|
||||
//
|
||||
this.searchBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.searchBox.Location = new System.Drawing.Point(3, 38);
|
||||
this.searchBox.Name = "searchBox";
|
||||
this.searchBox.Size = new System.Drawing.Size(307, 23);
|
||||
this.searchBox.TabIndex = 2;
|
||||
this.searchBox.TextChanged += new System.EventHandler(this.UpdateSidebarV);
|
||||
//
|
||||
// controls_settings
|
||||
//
|
||||
this.controls_settings.Location = new System.Drawing.Point(3, 6);
|
||||
this.controls_settings.Name = "controls_settings";
|
||||
this.controls_settings.Size = new System.Drawing.Size(27, 27);
|
||||
|
@ -187,6 +227,9 @@
|
|||
this.controls_settings.Text = "⚙";
|
||||
this.controls_settings.UseVisualStyleBackColor = true;
|
||||
this.controls_settings.Click += new System.EventHandler(this.Controls_settings_Click);
|
||||
//
|
||||
// controls_reload
|
||||
//
|
||||
this.controls_reload.Location = new System.Drawing.Point(34, 6);
|
||||
this.controls_reload.Name = "controls_reload";
|
||||
this.controls_reload.Size = new System.Drawing.Size(27, 27);
|
||||
|
@ -194,17 +237,73 @@
|
|||
this.controls_reload.Text = "↻";
|
||||
this.controls_reload.UseVisualStyleBackColor = true;
|
||||
this.controls_reload.Click += new System.EventHandler(this.Controls_reload_Click);
|
||||
//
|
||||
// toolTip
|
||||
//
|
||||
this.toolTip.AutoPopDelay = 5000;
|
||||
this.toolTip.InitialDelay = 300;
|
||||
this.toolTip.ReshowDelay = 100;
|
||||
this.toolTip.ShowAlways = true;
|
||||
//
|
||||
// changesButton
|
||||
//
|
||||
this.changesButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.changesButton.Location = new System.Drawing.Point(906, 0);
|
||||
this.changesButton.Name = "changesButton";
|
||||
this.changesButton.Size = new System.Drawing.Size(27, 26);
|
||||
this.changesButton.TabIndex = 4;
|
||||
this.changesButton.Text = "→";
|
||||
this.toolTip.SetToolTip(this.changesButton, "Perform changes");
|
||||
this.changesButton.UseVisualStyleBackColor = true;
|
||||
this.changesButton.Click += new System.EventHandler(this.changesButton_Click);
|
||||
//
|
||||
// searchPackageDialog
|
||||
//
|
||||
this.searchPackageDialog.Filter = "Packages (*.zip)|*.zip";
|
||||
//
|
||||
// changesPanel
|
||||
//
|
||||
this.changesPanel.Controls.Add(this.progressBar1);
|
||||
this.changesPanel.Controls.Add(this.changesButton);
|
||||
this.changesPanel.Controls.Add(this.changesLabel);
|
||||
this.changesPanel.Dock = System.Windows.Forms.DockStyle.Bottom;
|
||||
this.changesPanel.Location = new System.Drawing.Point(0, 493);
|
||||
this.changesPanel.Name = "changesPanel";
|
||||
this.changesPanel.Size = new System.Drawing.Size(933, 26);
|
||||
this.changesPanel.TabIndex = 1;
|
||||
this.changesPanel.Visible = false;
|
||||
//
|
||||
// progressBar1
|
||||
//
|
||||
this.progressBar1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.progressBar1.Location = new System.Drawing.Point(714, 0);
|
||||
this.progressBar1.Name = "progressBar1";
|
||||
this.progressBar1.Size = new System.Drawing.Size(186, 26);
|
||||
this.progressBar1.Step = 1;
|
||||
this.progressBar1.TabIndex = 5;
|
||||
//
|
||||
// changesLabel
|
||||
//
|
||||
this.changesLabel.Anchor = System.Windows.Forms.AnchorStyles.Left;
|
||||
this.changesLabel.AutoSize = true;
|
||||
this.changesLabel.Location = new System.Drawing.Point(7, 5);
|
||||
this.changesLabel.Name = "changesLabel";
|
||||
this.changesLabel.Size = new System.Drawing.Size(119, 15);
|
||||
this.changesLabel.TabIndex = 0;
|
||||
this.changesLabel.Text = "No Changes Selected";
|
||||
this.changesLabel.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
|
||||
this.changesLabel.Click += new System.EventHandler(this.changesLabel_Click);
|
||||
//
|
||||
// MainForm
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(933, 519);
|
||||
this.Controls.Add(this.splitContainer);
|
||||
this.Controls.Add(this.changesPanel);
|
||||
this.HelpButton = true;
|
||||
this.Icon = ((System.Drawing.Icon) (resources.GetObject("$this.Icon")));
|
||||
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
||||
this.MinimumSize = new System.Drawing.Size(631, 269);
|
||||
this.Name = "MainForm";
|
||||
this.ShowIcon = false;
|
||||
|
@ -214,11 +313,14 @@
|
|||
this.infoPanel.PerformLayout();
|
||||
this.splitContainer.Panel1.ResumeLayout(false);
|
||||
this.splitContainer.Panel2.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize) (this.splitContainer)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.splitContainer)).EndInit();
|
||||
this.splitContainer.ResumeLayout(false);
|
||||
this.optionsPanel.ResumeLayout(false);
|
||||
this.optionsPanel.PerformLayout();
|
||||
this.changesPanel.ResumeLayout(false);
|
||||
this.changesPanel.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
@ -240,6 +342,10 @@
|
|||
private System.Windows.Forms.Button action_run;
|
||||
private System.Windows.Forms.Button controls_upload;
|
||||
private System.Windows.Forms.OpenFileDialog searchPackageDialog;
|
||||
private System.Windows.Forms.Panel changesPanel;
|
||||
private System.Windows.Forms.Label changesLabel;
|
||||
private System.Windows.Forms.Button changesButton;
|
||||
private System.Windows.Forms.ProgressBar progressBar1;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -4,10 +4,11 @@ using System.IO;
|
|||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Windows.Forms;
|
||||
using UpTool2.Properties;
|
||||
using UpToolLib;
|
||||
using UpToolLib.DataStructures;
|
||||
using UpToolLib.Tool;
|
||||
using UpTool2.Task;
|
||||
using System.Collections.Generic;
|
||||
|
||||
#if DEBUG
|
||||
using System.Threading;
|
||||
|
@ -19,10 +20,12 @@ namespace UpTool2
|
|||
public sealed partial class MainForm : Form
|
||||
{
|
||||
private readonly HelpEventHandler _help;
|
||||
private List<IAppTask> _tasks;
|
||||
|
||||
public MainForm()
|
||||
{
|
||||
InitializeComponent();
|
||||
_tasks = new List<IAppTask>();
|
||||
_help = MainForm_HelpRequested;
|
||||
HelpRequested += _help;
|
||||
filterBox.DataSource = Enum.GetValues(typeof(Status));
|
||||
|
@ -43,61 +46,59 @@ namespace UpTool2
|
|||
|
||||
private void Action_install_Click(object sender, EventArgs e)
|
||||
{
|
||||
bool trying = true;
|
||||
while (trying)
|
||||
App tmp = (App)action_install.Tag;
|
||||
if (_tasks.Any(s => s is InstallTask t && t.App == tmp))
|
||||
{
|
||||
#if !DEBUG
|
||||
try
|
||||
{
|
||||
#endif
|
||||
AppInstall.Install((App) action_install.Tag, true);
|
||||
ReloadElements();
|
||||
trying = false;
|
||||
#if !DEBUG
|
||||
}
|
||||
catch (Exception e1)
|
||||
{
|
||||
trying = MessageBox.Show(e1.ToString(), "Install failed", MessageBoxButtons.RetryCancel) ==
|
||||
DialogResult.Retry;
|
||||
}
|
||||
#endif
|
||||
_tasks = _tasks.Where(s => !(s is InstallTask t) || t.App != tmp).ToList();
|
||||
action_install.ResetBackColor();
|
||||
}
|
||||
else
|
||||
{
|
||||
_tasks.Add(new InstallTask(tmp, ReloadElements));
|
||||
action_install.BackColor = Color.Green;
|
||||
}
|
||||
UpdateChangesLabel();
|
||||
}
|
||||
|
||||
private void Action_remove_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
App tmp = (App)action_install.Tag;
|
||||
if (_tasks.Any(s => s is RemoveTask t && t.App == tmp))
|
||||
{
|
||||
AppExtras.Remove((App) action_remove.Tag, true);
|
||||
ReloadElements();
|
||||
_tasks = _tasks.Where(s => !(s is RemoveTask t) || t.App != tmp).ToList();
|
||||
action_remove.ResetBackColor();
|
||||
}
|
||||
catch (Exception e1)
|
||||
else
|
||||
{
|
||||
MessageBox.Show(e1.ToString(), "Removal failed");
|
||||
_tasks.Add(new RemoveTask(tmp, ReloadElements));
|
||||
action_remove.BackColor = Color.Green;
|
||||
}
|
||||
UpdateChangesLabel();
|
||||
}
|
||||
|
||||
private void controls_upload_Click(object sender, EventArgs e)
|
||||
{
|
||||
#if !DEBUG
|
||||
try
|
||||
if (searchPackageDialog.ShowDialog() != DialogResult.OK)
|
||||
return;
|
||||
if (!_tasks.Any(s => s is UploadTask t && t.ZipFile == searchPackageDialog.FileName))
|
||||
_tasks.Add(new UploadTask(searchPackageDialog.FileName, AppNameDialog.Show(), ReloadElements));
|
||||
UpdateChangesLabel();
|
||||
}
|
||||
|
||||
private void Action_update_Click(object sender, EventArgs e)
|
||||
{
|
||||
App tmp = (App)action_install.Tag;
|
||||
if (_tasks.Any(s => s is UpdateTask t && t.App == tmp))
|
||||
{
|
||||
#endif
|
||||
if (searchPackageDialog.ShowDialog() != DialogResult.OK)
|
||||
return;
|
||||
Guid id = Guid.NewGuid();
|
||||
while (GlobalVariables.Apps.ContainsKey(id) || Directory.Exists(PathTool.GetAppPath(id)))
|
||||
id = Guid.NewGuid();
|
||||
App appI = new App(AppNameDialog.Show(), "Locally installed package, removal only",
|
||||
GlobalVariables.MinimumVer, "", true, "", id, Color.Red, Resources.C_64.ToBitmap(), false, "");
|
||||
AppInstall.InstallZip(searchPackageDialog.FileName, appI, true);
|
||||
#if !DEBUG
|
||||
_tasks = _tasks.Where(s => !(s is UpdateTask t) || t.App != tmp).ToList();
|
||||
action_update.ResetBackColor();
|
||||
}
|
||||
catch (Exception e1)
|
||||
else
|
||||
{
|
||||
MessageBox.Show(e1.ToString(), "Install failed");
|
||||
_tasks.Add(new UpdateTask(tmp, ReloadElements));
|
||||
action_update.BackColor = Color.Green;
|
||||
}
|
||||
#endif
|
||||
UpdateChangesLabel();
|
||||
}
|
||||
|
||||
private void ReloadElements()
|
||||
|
@ -139,10 +140,22 @@ namespace UpTool2
|
|||
infoPanel_Description.Text = app.Description;
|
||||
action_install.Tag = app;
|
||||
action_install.Enabled = !(app.Local || Directory.Exists(app.AppPath));
|
||||
if (_tasks.Any(s => s is InstallTask t && t.App == app))
|
||||
action_install.BackColor = Color.Green;
|
||||
else
|
||||
action_install.ResetBackColor();
|
||||
action_remove.Tag = app;
|
||||
action_remove.Enabled = Directory.Exists(app.AppPath);
|
||||
if (_tasks.Any(s => s is RemoveTask t && t.App == app))
|
||||
action_remove.BackColor = Color.Green;
|
||||
else
|
||||
action_remove.ResetBackColor();
|
||||
action_update.Tag = app;
|
||||
action_update.Enabled = updateable;
|
||||
if (_tasks.Any(s => s is UpdateTask t && t.App == app))
|
||||
action_update.BackColor = Color.Green;
|
||||
else
|
||||
action_update.ResetBackColor();
|
||||
action_run.Tag = app;
|
||||
action_run.Enabled = (app.Status & Status.Installed) == Status.Installed && !app.Local &&
|
||||
app.Runnable && Directory.Exists(app.AppPath);
|
||||
|
@ -169,19 +182,6 @@ namespace UpTool2
|
|||
}
|
||||
}
|
||||
|
||||
private void Action_update_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
AppExtras.Update((App) action_install.Tag, false);
|
||||
}
|
||||
catch (Exception e1)
|
||||
{
|
||||
MessageBox.Show(e1.ToString(), "Install failed");
|
||||
}
|
||||
ReloadElements();
|
||||
}
|
||||
|
||||
private void Controls_reload_Click(object sender, EventArgs e)
|
||||
{
|
||||
RepoManagement.FetchRepos();
|
||||
|
@ -243,6 +243,7 @@ namespace UpTool2
|
|||
{
|
||||
Program.Splash.Invoke((Action) Program.Splash.Hide);
|
||||
BringToFront();
|
||||
UpdateChangesLabel(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -261,7 +262,7 @@ namespace UpTool2
|
|||
}
|
||||
finally
|
||||
{
|
||||
if (stream != null) stream.Close();
|
||||
stream?.Close();
|
||||
}
|
||||
|
||||
int i = BitConverter.ToInt32(buffer, headerOffset);
|
||||
|
@ -272,7 +273,7 @@ namespace UpTool2
|
|||
return dt;
|
||||
}
|
||||
|
||||
private void MainForm_HelpRequested(object sender, HelpEventArgs hlpevent)
|
||||
private void MainForm_HelpRequested(object sender, HelpEventArgs hlpEvent)
|
||||
{
|
||||
HelpRequested -= _help;
|
||||
try
|
||||
|
@ -285,8 +286,41 @@ Build Date: {buildTime:dd.MM.yyyy}", "UpTool2");
|
|||
finally
|
||||
{
|
||||
HelpRequested += _help;
|
||||
hlpevent.Handled = true;
|
||||
hlpEvent.Handled = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void changesButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
TaskPreview.Show(ref _tasks);
|
||||
progressBar1.Maximum = _tasks.Count;
|
||||
progressBar1.Value = 0;
|
||||
foreach (IAppTask task in _tasks)
|
||||
{
|
||||
task.Run();
|
||||
progressBar1.PerformStep();
|
||||
}
|
||||
_tasks.Clear();
|
||||
UpdateChangesLabel();
|
||||
}
|
||||
|
||||
private void changesLabel_Click(object sender, EventArgs e)
|
||||
{
|
||||
TaskPreview.Show(ref _tasks);
|
||||
UpdateChangesLabel();
|
||||
}
|
||||
|
||||
private void UpdateChangesLabel(bool showPanel = true)
|
||||
{
|
||||
changesPanel.Visible = showPanel;
|
||||
changesButton.Enabled = _tasks.Count > 0;
|
||||
progressBar1.Maximum = _tasks.Count;
|
||||
changesLabel.Text = _tasks.Count switch
|
||||
{
|
||||
0 => "No Changes Selected",
|
||||
1 => "1 Change Selected",
|
||||
_ => $"{_tasks.Count} Changes Selected"
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace UpTool2.Task
|
||||
{
|
||||
interface IAppTask
|
||||
{
|
||||
public void Run();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using UpToolLib.DataStructures;
|
||||
|
||||
namespace UpTool2.Task
|
||||
{
|
||||
abstract class IKnownAppTask : IAppTask
|
||||
{
|
||||
public abstract App App { get; }
|
||||
public abstract void Run();
|
||||
|
||||
public override string ToString() => $"{TrimEnd(GetType().Name, "Task")} {App.Name}";
|
||||
|
||||
private static string TrimEnd(string target, string trimString)
|
||||
{
|
||||
if (string.IsNullOrEmpty(trimString)) return target;
|
||||
|
||||
string result = target;
|
||||
while (result.EndsWith(trimString))
|
||||
{
|
||||
result = result.Substring(0, result.Length - trimString.Length);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
using System;
|
||||
using System.Windows.Forms;
|
||||
using UpToolLib.DataStructures;
|
||||
using UpToolLib.Tool;
|
||||
|
||||
namespace UpTool2.Task
|
||||
{
|
||||
class InstallTask : IKnownAppTask
|
||||
{
|
||||
public override App App { get; }
|
||||
private readonly Action? _postInstall;
|
||||
public InstallTask(App app, Action? postInstall = null)
|
||||
{
|
||||
App = app;
|
||||
_postInstall = postInstall;
|
||||
}
|
||||
|
||||
public override void Run()
|
||||
{
|
||||
bool trying = true;
|
||||
while (trying)
|
||||
{
|
||||
#if !DEBUG
|
||||
try
|
||||
{
|
||||
#endif
|
||||
AppInstall.Install(App, true);
|
||||
_postInstall?.Invoke();
|
||||
trying = false;
|
||||
#if !DEBUG
|
||||
}
|
||||
catch (Exception e1)
|
||||
{
|
||||
trying = MessageBox.Show(e1.ToString(), "Install failed", MessageBoxButtons.RetryCancel) ==
|
||||
DialogResult.Retry;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using UpToolLib.DataStructures;
|
||||
using UpToolLib.Tool;
|
||||
|
||||
namespace UpTool2.Task
|
||||
{
|
||||
class RemoveTask : IKnownAppTask
|
||||
{
|
||||
public override App App { get; }
|
||||
private readonly Action? _postInstall;
|
||||
public RemoveTask(App app, Action? postInstall = null)
|
||||
{
|
||||
App = app;
|
||||
_postInstall = postInstall;
|
||||
}
|
||||
|
||||
public override void Run()
|
||||
{
|
||||
#if !DEBUG
|
||||
try
|
||||
{
|
||||
#endif
|
||||
AppExtras.Remove(App, true);
|
||||
_postInstall?.Invoke();
|
||||
#if !DEBUG
|
||||
}
|
||||
catch (Exception e1)
|
||||
{
|
||||
MessageBox.Show(e1.ToString(), "Removal failed");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using UpToolLib.DataStructures;
|
||||
using UpToolLib.Tool;
|
||||
|
||||
namespace UpTool2.Task
|
||||
{
|
||||
class UpdateTask : IKnownAppTask
|
||||
{
|
||||
public override App App { get; }
|
||||
private readonly Action? _postInstall;
|
||||
public UpdateTask(App app, Action? postInstall = null)
|
||||
{
|
||||
App = app;
|
||||
_postInstall = postInstall;
|
||||
}
|
||||
|
||||
public override void Run()
|
||||
{
|
||||
#if !DEBUG
|
||||
try
|
||||
{
|
||||
#endif
|
||||
AppExtras.Update(App, false);
|
||||
_postInstall?.Invoke();
|
||||
#if !DEBUG
|
||||
}
|
||||
catch (Exception e1)
|
||||
{
|
||||
MessageBox.Show(e1.ToString(), "Install failed");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using UpTool2.Properties;
|
||||
using UpToolLib;
|
||||
using UpToolLib.DataStructures;
|
||||
using UpToolLib.Tool;
|
||||
|
||||
namespace UpTool2.Task
|
||||
{
|
||||
class UploadTask : IAppTask
|
||||
{
|
||||
public readonly string ZipFile;
|
||||
private readonly string _name;
|
||||
private readonly Action? _postInstall;
|
||||
public UploadTask(string zipFile, string name, Action? postInstall = null)
|
||||
{
|
||||
ZipFile = zipFile;
|
||||
_name = name;
|
||||
_postInstall = postInstall;
|
||||
}
|
||||
|
||||
public void Run()
|
||||
{
|
||||
#if !DEBUG
|
||||
try
|
||||
{
|
||||
#endif
|
||||
Guid id = Guid.NewGuid();
|
||||
while (GlobalVariables.Apps.ContainsKey(id) || Directory.Exists(PathTool.GetAppPath(id)))
|
||||
id = Guid.NewGuid();
|
||||
App appI = new App(_name, "Locally installed package, removal only",
|
||||
GlobalVariables.MinimumVer, "", true, "", id, Color.Red, Resources.C_64.ToBitmap(), false, "");
|
||||
AppInstall.InstallZip(ZipFile, appI, true);
|
||||
_postInstall?.Invoke();
|
||||
#if !DEBUG
|
||||
}
|
||||
catch (Exception e1)
|
||||
{
|
||||
MessageBox.Show(e1.ToString(), "Install failed");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
public override string ToString() => $"Install local {Path.GetFileName(ZipFile)}";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
using UpTool2.Task;
|
||||
|
||||
namespace UpTool2
|
||||
{
|
||||
internal static class TaskPreview
|
||||
{
|
||||
public static void Show(ref List<IAppTask> tasks)
|
||||
{
|
||||
using Form tmp = new Form {Size = new Size(600, 300)};
|
||||
using CheckedListBox list = new CheckedListBox {Dock = DockStyle.Fill};
|
||||
list.Items.AddRange(tasks.ToArray());
|
||||
for (int i = 0; i < tasks.Count; i++)
|
||||
list.SetItemChecked(i, true);
|
||||
tmp.Controls.Add(list);
|
||||
tmp.ShowDialog();
|
||||
tasks = list.Items.OfType<IAppTask>().Where((s, i) => list.GetItemChecked(i)).ToList();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -2,7 +2,7 @@
|
|||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<LangVersion>8</LangVersion>
|
||||
<Deterministic>false</Deterministic>
|
||||
<Nullable>enable</Nullable>
|
||||
<UseWindowsForms>true</UseWindowsForms>
|
||||
|
|
Reference in New Issue