mirror of
https://github.com/bloxstraplabs/bloxstrap.git
synced 2025-04-21 10:01:27 -07:00
Remove option to enable/disable flags
:(
This commit is contained in:
parent
1b3049fbdb
commit
500b21d601
@ -1,15 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Bloxstrap.Models
|
|
||||||
{
|
|
||||||
public class FastFlag
|
|
||||||
{
|
|
||||||
public bool Enabled { get; set; }
|
|
||||||
public string Name { get; set; } = null!;
|
|
||||||
public string Value { get; set; } = null!;
|
|
||||||
}
|
|
||||||
}
|
|
@ -18,15 +18,15 @@
|
|||||||
|
|
||||||
<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 the value column to edit." FontSize="14" Foreground="{DynamicResource TextFillColorSecondaryBrush}" />
|
||||||
|
|
||||||
<ui:DataGrid Name="DataGrid" Grid.Row="1" HeadersVisibility="Column" GridLinesVisibility="Horizontal" AutoGenerateColumns="False" CanUserAddRows="False" CanUserDeleteRows="False" CellEditEnding="DataGrid_CellEditEnding">
|
<DataGrid Name="DataGrid" Grid.Row="1" HeadersVisibility="Column" GridLinesVisibility="Horizontal" AutoGenerateColumns="False" CanUserAddRows="False" CanUserDeleteRows="False" CellEditEnding="DataGrid_CellEditEnding">
|
||||||
<ui:DataGrid.Style>
|
<DataGrid.Style>
|
||||||
<Style TargetType="ui:DataGrid" BasedOn="{StaticResource {x:Type ui:DataGrid}}">
|
<Style TargetType="DataGrid" BasedOn="{StaticResource {x:Type DataGrid}}">
|
||||||
<Setter Property="Background" Value="Transparent" />
|
<Setter Property="Background" Value="Transparent" />
|
||||||
<Setter Property="BorderThickness" Value="0" />
|
<Setter Property="BorderThickness" Value="0" />
|
||||||
</Style>
|
</Style>
|
||||||
</ui:DataGrid.Style>
|
</DataGrid.Style>
|
||||||
|
|
||||||
<ui:DataGrid.ColumnHeaderStyle>
|
<DataGrid.ColumnHeaderStyle>
|
||||||
<Style TargetType="DataGridColumnHeader">
|
<Style TargetType="DataGridColumnHeader">
|
||||||
<Setter Property="Background" Value="{DynamicResource ControlFillColorTertiaryBrush}" />
|
<Setter Property="Background" Value="{DynamicResource ControlFillColorTertiaryBrush}" />
|
||||||
<Setter Property="Height" Value="32" />
|
<Setter Property="Height" Value="32" />
|
||||||
@ -34,9 +34,9 @@
|
|||||||
<Setter Property="BorderBrush" Value="{DynamicResource ControlElevationBorderBrush}" />
|
<Setter Property="BorderBrush" Value="{DynamicResource ControlElevationBorderBrush}" />
|
||||||
<Setter Property="BorderThickness" Value="1" />
|
<Setter Property="BorderThickness" Value="1" />
|
||||||
</Style>
|
</Style>
|
||||||
</ui:DataGrid.ColumnHeaderStyle>
|
</DataGrid.ColumnHeaderStyle>
|
||||||
|
|
||||||
<ui:DataGrid.CellStyle>
|
<DataGrid.CellStyle>
|
||||||
<Style TargetType="DataGridCell">
|
<Style TargetType="DataGridCell">
|
||||||
<Style.Triggers>
|
<Style.Triggers>
|
||||||
<Trigger Property="IsSelected" Value="True">
|
<Trigger Property="IsSelected" Value="True">
|
||||||
@ -44,6 +44,7 @@
|
|||||||
<Setter Property="Background" Value="{DynamicResource PaletteDeepPurpleBrush}" />
|
<Setter Property="Background" Value="{DynamicResource PaletteDeepPurpleBrush}" />
|
||||||
</Trigger>
|
</Trigger>
|
||||||
</Style.Triggers>
|
</Style.Triggers>
|
||||||
|
<Setter Property="Height" Value="32" />
|
||||||
<Setter Property="Template">
|
<Setter Property="Template">
|
||||||
<Setter.Value>
|
<Setter.Value>
|
||||||
<ControlTemplate TargetType="DataGridCell">
|
<ControlTemplate TargetType="DataGridCell">
|
||||||
@ -54,14 +55,13 @@
|
|||||||
</Setter.Value>
|
</Setter.Value>
|
||||||
</Setter>
|
</Setter>
|
||||||
</Style>
|
</Style>
|
||||||
</ui:DataGrid.CellStyle>
|
</DataGrid.CellStyle>
|
||||||
|
|
||||||
<ui:DataGrid.Columns>
|
<DataGrid.Columns>
|
||||||
<DataGridCheckBoxColumn Header="Enabled" Binding="{Binding Enabled}" Width="68" />
|
<DataGridTextColumn Header="Name" Binding="{Binding Key}" IsReadOnly="True" />
|
||||||
<DataGridTextColumn Header="Name" Binding="{Binding Name}" IsReadOnly="True" />
|
|
||||||
<DataGridTextColumn Header="Value" Binding="{Binding Value}" Width="*" />
|
<DataGridTextColumn Header="Value" Binding="{Binding Value}" Width="*" />
|
||||||
</ui:DataGrid.Columns>
|
</DataGrid.Columns>
|
||||||
</ui:DataGrid>
|
</DataGrid>
|
||||||
|
|
||||||
<StackPanel Grid.Row="2" Margin="0,16,0,0" Orientation="Horizontal">
|
<StackPanel Grid.Row="2" Margin="0,16,0,0" Orientation="Horizontal">
|
||||||
<ui:Button Icon="Add28" Content="Add new" Click="AddButton_Click" />
|
<ui:Button Icon="Add28" Content="Add new" Click="AddButton_Click" />
|
||||||
|
@ -15,7 +15,7 @@ namespace Bloxstrap.UI.Elements.Menu.Pages
|
|||||||
// believe me when i say there is absolutely zero point to using mvvm for this
|
// believe me when i say there is absolutely zero point to using mvvm for this
|
||||||
// using a datagrid is a codebehind thing only and thats it theres literally no way around it
|
// using a datagrid is a codebehind thing only and thats it theres literally no way around it
|
||||||
|
|
||||||
private readonly ObservableCollection<FastFlag> _fastFlagList = new();
|
private readonly ObservableCollection<KeyValuePair<string, string>> _fastFlagList = new();
|
||||||
private bool _showPresets = false;
|
private bool _showPresets = false;
|
||||||
|
|
||||||
public FastFlagEditorPage()
|
public FastFlagEditorPage()
|
||||||
@ -29,24 +29,11 @@ namespace Bloxstrap.UI.Elements.Menu.Pages
|
|||||||
|
|
||||||
var presetFlags = FastFlagManager.PresetFlags.Values;
|
var presetFlags = FastFlagManager.PresetFlags.Values;
|
||||||
|
|
||||||
foreach (var pair in App.FastFlags.Prop)
|
foreach (var entry in App.FastFlags.Prop)
|
||||||
{
|
{
|
||||||
if (!_showPresets && presetFlags.Contains(pair.Key))
|
if (!_showPresets && presetFlags.Contains(entry.Key))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
var entry = new FastFlag
|
|
||||||
{
|
|
||||||
Enabled = true,
|
|
||||||
Name = pair.Key,
|
|
||||||
Value = pair.Value
|
|
||||||
};
|
|
||||||
|
|
||||||
if (entry.Name.StartsWith("Disable"))
|
|
||||||
{
|
|
||||||
entry.Enabled = false;
|
|
||||||
entry.Name = entry.Name[7..];
|
|
||||||
}
|
|
||||||
|
|
||||||
_fastFlagList.Add(entry);
|
_fastFlagList.Add(entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,30 +46,14 @@ namespace Bloxstrap.UI.Elements.Menu.Pages
|
|||||||
private void DataGrid_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e)
|
private void DataGrid_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e)
|
||||||
{
|
{
|
||||||
int index = e.Row.GetIndex();
|
int index = e.Row.GetIndex();
|
||||||
FastFlag entry = _fastFlagList[index];
|
var entry = _fastFlagList[index];
|
||||||
|
|
||||||
switch (e.Column.Header)
|
switch (e.Column.Header)
|
||||||
{
|
{
|
||||||
case "Enabled":
|
|
||||||
bool enabled = (bool)((CheckBox)e.EditingElement).IsChecked!;
|
|
||||||
|
|
||||||
if (enabled)
|
|
||||||
{
|
|
||||||
App.FastFlags.SetValue(entry.Name, entry.Value);
|
|
||||||
App.FastFlags.SetValue($"Disable{entry.Name}", null);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
App.FastFlags.SetValue(entry.Name, null);
|
|
||||||
App.FastFlags.SetValue($"Disable{entry.Name}", entry.Value);
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "Name":
|
case "Name":
|
||||||
string newName = ((TextBox)e.EditingElement).Text;
|
string newName = ((TextBox)e.EditingElement).Text;
|
||||||
|
|
||||||
App.FastFlags.SetValue(entry.Name, null);
|
App.FastFlags.SetValue(entry.Key, null);
|
||||||
App.FastFlags.SetValue(newName, entry.Value);
|
App.FastFlags.SetValue(newName, entry.Value);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@ -90,7 +61,7 @@ namespace Bloxstrap.UI.Elements.Menu.Pages
|
|||||||
case "Value":
|
case "Value":
|
||||||
string newValue = ((TextBox)e.EditingElement).Text;
|
string newValue = ((TextBox)e.EditingElement).Text;
|
||||||
|
|
||||||
App.FastFlags.SetValue(entry.Name, newValue);
|
App.FastFlags.SetValue(entry.Key, newValue);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -104,29 +75,24 @@ namespace Bloxstrap.UI.Elements.Menu.Pages
|
|||||||
if (dialog.Result != MessageBoxResult.OK)
|
if (dialog.Result != MessageBoxResult.OK)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var entry = new FastFlag
|
var entry = new KeyValuePair<string, string>(dialog.FlagNameTextBox.Text, dialog.FlagValueTextBox.Text);
|
||||||
{
|
|
||||||
Enabled = true,
|
|
||||||
Name = dialog.FlagNameTextBox.Text,
|
|
||||||
Value = dialog.FlagValueTextBox.Text
|
|
||||||
};
|
|
||||||
|
|
||||||
_fastFlagList.Add(entry);
|
_fastFlagList.Add(entry);
|
||||||
|
|
||||||
App.FastFlags.SetValue(entry.Name, entry.Value);
|
App.FastFlags.SetValue(entry.Key, entry.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DeleteButton_Click(object sender, RoutedEventArgs e)
|
private void DeleteButton_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
var tempList = new List<FastFlag>();
|
var tempList = new List<KeyValuePair<string, string>>();
|
||||||
|
|
||||||
foreach (FastFlag entry in DataGrid.SelectedItems)
|
foreach (KeyValuePair<string, string> entry in DataGrid.SelectedItems)
|
||||||
tempList.Add(entry);
|
tempList.Add(entry);
|
||||||
|
|
||||||
foreach (FastFlag entry in tempList)
|
foreach (var entry in tempList)
|
||||||
{
|
{
|
||||||
_fastFlagList.Remove(entry);
|
_fastFlagList.Remove(entry);
|
||||||
App.FastFlags.SetValue(entry.Name, null);
|
App.FastFlags.SetValue(entry.Key, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user