From b3bf4f7026e663e5f315cb059fe17d5f1fcfa5b2 Mon Sep 17 00:00:00 2001 From: JFronny <33260128+JFronny@users.noreply.github.com> Date: Sun, 21 Jun 2020 16:46:34 +0200 Subject: [PATCH] Kleen --- Installer/InstallerForm.cs | 5 ++-- InstallerCLI/InstallerCLI.csproj | 2 +- InstallerCLI/Program.cs | 2 +- UpTool build tool/UpTool build tool.csproj | 2 +- UpTool2/MainForm.cs | 30 +++++++++++++++------- UpTool2/Program.cs | 21 +++++++++++---- UpTool2/TaskPreview.cs | 13 ++++++++-- UpTool2/UpTool2.csproj | 2 +- UpToolCLI/UpToolCLI.csproj | 2 +- UpToolLib/Tool/XmlTool.cs | 2 +- UpToolLib/UpToolLib.csproj | 2 +- 11 files changed, 58 insertions(+), 25 deletions(-) diff --git a/Installer/InstallerForm.cs b/Installer/InstallerForm.cs index e6e76c4..2a323d7 100644 --- a/Installer/InstallerForm.cs +++ b/Installer/InstallerForm.cs @@ -43,7 +43,8 @@ namespace Installer progress.Visible = true; WebClient client = new WebClient(); Step(1, "Downloading metadata"); - XElement meta = XDocument.Load("https://gitlab.com/JFronny/UpTool2/-/jobs/artifacts/master/raw/meta.xml?job=uptool") + XElement meta = XDocument + .Load("https://gitlab.com/JFronny/UpTool2/-/jobs/artifacts/master/raw/meta.xml?job=uptool") .Element("meta"); Step(2, "Downloading binary"); byte[] dl = client.DownloadData(meta.Element("File").Value); @@ -136,4 +137,4 @@ Online: {meta.Element("Hash").Value.ToUpper()}"); updateAppsBox.Checked = false; } } -} +} \ No newline at end of file diff --git a/InstallerCLI/InstallerCLI.csproj b/InstallerCLI/InstallerCLI.csproj index 648c3e0..99b2a35 100644 --- a/InstallerCLI/InstallerCLI.csproj +++ b/InstallerCLI/InstallerCLI.csproj @@ -12,7 +12,7 @@ - + diff --git a/InstallerCLI/Program.cs b/InstallerCLI/Program.cs index 0f6feb9..41e3530 100644 --- a/InstallerCLI/Program.cs +++ b/InstallerCLI/Program.cs @@ -79,4 +79,4 @@ Online: {UpdateCheck.AppHash}"); RepoManagement.FetchRepos(); } } -} +} \ No newline at end of file diff --git a/UpTool build tool/UpTool build tool.csproj b/UpTool build tool/UpTool build tool.csproj index 2f752e4..0325bba 100644 --- a/UpTool build tool/UpTool build tool.csproj +++ b/UpTool build tool/UpTool build tool.csproj @@ -15,7 +15,7 @@ ..\UpTool2.ico - + \ No newline at end of file diff --git a/UpTool2/MainForm.cs b/UpTool2/MainForm.cs index 726b1e3..75660ca 100644 --- a/UpTool2/MainForm.cs +++ b/UpTool2/MainForm.cs @@ -132,6 +132,12 @@ namespace UpTool2 BackgroundImage = (Bitmap) app.Icon, BackgroundImageLayout = ImageLayout.Stretch }; + sidebarIcon.Paint += (sender, args) => + { + args.Graphics.Clear(sidebarIcon.BackColor); + args.Graphics.DrawImage(sidebarIcon.BackgroundImage, args.ClipRectangle, + new Rectangle(new Point(0, 0), sidebarIcon.BackgroundImage.Size), GraphicsUnit.Pixel); + }; bool updateable = !app.Local && (app.Status & Status.Updatable) == Status.Updatable; sidebarIcon.Click += (sender, e) => { @@ -193,9 +199,13 @@ namespace UpTool2 private void ClearSelection() { action_install.Enabled = false; + action_install.ResetBackColor(); action_remove.Enabled = false; + action_remove.ResetBackColor(); action_update.Enabled = false; + action_update.ResetBackColor(); action_run.Enabled = false; + action_run.ResetBackColor(); infoPanel_Title.Text = ""; infoPanel_Description.Text = ""; } @@ -294,21 +304,23 @@ Build Date: {buildTime:dd.MM.yyyy}", "UpTool2"); private void changesButton_Click(object sender, EventArgs e) { - TaskPreview.Show(ref _tasks); - progressBar1.Maximum = _tasks.Count; - progressBar1.Value = 0; - foreach (IAppTask task in _tasks) + if (TaskPreview.Show(ref _tasks, true)) { - task.Run(); - progressBar1.PerformStep(); + progressBar1.Maximum = _tasks.Count; + progressBar1.Value = 0; + foreach (IAppTask task in _tasks) + { + task.Run(); + progressBar1.PerformStep(); + } + _tasks.Clear(); + UpdateChangesLabel(); } - _tasks.Clear(); - UpdateChangesLabel(); } private void changesLabel_Click(object sender, EventArgs e) { - TaskPreview.Show(ref _tasks); + TaskPreview.Show(ref _tasks, false); UpdateChangesLabel(); } diff --git a/UpTool2/Program.cs b/UpTool2/Program.cs index 7ba4f0c..689c116 100644 --- a/UpTool2/Program.cs +++ b/UpTool2/Program.cs @@ -3,8 +3,10 @@ using System.Diagnostics; using System.Drawing; using System.IO; using System.IO.Compression; +using System.Linq; using System.Reflection; using System.Security.Cryptography; +using System.Threading; using System.Windows.Forms; using System.Xml; using UpTool2.Tool; @@ -21,13 +23,17 @@ namespace UpTool2 public static bool Online; [STAThread] - private static void Main() + private static void Main(string[] args) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); BuildSplash(); - Splash.Show(); - //new Thread(() => { Splash.ShowDialog(); }).Start(); + //Splash.Show(); + //This is here because I had issues with this piece of code under wine in the past + if (args.Any(s => s.TrimStart('-', '/').ToLower() == "wine")) + Splash.Show(); + else + new Thread(() => { Splash.ShowDialog(); }).Start(); try { MutexLock.Lock(); @@ -167,8 +173,9 @@ namespace UpTool2 public static void SetSplash(int progress, string status) => Splash.Invoke(new Action(() => { + Console.WriteLine($"{progress} - {status}"); + Debug.WriteLine($"{progress} - {status}"); _splashProgress = progress; - Console.WriteLine(status); _splashMessage = status; Splash.Invoke((Action) Splash.Invalidate); })); @@ -192,7 +199,10 @@ namespace UpTool2 { SetSplash(3, "Comparing online version"); if (Assembly.GetExecutingAssembly().GetName().Version >= UpToolLib.UpdateCheck.OnlineVersion) + { + SetSplash(7, "Opening"); return true; + } byte[] dl; SetSplash(4, "Downloading latest"); using (DownloadDialog dlg = new DownloadDialog(UpToolLib.UpdateCheck.Installer.AbsoluteUri)) @@ -227,7 +237,8 @@ namespace UpTool2 WindowStyle = ProcessWindowStyle.Hidden, WorkingDirectory = PathTool.GetRelative("Install") }); + SetSplash(7, "Installing"); return false; } } -} +} \ No newline at end of file diff --git a/UpTool2/TaskPreview.cs b/UpTool2/TaskPreview.cs index c507595..5f36faf 100644 --- a/UpTool2/TaskPreview.cs +++ b/UpTool2/TaskPreview.cs @@ -8,16 +8,25 @@ namespace UpTool2 { internal static class TaskPreview { - public static void Show(ref List tasks) + public static bool Show(ref List tasks, bool showOk) { - using Form tmp = new Form {Size = new Size(600, 300)}; + bool ok = false; + using Form tmp = new Form {Size = new Size(600, 300), MinimumSize = new Size(300, showOk ? 138 : 133)}; using CheckedListBox list = new CheckedListBox {Dock = DockStyle.Fill}; + using Button okButton = new Button {Dock = DockStyle.Bottom, Text = "OK"}; list.Items.AddRange(tasks.ToArray()); for (int i = 0; i < tasks.Count; i++) list.SetItemChecked(i, true); tmp.Controls.Add(list); + okButton.Click += (sender, args) => + { + ok = true; + tmp.Close(); + }; + if (showOk) tmp.Controls.Add(okButton); tmp.ShowDialog(); tasks = list.Items.OfType().Where((s, i) => list.GetItemChecked(i)).ToList(); + return !showOk || ok; } } } \ No newline at end of file diff --git a/UpTool2/UpTool2.csproj b/UpTool2/UpTool2.csproj index 62ca05e..9c7cd3d 100644 --- a/UpTool2/UpTool2.csproj +++ b/UpTool2/UpTool2.csproj @@ -20,7 +20,7 @@ - + diff --git a/UpToolCLI/UpToolCLI.csproj b/UpToolCLI/UpToolCLI.csproj index 6309b4c..b1b0bc7 100644 --- a/UpToolCLI/UpToolCLI.csproj +++ b/UpToolCLI/UpToolCLI.csproj @@ -13,7 +13,7 @@ - + diff --git a/UpToolLib/Tool/XmlTool.cs b/UpToolLib/Tool/XmlTool.cs index 6eba414..b386335 100644 --- a/UpToolLib/Tool/XmlTool.cs +++ b/UpToolLib/Tool/XmlTool.cs @@ -48,4 +48,4 @@ namespace UpToolLib.Tool x.Save(PathTool.InfoXml); } } -} +} \ No newline at end of file diff --git a/UpToolLib/UpToolLib.csproj b/UpToolLib/UpToolLib.csproj index eb1808b..ecbddde 100644 --- a/UpToolLib/UpToolLib.csproj +++ b/UpToolLib/UpToolLib.csproj @@ -7,7 +7,7 @@ - +