-
-
Notifications
You must be signed in to change notification settings - Fork 220
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
1 parent
f1b6b01
commit baad4fe
Showing
30 changed files
with
189 additions
and
26 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 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
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
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
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
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
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
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
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
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
31 changes: 31 additions & 0 deletions
31
...egionToolkit.Lib.Automation/Steps/SpectrumKeyboardBacklightImportProfileAutomationStep.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,31 @@ | ||
using System.Threading.Tasks; | ||
using LenovoLegionToolkit.Lib.Controllers; | ||
using Newtonsoft.Json; | ||
|
||
namespace LenovoLegionToolkit.Lib.Automation.Steps; | ||
|
||
public class SpectrumKeyboardBacklightImportProfileAutomationStep : IAutomationStep | ||
{ | ||
private readonly SpectrumKeyboardBacklightController _controller = IoCContainer.Resolve<SpectrumKeyboardBacklightController>(); | ||
|
||
public string? Path { get; } | ||
|
||
[JsonConstructor] | ||
public SpectrumKeyboardBacklightImportProfileAutomationStep(string? path) | ||
{ | ||
Path = path; | ||
} | ||
|
||
public Task<bool> IsSupportedAsync() => _controller.IsSupportedAsync(); | ||
|
||
public async Task RunAsync() | ||
{ | ||
if (Path is null || !await _controller.IsSupportedAsync().ConfigureAwait(false)) | ||
return; | ||
|
||
var profile = await _controller.GetProfileAsync().ConfigureAwait(false); | ||
await _controller.ImportProfileDescription(profile, Path).ConfigureAwait(false); | ||
} | ||
|
||
IAutomationStep IAutomationStep.DeepCopy() => new SpectrumKeyboardBacklightImportProfileAutomationStep(Path); | ||
} |
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
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
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
92 changes: 92 additions & 0 deletions
92
.../Controls/Automation/Steps/SpectrumKeyboardBacklightImportProfileAutomationStepControl.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,92 @@ | ||
using System.Threading.Tasks; | ||
using System.Windows; | ||
using System.Windows.Controls; | ||
using LenovoLegionToolkit.Lib.Automation.Steps; | ||
using LenovoLegionToolkit.WPF.Resources; | ||
using Microsoft.Win32; | ||
using Wpf.Ui.Common; | ||
using Button = Wpf.Ui.Controls.Button; | ||
using TextBox = Wpf.Ui.Controls.TextBox; | ||
|
||
namespace LenovoLegionToolkit.WPF.Controls.Automation.Steps; | ||
|
||
public class SpectrumKeyboardBacklightImportProfileAutomationStepControl : AbstractAutomationStepControl<SpectrumKeyboardBacklightImportProfileAutomationStep> | ||
{ | ||
private readonly TextBox _path = new() | ||
{ | ||
PlaceholderText = Resource.SpectrumKeyboardBacklightImportProfileAutomationStepControl_Path, | ||
Width = 300 | ||
}; | ||
|
||
private readonly Button _openButton = new() | ||
{ | ||
Icon = SymbolRegular.MoreHorizontal24, | ||
MinWidth = 34, | ||
Height = 34, | ||
Margin = new(8, 0, 0, 0) | ||
}; | ||
|
||
private readonly StackPanel _stackPanel = new() | ||
{ | ||
Orientation = Orientation.Horizontal | ||
}; | ||
|
||
public SpectrumKeyboardBacklightImportProfileAutomationStepControl(SpectrumKeyboardBacklightImportProfileAutomationStep step) : base(step) | ||
{ | ||
Icon = SymbolRegular.BrightnessHigh24; | ||
Title = Resource.SpectrumKeyboardBacklightImportProfileAutomationStepControl_Title; | ||
Subtitle = Resource.SpectrumKeyboardBacklightImportProfileAutomationStepControl_Message; | ||
|
||
SizeChanged += RunAutomationStepControl_SizeChanged; | ||
} | ||
|
||
private void RunAutomationStepControl_SizeChanged(object sender, SizeChangedEventArgs e) | ||
{ | ||
if (!e.WidthChanged) | ||
return; | ||
|
||
var newWidth = e.NewSize.Width / 3; | ||
_path.Width = newWidth; | ||
} | ||
|
||
public override IAutomationStep CreateAutomationStep() => new SpectrumKeyboardBacklightImportProfileAutomationStep(_path.Text); | ||
|
||
protected override UIElement GetCustomControl() | ||
{ | ||
_path.TextChanged += (_, _) => | ||
{ | ||
if (_path.Text != AutomationStep.Path) | ||
RaiseChanged(); | ||
}; | ||
|
||
_openButton.Click += (_, _) => | ||
{ | ||
var ofd = new OpenFileDialog | ||
{ | ||
Title = Resource.Import, | ||
InitialDirectory = "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}", | ||
Filter = "Json Files (.json)|*.json", | ||
CheckFileExists = true, | ||
}; | ||
var result = ofd.ShowDialog(); | ||
if (!result.HasValue || !result.Value) | ||
return; | ||
_path.Text = ofd.FileName; | ||
}; | ||
|
||
_stackPanel.Children.Add(_path); | ||
_stackPanel.Children.Add(_openButton); | ||
|
||
return _stackPanel; | ||
} | ||
|
||
protected override void OnFinishedLoading() { } | ||
|
||
protected override Task RefreshAsync() | ||
{ | ||
_path.Text = AutomationStep.Path; | ||
return Task.CompletedTask; | ||
} | ||
} |
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 |
---|---|---|
|
@@ -63,8 +63,6 @@ | |
TextTrimming="CharacterEllipsis" /> | ||
</StackPanel> | ||
|
||
|
||
|
||
</StackPanel> | ||
|
||
<TextBlock | ||
|
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.