-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #23 from Mr-Technician/develop-1.0
Merge changes for version 1.3.0
- Loading branch information
Showing
12 changed files
with
852 additions
and
275 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<configuration> | ||
<startup> | ||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2"/> | ||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/> | ||
</startup> | ||
</configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using Microsoft.Win32; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace BorderlessMinecraft.Configuration | ||
{ | ||
static class AutoStartup | ||
{ | ||
/// <summary> | ||
/// Sets the auto startup location for borderless minecraft | ||
/// </summary> | ||
/// <param name="enabled"></param> | ||
internal static void SetStartup(bool enabled) | ||
{ | ||
RegistryKey key = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true); | ||
|
||
if (enabled) | ||
key.SetValue(nameof(BorderlessMinecraft), System.Reflection.Assembly.GetEntryAssembly().Location + " -autoStart"); //set the key value and append the flag | ||
else | ||
key.DeleteValue(nameof(BorderlessMinecraft), false); //remove the startup entry | ||
|
||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace BorderlessMinecraft.Configuration | ||
{ | ||
/// <summary> | ||
/// Exposes configuration properties that will be automatically saved to and retrieved from the registry | ||
/// </summary> | ||
class Config | ||
{ | ||
private RegistryEditor Registry { get; } | ||
public Config() | ||
{ | ||
Registry = new RegistryEditor(@"SOFTWARE\BorderlessMinecraft"); //open the registry in this location | ||
|
||
if (bool.TryParse((string)Registry.GetKeyValue(nameof(StartOnBoot)), out bool value1)) | ||
_startOnBoot = value1; | ||
if (bool.TryParse((string)Registry.GetKeyValue(nameof(StartMinimized)), out bool value2)) | ||
_startMinimized = value2; | ||
if (bool.TryParse((string)Registry.GetKeyValue(nameof(MinimizeToTray)), out bool value3)) | ||
_minimizeToTray = value3; | ||
if (bool.TryParse((string)Registry.GetKeyValue(nameof(AutomaticBorderless)), out bool value4)) | ||
_automaticBorderless = value4; | ||
if (bool.TryParse((string)Registry.GetKeyValue(nameof(PreserveTaskBar)), out bool value5)) | ||
_preserveTaskBar = value5; | ||
if (bool.TryParse((string)Registry.GetKeyValue(nameof(ShowAllClients)), out bool value6)) | ||
_showAllClients = value6; | ||
} | ||
|
||
public bool StartOnBoot | ||
{ | ||
get => _startOnBoot; | ||
set | ||
{ | ||
_startOnBoot = value; | ||
Registry.SetKeyValue(nameof(StartOnBoot), value); | ||
AutoStartup.SetStartup(value); | ||
} | ||
} | ||
private bool _startOnBoot; | ||
|
||
public bool StartMinimized | ||
{ | ||
get => _startMinimized; | ||
set | ||
{ | ||
_startMinimized = value; | ||
Registry.SetKeyValue(nameof(StartMinimized), value); | ||
} | ||
} | ||
private bool _startMinimized; | ||
public bool MinimizeToTray | ||
{ | ||
get => _minimizeToTray; set | ||
{ | ||
_minimizeToTray = value; | ||
Registry.SetKeyValue(nameof(MinimizeToTray), value); | ||
} | ||
} | ||
private bool _minimizeToTray; | ||
public bool AutomaticBorderless | ||
{ | ||
get => _automaticBorderless; set | ||
{ | ||
_automaticBorderless = value; | ||
Registry.SetKeyValue(nameof(AutomaticBorderless), value); | ||
} | ||
} | ||
private bool _automaticBorderless; | ||
public bool PreserveTaskBar | ||
{ | ||
get => _preserveTaskBar; set | ||
{ | ||
_preserveTaskBar = value; | ||
Registry.SetKeyValue(nameof(PreserveTaskBar), value); | ||
} | ||
} | ||
private bool _preserveTaskBar; | ||
public bool ShowAllClients | ||
{ | ||
get => _showAllClients; set | ||
{ | ||
_showAllClients = value; | ||
Registry.SetKeyValue(nameof(ShowAllClients), value); | ||
} | ||
} | ||
private bool _showAllClients; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
using Microsoft.Win32; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace BorderlessMinecraft.Configuration | ||
{ | ||
class RegistryEditor | ||
{ | ||
private string SubKeyName { get; } | ||
internal RegistryEditor(string subkeyName = @"SOFTWARE\TestSettings") | ||
{ | ||
SubKeyName = subkeyName; | ||
} | ||
|
||
internal object GetKeyValue(string key) | ||
{ | ||
RegistryKey regKey = Registry.CurrentUser.OpenSubKey(SubKeyName); | ||
|
||
//if it does exist, retrieve the stored values | ||
if (regKey != null) | ||
{ | ||
var value = regKey.GetValue(key); | ||
regKey.Close(); | ||
return value; | ||
} | ||
return null; | ||
} | ||
|
||
internal void SetKeyValue(string key, object value) | ||
{ | ||
RegistryKey regKey = Registry.CurrentUser.CreateSubKey(SubKeyName); | ||
regKey.SetValue(key, value); | ||
regKey.Close(); | ||
} | ||
} | ||
} |
Oops, something went wrong.