re-added autostart
This commit is contained in:
parent
36f6d03a01
commit
db8125de84
10 changed files with 136 additions and 9 deletions
|
@ -36,6 +36,10 @@ 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));
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ namespace WeeXnes.Core
|
|||
{
|
||||
public class Information
|
||||
{
|
||||
public const string Version = "4.0.0";
|
||||
public const string Version = "4.0.1";
|
||||
public const string EncryptionHash = "8zf5#RdyQ]$4x4_";
|
||||
public const string ApiUrl = "https://api.github.com/repos/weexnes/weexnessuite/releases/latest";
|
||||
}
|
||||
|
|
|
@ -6,12 +6,16 @@ namespace WeeXnes.Core
|
|||
{
|
||||
public class HandleLaunchArguments
|
||||
{
|
||||
public static class Data
|
||||
{
|
||||
public static bool Autostart = false;
|
||||
}
|
||||
private const int ATTACH_PARENT_PROCESS = -1;
|
||||
[DllImport("kernel32.dll")]
|
||||
private static extern bool AttachConsole(int dwProcessId);
|
||||
public static void arg_autostart()
|
||||
{
|
||||
|
||||
Data.Autostart = true;
|
||||
}
|
||||
public static void arg_debugMode()
|
||||
{
|
||||
|
|
|
@ -9,6 +9,11 @@ namespace WeeXnes.Core
|
|||
public static class Data
|
||||
{
|
||||
//Layout-Names for INIFiles
|
||||
public static class General
|
||||
{
|
||||
public const string Section = "GENERAL";
|
||||
public const string Autostart = "Autostart";
|
||||
}
|
||||
public static class KeyManager
|
||||
{
|
||||
public const string Section = "KEY_MANAGER";
|
||||
|
@ -38,6 +43,14 @@ 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()
|
||||
);
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
|
@ -26,7 +26,7 @@
|
|||
Grid.Row="0"
|
||||
Title="WeeXnes Suite"
|
||||
ForceShutdown="False"
|
||||
MinimizeToTray="False"
|
||||
MinimizeToTray="True"
|
||||
ShowHelp="False"
|
||||
ShowClose="True"
|
||||
ShowMaximize="True"
|
||||
|
@ -35,12 +35,16 @@
|
|||
<ui:TitleBar.Tray>
|
||||
|
||||
<ui:NotifyIcon Icon="/Images/wicon.png">
|
||||
<!--
|
||||
<ui:NotifyIcon.Menu>
|
||||
<ContextMenu>
|
||||
<MenuItem
|
||||
Header="Start RPC"
|
||||
Click="ContextStartRpc_OnClick"/>
|
||||
<MenuItem
|
||||
Header="Stop RPC"
|
||||
Click="ContextStopRpc_OnClick"/>
|
||||
</ContextMenu>
|
||||
</ui:NotifyIcon.Menu>
|
||||
-->
|
||||
</ui:NotifyIcon>
|
||||
</ui:TitleBar.Tray>
|
||||
|
||||
|
@ -60,6 +64,7 @@
|
|||
Content="Home"
|
||||
Icon="Home24"
|
||||
PageTag="home"
|
||||
Name="ButtonHome"
|
||||
PageType="{x:Type home:HomeView}"/>
|
||||
<ui:NavigationItem
|
||||
Content="Keys"
|
||||
|
@ -69,9 +74,10 @@
|
|||
<ui:NavigationItem
|
||||
Content="RPC"
|
||||
Icon="XboxController24"
|
||||
Name="RPCBtn"
|
||||
Name="ButtonRpc"
|
||||
PageTag="RPC"
|
||||
PageType="{x:Type discordrpc:DiscordRPCView}"/>
|
||||
PageType="{x:Type discordrpc:DiscordRPCView}"
|
||||
Loaded="RPCBtn_OnLoaded"/>
|
||||
</ui:NavigationStore.Items>
|
||||
<ui:NavigationStore.Footer>
|
||||
<ui:NavigationItem
|
||||
|
@ -84,7 +90,8 @@
|
|||
<Frame
|
||||
x:Name="MainFrame"
|
||||
Grid.Column="1"
|
||||
Margin="8,0,0,0" />
|
||||
Margin="8,0,0,0"
|
||||
/>
|
||||
</Grid>
|
||||
|
||||
</Grid>
|
||||
|
|
|
@ -9,8 +9,10 @@ using System.Windows.Forms;
|
|||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using WeeXnes.Core;
|
||||
using WeeXnes.Views.DiscordRPC;
|
||||
using Wpf.Ui.Mvvm.Services;
|
||||
using Button = System.Windows.Controls.Button;
|
||||
using ButtonBase = System.Windows.Controls.Primitives.ButtonBase;
|
||||
using MessageBox = System.Windows.MessageBox;
|
||||
|
||||
namespace WeeXnes
|
||||
|
@ -26,6 +28,27 @@ namespace WeeXnes
|
|||
}
|
||||
|
||||
|
||||
|
||||
private void RPCBtn_OnLoaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (HandleLaunchArguments.Data.Autostart)
|
||||
{
|
||||
ButtonRpc.RaiseEvent(new RoutedEventArgs(ButtonBase.ClickEvent));
|
||||
MainFrame.Source = new Uri("/Views/DiscordRPC/RunRPCView.xaml",UriKind.Relative);
|
||||
WindowState = WindowState.Minimized;
|
||||
}
|
||||
}
|
||||
|
||||
private void ContextStartRpc_OnClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
ButtonRpc.RaiseEvent(new RoutedEventArgs(ButtonBase.ClickEvent));
|
||||
MainFrame.Source = new Uri("/Views/DiscordRPC/RunRPCView.xaml",UriKind.Relative);
|
||||
}
|
||||
|
||||
private void ContextStopRpc_OnClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
ButtonHome.RaiseEvent(new RoutedEventArgs(ButtonBase.ClickEvent));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
xmlns:local="clr-namespace:WeeXnes.Views.DiscordRPC"
|
||||
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
|
||||
mc:Ignorable="d"
|
||||
Tag="RPCView"
|
||||
Title="DiscordRPCView" Height="Auto" Width="Auto">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
|
|
|
@ -36,6 +36,11 @@
|
|||
Name="CheckboxCensorKeys"
|
||||
Checked="CheckboxCensorKeys_OnChecked"
|
||||
Unchecked="CheckboxCensorKeys_OnUnchecked"/>
|
||||
<TextBlock Text="Discord Rich Presence"
|
||||
HorizontalAlignment="Center"
|
||||
Foreground="White"/>
|
||||
<CheckBox Content="Autostart RPC"
|
||||
Name="CheckboxAutostartRpc"/>
|
||||
</StackPanel>
|
||||
</ScrollViewer>
|
||||
</Grid>
|
||||
|
|
|
@ -18,6 +18,7 @@ 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()
|
||||
{
|
||||
|
@ -28,6 +29,9 @@ 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)
|
||||
{
|
||||
|
@ -99,5 +103,71 @@ namespace WeeXnes.Views.Settings
|
|||
Console.WriteLine(ex);
|
||||
}
|
||||
}
|
||||
|
||||
void SetCheckboxAutostartRpc()
|
||||
{
|
||||
CheckboxAutostartRpc.Checked += CheckboxAutostartRpc_OnChecked;
|
||||
CheckboxAutostartRpc.Unchecked += CheckboxAutostartRpc_OnUnchecked;
|
||||
}
|
||||
void UnsetCheckboxAutostartRpc()
|
||||
{
|
||||
CheckboxAutostartRpc.Checked -= CheckboxAutostartRpc_OnChecked;
|
||||
CheckboxAutostartRpc.Unchecked -= CheckboxAutostartRpc_OnUnchecked;
|
||||
}
|
||||
|
||||
void SwitchAutostartRpc(bool enable)
|
||||
{
|
||||
UnsetCheckboxAutostartRpc();
|
||||
|
||||
|
||||
if (enable)
|
||||
{
|
||||
bool proc_suc;
|
||||
try
|
||||
{
|
||||
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
|
||||
{
|
||||
bool proc_suc;
|
||||
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)
|
||||
{
|
||||
SwitchAutostartRpc(false);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -4,7 +4,7 @@
|
|||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<Version>4.0.0</Version>
|
||||
<Version>4.0.1</Version>
|
||||
<ProjectGuid>{4B33CEE7-C74D-43B9-B99A-8B273D5195BC}</ProjectGuid>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<RootNamespace>WeeXnes</RootNamespace>
|
||||
|
|
Loading…
Add table
Reference in a new issue