From 36dbd1a8895087162c492e896e439e3713a89fa9 Mon Sep 17 00:00:00 2001 From: VPKSoft Date: Mon, 27 Feb 2023 12:38:40 +0200 Subject: [PATCH 1/5] Add keyboard seeking with arrow keys. --- amp.EtoForms/FormMain.Events.cs | 7 ++++++- amp.Playback/PlaybackManager.cs | 19 +++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/amp.EtoForms/FormMain.Events.cs b/amp.EtoForms/FormMain.Events.cs index c62f5615..92870bf8 100644 --- a/amp.EtoForms/FormMain.Events.cs +++ b/amp.EtoForms/FormMain.Events.cs @@ -64,7 +64,7 @@ private async void FormMain_KeyDown(object? sender, KeyEventArgs e) { if (e.Key is Keys.Up or Keys.Down or Keys.PageDown or Keys.PageUp or Keys.Equal or Keys.F1 or Keys.F2 or Keys.F3 or Keys.F4 or Keys.F5 or Keys.F6 or Keys.F7 or Keys.F8 or Keys.F9 or - Keys.Escape or Keys.Enter or Keys.Add or Keys.Multiply) + Keys.Escape or Keys.Enter or Keys.Add or Keys.Multiply or Keys.Left or Keys.Right) { if (gvAudioTracks.SelectedItem == null && gvAudioTracks.DataStore.Any()) { @@ -184,6 +184,11 @@ await playbackOrder.MoveToQueueTopOrBottom(tracks, shift, e.Key == Keys.PageUp, return; } + if (e.Key is Keys.Right or Keys.Left) + { + playbackManager.SeekSeconds(e.Key == Keys.Right ? 5 : -5); + } + if (e.Modifiers == Keys.None) { if (e.IsChar && !(e.Key is Keys.Up or Keys.Down or Keys.PageDown or Keys.PageUp)) diff --git a/amp.Playback/PlaybackManager.cs b/amp.Playback/PlaybackManager.cs index 52784bd9..6ef3f7b5 100644 --- a/amp.Playback/PlaybackManager.cs +++ b/amp.Playback/PlaybackManager.cs @@ -622,6 +622,25 @@ public double PlaybackPositionPercentage set => PlaybackPosition = value == 0 ? 0 : PlaybackLength * value / 100; } + /// + /// Seeks the with the specified amount of seconds. + /// + /// The value in seconds to seek. + public void SeekSeconds(int value) + { + var newPosition = PlaybackPosition + value; + if (newPosition < 0) + { + PlaybackPosition = 0; + return; + } + + if (newPosition >= 0 && newPosition < PlaybackLength) + { + PlaybackPosition = newPosition; + } + } + /// /// Gets or sets the playback position in seconds. /// From 718f0c63a4590aac84d645e2039a0d960dd555b2 Mon Sep 17 00:00:00 2001 From: VPKSoft Date: Mon, 27 Feb 2023 12:47:58 +0200 Subject: [PATCH 2/5] Some refactorings. --- EtoForms.Controls.Custom/Drawing/CellPainter.cs | 4 ++-- EtoForms.Controls.Custom/PositionSlider.cs | 1 - EtoForms.Controls.Custom/RatingSlider.cs | 1 - EtoForms.Controls.Custom/SvgColorization/SvgColorize.cs | 8 ++++---- EtoForms.Controls.Custom/UserIdle/UserIdleEventArgs.cs | 2 +- amp.EtoForms/Classes/CommandLineArguments.cs | 6 +++--- amp.EtoForms/FormMain.Methods.cs | 1 - amp.Shared/Classes/UtilityOS.cs | 4 ++-- 8 files changed, 12 insertions(+), 15 deletions(-) diff --git a/EtoForms.Controls.Custom/Drawing/CellPainter.cs b/EtoForms.Controls.Custom/Drawing/CellPainter.cs index 151b6cce..901b0573 100644 --- a/EtoForms.Controls.Custom/Drawing/CellPainter.cs +++ b/EtoForms.Controls.Custom/Drawing/CellPainter.cs @@ -52,7 +52,7 @@ public abstract class CellPainter : IDisposable /// The property name must exists within the type T. protected CellPainter(GridView gridView, GridColumn column, Func getValueFunc) { - this.GridView = gridView; + GridView = gridView; if (column.DataCell is DrawableCell drawableCell) { cell = drawableCell; @@ -63,7 +63,7 @@ protected CellPainter(GridView gridView, GridColumn column, Func get column.DataCell = cell; } - this.GridView = gridView; + GridView = gridView; this.getValueFunc = getValueFunc; cell.Paint += DrawableCell_Paint; } diff --git a/EtoForms.Controls.Custom/PositionSlider.cs b/EtoForms.Controls.Custom/PositionSlider.cs index 2a2ce4dc..79af6323 100644 --- a/EtoForms.Controls.Custom/PositionSlider.cs +++ b/EtoForms.Controls.Custom/PositionSlider.cs @@ -29,7 +29,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE using EtoForms.Controls.Custom.EventArguments; using EtoForms.Controls.Custom.Interfaces.BaseClasses; using EtoForms.Controls.Custom.Properties; -using FluentIcons.Resources.Filled; namespace EtoForms.Controls.Custom; diff --git a/EtoForms.Controls.Custom/RatingSlider.cs b/EtoForms.Controls.Custom/RatingSlider.cs index 60ba5860..9a01bcb1 100644 --- a/EtoForms.Controls.Custom/RatingSlider.cs +++ b/EtoForms.Controls.Custom/RatingSlider.cs @@ -28,7 +28,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE using System.Linq; using Eto.Drawing; using EtoForms.Controls.Custom.Interfaces.BaseClasses; -using EtoForms.Controls.Custom.Properties; using EtoForms.Controls.Custom.Utilities; using FluentIcons.Resources.Filled; diff --git a/EtoForms.Controls.Custom/SvgColorization/SvgColorize.cs b/EtoForms.Controls.Custom/SvgColorization/SvgColorize.cs index be1dee1c..262c73dc 100644 --- a/EtoForms.Controls.Custom/SvgColorization/SvgColorize.cs +++ b/EtoForms.Controls.Custom/SvgColorization/SvgColorize.cs @@ -116,12 +116,12 @@ private static string NodeName(SvgElement element) /// /// A regex to match the fill value of the style attribute. /// - private static readonly Regex FillRegex = new("fill:.*?;", RegexOptions.Compiled); + private static readonly Regex fillRegex = new("fill:.*?;", RegexOptions.Compiled); /// /// A regex to match the stroke value of the style attribute. /// - private static readonly Regex StrokeRegex = new("stroke:.*?;", RegexOptions.Compiled); + private static readonly Regex strokeRegex = new("stroke:.*?;", RegexOptions.Compiled); /// /// Colorizes the elements of the SVG document specified by the element type. @@ -133,7 +133,7 @@ public SvgColorize ColorizeElementsStroke(SvgElement element, SvgColor? stroke) { if (SvgDocument.Root != null) { - ProcessNodes(SvgDocument.Root, element, StrokeRegex, stroke, false); + ProcessNodes(SvgDocument.Root, element, strokeRegex, stroke, false); } return this; @@ -207,7 +207,7 @@ public SvgColorize ColorizeElementsFill(SvgElement element, SvgColor? fill) { if (SvgDocument.Root != null) { - ProcessNodes(SvgDocument.Root, element, FillRegex, fill, true); + ProcessNodes(SvgDocument.Root, element, fillRegex, fill, true); } return this; diff --git a/EtoForms.Controls.Custom/UserIdle/UserIdleEventArgs.cs b/EtoForms.Controls.Custom/UserIdle/UserIdleEventArgs.cs index 20f44db8..a56b3bb8 100644 --- a/EtoForms.Controls.Custom/UserIdle/UserIdleEventArgs.cs +++ b/EtoForms.Controls.Custom/UserIdle/UserIdleEventArgs.cs @@ -48,5 +48,5 @@ public UserIdleEventArgs(bool isUserIdle) /// Gets a value indicating whether the user is currently idle. /// /// true if the user is currently idle; otherwise, false. - private bool IsUserIdle { get; } + public bool IsUserIdle { get; } } \ No newline at end of file diff --git a/amp.EtoForms/Classes/CommandLineArguments.cs b/amp.EtoForms/Classes/CommandLineArguments.cs index 08fdc604..0bdd1b65 100644 --- a/amp.EtoForms/Classes/CommandLineArguments.cs +++ b/amp.EtoForms/Classes/CommandLineArguments.cs @@ -38,20 +38,20 @@ public class CommandLineArguments /// Gets or sets the PID (Process Identifier) to wait for before starting the application. /// /// The PID to wait for before starting the application. - [Option('p', "pid", Required = false, HelpText = nameof(amp.Shared.Localization.Messages.AProcessIdentifierPIDToWaitForExitBeforeStartingTheApplication), ResourceType = typeof(amp.Shared.Localization.Messages))] + [Option('p', "pid", Required = false, HelpText = nameof(Shared.Localization.Messages.AProcessIdentifierPIDToWaitForExitBeforeStartingTheApplication), ResourceType = typeof(Shared.Localization.Messages))] public int? PidWait { get; set; } /// /// Gets or sets the name of the backup file to backup the application data before complete startup. /// /// The name of the backup file. - [Option('b', "backup", Required = false, HelpText = nameof(amp.Shared.Localization.Messages.AFileNameToBackupTheApplicationDataBeforeCompleteStartup), ResourceType = typeof(amp.Shared.Localization.Messages))] + [Option('b', "backup", Required = false, HelpText = nameof(Shared.Localization.Messages.AFileNameToBackupTheApplicationDataBeforeCompleteStartup), ResourceType = typeof(Shared.Localization.Messages))] public string? BackupFileName { get; set; } /// /// Gets or sets the name of the archive file to restore the backed up application data settings from. /// /// The file name to restore backup the backup from. - [Option('r', "restore", Required = false, HelpText = nameof(amp.Shared.Localization.Messages.RestoresABackupFromAZippedFileIntoTheProgramApplicationDataFolderOverridingTheExisting), ResourceType = typeof(amp.Shared.Localization.Messages))] + [Option('r', "restore", Required = false, HelpText = nameof(Shared.Localization.Messages.RestoresABackupFromAZippedFileIntoTheProgramApplicationDataFolderOverridingTheExisting), ResourceType = typeof(Shared.Localization.Messages))] public string? RestoreBackupFile { get; set; } } \ No newline at end of file diff --git a/amp.EtoForms/FormMain.Methods.cs b/amp.EtoForms/FormMain.Methods.cs index 54f0cc30..e8202073 100644 --- a/amp.EtoForms/FormMain.Methods.cs +++ b/amp.EtoForms/FormMain.Methods.cs @@ -282,7 +282,6 @@ private void FilterTracks(bool fromUserIdleEvent) userIdleSelectedRow = -1; } - var text = tbSearch.Text; var queueOnly = btnShowQueue.Checked; var userIdle = idleChecker.IsUserIdle; if (queueOnly) diff --git a/amp.Shared/Classes/UtilityOS.cs b/amp.Shared/Classes/UtilityOS.cs index 7fe4d00f..3556a524 100644 --- a/amp.Shared/Classes/UtilityOS.cs +++ b/amp.Shared/Classes/UtilityOS.cs @@ -103,7 +103,7 @@ public static T GetValueForOSNotNull(T windowsValue, T linuxValue, T macValue /// /// The macOS operating system name in lower case ("macos"). /// - public const string MacOSNameLowerCase = "macos"; + public const string MacOsNameLowerCase = "macos"; /// /// The Windows operating system name in lower case ("windows"). @@ -126,7 +126,7 @@ public static string OsNameLowerCase { if (IsMacOS) { - return MacOSNameLowerCase; + return MacOsNameLowerCase; } if (IsLinuxOS) From 57522483e5442473b272ba261ec6fd0d166b3645 Mon Sep 17 00:00:00 2001 From: VPKSoft Date: Mon, 27 Feb 2023 12:48:46 +0200 Subject: [PATCH 3/5] Update version. --- amp.EtoForms/amp.EtoForms.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/amp.EtoForms/amp.EtoForms.csproj b/amp.EtoForms/amp.EtoForms.csproj index f51c08c9..77ebce9c 100644 --- a/amp.EtoForms/amp.EtoForms.csproj +++ b/amp.EtoForms/amp.EtoForms.csproj @@ -18,7 +18,7 @@ true true true - 1.0.4.0 + 1.0.5.0 From f09a2552cdffed27be97e520625137453ff22f25 Mon Sep 17 00:00:00 2001 From: VPKSoft Date: Mon, 27 Feb 2023 13:27:57 +0200 Subject: [PATCH 4/5] Fix Linux file adding and add handled flag. --- amp.EtoForms/FormMain.Events.cs | 2 ++ amp.EtoForms/FormMain.Methods.cs | 9 +++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/amp.EtoForms/FormMain.Events.cs b/amp.EtoForms/FormMain.Events.cs index 92870bf8..5902671a 100644 --- a/amp.EtoForms/FormMain.Events.cs +++ b/amp.EtoForms/FormMain.Events.cs @@ -187,6 +187,8 @@ await playbackOrder.MoveToQueueTopOrBottom(tracks, shift, e.Key == Keys.PageUp, if (e.Key is Keys.Right or Keys.Left) { playbackManager.SeekSeconds(e.Key == Keys.Right ? 5 : -5); + e.Handled = true; + return; } if (e.Modifiers == Keys.None) diff --git a/amp.EtoForms/FormMain.Methods.cs b/amp.EtoForms/FormMain.Methods.cs index e8202073..057bd13e 100644 --- a/amp.EtoForms/FormMain.Methods.cs +++ b/amp.EtoForms/FormMain.Methods.cs @@ -59,7 +59,10 @@ private void AddAudioFiles(bool toAlbum) { using var dialog = new OpenFileDialog { MultiSelect = true, }; dialog.Filters.Add(new FileFilter(UI.MusicFiles, MusicConstants.SupportedExtensionArray)); - if (dialog.ShowDialog(this) == DialogResult.Ok) + + var result = dialog.ShowDialog(this); + + if (result is DialogResult.Ok or DialogResult.Ignore) { FormAddFilesProgress.Show(this, context, toAlbum ? CurrentAlbumId : 0, AddFilesAction, dialog.Filenames.ToArray()); } @@ -74,7 +77,9 @@ private void AddFilesAction(bool result) private void AddDirectory(bool toAlbum) { using var dialog = new SelectFolderDialog { Title = UI.SelectMusicFolder, }; - if (dialog.ShowDialog(this) == DialogResult.Ok) + var result = dialog.ShowDialog(this); + + if (result is DialogResult.Ok or DialogResult.Ignore) { FormAddFilesProgress.Show(this, context, dialog.Directory, toAlbum ? CurrentAlbumId : 0, AddFilesAction); } From 1ad2c3b8beb4def04702b0bb7e0e22d5ab3300be Mon Sep 17 00:00:00 2001 From: VPKSoft Date: Mon, 27 Feb 2023 13:57:08 +0200 Subject: [PATCH 5/5] Update docs. --- Help/amp-en/docs/keyboard_shortcuts.md | 5 +++++ Help/amp-fi/docs/keyboard_shortcuts.md | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/Help/amp-en/docs/keyboard_shortcuts.md b/Help/amp-en/docs/keyboard_shortcuts.md index 494d0e32..fa2c0709 100644 --- a/Help/amp-en/docs/keyboard_shortcuts.md +++ b/Help/amp-en/docs/keyboard_shortcuts.md @@ -21,6 +21,11 @@ ## Display all the album tracks F9 - This function clears all search filters. +## Track seeking + - Seek the track 5 seconds backwards. + + - Seek the track 5 seconds forwards. + ## Stash current queue Ctrl+T or +T - Saves to current queue into the stash. diff --git a/Help/amp-fi/docs/keyboard_shortcuts.md b/Help/amp-fi/docs/keyboard_shortcuts.md index 10874bf2..c4c0c8ab 100644 --- a/Help/amp-fi/docs/keyboard_shortcuts.md +++ b/Help/amp-fi/docs/keyboard_shortcuts.md @@ -21,6 +21,11 @@ ## Näytä kaikki albumin kappaleet F9 - Tämä toiminto tyhjentää hakusuodattimet. +## Kappaleen kelaus + - Kelaa kappaletta 5 sekuntia taaksepäin. + + - Kelaa kappaletta 5 sekuntia eteenpäin. + ## Varastoi nykyinen jono Ctrl+T tai +T - Tallentaa nykyisen jonon väliaikaiseen varastoon.