Skip to content

Commit

Permalink
Remove unused using directives and NuGet packages
Browse files Browse the repository at this point in the history
  • Loading branch information
rguida committed May 20, 2024
1 parent f7cb0a9 commit d5a18dd
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 41 deletions.
1 change: 0 additions & 1 deletion MMExNotifier/MMExNotifier.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Hardcodet.NotifyIcon.Wpf" Version="1.1.0" />
<PackageReference Include="linq2db" Version="5.1.1" />
<PackageReference Include="linq2db.SQLite" Version="5.1.1" />
<PackageReference Include="Microsoft.Toolkit.Uwp.Notifications" Version="7.1.3" />
Expand Down
4 changes: 1 addition & 3 deletions MMExNotifier/Views/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -278,10 +278,8 @@

<CheckBox
Margin="20"
Checked="RunOnLogon_Checked"
Content="Run MMExNotifier on Windows logon"
IsChecked="{Binding Path=AppSettings.RunAtLogon}"
Unchecked="RunOnLogon_Unchecked" />
IsChecked="{Binding Path=AppSettings.RunAtLogon}" />

<Grid Margin="20,10">
<Grid.ColumnDefinitions>
Expand Down
38 changes: 1 addition & 37 deletions MMExNotifier/Views/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,8 @@
using System;
using System.Windows;
using System.Windows.Input;
using Microsoft.Win32;
using Microsoft.Win32.TaskScheduler;
using System.Security.Principal;
using System.Windows;
using System.IO;
using Drawing = System.Drawing;
using System.Reflection;
using WpfUi = Wpf.Ui.Controls;
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
using System.Windows.Forms;
using Windows.UI.ApplicationSettings;

namespace MMExNotifier
{
Expand Down Expand Up @@ -51,34 +43,6 @@ private void SettingsPanelClose_Click(object sender, RoutedEventArgs e)
settingsPanel.Visibility = Visibility.Collapsed;
}


private void RunOnLogon_Checked(object sender, RoutedEventArgs e)
{
using TaskService taskService = new();
TaskDefinition taskDefinition = taskService.NewTask();

// Set the task settings
taskDefinition.RegistrationInfo.Description = "MMExNotifier";
var userId = WindowsIdentity.GetCurrent().Name;

// Set the trigger to run on logon
LogonTrigger logonTrigger = new() { UserId = userId };
taskDefinition.Triggers.Add(logonTrigger);

// Set the action to run the executable that creates the task
string executablePath = Environment.ProcessPath ?? "";
taskDefinition.Actions.Add(new ExecAction(executablePath));

// Register the task in the Windows Task Scheduler
taskService.RootFolder.RegisterTaskDefinition("MMExNotifier", taskDefinition);
}

private void RunOnLogon_Unchecked(object sender, RoutedEventArgs e)
{
using TaskService taskService = new();
taskService.RootFolder.DeleteTask("MMExNotifier", false);
}

private void OpenFile_Click(object sender, RoutedEventArgs e)
{
var openFileDialog = new Microsoft.Win32.OpenFileDialog
Expand Down

0 comments on commit d5a18dd

Please sign in to comment.