-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
104 additions
and
3 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
17 changes: 17 additions & 0 deletions
17
src/Fluent Auto Clicker/Contracts/Services/IAlwaysOnTopService.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,17 @@ | ||
using Microsoft.UI.Xaml; | ||
|
||
namespace Fluent_Auto_Clicker.Contracts.Services; | ||
|
||
public interface IAlwaysOnTopService | ||
{ | ||
bool AlwaysOnTop | ||
{ | ||
get; | ||
} | ||
|
||
Task InitializeAsync(); | ||
|
||
Task SetAlwaysOnTopAsync(bool AlwaysOnTop); | ||
|
||
Task SetRequestedAlwaysOnTopAsync(); | ||
} |
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,55 @@ | ||
using Fluent_Auto_Clicker.Contracts.Services; | ||
using Fluent_Auto_Clicker.Helpers; | ||
|
||
using Microsoft.UI.Xaml; | ||
using Param_RootNamespace.Helpers; | ||
|
||
namespace Fluent_Auto_Clicker.Services; | ||
|
||
public class AlwaysOnTopService : IAlwaysOnTopService | ||
{ | ||
private const string SettingsKey = "AlwaysOnTopEnabled"; | ||
|
||
public bool AlwaysOnTop { get; set; } = true; | ||
|
||
private readonly ILocalSettingsService _localSettingsService; | ||
|
||
public AlwaysOnTopService(ILocalSettingsService localSettingsService) | ||
{ | ||
_localSettingsService = localSettingsService; | ||
} | ||
|
||
public async Task InitializeAsync() | ||
{ | ||
AlwaysOnTop = await LoadAlwaysOnTopSettingAsync(); | ||
await Task.CompletedTask; | ||
} | ||
|
||
public async Task SetAlwaysOnTopAsync(bool topmost) | ||
{ | ||
AlwaysOnTop = topmost; | ||
|
||
await SetRequestedAlwaysOnTopAsync(); | ||
await SaveAlwaysOnTopSettingAsync(AlwaysOnTop); | ||
} | ||
|
||
public async Task SetRequestedAlwaysOnTopAsync() | ||
{ | ||
if (App.MainWindow is Window mainWindow) | ||
{ | ||
mainWindow.SetIsAlwaysOnTop(AlwaysOnTop); | ||
} | ||
|
||
await Task.CompletedTask; | ||
} | ||
|
||
private async Task<bool> LoadAlwaysOnTopSettingAsync() | ||
{ | ||
return await _localSettingsService.ReadSettingAsync<bool>(SettingsKey); | ||
} | ||
|
||
private async Task SaveAlwaysOnTopSettingAsync(bool alwaysOnTopEnabled) | ||
{ | ||
await _localSettingsService.SaveSettingAsync(SettingsKey, alwaysOnTopEnabled); | ||
} | ||
} |
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