1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- 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;
- using System.Threading.Tasks;
- using System.Windows;
- using System.Windows.Controls;
- namespace InABox.DynamicGrid
- {
- public class DFStringControl : DynamicFormFieldControl<DFLayoutStringField, DFLayoutStringFieldProperties, string>
- {
- 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()
- {
- 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;
- public override void SetValue(string? value) => Text = value;
- protected override bool IsEmpty() => string.IsNullOrWhiteSpace(Text);
- }
- }
|