|
@@ -28,6 +28,12 @@ public class ButtonsOptionControl : ContentControl, IOptionControl
|
|
|
|
|
|
private TabStrip _tabStrip;
|
|
|
|
|
|
+ IBrush? IOptionControl.Background
|
|
|
+ {
|
|
|
+ get => _tabStrip.Background;
|
|
|
+ set => _tabStrip.Background = value;
|
|
|
+ }
|
|
|
+
|
|
|
public ButtonsOptionControl(string[] options, Action onChanged)
|
|
|
{
|
|
|
OnChanged = onChanged;
|
|
@@ -69,29 +75,32 @@ public class ButtonsOptionControl : ContentControl, IOptionControl
|
|
|
public bool IsEmpty() => GetValue() == null;
|
|
|
}
|
|
|
|
|
|
-public class RadioOptionControl : Grid, IOptionControl
|
|
|
+public class RadioOptionControl : ContentControl, IOptionControl
|
|
|
{
|
|
|
private Action OnChanged;
|
|
|
+ private Grid _grid;
|
|
|
|
|
|
public RadioOptionControl(string[] options, Action onChanged)
|
|
|
{
|
|
|
- Margin = new Thickness(4, 2, 4, 2);
|
|
|
+ _grid = new Grid();
|
|
|
|
|
|
OnChanged = onChanged;
|
|
|
|
|
|
foreach (var option in options)
|
|
|
{
|
|
|
- RowDefinitions.Add(new RowDefinition() { Height = new GridLength(1, GridUnitType.Auto) });
|
|
|
+ _grid.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(1, GridUnitType.Auto) });
|
|
|
var button = new RadioButton();
|
|
|
- button.Margin = new Thickness(0, 2, 0, 2);
|
|
|
+ button.Margin = new(5, 0, 5, 0);
|
|
|
button.Content = option.Replace("\r", "").Replace("\n", "");
|
|
|
button.VerticalContentAlignment = VerticalAlignment.Center;
|
|
|
- button.Padding = new Thickness(5.0F, 0.0F, 5.0F, 0.0F);
|
|
|
- button.SetValue(RowProperty, Children.Count);
|
|
|
+ button.HorizontalAlignment = HorizontalAlignment.Stretch;
|
|
|
+ button.SetValue(Grid.RowProperty, _grid.Children.Count);
|
|
|
button.Tag = option;
|
|
|
button.IsCheckedChanged += Button_IsCheckedChanged;
|
|
|
- Children.Add(button);
|
|
|
+ _grid.Children.Add(button);
|
|
|
}
|
|
|
+
|
|
|
+ Content = _grid;
|
|
|
}
|
|
|
|
|
|
private void Button_IsCheckedChanged(object? sender, global::Avalonia.Interactivity.RoutedEventArgs e)
|
|
@@ -101,7 +110,7 @@ public class RadioOptionControl : Grid, IOptionControl
|
|
|
|
|
|
public string? GetValue()
|
|
|
{
|
|
|
- foreach (var child in Children)
|
|
|
+ foreach (var child in _grid.Children)
|
|
|
{
|
|
|
if (child is RadioButton radio)
|
|
|
{
|
|
@@ -116,7 +125,7 @@ public class RadioOptionControl : Grid, IOptionControl
|
|
|
|
|
|
public void SetValue(string value)
|
|
|
{
|
|
|
- foreach (var child in Children)
|
|
|
+ foreach (var child in _grid.Children)
|
|
|
{
|
|
|
if (child is RadioButton radio)
|
|
|
{
|
|
@@ -130,20 +139,34 @@ public class RadioOptionControl : Grid, IOptionControl
|
|
|
public bool IsEmpty() => GetValue() == null;
|
|
|
}
|
|
|
|
|
|
-public class ComboBoxOptionControl : ComboBox, IOptionControl
|
|
|
+public class ComboBoxOptionControl : ContentControl, IOptionControl
|
|
|
{
|
|
|
private readonly Action OnChanged;
|
|
|
|
|
|
+ private ComboBox _comboBox;
|
|
|
+
|
|
|
+ IBrush? IOptionControl.Background
|
|
|
+ {
|
|
|
+ get => _comboBox.Background;
|
|
|
+ set => _comboBox.Background = value;
|
|
|
+ }
|
|
|
+
|
|
|
public ComboBoxOptionControl(string[] options, Action onChanged)
|
|
|
{
|
|
|
- // SetResourceReference(StyleProperty, typeof(ComboBox));
|
|
|
+ _comboBox = new ComboBox
|
|
|
+ {
|
|
|
+ HorizontalAlignment = HorizontalAlignment.Stretch,
|
|
|
+ VerticalAlignment = VerticalAlignment.Stretch
|
|
|
+ };
|
|
|
|
|
|
OnChanged = onChanged;
|
|
|
|
|
|
foreach (var option in options)
|
|
|
- Items.Add(option);
|
|
|
+ _comboBox.Items.Add(option);
|
|
|
VerticalContentAlignment = VerticalAlignment.Center;
|
|
|
- SelectionChanged += ComboBoxOptionControl_SelectionChanged;
|
|
|
+ _comboBox.SelectionChanged += ComboBoxOptionControl_SelectionChanged;
|
|
|
+
|
|
|
+ Content = _comboBox;
|
|
|
}
|
|
|
|
|
|
private void ComboBoxOptionControl_SelectionChanged(object? sender, SelectionChangedEventArgs e)
|
|
@@ -153,12 +176,12 @@ public class ComboBoxOptionControl : ComboBox, IOptionControl
|
|
|
|
|
|
public string? GetValue()
|
|
|
{
|
|
|
- return SelectedValue as string;
|
|
|
+ return _comboBox.SelectedValue as string;
|
|
|
}
|
|
|
|
|
|
public void SetValue(string value)
|
|
|
{
|
|
|
- SelectedValue = value;
|
|
|
+ _comboBox.SelectedValue = value;
|
|
|
}
|
|
|
public bool IsEmpty() => GetValue() == null;
|
|
|
}
|
|
@@ -206,8 +229,18 @@ class DFOptionControl : DigitalFormFieldControl<DFLayoutOptionField, DFLayoutOpt
|
|
|
|
|
|
protected override bool IsEmpty() => OptionControl.IsEmpty();
|
|
|
|
|
|
- public override void SetBackground(IBrush brush)
|
|
|
+ public override void SetBackground(IBrush brush, bool defaultColour)
|
|
|
{
|
|
|
- OptionControl.Background = brush;
|
|
|
+ if(OptionControl is ButtonsOptionControl)
|
|
|
+ {
|
|
|
+ if (!defaultColour)
|
|
|
+ {
|
|
|
+ Background = brush;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ OptionControl.Background = brush;
|
|
|
+ }
|
|
|
}
|
|
|
}
|