|
@@ -1,7 +1,9 @@
|
|
|
using InABox.Core;
|
|
|
+using InABox.WPF;
|
|
|
using Syncfusion.Windows.Shared;
|
|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
+using System.Diagnostics.CodeAnalysis;
|
|
|
using System.Globalization;
|
|
|
using System.Linq;
|
|
|
using System.Text;
|
|
@@ -13,22 +15,63 @@ namespace InABox.DynamicGrid
|
|
|
{
|
|
|
public class DFStringControl : DynamicFormFieldControl<DFLayoutStringField, DFLayoutStringFieldProperties, string>
|
|
|
{
|
|
|
- private TextBox Text = null!; // late-initialising
|
|
|
+ private string? text;
|
|
|
+
|
|
|
+ private TextBox? TextBox;
|
|
|
+ private Button? Btn;
|
|
|
+
|
|
|
+ [NotNull]
|
|
|
+ private string? Text
|
|
|
+ {
|
|
|
+ get => (Field.Properties.PopupEditor ? text : TextBox?.Text) ?? "";
|
|
|
+ set
|
|
|
+ {
|
|
|
+ if (Field.Properties.PopupEditor)
|
|
|
+ {
|
|
|
+ text = value;
|
|
|
+ }
|
|
|
+ else if(TextBox is not null)
|
|
|
+ {
|
|
|
+ TextBox.Text = value;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
protected override FrameworkElement Create()
|
|
|
{
|
|
|
- Text = new TextBox();
|
|
|
- Text.Text = Field.Properties.Default;
|
|
|
- Text.HorizontalContentAlignment = HorizontalAlignment.Left;
|
|
|
- Text.VerticalContentAlignment = VerticalAlignment.Center;
|
|
|
- Text.TextChanged += (sender, e) => ChangeField();
|
|
|
- return Text;
|
|
|
+ FrameworkElement element;
|
|
|
+ if (Field.Properties.PopupEditor)
|
|
|
+ {
|
|
|
+ Btn = new Button { Content = "..." };
|
|
|
+ Btn.Click += Btn_Click;
|
|
|
+ element = Btn;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ TextBox = new TextBox();
|
|
|
+ TextBox.Text = Field.Properties.Default;
|
|
|
+ TextBox.HorizontalContentAlignment = HorizontalAlignment.Left;
|
|
|
+ TextBox.VerticalContentAlignment = VerticalAlignment.Center;
|
|
|
+ TextBox.TextChanged += (sender, e) => ChangeField();
|
|
|
+ element = TextBox;
|
|
|
+ }
|
|
|
+
|
|
|
+ return element;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void Btn_Click(object sender, RoutedEventArgs e)
|
|
|
+ {
|
|
|
+ var text = Text;
|
|
|
+ if(TextBoxDialog.Execute("Edit Comment", ref text))
|
|
|
+ {
|
|
|
+ Text = text;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- public override string GetValue() => Text.Text;
|
|
|
+ public override string GetValue() => Text;
|
|
|
|
|
|
- public override void SetValue(string? value) => Text.Text = value;
|
|
|
+ public override void SetValue(string? value) => Text = value;
|
|
|
|
|
|
- protected override bool IsEmpty() => string.IsNullOrWhiteSpace(Text.Text);
|
|
|
+ protected override bool IsEmpty() => string.IsNullOrWhiteSpace(Text);
|
|
|
}
|
|
|
}
|