diff --git a/Deploy/Choco/lightbulb.nuspec b/Deploy/Choco/lightbulb.nuspec deleted file mode 100644 index 05961392..00000000 --- a/Deploy/Choco/lightbulb.nuspec +++ /dev/null @@ -1,26 +0,0 @@ - - - - lightbulb - LightBulb - 1.6.4.1 - Tyrrrz - Tyrrrz - Copyright (C) Alexey Golub - Reduces eye strain by adjusting gamma based on the current time - LightBulb is an application that reduces eye strain produced by staring at a computer screen when working late hours. As the day goes on, it continuously adjusts gamma, transitioning the display color temperature from cold blue in the afternoon to warm yellow during the night. Its primary objective is to match the color of the screen to the light sources of your surrounding environment - typically, sunlight during the day and artificial light during the night. LightBulb has minimal impact on performance and offers many customization options. - lightbulb admin screen gamma correction utility eye-strain sunrise sunset - https://github.com/Tyrrrz/LightBulb - https://github.com/Tyrrrz/LightBulb - http://tyrrrz.me/Projects/LightBulb - https://github.com/Tyrrrz/LightBulb/blob/master/Changelog.md - https://raw.githubusercontent.com/Tyrrrz/LightBulb/master/favicon.png - https://raw.githubusercontent.com/Tyrrrz/LightBulb/master/License.txt - true - https://github.com/Tyrrrz/LightBulb/wiki - https://github.com/Tyrrrz/LightBulb/issues - - - - - diff --git a/Deploy/Choco/tools/chocolateyinstall.ps1 b/Deploy/Choco/tools/chocolateyinstall.ps1 deleted file mode 100644 index 032cd833..00000000 --- a/Deploy/Choco/tools/chocolateyinstall.ps1 +++ /dev/null @@ -1,10 +0,0 @@ -$ErrorActionPreference = 'Stop'; -$packageArgs = @{ - packageName = $env:ChocolateyPackageName - softwareName = 'lightbulb*' - unzipLocation = "$(Split-Path -parent $MyInvocation.MyCommand.Definition)" - url = 'https://github.com/Tyrrrz/LightBulb/releases/download/1.6.4.1/LightBulb-Installer.exe' - fileType = 'exe' - silentArgs = '/VERYSILENT /SUPPRESSMSGBOXES /NORESTART /SP-' -} -Install-ChocolateyPackage @packageArgs \ No newline at end of file diff --git a/Deploy/Installer/Installer.iss b/Deploy/Installer/Installer.iss deleted file mode 100644 index bd149098..00000000 --- a/Deploy/Installer/Installer.iss +++ /dev/null @@ -1,50 +0,0 @@ -#define MyAppName "LightBulb" -#define MyAppVersion "1.6.4.1" -#define MyAppPublisher "Alexey 'Tyrrrz' Golub" -#define MyAppURL "http://tyrrrz.me/Projects/LightBulb" - -[Setup] -AppId={{892F745F-A497-42ED-B503-8D74936D0BEB} -AppName={#MyAppName} -AppVersion={#MyAppVersion} -AppVerName={#MyAppName} {#MyAppVersion} -AppPublisher={#MyAppPublisher} -AppPublisherURL={#MyAppURL} -AppSupportURL={#MyAppURL} -AppUpdatesURL={#MyAppURL} -AppMutex=LightBulb_Identity -DefaultDirName={pf}\{#MyAppName} -DefaultGroupName={#MyAppName} -ArchitecturesInstallIn64BitMode=x64 -ChangesEnvironment=yes -AllowNoIcons=yes -DisableWelcomePage=yes -DisableProgramGroupPage=no -DisableReadyPage=yes -SetupIconFile=..\..\favicon.ico -UninstallDisplayIcon=..\..\favicon.ico -LicenseFile=..\..\License.txt -OutputDir=bin\ -OutputBaseFilename=LightBulb-Installer - -[Languages] -Name: "english"; MessagesFile: "compiler:Default.isl" - -[Files] -Source: "..\..\License.txt"; DestDir: "{app}"; Flags: ignoreversion -Source: "..\..\LightBulb\bin\Release\LightBulb.exe"; DestDir: "{app}"; Flags: ignoreversion -Source: "..\..\LightBulb\bin\Release\*.config"; DestDir: "{app}"; Flags: ignoreversion -Source: "..\..\LightBulb\bin\Release\*.dll"; DestDir: "{app}"; Flags: ignoreversion - -[Icons] -Name: "{group}\{#MyAppName}"; Filename: "{app}\LightBulb.exe" -Name: "{group}\{cm:UninstallProgram,{#MyAppName}}"; Filename: "{uninstallexe}" -Name: "{group}\{#MyAppName} on Github"; Filename: "https://github.com/Tyrrrz/LightBulb" -Name: "{commonstartup}\{#MyAppName}"; Filename: "{app}\LightBulb.exe" - -[Registry] -; Change valid gamma range -Root: HKLM; Subkey: "Software\Microsoft\Windows NT\CurrentVersion\ICM"; ValueType: dword; ValueName: "GdiICMGammaRange"; ValueData: "256" - -[Run] -Filename: "{app}\LightBulb.exe"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent \ No newline at end of file diff --git a/Deploy/Portable/LightBulb_Portable.bat b/Deploy/Portable/LightBulb_Portable.bat deleted file mode 100644 index 5c069ffe..00000000 --- a/Deploy/Portable/LightBulb_Portable.bat +++ /dev/null @@ -1,2 +0,0 @@ -start LightBulb.exe -portable -exit \ No newline at end of file diff --git a/Deploy/Portable/LightBulb_Portable_Readme.txt b/Deploy/Portable/LightBulb_Portable_Readme.txt deleted file mode 100644 index 804e4342..00000000 --- a/Deploy/Portable/LightBulb_Portable_Readme.txt +++ /dev/null @@ -1,6 +0,0 @@ -0. Make sure .NET Framework 4.5.2 is installed -1. Copy the contents to a directory with write permissions -2. If you haven't before, update computer's gamma range: - 2a. Run Manual_Gamma_Registry_Fix.reg as administrator - 2b. Restart computer -3. Use LightBulb_Portable.bat to launch the program (don't launch the exe directly) \ No newline at end of file diff --git a/Deploy/Portable/Manual_Gamma_Registry_Fix.reg b/Deploy/Portable/Manual_Gamma_Registry_Fix.reg deleted file mode 100644 index 23f06408..00000000 --- a/Deploy/Portable/Manual_Gamma_Registry_Fix.reg +++ /dev/null @@ -1,4 +0,0 @@ -Windows Registry Editor Version 5.00 - -[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ICM] -"GdiIcmGammaRange"=dword:00000100 \ No newline at end of file diff --git a/Deploy/Prepare.ps1 b/Deploy/Prepare.ps1 index 4a029925..f80e9bb4 100644 --- a/Deploy/Prepare.ps1 +++ b/Deploy/Prepare.ps1 @@ -1,22 +1,21 @@ -# --- INSTALLER --- +$licenseFilePath = "$PSScriptRoot/../License.txt" -# Run Inno Setup Compiler -& "c:\Program Files (x86)\Inno Setup 5\iscc" "$PSScriptRoot\Installer\Installer.iss" +$projectDirPath = "$PSScriptRoot/../LightBulb" +$publishDirPath = "$PSScriptRoot/bin/build/" +$artifactFilePath = "$PSScriptRoot/bin/LightBulb.zip" -# --- PORTABLE --- +# Prepare directory +if (Test-Path $publishDirPath) { + Remove-Item $publishDirPath -Recurse -Force +} +New-Item $publishDirPath -ItemType Directory -Force + +# Build & publish +dotnet publish $projectDirPath -o $publishDirPath -c Release | Out-Host -# Get files $files = @() -$files += Get-Item -Path "$PSScriptRoot\..\License.txt" -$files += Get-ChildItem -Path "$PSScriptRoot\..\LightBulb\bin\Release\*" -Include "*.exe", "*.dll", "*.config" -$files += Get-ChildItem -Path "$PSScriptRoot\Portable\*"; +$files += Get-Item -Path $licenseFilePath +$files += Get-ChildItem -Path $publishDirPath # Pack into archive -New-Item "$PSScriptRoot\Portable\bin" -ItemType Directory -Force -$files | Compress-Archive -DestinationPath "$PSScriptRoot\Portable\bin\LightBulb-Portable.zip" -Force - -# --- CHOCOLATEY --- - -# Create package -New-Item "$PSScriptRoot\Choco\bin\" -ItemType Directory -Force -choco pack $PSScriptRoot\Choco\lightbulb.nuspec --out $PSScriptRoot\Choco\bin\ \ No newline at end of file +$files | Compress-Archive -DestinationPath $artifactFilePath -Force \ No newline at end of file diff --git a/LightBulb.Tests/Converters/TimeSpanToHumanizedDurationStringConverterTests.cs b/LightBulb.Tests/Converters/TimeSpanToHumanizedDurationStringConverterTests.cs new file mode 100644 index 00000000..0c9a81a7 --- /dev/null +++ b/LightBulb.Tests/Converters/TimeSpanToHumanizedDurationStringConverterTests.cs @@ -0,0 +1,95 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using LightBulb.Converters; +using NUnit.Framework; + +namespace LightBulb.Tests.Converters +{ + [TestFixture] + public class TimeSpanToHumanizedDurationStringConverterTests + { + private static IEnumerable GetTestCases_Convert() + { + yield return new TestCaseData( + TimeSpan.FromHours(1), + "1 hour", + null + ); + + yield return new TestCaseData( + TimeSpan.FromHours(2), + "2 hours", + null + ); + + yield return new TestCaseData( + TimeSpan.FromHours(1.5), + "1 hour 30 minutes", + null + ); + + yield return new TestCaseData( + TimeSpan.FromHours(4.5), + "4 hours 30 minutes", + null + ); + + yield return new TestCaseData( + TimeSpan.FromHours(1) + TimeSpan.FromMinutes(1), + "1 hour 1 minute", + null + ); + + yield return new TestCaseData( + TimeSpan.FromHours(2) + TimeSpan.FromMinutes(1), + "2 hours 1 minute", + null + ); + + yield return new TestCaseData( + TimeSpan.FromHours(2) + TimeSpan.FromMinutes(10) + TimeSpan.FromSeconds(15), + "2 hours 10 minutes", + null + ); + + yield return new TestCaseData( + TimeSpan.FromSeconds(10), + "10 seconds", + null + ); + + yield return new TestCaseData( + TimeSpan.FromSeconds(1), + "1 second", + null + ); + + yield return new TestCaseData( + TimeSpan.FromSeconds(0), + "0 seconds", + null + ); + + yield return new TestCaseData( + TimeSpan.Zero, + "0 seconds", + null + ); + } + + [Test] + [TestCaseSource(nameof(GetTestCases_Convert))] + public void Convert_Test(TimeSpan input, string expectedOutput, CultureInfo cultureInfo) + { + // Arrange + var converter = new TimeSpanToHumanizedDurationStringConverter(); + + // Act + var output = converter.Convert(input, expectedOutput.GetType(), null, cultureInfo); + + // Assert + Assert.That(output, Is.EqualTo(expectedOutput)); + } + } +} \ No newline at end of file diff --git a/LightBulb.Tests/Helpers/AstronomyTests.cs b/LightBulb.Tests/Helpers/AstronomyTests.cs new file mode 100644 index 00000000..e3393604 --- /dev/null +++ b/LightBulb.Tests/Helpers/AstronomyTests.cs @@ -0,0 +1,88 @@ +using System; +using System.Collections.Generic; +using LightBulb.Helpers; +using LightBulb.Models; +using NUnit.Framework; + +namespace LightBulb.Tests.Helpers +{ + [TestFixture] + public class AstronomyTests + { + private static IEnumerable GetTestCases_CalculateSunrise() + { + yield return new TestCaseData( + new GeoLocation(40.7128, -74.0060), + new DateTimeOffset(2019, 10, 08, 00, 00, 00, TimeSpan.FromHours(-4)), + new TimeSpan(07, 01, 00) + ); + + yield return new TestCaseData( + new GeoLocation(40.7128, -74.0060), + new DateTimeOffset(2019, 10, 08, 13, 37, 59, TimeSpan.FromHours(-4)), + new TimeSpan(07, 01, 00) + ); + + yield return new TestCaseData( + new GeoLocation(55.6761, 12.5683), + new DateTimeOffset(2019, 10, 08, 00, 00, 00, TimeSpan.FromHours(+2)), + new TimeSpan(07, 27, 00) + ); + + yield return new TestCaseData( + new GeoLocation(55.6761, 12.5683), + new DateTimeOffset(2019, 10, 08, 05, 41, 01, TimeSpan.FromHours(+2)), + new TimeSpan(07, 27, 00) + ); + } + + [Test] + [TestCaseSource(nameof(GetTestCases_CalculateSunrise))] + public void CalculateSunrise_Test(GeoLocation location, DateTimeOffset instant, TimeSpan expectedSunriseTime) + { + // Act + var sunriseTime = Astronomy.CalculateSunrise(location, instant).TimeOfDay; + + // Assert + Assert.That(sunriseTime, Is.EqualTo(expectedSunriseTime).Within(TimeSpan.FromMinutes(3))); + } + + private static IEnumerable GetTestCases_CalculateSunset() + { + yield return new TestCaseData( + new GeoLocation(40.7128, -74.0060), + new DateTimeOffset(2019, 10, 08, 00, 00, 00, TimeSpan.FromHours(-4)), + new TimeSpan(18, 27, 00) + ); + + yield return new TestCaseData( + new GeoLocation(40.7128, -74.0060), + new DateTimeOffset(2019, 10, 08, 13, 37, 59, TimeSpan.FromHours(-4)), + new TimeSpan(18, 27, 00) + ); + + yield return new TestCaseData( + new GeoLocation(35.6762, 139.6503), + new DateTimeOffset(2019, 10, 08, 00, 00, 00, TimeSpan.FromHours(+9)), + new TimeSpan(17, 15, 00) + ); + + yield return new TestCaseData( + new GeoLocation(35.6762, 139.6503), + new DateTimeOffset(2019, 10, 08, 23, 59, 59, TimeSpan.FromHours(+9)), + new TimeSpan(17, 15, 00) + ); + } + + [Test] + [TestCaseSource(nameof(GetTestCases_CalculateSunset))] + public void CalculateSunset_Test(GeoLocation location, DateTimeOffset instant, TimeSpan expectedSunsetTime) + { + // Act + var sunsetTime = Astronomy.CalculateSunset(location, instant).TimeOfDay; + + // Assert + Assert.That(sunsetTime, Is.EqualTo(expectedSunsetTime).Within(TimeSpan.FromMinutes(3))); + } + } +} \ No newline at end of file diff --git a/LightBulb.Tests/LightBulb.Tests.csproj b/LightBulb.Tests/LightBulb.Tests.csproj new file mode 100644 index 00000000..9d322212 --- /dev/null +++ b/LightBulb.Tests/LightBulb.Tests.csproj @@ -0,0 +1,19 @@ + + + + netcoreapp3.0 + false + true + + + + + + + + + + + + + \ No newline at end of file diff --git a/LightBulb.Tests/Models/GeoLocationTests.cs b/LightBulb.Tests/Models/GeoLocationTests.cs new file mode 100644 index 00000000..f89785eb --- /dev/null +++ b/LightBulb.Tests/Models/GeoLocationTests.cs @@ -0,0 +1,49 @@ +using System.Collections.Generic; +using LightBulb.Models; +using NUnit.Framework; + +namespace LightBulb.Tests.Models +{ + [TestFixture] + public class GeoLocationTests + { + private static IEnumerable GetTestCases_TryParse() + { + // Valid + yield return new TestCaseData("41.25 -120.9762", true, new GeoLocation(41.25, -120.9762)); + yield return new TestCaseData("41.25, -120.9762", true, new GeoLocation(41.25, -120.9762)); + yield return new TestCaseData("41.25,-120.9762", true, new GeoLocation(41.25, -120.9762)); + yield return new TestCaseData("-41.25, -120.9762", true, new GeoLocation(-41.25, -120.9762)); + yield return new TestCaseData("41.25, 120.9762", true, new GeoLocation(41.25, 120.9762)); + yield return new TestCaseData("41.25°N, 120.9762°W", true, new GeoLocation(41.25, -120.9762)); + yield return new TestCaseData("41.25N 120.9762W", true, new GeoLocation(41.25, -120.9762)); + yield return new TestCaseData("41.25N, 120.9762W", true, new GeoLocation(41.25, -120.9762)); + yield return new TestCaseData("41.25 N, 120.9762 W", true, new GeoLocation(41.25, -120.9762)); + yield return new TestCaseData("41.25 S, 120.9762 W", true, new GeoLocation(-41.25, -120.9762)); + yield return new TestCaseData("41.25 S, 120.9762 E", true, new GeoLocation(-41.25, 120.9762)); + yield return new TestCaseData("41, 120", true, new GeoLocation(41, 120)); + yield return new TestCaseData("-41, -120", true, new GeoLocation(-41, -120)); + yield return new TestCaseData("41 N, 120 E", true, new GeoLocation(41, 120)); + yield return new TestCaseData("41 N, 120 W", true, new GeoLocation(41, -120)); + + // Invalid + yield return new TestCaseData("41.25; -120.9762", false, default(GeoLocation)); + yield return new TestCaseData("-41.25 S, 120.9762 E", false, default(GeoLocation)); + yield return new TestCaseData("41.25", false, default(GeoLocation)); + yield return new TestCaseData("", false, default(GeoLocation)); + yield return new TestCaseData(null, false, default(GeoLocation)); + } + + [Test] + [TestCaseSource(nameof(GetTestCases_TryParse))] + public void TryParse_Test(string value, bool isValid, GeoLocation expectedResult = default) + { + // Act + var success = GeoLocation.TryParse(value, out var result); + + // Assert + Assert.That(success, Is.EqualTo(isValid), "Is valid"); + Assert.That(result, Is.EqualTo(expectedResult), "Result value"); + } + } +} \ No newline at end of file diff --git a/LightBulb.Tests/Services/LocationServiceTests.cs b/LightBulb.Tests/Services/LocationServiceTests.cs new file mode 100644 index 00000000..29872a30 --- /dev/null +++ b/LightBulb.Tests/Services/LocationServiceTests.cs @@ -0,0 +1,42 @@ +using System.Threading.Tasks; +using LightBulb.Models; +using LightBulb.Services; +using NUnit.Framework; + +namespace LightBulb.Tests.Services +{ + [TestFixture] + public class LocationServiceTests + { + [Test] + public async Task GetLocationAsync_Test() + { + // Arrange + using var locationService = new LocationService(); + + // Act + var location = await locationService.GetLocationAsync(); + + // Assert + Assert.That(location, Is.Not.EqualTo(default(GeoLocation))); + } + + [Test] + [TestCase("Kyiv, Ukraine")] + [TestCase("Dresden")] + [TestCase("UK")] + [TestCase("King's Cross, Platform 9 3/4")] + [TestCase("Statue of Liberty")] + public async Task GetLocationAsync_Query_Test(string query) + { + // Arrange + using var locationService = new LocationService(); + + // Act + var location = await locationService.GetLocationAsync(query); + + // Assert + Assert.That(location, Is.Not.EqualTo(default(GeoLocation))); + } + } +} \ No newline at end of file diff --git a/LightBulb.Timers/AutoResetTimer.cs b/LightBulb.Timers/AutoResetTimer.cs index 638b388e..2974986f 100644 --- a/LightBulb.Timers/AutoResetTimer.cs +++ b/LightBulb.Timers/AutoResetTimer.cs @@ -11,6 +11,7 @@ public class AutoResetTimer : IDisposable private readonly Timer _internalTimer; private bool _isBusy; + private bool _isDisposed; public AutoResetTimer(Action handler) { @@ -21,20 +22,25 @@ public AutoResetTimer(Action handler) private void Tick() { // Prevent multiple reentry + if (_isBusy) + return; + lock (_lock) { - if (_isBusy) return; + // Prevent executing when already disposed (race condition) + if (_isDisposed) + return; + _isBusy = true; - } - // Execute handler and reset busy state - try - { - _handler(); - } - finally - { - _isBusy = false; + try + { + _handler(); + } + finally + { + _isBusy = false; + } } } @@ -52,6 +58,14 @@ public AutoResetTimer Stop() return this; } - public void Dispose() => _internalTimer.Dispose(); + public void Dispose() + { + // Lock so that tick doesn't trigger after dispose (bad idea?) + lock (_lock) + { + _isDisposed = true; + _internalTimer.Dispose(); + } + } } } \ No newline at end of file diff --git a/LightBulb.Timers/LightBulb.Timers.csproj b/LightBulb.Timers/LightBulb.Timers.csproj index cbe7f440..30e4a4e4 100644 --- a/LightBulb.Timers/LightBulb.Timers.csproj +++ b/LightBulb.Timers/LightBulb.Timers.csproj @@ -1,9 +1,8 @@  - net48 + netcoreapp3.0 true - latest \ No newline at end of file diff --git a/LightBulb.WindowsApi/HotkeyManager.cs b/LightBulb.WindowsApi/HotkeyManager.cs index a343092b..3153a83f 100644 --- a/LightBulb.WindowsApi/HotkeyManager.cs +++ b/LightBulb.WindowsApi/HotkeyManager.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.Linq; using LightBulb.WindowsApi.Internal; -using Tyrrrz.Extensions; namespace LightBulb.WindowsApi { diff --git a/LightBulb.WindowsApi/LightBulb.WindowsApi.csproj b/LightBulb.WindowsApi/LightBulb.WindowsApi.csproj index 8b3ec81d..de44923f 100644 --- a/LightBulb.WindowsApi/LightBulb.WindowsApi.csproj +++ b/LightBulb.WindowsApi/LightBulb.WindowsApi.csproj @@ -1,13 +1,12 @@  - net48 + netcoreapp3.0 true - latest - + \ No newline at end of file diff --git a/LightBulb.WindowsApi/Models/ColorBalance.cs b/LightBulb.WindowsApi/Models/ColorBalance.cs index 686e169a..e285f9d3 100644 --- a/LightBulb.WindowsApi/Models/ColorBalance.cs +++ b/LightBulb.WindowsApi/Models/ColorBalance.cs @@ -27,17 +27,9 @@ public override bool Equals(object obj) return obj is ColorBalance other && Equals(other); } - public override int GetHashCode() - { - unchecked - { - var hashCode = Red.GetHashCode(); - hashCode = (hashCode * 397) ^ Green.GetHashCode(); - hashCode = (hashCode * 397) ^ Blue.GetHashCode(); - - return hashCode; - } - } + public override int GetHashCode() => HashCode.Combine(Red, Green, Blue); + + public override string ToString() => $"R:{Red} G:{Green} B:{Blue}"; } public partial struct ColorBalance diff --git a/LightBulb.sln b/LightBulb.sln index 078922e5..bc23902c 100644 --- a/LightBulb.sln +++ b/LightBulb.sln @@ -1,9 +1,9 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.28307.329 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.29318.209 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LightBulb", "LightBulb\LightBulb.csproj", "{0A32502C-95DD-4CDA-B98F-36891AD566C4}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LightBulb", "LightBulb\LightBulb.csproj", "{0A32502C-95DD-4CDA-B98F-36891AD566C4}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LightBulb.WindowsApi", "LightBulb.WindowsApi\LightBulb.WindowsApi.csproj", "{966EE539-7568-40BE-85D7-362D8922DEA8}" EndProject @@ -16,6 +16,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LightBulb.Timers", "LightBulb.Timers\LightBulb.Timers.csproj", "{AD032031-20FE-43C7-8531-92C9AB99F318}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LightBulb.Tests", "LightBulb.Tests\LightBulb.Tests.csproj", "{6DE898D9-0BAF-4C96-B19A-FCFCF8CE046F}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -34,6 +36,10 @@ Global {AD032031-20FE-43C7-8531-92C9AB99F318}.Debug|Any CPU.Build.0 = Debug|Any CPU {AD032031-20FE-43C7-8531-92C9AB99F318}.Release|Any CPU.ActiveCfg = Release|Any CPU {AD032031-20FE-43C7-8531-92C9AB99F318}.Release|Any CPU.Build.0 = Release|Any CPU + {6DE898D9-0BAF-4C96-B19A-FCFCF8CE046F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6DE898D9-0BAF-4C96-B19A-FCFCF8CE046F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6DE898D9-0BAF-4C96-B19A-FCFCF8CE046F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6DE898D9-0BAF-4C96-B19A-FCFCF8CE046F}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/LightBulb/App.config b/LightBulb/App.config deleted file mode 100644 index 2d2a12d8..00000000 --- a/LightBulb/App.config +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/LightBulb/App.xaml b/LightBulb/App.xaml index b2a0077f..f935008f 100644 --- a/LightBulb/App.xaml +++ b/LightBulb/App.xaml @@ -119,15 +119,11 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + - - + - - - - - - - - - + FontSize="19" + TextAlignment="Center"> + + + + + + + + + - - - - - - - - - - + + + + - - + + - - - - - + + - - + + + + + + + + + - - - - - + + + + + + - - - + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - + + + + - - - - - - + + - - + + - - - - - - - - - + + + - + \ No newline at end of file diff --git a/LightBulb/Views/RootView.xaml.cs b/LightBulb/Views/RootView.xaml.cs index 38c54c05..df86d6bc 100644 --- a/LightBulb/Views/RootView.xaml.cs +++ b/LightBulb/Views/RootView.xaml.cs @@ -36,26 +36,17 @@ private void RestoreFromTray() private void RootView_OnLoaded(object sender, RoutedEventArgs e) { - // Hide window to tray - HideToTray(); - - // Position window above the taskbar and at the edge of the screen - Left = SystemParameters.WorkArea.Width - Width - 5; - Top = SystemParameters.WorkArea.Height - Height; - } - - private void RootView_OnDeactivated(object sender, EventArgs e) - { - // Hide window to tray - HideToTray(); + // Hide to tray as soon as window loads if the application was started automatically + if (!App.IsStartedByUser) + HideToTray(); } - private void TaskbarIcon_OnTrayLeftMouseUp(object sender, RoutedEventArgs routedEventArgs) + private void TaskbarIcon_OnTrayLeftMouseUp(object sender, RoutedEventArgs e) { RestoreFromTray(); } - private void ConfigureMenuItem_OnClick(object sender, RoutedEventArgs e) + private void ShowWindowMenuItem_OnClick(object sender, RoutedEventArgs e) { RestoreFromTray(); } @@ -65,5 +56,10 @@ private void Header_OnMouseDown(object sender, MouseButtonEventArgs e) if (e.ChangedButton == MouseButton.Left) DragMove(); } + + private void CloseButton_OnClick(object sender, RoutedEventArgs e) + { + HideToTray(); + } } } \ No newline at end of file diff --git a/ReadMe.md b/ReadMe.md index bc839fde..f4489415 100644 --- a/ReadMe.md +++ b/ReadMe.md @@ -19,7 +19,6 @@ _Currently only compatible with Windows 7 or higher._ ## Download - [Stable releases](https://github.com/Tyrrrz/LightBulb/releases) -- [Chocolatey](https://chocolatey.org/packages/LightBulb): `choco install lightbulb` - [Continuous integration](https://ci.appveyor.com/project/Tyrrrz/LightBulb) ## Features @@ -37,21 +36,16 @@ LightBulb aims to be very customizable. Refer to [this guide](https://github.com You can also manually fine-tune every detail using the [configuration file](https://github.com/Tyrrrz/LightBulb/wiki/Config-file). -## Web APIs used - -- [IP-API](http://ip-api.com) -- [SunriseSunset](https://sunrise-sunset.org) -- [GitHub](https://developer.github.com) - ## Libraries used - - [GalaSoft.MVVMLight](http://www.mvvmlight.net) - - [Newtonsoft.Json](http://www.newtonsoft.com/json) - - [MaterialDesignInXamlToolkit](https://github.com/ButchersBoy/MaterialDesignInXamlToolkit) - - [Hardcodet.NotifyIcon.Wpf](http://www.hardcodet.net/wpf-notifyicon) - - [Tyrrrz.Extensions](https://github.com/Tyrrrz/Extensions) - - [Tyrrrz.WpfExtensions](https://github.com/Tyrrrz/WpfExtensions) - - [Tyrrrz.Settings](https://github.com/Tyrrrz/Settings) +- [Stylet](https://github.com/canton7/Stylet) +- [PropertyChanged.Fody](https://github.com/Fody/PropertyChanged) +- [MaterialDesignInXamlToolkit](https://github.com/ButchersBoy/MaterialDesignInXamlToolkit) +- [Newtonsoft.Json](http://www.newtonsoft.com/json) +- [Hardcodet.NotifyIcon.Wpf](http://www.hardcodet.net/wpf-notifyicon) +- [Onova](https://github.com/Tyrrrz/Onova) +- [Tyrrrz.Extensions](https://github.com/Tyrrrz/Extensions) +- [Tyrrrz.Settings](https://github.com/Tyrrrz/Settings) ## Donate diff --git a/appveyor.yml b/appveyor.yml index 5fe8e8c3..0cae184c 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,6 +1,6 @@ version: '{build}' -image: Visual Studio 2017 +image: Visual Studio 2019 configuration: Release before_build: @@ -13,28 +13,15 @@ after_build: - ps: Deploy\Prepare.ps1 artifacts: -- path: Deploy\Installer\bin\LightBulb-Installer.exe - name: LightBulb-Installer.exe -- path: Deploy\Portable\bin\LightBulb-Portable.zip - name: LightBulb-Portable.zip -- path: Deploy\Choco\bin\LightBulb*.nupkg - name: LightBulb-Choco.nupkg +- path: Deploy\bin\LightBulb.zip + name: LightBulb.zip deploy: - provider: GitHub auth_token: secure: sjQHWRw29AMiVMn3MtidtWnAzAf1mJ+mkJ/7h1B9TIAHhkFrqwMK7LtXV+uNJ9AO - artifact: LightBulb-Installer.exe,LightBulb-Portable.zip + artifact: LightBulb.zip description: '[Changelog](https://github.com/Tyrrrz/LightBulb/blob/master/Changelog.md)' - on: - branch: master - appveyor_repo_tag: true -- provider: NuGet - server: https://push.chocolatey.org/ - api_key: - secure: aQVQ50i8GcwxMXTHf2ck5PijnOeVZY8Z9MEROQTvT49/7/az9w8ru8NCyEsV6H5I - artifact: LightBulb-Choco.nupkg - skip_symbols: true on: branch: master appveyor_repo_tag: true \ No newline at end of file