diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/ContextMenu.cs b/Plugins/Flow.Launcher.Plugin.Explorer/ContextMenu.cs index c331c4985..fe4164e7c 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/ContextMenu.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/ContextMenu.cs @@ -10,6 +10,7 @@ using Flow.Launcher.Plugin.Explorer.Search; using Flow.Launcher.Plugin.Explorer.Search.QuickAccessLinks; using Flow.Launcher.Plugin.Explorer.Helper; using Flow.Launcher.Plugin.Explorer.ViewModels; +using Flow.Launcher.Plugin.Explorer.Views; namespace Flow.Launcher.Plugin.Explorer { @@ -188,6 +189,24 @@ namespace Flow.Launcher.Plugin.Explorer IcoPath = icoPath, Glyph = new GlyphInfo(FontFamily: "/Resources/#Segoe Fluent Icons", Glyph: "\uf12b") }); + contextMenus.Add(new Result + { + Title = "Rename", + SubTitle = "Opens a dialogue to this", + Action = _ => + { + + RenameFile window = new(Context.API); + Context.API.FocusQueryTextBox(); + if (!(window.ShowDialog() ?? false)) + { + Context.API.FocusQueryTextBox(); + return false; + } + Context.API.FocusQueryTextBox(); + return false; + } + }); if (record.Type is ResultType.File or ResultType.Folder) diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml b/Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml index 7000e74ae..62f17bf5b 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml @@ -190,4 +190,9 @@ {0} months ago 1 year ago {0} years ago + + + New File name: + Rename + Rename diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Views/RenameFile.xaml b/Plugins/Flow.Launcher.Plugin.Explorer/Views/RenameFile.xaml index 645febe7e..c7c81d486 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Views/RenameFile.xaml +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Views/RenameFile.xaml @@ -1,9 +1,120 @@ - + xmlns:d="http://schemas.microsoft.com/expression/blend/2008" + xmlns:local="clr-namespace:Flow.Launcher.Plugin.Explorer.Views" + xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" + Title="{DynamicResource plugin_explorer_manageactionkeywords_header}" + Width="Auto" + Height="160" + Background="{DynamicResource PopuBGColor}" + DataContext="{Binding RelativeSource={RelativeSource Self}}" + Foreground="{DynamicResource PopupTextColor}" + ResizeMode="NoResize" + SizeToContent="Width" + WindowStartupLocation="CenterScreen" + mc:Ignorable="d"> + + + - + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Views/RenameFile.xaml.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Views/RenameFile.xaml.cs index 8d3b4b3d0..198928096 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Views/RenameFile.xaml.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Views/RenameFile.xaml.cs @@ -1,8 +1,119 @@ -using System; +using System.Linq; +using System.Windows; +using System.Windows.Input; +using CommunityToolkit.Mvvm.ComponentModel; -namespace Flow.Launcher.Plugin.Explorer.Views; -public partial class RenameFile +namespace Flow.Launcher.Plugin.Explorer.Views { - + [INotifyPropertyChanged] + public partial class RenameFile : Window + { + + + public string NewFileName + { + get => newFileName; + set + { + _ = SetProperty(ref newFileName, value); + } + } + + + private string newFileName = "gayTest"; + private string renamingText = "fes"; + public string RenamingText + { + get => renamingText; + set + { + _ = SetProperty(ref renamingText, value); + } + } + private readonly IPublicAPI _api; + + + public RenameFile(IPublicAPI api) + { + _api = api; + + + InitializeComponent(); + + RenameTb.Focus(); + Deactivated += (s, e) => + { + DialogResult = false; + Close(); + + }; + ShowInTaskbar = false; + RenameTb.Select(RenameTb.Text.Length, 0); + } + + private void OnDoneButtonClick(object sender, RoutedEventArgs e) + { + + + + + // if (ActionKeyword == Query.GlobalPluginWildcardSign) + // switch (CurrentActionKeyword.KeywordProperty, KeywordEnabled) + // { + // case (Settings.ActionKeyword.FileContentSearchActionKeyword, true): + // _api.ShowMsgBox(_api.GetTranslation("plugin_explorer_globalActionKeywordInvalid")); + // return; + // case (Settings.ActionKeyword.QuickAccessActionKeyword, true): + // _api.ShowMsgBox(_api.GetTranslation("plugin_explorer_quickaccess_globalActionKeywordInvalid")); + // return; + // } + + // if (!KeywordEnabled || !_api.ActionKeywordAssigned(ActionKeyword)) + // { + // DialogResult = true; + // Close(); + // return; + // } + + // The keyword is not valid, so show message + _api.ShowMsgBox("new action keyword"); + } + + private void BtnCancel(object sender, RoutedEventArgs e) + { + Close(); + } + + private void TxtCurrentActionKeyword_OnKeyDown(object sender, KeyEventArgs e) + { + if (e.Key == Key.Enter) + { + btnDone.Focus(); + OnDoneButtonClick(sender, e); + e.Handled = true; + } + if (e.Key == Key.Space) + { + e.Handled = true; + } + } + + + private void TextBox_Pasting(object sender, DataObjectPastingEventArgs e) + { + if (e.DataObject.GetDataPresent(DataFormats.Text)) + { + string text = e.DataObject.GetData(DataFormats.Text) as string; + if (!string.IsNullOrEmpty(text) && text.Any(char.IsWhiteSpace)) + { + e.CancelCommand(); + } + } + else + { + e.CancelCommand(); + } + } + } }