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(
|
Convert.ToBoolean(SettingsView.Data.settingsFile.GetValue(
|
||||||
SaveSettingsHandler.Data.KeyManager.Section,
|
SaveSettingsHandler.Data.KeyManager.Section,
|
||||||
SaveSettingsHandler.Data.KeyManager.CensorKeys));
|
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 static class General
|
||||||
{
|
{
|
||||||
public const string Section = "GENERAL";
|
public const string Section = "GENERAL";
|
||||||
public const string Autostart = "Autostart";
|
|
||||||
}
|
}
|
||||||
public static class KeyManager
|
public static class KeyManager
|
||||||
{
|
{
|
||||||
|
@ -43,14 +42,6 @@ namespace WeeXnes.Core
|
||||||
KeyManagerView.Data.censorKeys.Value.ToString()
|
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"
|
Name="DialogUpdate"
|
||||||
ButtonLeftClick="DialogUpdate_OnButtonLeftClick"
|
ButtonLeftClick="DialogUpdate_OnButtonLeftClick"
|
||||||
ButtonRightClick="DialogUpdate_OnButtonRightClick"/>
|
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"
|
<TextBlock Text="Key Manager Settings"
|
||||||
HorizontalAlignment="Center"
|
HorizontalAlignment="Center"
|
||||||
Foreground="White"/>
|
Foreground="White"/>
|
||||||
|
@ -39,8 +51,15 @@
|
||||||
<TextBlock Text="Discord Rich Presence"
|
<TextBlock Text="Discord Rich Presence"
|
||||||
HorizontalAlignment="Center"
|
HorizontalAlignment="Center"
|
||||||
Foreground="White"/>
|
Foreground="White"/>
|
||||||
<CheckBox Content="Autostart RPC"
|
<StackPanel Orientation="Horizontal">
|
||||||
Name="CheckboxAutostartRpc"/>
|
<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>
|
</StackPanel>
|
||||||
</ScrollViewer>
|
</ScrollViewer>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
|
@ -18,7 +18,6 @@ namespace WeeXnes.Views.Settings
|
||||||
{
|
{
|
||||||
public static INIFile settingsFile = new INIFile(Global.AppDataPath + "\\" + Global.SettingsFile, true);
|
public static INIFile settingsFile = new INIFile(Global.AppDataPath + "\\" + Global.SettingsFile, true);
|
||||||
public static GithubApiResponse updateResponse = null;
|
public static GithubApiResponse updateResponse = null;
|
||||||
public static UpdateVar<bool> Autostart = new UpdateVar<bool>();
|
|
||||||
}
|
}
|
||||||
public SettingsView()
|
public SettingsView()
|
||||||
{
|
{
|
||||||
|
@ -29,9 +28,6 @@ namespace WeeXnes.Views.Settings
|
||||||
private void LoadSettingsToGui()
|
private void LoadSettingsToGui()
|
||||||
{
|
{
|
||||||
CheckboxCensorKeys.IsChecked = KeyManagerView.Data.censorKeys.Value;
|
CheckboxCensorKeys.IsChecked = KeyManagerView.Data.censorKeys.Value;
|
||||||
CheckboxAutostartRpc.IsChecked = Data.Autostart.Value;
|
|
||||||
|
|
||||||
SetCheckboxAutostartRpc();
|
|
||||||
}
|
}
|
||||||
private void CheckboxCensorKeys_OnChecked(object sender, RoutedEventArgs e)
|
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();
|
try
|
||||||
|
|
||||||
|
|
||||||
if (enable)
|
|
||||||
{
|
{
|
||||||
bool proc_suc;
|
Process uac_prompt = Process.Start("WeeXnes_UAC.exe", "-EnableAutostart");
|
||||||
try
|
uac_prompt.WaitForExit();
|
||||||
{
|
|
||||||
Process uacpromp = Process.Start("WeeXnes_UAC.exe", "-EnableAutostart");
|
|
||||||
uacpromp.WaitForExit();
|
|
||||||
proc_suc = true;
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
Console.WriteLine(ex);
|
|
||||||
proc_suc = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
Data.Autostart.Value = proc_suc;
|
|
||||||
CheckboxAutostartRpc.IsChecked = proc_suc;
|
|
||||||
}
|
}
|
||||||
else
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
bool proc_suc;
|
MessageBox.Show(ex.Message);
|
||||||
try
|
|
||||||
{
|
|
||||||
Process uacpromp = Process.Start("WeeXnes_UAC.exe", "-DisableAutostart");
|
|
||||||
uacpromp.WaitForExit();
|
|
||||||
proc_suc = true;
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
Console.WriteLine(ex);
|
|
||||||
proc_suc = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
Data.Autostart.Value = !proc_suc;
|
|
||||||
CheckboxAutostartRpc.IsChecked = !proc_suc;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
SetCheckboxAutostartRpc();
|
|
||||||
}
|
|
||||||
private void CheckboxAutostartRpc_OnChecked(object sender, RoutedEventArgs e)
|
|
||||||
{
|
|
||||||
SwitchAutostartRpc(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CheckboxAutostartRpc_OnUnchecked(object sender, RoutedEventArgs e)
|
private void ButtonDisableRPC_OnClick(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
SwitchAutostartRpc(false);
|
try
|
||||||
|
{
|
||||||
|
Process uac_prompt = Process.Start("WeeXnes_UAC.exe", "-DisableAutostart");
|
||||||
|
uac_prompt.WaitForExit();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonCreateStartMenuShortcut_OnClick(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
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