Skip to content

Commit

Permalink
Disable admin button if we are running as admin
Browse files Browse the repository at this point in the history
  • Loading branch information
Azyyyyyy committed Sep 1, 2019
1 parent f9bb386 commit 340285d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
3 changes: 3 additions & 0 deletions MultiRPC/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Security.Principal;
using System.Windows;
using System.Windows.Threading;
using MultiRPC.Functions;
Expand Down Expand Up @@ -31,6 +32,8 @@ public partial class App : Application
Formatting = Formatting.Indented
};

public static bool IsAdministrator =>
new WindowsPrincipal(WindowsIdentity.GetCurrent()).IsInRole(WindowsBuiltInRole.Administrator);

public App()
{
Expand Down
8 changes: 2 additions & 6 deletions MultiRPC/GUI/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System;
using System.ComponentModel;
using System.IO;
using System.Security.Principal;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
Expand Down Expand Up @@ -35,14 +34,11 @@ public partial class MainWindow : Window
public object ToReturn { get; private set; }
protected long WindowID; //This is so we can know that the window we look for is the window we are looking for

public static bool IsAdministrator =>
new WindowsPrincipal(WindowsIdentity.GetCurrent()).IsInRole(WindowsBuiltInRole.Administrator);

public MainWindow()
{
InitializeComponent();

Title += (IsAdministrator ? " (Administrator)" : "");
Title += (App.IsAdministrator ? " (Administrator)" : "");
tblTitle.Text = Title;
if (this != Application.Current.MainWindow)
{
Expand All @@ -66,7 +62,7 @@ private MainWindow(Page page, bool minButton = true)
InitializeComponent();
StartLogic(page);
ShowInTaskbar = false;
Title = $"MultiRPC - {page.Title} {(IsAdministrator ? "(Administrator)" : "")}";
Title = $"MultiRPC - {page.Title} {(App.IsAdministrator ? "(Administrator)" : "")}";
tblTitle.Text = Title;

if (!minButton)
Expand Down
1 change: 1 addition & 0 deletions MultiRPC/GUI/Pages/SettingsPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public SettingsPage()
cbAutoStart.SelectedItem = item;
}

btnAdmin.IsEnabled = !App.IsAdministrator;
cbAfkTime.IsChecked = App.Config.AFKTime;
cbDiscordCheck.IsChecked = !App.Config.DiscordCheck;
cbTokenCheck.IsChecked = !App.Config.CheckToken;
Expand Down

0 comments on commit 340285d

Please sign in to comment.