Skip to content

Commit

Permalink
remove KPreisser.UI.TaskDialog as dotnet supports task dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
MishaProductions committed May 30, 2024
1 parent 0cc3f4f commit aea84cf
Show file tree
Hide file tree
Showing 9 changed files with 44 additions and 65 deletions.
29 changes: 15 additions & 14 deletions Rectify11Installer/Core/Backend/Common.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
using KPreisser.UI;
using Microsoft.Win32;
using Microsoft.Win32;
using Rectify11Installer.Win32;
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Windows.Forms;

namespace Rectify11Installer.Core
{
Expand Down Expand Up @@ -196,21 +196,22 @@ public static bool InstallRuntimes()
/// <param name="link">link to download the app</param>
public static void RuntimeInstallError(string app, string info, string link)
{
TaskDialog td = new();
td.Page.Text = Rectify11Installer.Strings.Rectify11.rtInstallFailPart1 + app + Rectify11Installer.Strings.Rectify11.rtInstallFailPart2;
td.Page.Instruction = Rectify11Installer.Strings.Rectify11.rtInstallFailInstruc;
td.Page.Title = Rectify11Installer.Strings.Rectify11.Title;
td.Page.StandardButtons = TaskDialogButtons.OK;
td.Page.Icon = TaskDialogStandardIcon.SecurityWarningYellowBar;
td.Page.EnableHyperlinks = true;
TaskDialogPage td = new();
td.Text = Strings.Rectify11.rtInstallFailPart1 + app + Strings.Rectify11.rtInstallFailPart2;
td.Heading = Strings.Rectify11.rtInstallFailInstruc;
td.Caption = Strings.Rectify11.Title;
td.Buttons = [TaskDialogButton.OK];
td.Icon = TaskDialogIcon.ShieldErrorRedBar;
td.EnableLinks = true;

TaskDialogExpander tde = new();
tde.Text = info + " \nDownload from <a href=\"" + link + "\">here</a>";
tde.Expanded = false;
tde.ExpandFooterArea = true;
tde.CollapsedButtonText = Rectify11Installer.Strings.Rectify11.moreInfo;
tde.ExpandedButtonText = Rectify11Installer.Strings.Rectify11.lessInfo;
td.Page.Expander = tde;
td.Show();
tde.CollapsedButtonText = Strings.Rectify11.moreInfo;
tde.ExpandedButtonText = Strings.Rectify11.lessInfo;

td.Expander = tde;
TaskDialog.ShowDialog(td);
}

/// <summary>
Expand Down
5 changes: 1 addition & 4 deletions Rectify11Installer/Core/Backend/Icons.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
using KPreisser.UI;
using Microsoft.VisualBasic;
using Microsoft.VisualBasic;
using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Reflection;
using static System.Environment;
using static System.Windows.Forms.VisualStyles.VisualStyleElement;

namespace Rectify11Installer.Core
{
Expand Down
1 change: 0 additions & 1 deletion Rectify11Installer/Core/Backend/Themes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
using System.Diagnostics;
using System.IO;
using System.Windows.Forms;
using static Rectify11Installer.Win32.NativeMethods;

namespace Rectify11Installer.Core
{
Expand Down
15 changes: 8 additions & 7 deletions Rectify11Installer/Core/Helpers.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using KPreisser.UI;
using Microsoft.VisualBasic;
using Microsoft.VisualBasic;
using Microsoft.Win32;
using Rectify11Installer.Pages;
using Rectify11Installer.Win32;
Expand All @@ -10,6 +9,7 @@
using System.IO;
using System.Reflection;
using System.Text;
using System.Windows.Forms;

namespace Rectify11Installer.Core
{
Expand All @@ -21,11 +21,12 @@ public static bool CheckIfUpdatesPending()
if (Variables.skipUpdateCheck) return true;
if (!RebootRequired()) return true;

TaskDialog.Show(text: Strings.Rectify11.updatePending,
instruction: "Compatibility Error",
title: Strings.Rectify11.Title,
buttons: TaskDialogButtons.OK,
icon: TaskDialogStandardIcon.SecurityErrorRedBar);
TaskDialogPage pg = new TaskDialogPage();
pg.Text = Strings.Rectify11.updatePending;
pg.Caption = Strings.Rectify11.Title;
pg.Heading = "Compatibility check failed";
pg.Icon = TaskDialogIcon.ShieldErrorRedBar;
TaskDialog.ShowDialog(pg);

return false;
}
Expand Down
10 changes: 1 addition & 9 deletions Rectify11Installer/Pages/DefenderPage.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
using KPreisser.UI;
using Rectify11Installer.Core;
using Rectify11Installer.Win32;
using System;
using System.Drawing;
using System.IO;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Rectify11Installer.Pages
{
public partial class DefenderPage : WizardPage
public partial class DefenderPage : WizardPage
{
#region Classes
#endregion
Expand Down
18 changes: 4 additions & 14 deletions Rectify11Installer/Pages/ProgressPage.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using KPreisser.UI;
using Rectify11Installer.Core;
using Rectify11Installer.Win32;
using System;
Expand All @@ -8,7 +7,7 @@
using System.Windows.Forms;
namespace Rectify11Installer.Pages
{
public partial class ProgressPage : WizardPage
public partial class ProgressPage : WizardPage
{
#region Variables
private FrmWizard frmwiz;
Expand Down Expand Up @@ -149,10 +148,7 @@ private async void NavigationHelper_OnNavigate(object sender, EventArgs e)
{
Common.Cleanup();
Logger.CommitLog();
KPreisser.UI.TaskDialog.Show(text: Rectify11Installer.Strings.Rectify11.r11InstallErrorPart1 + Path.Combine(Variables.r11Folder, "installer.log") + Rectify11Installer.Strings.Rectify11.r11InstallErrorPart2,
title: "Error",
buttons: TaskDialogButtons.OK,
icon: TaskDialogStandardIcon.Error);
MessageBox.Show(Strings.Rectify11.r11InstallErrorPart1 + Path.Combine(Variables.r11Folder, "installer.log") + Strings.Rectify11.r11InstallErrorPart2, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
Application.Exit();
}
//Logger.CommitLog();
Expand Down Expand Up @@ -184,10 +180,7 @@ private async void NavigationHelper_OnNavigate(object sender, EventArgs e)
{
Common.Cleanup();
Logger.CommitLog();
KPreisser.UI.TaskDialog.Show(text: Rectify11Installer.Strings.Rectify11.r11InstallErrorPart1 + Path.Combine(Variables.r11Folder, "installer.log") + Rectify11Installer.Strings.Rectify11.r11InstallErrorPart2,
title: "Error",
buttons: TaskDialogButtons.OK,
icon: TaskDialogStandardIcon.Error);
MessageBox.Show(text: Strings.Rectify11.r11InstallErrorPart1 + Path.Combine(Variables.r11Folder, "installer.log") + Strings.Rectify11.r11InstallErrorPart2, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
Application.Exit();
}
Logger.CommitLog();
Expand All @@ -199,10 +192,7 @@ private async void NavigationHelper_OnNavigate(object sender, EventArgs e)
{
Common.Cleanup();
Logger.CommitLog();
KPreisser.UI.TaskDialog.Show(text: Rectify11Installer.Strings.Rectify11.r11InstallErrorPart1 + Path.Combine(Variables.r11Folder, "installer.log") + Rectify11Installer.Strings.Rectify11.r11InstallErrorPart2,
title: "Error",
buttons: TaskDialogButtons.OK,
icon: TaskDialogStandardIcon.Error);
MessageBox.Show(Strings.Rectify11.r11InstallErrorPart1 + Path.Combine(Variables.r11Folder, "installer.log") + Strings.Rectify11.r11InstallErrorPart2, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
Application.Exit();
}
Logger.CommitLog();
Expand Down
16 changes: 12 additions & 4 deletions Rectify11Installer/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,14 @@ private static void Main(string[] args)
bool isAnotherInstanceOpen = !mutex.WaitOne(TimeSpan.Zero);
if (isAnotherInstanceOpen)
{
MessageBox.Show("Another instance of the rectify11 setup is already running.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
// TODO localize
TaskDialogPage pg = new TaskDialogPage();
pg.Heading = "Installer is already running";
pg.Text = "Another instance of the rectify11 setup is already running.";
pg.Icon = TaskDialogIcon.ShieldGrayBar;
pg.Buttons = [TaskDialogButton.OK];
pg.Caption = Strings.Rectify11.Title;
TaskDialog.ShowDialog(pg);
return;
}

Expand Down Expand Up @@ -92,16 +99,16 @@ private static bool ShowCompatibilityMessage(bool CanAllow, string header, strin
if (CanAllow)
{
// in this case, we can skip the warning
bool yes = false;
TaskDialogPage pg = new TaskDialogPage();
pg.Heading = text;
pg.Text = header;
pg.Buttons = [TaskDialogButton.OK];
pg.Icon = TaskDialogIcon.ShieldWarningYellowBar;
pg.EnableLinks = true;
pg.Caption = Strings.Rectify11.Title;

TaskDialogExpander tde = new();
tde.Text = "<a href=\"link1\">Run anyway (not recommended)</a>";
tde.Text = "<a href=\"lnkRun\">Run anyway (not recommended)</a>";
tde.Expanded = false;
tde.CollapsedButtonText = Strings.Rectify11.moreInfo;
tde.ExpandedButtonText = Strings.Rectify11.lessInfo;
Expand All @@ -110,7 +117,7 @@ private static bool ShowCompatibilityMessage(bool CanAllow, string header, strin

pg.LinkClicked += delegate (object s, TaskDialogLinkClickedEventArgs e)
{
if (e.LinkHref == "link1")
if (e.LinkHref == "lnkRun")
{
pg.BoundDialog.Close();
}
Expand All @@ -127,6 +134,7 @@ private static bool ShowCompatibilityMessage(bool CanAllow, string header, strin
pg.Heading = text;
pg.Buttons = [TaskDialogButton.OK];
pg.Icon = TaskDialogIcon.ShieldErrorRedBar;
pg.Caption = Strings.Rectify11.Title;
TaskDialog.ShowDialog(pg);
return false;
}
Expand Down
1 change: 0 additions & 1 deletion Rectify11Installer/Rectify11Installer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
<Content Include="r11.ico" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="KPreisser.UI.TaskDialog" Version="1.0.0" />
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
<PackageReference Include="Microsoft.VisualBasic" Version="10.4.0-preview.18571.3" />
<PackageReference Include="Resource.Embedder">
Expand Down
14 changes: 3 additions & 11 deletions Rectify11Installer/frmWizard.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using KPreisser.UI;
using Microsoft.Win32;
using Microsoft.Win32;
using Rectify11Installer.Core;
using Rectify11Installer.Pages;
using Rectify11Installer.Win32;
Expand Down Expand Up @@ -169,10 +168,7 @@ private void FrmWizard_FormClosing(object sender, FormClosingEventArgs e)
if (Variables.IsUninstall) { }
else if (!Variables.isInstall)
{
if (KPreisser.UI.TaskDialog.Show(text: Strings.Rectify11.exitText,
title: Strings.Rectify11.Title,
buttons: TaskDialogButtons.Yes | TaskDialogButtons.No,
icon: TaskDialogStandardIcon.Information) == TaskDialogResult.No) e.Cancel = true;
if (MessageBox.Show(Strings.Rectify11.exitText, Strings.Rectify11.Title, MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.No) e.Cancel = true;
}
else if (e.CloseReason == CloseReason.UserClosing) e.Cancel = true;
Theme.OnThemeChanged -= SystemEvents_UserPreferenceChanged;
Expand Down Expand Up @@ -291,11 +287,7 @@ private void UninstallButton_Click(object sender, EventArgs e)
{
if (Helper.CheckIfUpdatesPending())
{
var res = KPreisser.UI.TaskDialog.Show(text: Strings.Rectify11.uninstallConfirmText,
title: Strings.Rectify11.uninstallTitle,
buttons: TaskDialogButtons.Yes | TaskDialogButtons.No,
icon: TaskDialogStandardIcon.Information);
if (res == TaskDialogResult.Yes)
if (MessageBox.Show(Strings.Rectify11.uninstallConfirmText, Strings.Rectify11.uninstallTitle, MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
{
Variables.IsUninstall = true;
Navigate(RectifyPages.ProgressPage);
Expand Down

0 comments on commit aea84cf

Please sign in to comment.