Skip to content

Commit

Permalink
Merge pull request #23 from Mr-Technician/develop-1.0
Browse files Browse the repository at this point in the history
Merge changes for version 1.3.0
  • Loading branch information
Mr-Technician committed Dec 11, 2021
2 parents 3b5599b + cf91c28 commit dfaaaae
Show file tree
Hide file tree
Showing 12 changed files with 852 additions and 275 deletions.
2 changes: 1 addition & 1 deletion BorderlessMinecraft/App.config
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>
53 changes: 52 additions & 1 deletion BorderlessMinecraft/BorderlessMinecraft.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,26 @@
<OutputType>WinExe</OutputType>
<RootNamespace>BorderlessMinecraft</RootNamespace>
<AssemblyName>BorderlessMinecraft</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<TargetFrameworkProfile />
<IsWebBootstrapper>false</IsWebBootstrapper>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>1</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<PublishWizardCompleted>true</PublishWizardCompleted>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
Expand All @@ -35,9 +51,25 @@
<PropertyGroup>
<ApplicationIcon>barrier.ico</ApplicationIcon>
</PropertyGroup>
<PropertyGroup>
<ManifestCertificateThumbprint>F0BB6B4AB81DCB530A46721FAE58938516286746</ManifestCertificateThumbprint>
</PropertyGroup>
<PropertyGroup>
<ManifestKeyFile>BorderlessMinecraft_TemporaryKey.pfx</ManifestKeyFile>
</PropertyGroup>
<PropertyGroup>
<GenerateManifests>true</GenerateManifests>
</PropertyGroup>
<PropertyGroup>
<SignManifests>true</SignManifests>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.CodeDom, Version=6.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.CodeDom.6.0.0\lib\net461\System.CodeDom.dll</HintPath>
</Reference>
<Reference Include="System.Core" />
<Reference Include="System.Management" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
Expand All @@ -49,12 +81,17 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Configuration\AutoStartup.cs" />
<Compile Include="Configuration\RegistryEditor.cs" />
<Compile Include="Configuration\Config.cs" />
<Compile Include="DLLInterop.cs" />
<Compile Include="Form1.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Form1.Designer.cs">
<DependentUpon>Form1.cs</DependentUpon>
</Compile>
<Compile Include="Processes\ProcessMonitor.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="Form1.resx">
Expand All @@ -70,6 +107,8 @@
<DependentUpon>Resources.resx</DependentUpon>
<DesignTime>True</DesignTime>
</Compile>
<None Include="BorderlessMinecraft_TemporaryKey.pfx" />
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
Expand All @@ -86,5 +125,17 @@
<ItemGroup>
<Content Include="barrier.ico" />
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include=".NETFramework,Version=v4.7.2">
<Visible>False</Visible>
<ProductName>Microsoft .NET Framework 4.7.2 %28x86 and x64%29</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>false</Install>
</BootstrapperPackage>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
27 changes: 27 additions & 0 deletions BorderlessMinecraft/Configuration/AutoStartup.cs
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

}
}
}
92 changes: 92 additions & 0 deletions BorderlessMinecraft/Configuration/Config.cs
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;
}
}
39 changes: 39 additions & 0 deletions BorderlessMinecraft/Configuration/RegistryEditor.cs
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();
}
}
}
Loading

0 comments on commit dfaaaae

Please sign in to comment.