-
Notifications
You must be signed in to change notification settings - Fork 0
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 LegendaryB/develop
Release v1.3
- Loading branch information
Showing
19 changed files
with
180 additions
and
56 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
This file was deleted.
Oops, something went wrong.
4 changes: 2 additions & 2 deletions
4
src/Kirei.Application/IDesktop.cs → ...ication/System/Desktop/IDesktopService.cs
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,7 @@ | ||
namespace Kirei.Application.System | ||
{ | ||
public interface IHibernationService | ||
{ | ||
void PreventSleep(); | ||
} | ||
} |
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,10 @@ | ||
using System; | ||
|
||
namespace Kirei.Application.System.Input | ||
{ | ||
public interface IInputActionMapper | ||
{ | ||
void HandleInput(); | ||
void RegisterAction(Action action, Func<bool> condition); | ||
} | ||
} |
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,9 @@ | ||
using System; | ||
|
||
namespace Kirei.Application.System.Input | ||
{ | ||
public interface IInputListener | ||
{ | ||
void Listen(IInputActionMapper inputActionMapper); | ||
} | ||
} |
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,11 @@ | ||
using System; | ||
|
||
namespace Kirei.Domain.Native.Enums | ||
{ | ||
[Flags] | ||
public enum ExecutionStates : uint | ||
{ | ||
ES_DISPLAY_REQUIRED = 0x00000002, | ||
ES_CONTINUOUS = 0x80000000 | ||
} | ||
} |
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,12 @@ | ||
using Kirei.Domain.Native.Enums; | ||
|
||
using System.Runtime.InteropServices; | ||
|
||
namespace Kirei.Infrastructure.Native | ||
{ | ||
internal static class Kernel32 | ||
{ | ||
[DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)] | ||
internal static extern ExecutionStates SetThreadExecutionState(ExecutionStates esFlags); | ||
} | ||
} |
10 changes: 5 additions & 5 deletions
10
...irei.Infrastructure/DesktopAPI/Desktop.cs → ...tructure/System/Desktop/DesktopService.cs
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
5 changes: 3 additions & 2 deletions
5
...irei.Infrastructure/DesktopAPI/TaskBar.cs → ....Infrastructure/System/Desktop/TaskBar.cs
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 Kirei.Application.System; | ||
using Kirei.Domain.Native.Enums; | ||
using Kirei.Infrastructure.Native; | ||
|
||
using System.Threading.Tasks; | ||
|
||
namespace Kirei.Infrastructure.System | ||
{ | ||
public class HibernationService : IHibernationService | ||
{ | ||
public void PreventSleep() | ||
{ | ||
Task.Run(async () => | ||
{ | ||
while (true) | ||
{ | ||
Kernel32.SetThreadExecutionState( | ||
ExecutionStates.ES_CONTINUOUS | | ||
ExecutionStates.ES_DISPLAY_REQUIRED); | ||
await Task.Delay(5000); | ||
} | ||
}); | ||
} | ||
|
||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
src/Kirei.Infrastructure/System/Input/InputActionMapper.cs
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,33 @@ | ||
using Kirei.Application.System.Input; | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
|
||
namespace Kirei.Infrastructure.System.Input | ||
{ | ||
public class InputActionMapper : IInputActionMapper | ||
{ | ||
private readonly List<Action> _actionsOnInput; | ||
|
||
public InputActionMapper() | ||
{ | ||
_actionsOnInput = new List<Action>(); | ||
} | ||
|
||
public void HandleInput() | ||
{ | ||
foreach (var action in _actionsOnInput) | ||
action?.Invoke(); | ||
} | ||
|
||
public void RegisterAction( | ||
Action action, | ||
Func<bool> condition) | ||
{ | ||
if (action == null || condition?.Invoke() != true) | ||
return; | ||
|
||
_actionsOnInput.Add(action); | ||
} | ||
} | ||
} |
22 changes: 11 additions & 11 deletions
22
src/Kirei.Infrastructure/InputHandler.cs → ...rastructure/System/Input/InputListener.cs
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 |
---|---|---|
@@ -1,42 +1,57 @@ | ||
using Kirei.Application; | ||
using Kirei.Application.System; | ||
using Kirei.Application.System.Desktop; | ||
using Kirei.Application.System.Input; | ||
using Kirei.Infrastructure.Configuration; | ||
|
||
namespace Kirei | ||
{ | ||
internal class App | ||
{ | ||
private readonly IInstallWizard _installWizard; | ||
private readonly IDesktop _desktopAPI; | ||
private readonly IInputHandler _inputHandler; | ||
private readonly IInstallWizard _installWizard; | ||
private readonly IInputListener _inputListener; | ||
private readonly IInputActionMapper _inputActionMapper; | ||
private readonly IDesktopService _desktopService; | ||
private readonly IHibernationService _hibernationService; | ||
|
||
public App(IInstallWizard installWizard, | ||
IDesktop desktopAPI, | ||
IInputHandler inputHandler) | ||
IInputListener inputListener, | ||
IInputActionMapper inputActionMapper, | ||
IDesktopService desktopService, | ||
IHibernationService hibernationService) | ||
{ | ||
_installWizard = installWizard; | ||
_desktopAPI = desktopAPI; | ||
_inputHandler = inputHandler; | ||
_installWizard = installWizard; | ||
_inputListener = inputListener; | ||
_inputActionMapper = inputActionMapper; | ||
_desktopService = desktopService; | ||
_hibernationService = hibernationService; | ||
} | ||
|
||
internal void Run() | ||
{ | ||
if (ConfigurationProvider.Configuration.Application.ShouldRunOnStartup) | ||
_installWizard.RunOnStartup(); | ||
|
||
_inputHandler.Handler = OnUserActiveOrInactive; | ||
_inputHandler.Handle(); | ||
} | ||
var cfg = ConfigurationProvider | ||
.Configuration | ||
.Actions; | ||
|
||
private void OnUserActiveOrInactive() | ||
{ | ||
if (ConfigurationProvider.Configuration.Actions.HideDesktopIcons) | ||
_desktopAPI.ToggleIcons(); | ||
_inputActionMapper.RegisterAction( | ||
_desktopService.ToggleIcons, | ||
() => cfg.HideDesktopIcons); | ||
|
||
_inputActionMapper.RegisterAction( | ||
_desktopService.ToggleTaskBar, | ||
() => cfg.HideTaskBar); | ||
|
||
_inputActionMapper.RegisterAction( | ||
_desktopService.ToggleWindows, | ||
() => cfg.HideApplicationWindows); | ||
|
||
if (ConfigurationProvider.Configuration.Actions.HideTaskBar) | ||
_desktopAPI.ToggleTaskBar(); | ||
if (cfg.PreventSleep) | ||
_hibernationService.PreventSleep(); | ||
|
||
if (ConfigurationProvider.Configuration.Actions.HideApplicationWindows) | ||
_desktopAPI.ToggleWindows(); | ||
_inputListener.Listen(_inputActionMapper); | ||
} | ||
} | ||
} |
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