changes
This commit is contained in:
@@ -38,6 +38,10 @@ namespace ModVersionChecker
|
|||||||
{
|
{
|
||||||
Console.WriteLine("Application is shutting down...");
|
Console.WriteLine("Application is shutting down...");
|
||||||
});
|
});
|
||||||
|
lifetime.ApplicationStopping.Register(() =>
|
||||||
|
{
|
||||||
|
Console.WriteLine("Application is shutting down...");
|
||||||
|
});
|
||||||
|
|
||||||
Application.SetHighDpiMode(HighDpiMode.SystemAware);
|
Application.SetHighDpiMode(HighDpiMode.SystemAware);
|
||||||
Application.EnableVisualStyles();
|
Application.EnableVisualStyles();
|
||||||
@@ -78,7 +82,13 @@ namespace ModVersionChecker
|
|||||||
|
|
||||||
var contextMenu = new ContextMenuStrip();
|
var contextMenu = new ContextMenuStrip();
|
||||||
contextMenu.Items.Add("Configure", null, openFormHandler);
|
contextMenu.Items.Add("Configure", null, openFormHandler);
|
||||||
contextMenu.Items.Add("Exit", null, (s, e) => Application.Exit());
|
contextMenu.Items.Add("Exit", null, (s, e) =>
|
||||||
|
{
|
||||||
|
notifyIcon.Visible = false;
|
||||||
|
Application.Exit();
|
||||||
|
lifetime.StopApplication();
|
||||||
|
//host.StopAsync().GetAwaiter().GetResult();
|
||||||
|
});
|
||||||
notifyIcon.ContextMenuStrip = contextMenu;
|
notifyIcon.ContextMenuStrip = contextMenu;
|
||||||
|
|
||||||
notifyIcon.DoubleClick += openFormHandler;
|
notifyIcon.DoubleClick += openFormHandler;
|
||||||
@@ -119,21 +129,14 @@ namespace ModVersionChecker
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Add to startup
|
host.Start();
|
||||||
// AddToStartup();
|
|
||||||
|
|
||||||
Application.Run(); // Keep app running for tray icon
|
Application.Run(); // Keep app running for tray icon
|
||||||
|
|
||||||
|
host.StopAsync().GetAwaiter().GetResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
host.RunAsync().GetAwaiter().GetResult();
|
|
||||||
}
|
|
||||||
|
|
||||||
static void AddToStartup()
|
|
||||||
{
|
|
||||||
using (var key = Microsoft.Win32.Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run", true))
|
|
||||||
{
|
|
||||||
key?.SetValue("XintanalabsUpdateChecker", $"\"{Application.ExecutablePath}\"");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -6,6 +6,7 @@
|
|||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<UseWindowsForms>true</UseWindowsForms>
|
<UseWindowsForms>true</UseWindowsForms>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<ApplicationIcon>Resources\MVC-Icon.ico</ApplicationIcon>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@@ -1,10 +1,7 @@
|
|||||||
using ModVersionChecker.data.model;
|
using ModVersionChecker.data.model;
|
||||||
using ModVersionChecker.forms;
|
|
||||||
using ModVersionChecker.managers.interfaces;
|
using ModVersionChecker.managers.interfaces;
|
||||||
using ModVersionChecker.utils;
|
using ModVersionChecker.utils;
|
||||||
using NuGet.Versioning;
|
using NuGet.Versioning;
|
||||||
using OpenQA.Selenium.BiDi.Script;
|
|
||||||
using System.Windows.Forms;
|
|
||||||
|
|
||||||
|
|
||||||
namespace ModVersionChecker
|
namespace ModVersionChecker
|
||||||
|
@@ -17,5 +17,8 @@ namespace ModVersionChecker.data.model
|
|||||||
|
|
||||||
[JsonPropertyName("checkOnStartup")]
|
[JsonPropertyName("checkOnStartup")]
|
||||||
public bool CheckOnStartup { get; set; } = true;
|
public bool CheckOnStartup { get; set; } = true;
|
||||||
|
|
||||||
|
[JsonPropertyName("runOnStartup")]
|
||||||
|
public bool RunOnStartup { get; set; } = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -8,9 +8,9 @@ namespace ModVersionChecker.forms
|
|||||||
private IConfigManager _configManager;
|
private IConfigManager _configManager;
|
||||||
private GlobalConfig _config;
|
private GlobalConfig _config;
|
||||||
|
|
||||||
private Label _millislabel, _checkStartupLabel;
|
private Label _millislabel, _checkStartupLabel, _runOnStartupLabel;
|
||||||
private TrackBar _millisField;
|
private TrackBar _millisField;
|
||||||
private CheckBox _checkStartupField;
|
private CheckBox _checkStartupField, _runOnStartupField;
|
||||||
private Button _saveButton, _cancelButton;
|
private Button _saveButton, _cancelButton;
|
||||||
private TableLayoutPanel _mainLayout, _configsPanel;
|
private TableLayoutPanel _mainLayout, _configsPanel;
|
||||||
private FlowLayoutPanel _buttonPanel;
|
private FlowLayoutPanel _buttonPanel;
|
||||||
@@ -54,8 +54,10 @@ namespace ModVersionChecker.forms
|
|||||||
{
|
{
|
||||||
_config.IntervalMinutes = _millisField.Value;
|
_config.IntervalMinutes = _millisField.Value;
|
||||||
_config.CheckOnStartup = _checkStartupField.Checked;
|
_config.CheckOnStartup = _checkStartupField.Checked;
|
||||||
|
_config.RunOnStartup = _runOnStartupField.Checked;
|
||||||
_configManager.Save(_config);
|
_configManager.Save(_config);
|
||||||
DialogResult = DialogResult.OK;
|
DialogResult = DialogResult.OK;
|
||||||
|
UpdateStartupSetting(_config.RunOnStartup);
|
||||||
Close();
|
Close();
|
||||||
};
|
};
|
||||||
_cancelButton = new Button { Text = "Cancel", AutoSize = true };
|
_cancelButton = new Button { Text = "Cancel", AutoSize = true };
|
||||||
@@ -90,13 +92,17 @@ namespace ModVersionChecker.forms
|
|||||||
|
|
||||||
_millisField.Scroll += (sender, e) => { millisValue.Text = _millisField.Value.ToString() + " minutes"; };
|
_millisField.Scroll += (sender, e) => { millisValue.Text = _millisField.Value.ToString() + " minutes"; };
|
||||||
|
|
||||||
_checkStartupLabel = new Label { Text = "Check on Startup:", Width = 150 };
|
_checkStartupLabel = new Label { Text = "Check on Application Start:", Width = 150 };
|
||||||
_checkStartupField = new CheckBox { Checked = _config.CheckOnStartup };
|
_checkStartupField = new CheckBox { Checked = _config.CheckOnStartup };
|
||||||
|
_runOnStartupLabel= new Label { Text = "Run on Windows Startup:", Width = 150 };
|
||||||
|
_runOnStartupField = new CheckBox { Checked = _config.RunOnStartup };
|
||||||
|
|
||||||
configsPanel.Controls.Add(_millislabel, 0, 0);
|
configsPanel.Controls.Add(_millislabel, 0, 0);
|
||||||
configsPanel.Controls.Add(millisPanel, 1, 0);
|
configsPanel.Controls.Add(millisPanel, 1, 0);
|
||||||
configsPanel.Controls.Add(_checkStartupLabel, 0, 1);
|
configsPanel.Controls.Add(_checkStartupLabel, 0, 1);
|
||||||
configsPanel.Controls.Add(_checkStartupField, 1, 1);
|
configsPanel.Controls.Add(_checkStartupField, 1, 1);
|
||||||
|
configsPanel.Controls.Add(_runOnStartupLabel, 0, 2);
|
||||||
|
configsPanel.Controls.Add(_runOnStartupField, 1, 2);
|
||||||
|
|
||||||
return configsPanel;
|
return configsPanel;
|
||||||
}
|
}
|
||||||
@@ -116,6 +122,20 @@ namespace ModVersionChecker.forms
|
|||||||
return mainLayout;
|
return mainLayout;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void UpdateStartupSetting(bool runOnStartup)
|
||||||
|
{
|
||||||
|
using (var key = Microsoft.Win32.Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run", true))
|
||||||
|
{
|
||||||
|
if (runOnStartup)
|
||||||
|
{
|
||||||
|
key?.SetValue("XintanalabsUpdateChecker", $"\"{Application.ExecutablePath}\"");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
key?.DeleteValue("XintanalabsUpdateChecker", false); // Remove if unchecked
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
// Add methods and properties for global configuration management here
|
// Add methods and properties for global configuration management here
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user