Skip to content

Commit

Permalink
Allow for flag names to be editable
Browse files Browse the repository at this point in the history
  • Loading branch information
pizzaboxer committed Aug 24, 2023
1 parent 5741d82 commit b6dee9c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Bloxstrap/UI/Elements/Menu/Pages/FastFlagEditorPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<RowDefinition Height="*" />
</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">
<ui:Button Icon="ArrowLeft48" Content="Back" Click="BackButton_Click" />
Expand Down Expand Up @@ -87,7 +87,7 @@
</DataGrid.CellStyle>

<DataGrid.Columns>
<DataGridTextColumn Header="Name" Binding="{Binding Name}" IsReadOnly="True" />
<DataGridTextColumn Header="Name" Binding="{Binding Name}" />
<DataGridTextColumn Header="Value" Binding="{Binding Value}" Width="*" />
</DataGrid.Columns>
</DataGrid>
Expand Down
22 changes: 20 additions & 2 deletions Bloxstrap/UI/Elements/Menu/Pages/FastFlagEditorPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using Wpf.Ui.Mvvm.Contracts;

using Bloxstrap.UI.Elements.Dialogs;
using System.Xml.Linq;

namespace Bloxstrap.UI.Elements.Menu.Pages
{
Expand Down Expand Up @@ -111,11 +112,28 @@ private void DataGrid_CellEditEnding(object sender, DataGridCellEditEndingEventA
break; */

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);

if (!newName.Contains(_searchFilter))
ClearSearch();

break;

case "Value":
Expand Down

0 comments on commit b6dee9c

Please sign in to comment.