mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-12-16 11:48:06 +01:00
[Hosts]Duplicate an existing entry (#31075)
* clone an existing entry * addressed feedbacks
This commit is contained in:
committed by
GitHub
parent
e6a1dd586a
commit
6da7e3ae39
@@ -185,6 +185,17 @@
|
|||||||
ScopeOwner="{x:Bind Entries}" />
|
ScopeOwner="{x:Bind Entries}" />
|
||||||
</MenuFlyoutItem.KeyboardAccelerators>
|
</MenuFlyoutItem.KeyboardAccelerators>
|
||||||
</MenuFlyoutItem>
|
</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
|
<MenuFlyoutItem
|
||||||
x:Uid="Ping"
|
x:Uid="Ping"
|
||||||
Click="Ping_Click"
|
Click="Ping_Click"
|
||||||
|
|||||||
@@ -44,12 +44,7 @@ namespace Hosts.Views
|
|||||||
|
|
||||||
private async Task OpenNewDialogAsync()
|
private async Task OpenNewDialogAsync()
|
||||||
{
|
{
|
||||||
var resourceLoader = Helpers.ResourceLoaderInstance.ResourceLoader;
|
await ShowAddDialogAsync();
|
||||||
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();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task OpenAdditionalLinesDialogAsync()
|
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)
|
private async void Ping_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
if (Entries.SelectedItem is Entry entry)
|
if (Entries.SelectedItem is Entry entry)
|
||||||
@@ -189,6 +192,20 @@ namespace Hosts.Views
|
|||||||
ViewModel.Selected = entry;
|
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)
|
private void ContentDialog_Loaded_ApplyMargin(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|||||||
@@ -193,6 +193,10 @@
|
|||||||
<data name="DeleteDialogAreYouSure.Text" xml:space="preserve">
|
<data name="DeleteDialogAreYouSure.Text" xml:space="preserve">
|
||||||
<value>Are you sure you want to delete this entry?</value>
|
<value>Are you sure you want to delete this entry?</value>
|
||||||
</data>
|
</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">
|
<data name="DuplicateEntryIcon.[using:Microsoft.UI.Xaml.Controls]ToolTipService.ToolTip" xml:space="preserve">
|
||||||
<value>Duplicate entry</value>
|
<value>Duplicate entry</value>
|
||||||
</data>
|
</data>
|
||||||
|
|||||||
Reference in New Issue
Block a user