mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-01-19 15:03:36 +08:00
[Hosts]Duplicate an existing entry (#31075)
* clone an existing entry * addressed feedbacks
This commit is contained in:
parent
e6a1dd586a
commit
6da7e3ae39
@ -185,6 +185,17 @@
|
||||
ScopeOwner="{x:Bind Entries}" />
|
||||
</MenuFlyoutItem.KeyboardAccelerators>
|
||||
</MenuFlyoutItem>
|
||||
<MenuFlyoutItem x:Uid="Duplicate" Click="Duplicate_Click">
|
||||
<MenuFlyoutItem.Icon>
|
||||
<FontIcon Glyph="" />
|
||||
</MenuFlyoutItem.Icon>
|
||||
<MenuFlyoutItem.KeyboardAccelerators>
|
||||
<KeyboardAccelerator
|
||||
Key="D"
|
||||
Modifiers="Control"
|
||||
ScopeOwner="{x:Bind Entries}" />
|
||||
</MenuFlyoutItem.KeyboardAccelerators>
|
||||
</MenuFlyoutItem>
|
||||
<MenuFlyoutItem
|
||||
x:Uid="Ping"
|
||||
Click="Ping_Click"
|
||||
|
@ -44,12 +44,7 @@ namespace Hosts.Views
|
||||
|
||||
private async Task OpenNewDialogAsync()
|
||||
{
|
||||
var resourceLoader = Helpers.ResourceLoaderInstance.ResourceLoader;
|
||||
EntryDialog.Title = resourceLoader.GetString("AddNewEntryDialog_Title");
|
||||
EntryDialog.PrimaryButtonText = resourceLoader.GetString("AddBtn");
|
||||
EntryDialog.PrimaryButtonCommand = AddCommand;
|
||||
EntryDialog.DataContext = new Entry(ViewModel.NextId, string.Empty, string.Empty, string.Empty, true);
|
||||
await EntryDialog.ShowAsync();
|
||||
await ShowAddDialogAsync();
|
||||
}
|
||||
|
||||
private async Task OpenAdditionalLinesDialogAsync()
|
||||
@ -113,6 +108,14 @@ namespace Hosts.Views
|
||||
}
|
||||
}
|
||||
|
||||
private async void Duplicate_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (Entries.SelectedItem is Entry entry)
|
||||
{
|
||||
await ShowAddDialogAsync(entry);
|
||||
}
|
||||
}
|
||||
|
||||
private async void Ping_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (Entries.SelectedItem is Entry entry)
|
||||
@ -189,6 +192,20 @@ namespace Hosts.Views
|
||||
ViewModel.Selected = entry;
|
||||
}
|
||||
|
||||
private async Task ShowAddDialogAsync(Entry template = null)
|
||||
{
|
||||
var resourceLoader = ResourceLoaderInstance.ResourceLoader;
|
||||
EntryDialog.Title = resourceLoader.GetString("AddNewEntryDialog_Title");
|
||||
EntryDialog.PrimaryButtonText = resourceLoader.GetString("AddBtn");
|
||||
EntryDialog.PrimaryButtonCommand = AddCommand;
|
||||
|
||||
EntryDialog.DataContext = template == null
|
||||
? new Entry(ViewModel.NextId, string.Empty, string.Empty, string.Empty, true)
|
||||
: new Entry(ViewModel.NextId, template.Address, template.Hosts, template.Comment, template.Active);
|
||||
|
||||
await EntryDialog.ShowAsync();
|
||||
}
|
||||
|
||||
private void ContentDialog_Loaded_ApplyMargin(object sender, RoutedEventArgs e)
|
||||
{
|
||||
try
|
||||
|
@ -193,6 +193,10 @@
|
||||
<data name="DeleteDialogAreYouSure.Text" xml:space="preserve">
|
||||
<value>Are you sure you want to delete this entry?</value>
|
||||
</data>
|
||||
<data name="Duplicate.Text" xml:space="preserve">
|
||||
<value>Duplicate</value>
|
||||
<comment>Refers to the action of duplicate an existing entry</comment>
|
||||
</data>
|
||||
<data name="DuplicateEntryIcon.[using:Microsoft.UI.Xaml.Controls]ToolTipService.ToolTip" xml:space="preserve">
|
||||
<value>Duplicate entry</value>
|
||||
</data>
|
||||
|
Loading…
Reference in New Issue
Block a user