-
-
Notifications
You must be signed in to change notification settings - Fork 262
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
90e5775
commit 06a3708
Showing
11 changed files
with
153 additions
and
2 deletions.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
LenovoLegionToolkit.Lib.Automation/Steps/NotificationAutomationStep.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,26 @@ | ||
using System.Threading.Tasks; | ||
using Newtonsoft.Json; | ||
|
||
namespace LenovoLegionToolkit.Lib.Automation.Steps; | ||
|
||
public class NotificationAutomationStep : IAutomationStep | ||
{ | ||
public string? Text { get; } | ||
|
||
[JsonConstructor] | ||
public NotificationAutomationStep(string? text) | ||
{ | ||
Text = text; | ||
} | ||
|
||
public Task<bool> IsSupportedAsync() => Task.FromResult(true); | ||
|
||
public Task RunAsync(AutomationEnvironment environment) | ||
{ | ||
if (!string.IsNullOrWhiteSpace(Text)) | ||
MessagingCenter.Publish(new Notification(NotificationType.AutomationNotification, Text)); | ||
return Task.CompletedTask; | ||
} | ||
|
||
IAutomationStep IAutomationStep.DeepCopy() => new NotificationAutomationStep(Text); | ||
} |
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
60 changes: 60 additions & 0 deletions
60
LenovoLegionToolkit.WPF/Controls/Automation/Steps/NotificationAutomationStepControl.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,60 @@ | ||
using System.Threading.Tasks; | ||
using System.Windows; | ||
using System.Windows.Controls; | ||
using LenovoLegionToolkit.Lib.Automation.Steps; | ||
using LenovoLegionToolkit.WPF.Resources; | ||
using Wpf.Ui.Common; | ||
using TextBox = Wpf.Ui.Controls.TextBox; | ||
|
||
namespace LenovoLegionToolkit.WPF.Controls.Automation.Steps; | ||
|
||
public class NotificationAutomationStepControl : AbstractAutomationStepControl<NotificationAutomationStep> | ||
{ | ||
private readonly TextBox _scriptPath = new() | ||
{ | ||
PlaceholderText = Resource.NotificationAutomationStepControl_NotificationText, | ||
Width = 300 | ||
}; | ||
|
||
private readonly StackPanel _stackPanel = new(); | ||
|
||
public NotificationAutomationStepControl(NotificationAutomationStep step) : base(step) | ||
{ | ||
Icon = SymbolRegular.Rocket24; | ||
Title = Resource.NotificationAutomationStepControl_Title; | ||
|
||
SizeChanged += RunAutomationStepControl_SizeChanged; | ||
} | ||
|
||
private void RunAutomationStepControl_SizeChanged(object sender, SizeChangedEventArgs e) | ||
{ | ||
if (!e.WidthChanged) | ||
return; | ||
|
||
var newWidth = e.NewSize.Width / 3; | ||
_scriptPath.Width = newWidth; | ||
} | ||
|
||
public override IAutomationStep CreateAutomationStep() => new NotificationAutomationStep(_scriptPath.Text); | ||
|
||
protected override UIElement GetCustomControl() | ||
{ | ||
_scriptPath.TextChanged += (_, _) => | ||
{ | ||
if (_scriptPath.Text != AutomationStep.Text) | ||
RaiseChanged(); | ||
}; | ||
|
||
_stackPanel.Children.Add(_scriptPath); | ||
|
||
return _stackPanel; | ||
} | ||
|
||
protected override void OnFinishedLoading() { } | ||
|
||
protected override Task RefreshAsync() | ||
{ | ||
_scriptPath.Text = AutomationStep.Text; | ||
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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