Allow for flag names to be editable

This commit is contained in:
pizzaboxer 2023-08-24 22:22:41 +01:00
parent 5741d82f3d
commit b6dee9c772
No known key found for this signature in database
GPG Key ID: 59D4A1DBAD0F2BA8
2 changed files with 22 additions and 4 deletions

View File

@ -17,7 +17,7 @@
<RowDefinition Height="*" /> <RowDefinition Height="*" />
</Grid.RowDefinitions> </Grid.RowDefinitions>
<TextBlock Grid.Row="0" Margin="0,0,0,16" Text="Manage your own FastFlags. Double click the value column to edit." FontSize="14" Foreground="{DynamicResource TextFillColorSecondaryBrush}" /> <TextBlock Grid.Row="0" Margin="0,0,0,16" Text="Manage your own FastFlags. Double click a column to edit." FontSize="14" Foreground="{DynamicResource TextFillColorSecondaryBrush}" />
<StackPanel Grid.Row="1" Margin="0,0,0,16" Orientation="Horizontal"> <StackPanel Grid.Row="1" Margin="0,0,0,16" Orientation="Horizontal">
<ui:Button Icon="ArrowLeft48" Content="Back" Click="BackButton_Click" /> <ui:Button Icon="ArrowLeft48" Content="Back" Click="BackButton_Click" />
@ -87,7 +87,7 @@
</DataGrid.CellStyle> </DataGrid.CellStyle>
<DataGrid.Columns> <DataGrid.Columns>
<DataGridTextColumn Header="Name" Binding="{Binding Name}" IsReadOnly="True" /> <DataGridTextColumn Header="Name" Binding="{Binding Name}" />
<DataGridTextColumn Header="Value" Binding="{Binding Value}" Width="*" /> <DataGridTextColumn Header="Value" Binding="{Binding Value}" Width="*" />
</DataGrid.Columns> </DataGrid.Columns>
</DataGrid> </DataGrid>

View File

@ -8,6 +8,7 @@ using Microsoft.Win32;
using Wpf.Ui.Mvvm.Contracts; using Wpf.Ui.Mvvm.Contracts;
using Bloxstrap.UI.Elements.Dialogs; using Bloxstrap.UI.Elements.Dialogs;
using System.Xml.Linq;
namespace Bloxstrap.UI.Elements.Menu.Pages namespace Bloxstrap.UI.Elements.Menu.Pages
{ {
@ -111,11 +112,28 @@ namespace Bloxstrap.UI.Elements.Menu.Pages
break; */ break; */
case "Name": case "Name":
string newName = ((TextBox)e.EditingElement).Text; var textbox = e.EditingElement as TextBox;
App.FastFlags.SetValue(entry.Name, null); string oldName = entry.Name;
string newName = textbox!.Text;
if (newName == oldName)
return;
if (App.FastFlags.GetValue(newName) is not null)
{
Controls.ShowMessageBox("A FastFlag with this name already exists.", MessageBoxImage.Information);
e.Cancel = true;
textbox.Text = oldName;
return;
}
App.FastFlags.SetValue(oldName, null);
App.FastFlags.SetValue(newName, entry.Value); App.FastFlags.SetValue(newName, entry.Value);
if (!newName.Contains(_searchFilter))
ClearSearch();
break; break;
case "Value": case "Value":