Skip to content

Commit

Permalink
Fix Autostart; Replace ClickOnce installer with Setup project; (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
EricBanker12 authored Aug 20, 2022
1 parent 654c93c commit b987407
Show file tree
Hide file tree
Showing 3 changed files with 13,106 additions and 7 deletions.
12 changes: 10 additions & 2 deletions DebugOutputToasts/DebugOutputToasts.sln
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.31727.386
# Visual Studio Version 17
VisualStudioVersion = 17.3.32811.315
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DebugOutputToasts", "DebugOutputToasts.csproj", "{735D1A28-994F-4EDD-A73D-4B4E37336368}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTestProject1", "..\UnitTestProject1\UnitTestProject1.csproj", "{7EC80019-E5F5-4BA3-8C82-49DC497D9707}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DebugOutputHelper", "..\DebugOutputHelper\DebugOutputHelper.csproj", "{83810BFC-F718-4D6F-B3E5-A5304412D8A2}"
EndProject
Project("{54435603-DBB4-11D2-8724-00A0C9A8B90C}") = "Setup", "..\Setup\Setup.vdproj", "{4323FA10-54B4-4478-AFF6-23D3CF32F3E3}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -55,6 +57,12 @@ Global
{83810BFC-F718-4D6F-B3E5-A5304412D8A2}.Release|x64.Build.0 = Release|Any CPU
{83810BFC-F718-4D6F-B3E5-A5304412D8A2}.Release|x86.ActiveCfg = Release|Any CPU
{83810BFC-F718-4D6F-B3E5-A5304412D8A2}.Release|x86.Build.0 = Release|Any CPU
{4323FA10-54B4-4478-AFF6-23D3CF32F3E3}.Debug|Any CPU.ActiveCfg = Debug
{4323FA10-54B4-4478-AFF6-23D3CF32F3E3}.Debug|x64.ActiveCfg = Debug
{4323FA10-54B4-4478-AFF6-23D3CF32F3E3}.Debug|x86.ActiveCfg = Debug
{4323FA10-54B4-4478-AFF6-23D3CF32F3E3}.Release|Any CPU.ActiveCfg = Release
{4323FA10-54B4-4478-AFF6-23D3CF32F3E3}.Release|x64.ActiveCfg = Release
{4323FA10-54B4-4478-AFF6-23D3CF32F3E3}.Release|x86.ActiveCfg = Release
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
11 changes: 6 additions & 5 deletions DebugOutputToasts/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ private void StackPanel_Loaded_MessagePanel(object sender, RoutedEventArgs e)
chkThrottle.IsChecked = Config.Throttle;
chkDebounce.IsChecked = Config.Debounce;
chkMinimizeToTray.IsChecked = Config.MinimizeToTrayIcon;
chkStartWithLogin.IsChecked = Config.StartWithLogin;
txtThrottle.Text = Config.ThrottleTime.ToString();
txtDebounce.Text = Config.DebounceTime.ToString();

Expand Down Expand Up @@ -192,7 +193,7 @@ private void CheckBox_Checked(object sender, RoutedEventArgs e)
break;
case "chkStartWithLogin":
Config.StartWithLogin = true;
SetTaskScheduler(true);
SetTaskScheduler(Config.StartWithLogin);
break;
}
Nett.Toml.WriteFile(Config, ConfigPath);
Expand Down Expand Up @@ -220,7 +221,7 @@ private void CheckBox_Unhecked(object sender, RoutedEventArgs e)
break;
case "chkStartWithLogin":
Config.StartWithLogin = false;
SetTaskScheduler(false);
SetTaskScheduler(Config.StartWithLogin);
break;
}
Nett.Toml.WriteFile(Config, ConfigPath);
Expand Down Expand Up @@ -1016,6 +1017,7 @@ private void SetTaskScheduler(bool enable)
if (task == null)
{
var def = ts.NewTask();
def.Settings.Enabled = enable;
def.Settings.DisallowStartIfOnBatteries = false;
def.Settings.StopIfGoingOnBatteries = false;
def.Settings.ExecutionTimeLimit = TimeSpan.Zero;
Expand All @@ -1032,16 +1034,15 @@ private void SetTaskScheduler(bool enable)
def.Actions.Add(action);

task = ts.RootFolder.RegisterTaskDefinition(taskName, def);
task.Enabled = enable;
}
else
{
task.Enabled = enable;

var action = (ExecAction)task.Definition.Actions.First();
action.Path = System.Reflection.Assembly.GetExecutingAssembly().Location;
action.WorkingDirectory = Path.GetDirectoryName(action.Path);

task.Definition.Settings.Enabled = enable;

task.RegisterChanges();
}
}
Expand Down
Loading

0 comments on commit b987407

Please sign in to comment.