re-added start menu shortcut button
This commit is contained in:
parent
95376fa0e6
commit
f720cc7325
4 changed files with 50 additions and 74 deletions
|
@ -36,10 +36,6 @@ namespace WeeXnes
|
|||
Convert.ToBoolean(SettingsView.Data.settingsFile.GetValue(
|
||||
SaveSettingsHandler.Data.KeyManager.Section,
|
||||
SaveSettingsHandler.Data.KeyManager.CensorKeys));
|
||||
SettingsView.Data.Autostart.Value =
|
||||
Convert.ToBoolean(SettingsView.Data.settingsFile.GetValue(
|
||||
SaveSettingsHandler.Data.General.Section,
|
||||
SaveSettingsHandler.Data.General.Autostart));
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -12,7 +12,6 @@ namespace WeeXnes.Core
|
|||
public static class General
|
||||
{
|
||||
public const string Section = "GENERAL";
|
||||
public const string Autostart = "Autostart";
|
||||
}
|
||||
public static class KeyManager
|
||||
{
|
||||
|
@ -43,14 +42,6 @@ namespace WeeXnes.Core
|
|||
KeyManagerView.Data.censorKeys.Value.ToString()
|
||||
);
|
||||
};
|
||||
SettingsView.Data.Autostart.ValueChanged += () =>
|
||||
{
|
||||
SettingsView.Data.settingsFile.SetValue(
|
||||
Data.General.Section,
|
||||
Data.General.Autostart,
|
||||
SettingsView.Data.Autostart.Value.ToString()
|
||||
);
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
|
@ -29,6 +29,18 @@
|
|||
Name="DialogUpdate"
|
||||
ButtonLeftClick="DialogUpdate_OnButtonLeftClick"
|
||||
ButtonRightClick="DialogUpdate_OnButtonRightClick"/>
|
||||
<ui:CardAction Icon="LinkSquare20"
|
||||
Name="ButtonCreateStartMenuShortcut"
|
||||
Click="ButtonCreateStartMenuShortcut_OnClick"
|
||||
Margin="0,10">
|
||||
<StackPanel>
|
||||
<TextBlock
|
||||
Margin="0,0,0,4"
|
||||
FontWeight="Medium"
|
||||
Text="Create Start-Menu Shortcut"
|
||||
/>
|
||||
</StackPanel>
|
||||
</ui:CardAction>
|
||||
<TextBlock Text="Key Manager Settings"
|
||||
HorizontalAlignment="Center"
|
||||
Foreground="White"/>
|
||||
|
@ -39,8 +51,15 @@
|
|||
<TextBlock Text="Discord Rich Presence"
|
||||
HorizontalAlignment="Center"
|
||||
Foreground="White"/>
|
||||
<CheckBox Content="Autostart RPC"
|
||||
Name="CheckboxAutostartRpc"/>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<Button Content="Enable RPC Autostart"
|
||||
Name="ButtonEnableRPC"
|
||||
Click="ButtonEnableRPC_OnClick"/>
|
||||
<Button Content="Disable RPC Autostart"
|
||||
Margin="10,0,0,0"
|
||||
Name="ButtonDisableRPC"
|
||||
Click="ButtonDisableRPC_OnClick"/>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</ScrollViewer>
|
||||
</Grid>
|
||||
|
|
|
@ -18,7 +18,6 @@ namespace WeeXnes.Views.Settings
|
|||
{
|
||||
public static INIFile settingsFile = new INIFile(Global.AppDataPath + "\\" + Global.SettingsFile, true);
|
||||
public static GithubApiResponse updateResponse = null;
|
||||
public static UpdateVar<bool> Autostart = new UpdateVar<bool>();
|
||||
}
|
||||
public SettingsView()
|
||||
{
|
||||
|
@ -29,9 +28,6 @@ namespace WeeXnes.Views.Settings
|
|||
private void LoadSettingsToGui()
|
||||
{
|
||||
CheckboxCensorKeys.IsChecked = KeyManagerView.Data.censorKeys.Value;
|
||||
CheckboxAutostartRpc.IsChecked = Data.Autostart.Value;
|
||||
|
||||
SetCheckboxAutostartRpc();
|
||||
}
|
||||
private void CheckboxCensorKeys_OnChecked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
|
@ -104,70 +100,44 @@ namespace WeeXnes.Views.Settings
|
|||
}
|
||||
}
|
||||
|
||||
void SetCheckboxAutostartRpc()
|
||||
{
|
||||
CheckboxAutostartRpc.Checked += CheckboxAutostartRpc_OnChecked;
|
||||
CheckboxAutostartRpc.Unchecked += CheckboxAutostartRpc_OnUnchecked;
|
||||
}
|
||||
void UnsetCheckboxAutostartRpc()
|
||||
{
|
||||
CheckboxAutostartRpc.Checked -= CheckboxAutostartRpc_OnChecked;
|
||||
CheckboxAutostartRpc.Unchecked -= CheckboxAutostartRpc_OnUnchecked;
|
||||
}
|
||||
|
||||
void SwitchAutostartRpc(bool enable)
|
||||
private void ButtonEnableRPC_OnClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
UnsetCheckboxAutostartRpc();
|
||||
|
||||
|
||||
if (enable)
|
||||
{
|
||||
bool proc_suc;
|
||||
try
|
||||
{
|
||||
Process uacpromp = Process.Start("WeeXnes_UAC.exe", "-EnableAutostart");
|
||||
uacpromp.WaitForExit();
|
||||
proc_suc = true;
|
||||
Process uac_prompt = Process.Start("WeeXnes_UAC.exe", "-EnableAutostart");
|
||||
uac_prompt.WaitForExit();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine(ex);
|
||||
proc_suc = false;
|
||||
MessageBox.Show(ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
Data.Autostart.Value = proc_suc;
|
||||
CheckboxAutostartRpc.IsChecked = proc_suc;
|
||||
}
|
||||
else
|
||||
private void ButtonDisableRPC_OnClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
bool proc_suc;
|
||||
try
|
||||
{
|
||||
Process uacpromp = Process.Start("WeeXnes_UAC.exe", "-DisableAutostart");
|
||||
uacpromp.WaitForExit();
|
||||
proc_suc = true;
|
||||
Process uac_prompt = Process.Start("WeeXnes_UAC.exe", "-DisableAutostart");
|
||||
uac_prompt.WaitForExit();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine(ex);
|
||||
proc_suc = false;
|
||||
MessageBox.Show(ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
Data.Autostart.Value = !proc_suc;
|
||||
CheckboxAutostartRpc.IsChecked = !proc_suc;
|
||||
}
|
||||
|
||||
|
||||
SetCheckboxAutostartRpc();
|
||||
}
|
||||
private void CheckboxAutostartRpc_OnChecked(object sender, RoutedEventArgs e)
|
||||
private void ButtonCreateStartMenuShortcut_OnClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
SwitchAutostartRpc(true);
|
||||
}
|
||||
|
||||
private void CheckboxAutostartRpc_OnUnchecked(object sender, RoutedEventArgs e)
|
||||
try
|
||||
{
|
||||
SwitchAutostartRpc(false);
|
||||
Process p = Process.Start("WeeXnes_UAC.exe", "-CreateStartMenuShortcut");
|
||||
p.WaitForExit();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue