mirror of
https://github.com/bloxstraplabs/bloxstrap.git
synced 2025-04-21 10:01:27 -07:00
Re-add FastFlag struct class
forgot keyvaluepairs arent editable :(
This commit is contained in:
parent
b3b174ed4b
commit
52b6a60d02
9
Bloxstrap/Models/FastFlag.cs
Normal file
9
Bloxstrap/Models/FastFlag.cs
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
namespace Bloxstrap.Models
|
||||||
|
{
|
||||||
|
public class FastFlag
|
||||||
|
{
|
||||||
|
// public bool Enabled { get; set; }
|
||||||
|
public string Name { get; set; } = null!;
|
||||||
|
public string Value { get; set; } = null!;
|
||||||
|
}
|
||||||
|
}
|
@ -75,7 +75,7 @@
|
|||||||
</DataGrid.CellStyle>
|
</DataGrid.CellStyle>
|
||||||
|
|
||||||
<DataGrid.Columns>
|
<DataGrid.Columns>
|
||||||
<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="*" />
|
||||||
</DataGrid.Columns>
|
</DataGrid.Columns>
|
||||||
</DataGrid>
|
</DataGrid>
|
||||||
|
@ -17,7 +17,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<KeyValuePair<string, string>> _fastFlagList = new();
|
private readonly ObservableCollection<FastFlag> _fastFlagList = new();
|
||||||
private bool _showPresets = false;
|
private bool _showPresets = false;
|
||||||
|
|
||||||
public FastFlagEditorPage()
|
public FastFlagEditorPage()
|
||||||
@ -31,11 +31,24 @@ namespace Bloxstrap.UI.Elements.Menu.Pages
|
|||||||
|
|
||||||
var presetFlags = FastFlagManager.PresetFlags.Values;
|
var presetFlags = FastFlagManager.PresetFlags.Values;
|
||||||
|
|
||||||
foreach (var entry in App.FastFlags.Prop)
|
foreach (var pair in App.FastFlags.Prop)
|
||||||
{
|
{
|
||||||
if (!_showPresets && presetFlags.Contains(entry.Key))
|
if (!_showPresets && presetFlags.Contains(pair.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);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -48,14 +61,30 @@ 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();
|
||||||
var entry = _fastFlagList[index];
|
FastFlag 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.Key, null);
|
App.FastFlags.SetValue(entry.Name, null);
|
||||||
App.FastFlags.SetValue(newName, entry.Value);
|
App.FastFlags.SetValue(newName, entry.Value);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@ -63,7 +92,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.Key, newValue);
|
App.FastFlags.SetValue(entry.Name, newValue);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -83,24 +112,29 @@ namespace Bloxstrap.UI.Elements.Menu.Pages
|
|||||||
if (dialog.Result != MessageBoxResult.OK)
|
if (dialog.Result != MessageBoxResult.OK)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var entry = new KeyValuePair<string, string>(dialog.FlagNameTextBox.Text, dialog.FlagValueTextBox.Text);
|
var entry = new FastFlag
|
||||||
|
{
|
||||||
|
// Enabled = true,
|
||||||
|
Name = dialog.FlagNameTextBox.Text,
|
||||||
|
Value = dialog.FlagValueTextBox.Text
|
||||||
|
};
|
||||||
|
|
||||||
_fastFlagList.Add(entry);
|
_fastFlagList.Add(entry);
|
||||||
|
|
||||||
App.FastFlags.SetValue(entry.Key, entry.Value);
|
App.FastFlags.SetValue(entry.Name, entry.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DeleteButton_Click(object sender, RoutedEventArgs e)
|
private void DeleteButton_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
var tempList = new List<KeyValuePair<string, string>>();
|
var tempList = new List<FastFlag>();
|
||||||
|
|
||||||
foreach (KeyValuePair<string, string> entry in DataGrid.SelectedItems)
|
foreach (FastFlag entry in DataGrid.SelectedItems)
|
||||||
tempList.Add(entry);
|
tempList.Add(entry);
|
||||||
|
|
||||||
foreach (var entry in tempList)
|
foreach (FastFlag entry in tempList)
|
||||||
{
|
{
|
||||||
_fastFlagList.Remove(entry);
|
_fastFlagList.Remove(entry);
|
||||||
App.FastFlags.SetValue(entry.Key, null);
|
App.FastFlags.SetValue(entry.Name, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user