Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
Belim committed Aug 11, 2021
1 parent 7fb5edc commit 0e0e165
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 18 deletions.
27 changes: 27 additions & 0 deletions src/RSV/Helpers/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Diagnostics;
using System.IO;
using System.Net;
using System.Reflection;
using System.Security.Principal;
using System.Windows.Forms;

Expand Down Expand Up @@ -63,6 +64,32 @@ public static String FormatBytes(long byteCount)
return (Math.Sign(byteCount) * num).ToString() + suf[place];
}

public static void RelaunchIfNotAdministrator()
{
if (!IsAdministrator())
{
if (MessageBox.Show(Locales.Locale.infoElevation.Replace("\\n", "\n"), "", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{

ProcessStartInfo proc = new ProcessStartInfo();
proc.UseShellExecute = true;
proc.WorkingDirectory = Environment.CurrentDirectory;
proc.FileName = Assembly.GetEntryAssembly().CodeBase;
proc.Verb = "runas";
try
{
Process.Start(proc);
Environment.Exit(0);
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString(), "", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
Environment.Exit(0);
}
}
}
}

// Check elevation
public static bool IsAdministrator()
{
Expand Down
2 changes: 1 addition & 1 deletion src/RSV/Locales/Locale.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/RSV/Locales/Locale.de.resx
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
<comment>Assessment</comment>
</data>
<data name="assessmentSecureBootOK" xml:space="preserve">
<value>Unterstüzt</value>
<value>Unterstützt</value>
<comment>Assessment</comment>
</data>
<data name="assessmentStorage" xml:space="preserve">
Expand Down Expand Up @@ -336,7 +336,7 @@
<comment>GUI</comment>
</data>
<data name="infoElevation" xml:space="preserve">
<value>Es sind erhöhte Rechte sind für die Erkennung von TPM und Secure Boot erforderlich.\n\nBitte führe die App als Administrator aus.</value>
<value>Es sind erhöhte Rechte für die Erkennung von TPM und Secure Boot erforderlich.\n\nDarf ReadySunValley mit administrativen Rechten gestartet werden?</value>
</data>
<data name="infoUpdate" xml:space="preserve">
<value>App-Aktualisierung verfügbar</value>
Expand Down
2 changes: 1 addition & 1 deletion src/RSV/Locales/Locale.resx
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@
<comment>GUI</comment>
</data>
<data name="infoElevation" xml:space="preserve">
<value>Elevated rights are required for TPM and Secure Boot detection.\n\nPlease run the app as administrator.</value>
<value>Elevated rights are required for TPM and Secure Boot detection.\n\nCan the app be restarted with administrative rights?</value>
</data>
<data name="infoUpdate" xml:space="preserve">
<value>App update available</value>
Expand Down
21 changes: 9 additions & 12 deletions src/RSV/MainWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ namespace ReadySunValley
{
public partial class MainWindow : Form
{

// Using same apps settings storage root as for the App Store version
// The name of <emPACKAGEID> is concatenated from the application package name and a signing certificate based postfix.
public static string mAppDataDir = Environment.GetFolderPath
Expand Down Expand Up @@ -45,6 +44,15 @@ public MainWindow()
UISelection();
}

private void MainWindow_Shown(object sender, EventArgs e)
{
// Run Assessments
DoCompatibilityCheck();

// Check elevation
Helpers.Utils.RelaunchIfNotAdministrator();
}

private void UISelection()
{
// GUI options
Expand Down Expand Up @@ -117,17 +125,6 @@ private void InitializeAppDataDir()
catch { }
}

private void MainWindow_Shown(object sender, EventArgs e)
{
// Run Assessments
DoCompatibilityCheck();

// Check elevation
if (!Helpers.Utils.IsAdministrator())
MessageBox.Show(Locales.Locale.infoElevation.Replace("\\n", "\n"), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

}

private void MainWindow_SizeChanged(object sender, EventArgs e)
{
int formWidth = this.Width;
Expand Down
4 changes: 2 additions & 2 deletions src/RSV/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.60.0")]
[assembly: AssemblyFileVersion("0.60.0")]
[assembly: AssemblyVersion("0.61.0")]
[assembly: AssemblyFileVersion("0.61.0")]

0 comments on commit 0e0e165

Please sign in to comment.