Allow configuration of entry width
This commit is contained in:
@@ -15,7 +15,7 @@
|
|||||||
SelectedValueBinding="{ReflectionBinding Value}">
|
SelectedValueBinding="{ReflectionBinding Value}">
|
||||||
<ComboBox.Styles>
|
<ComboBox.Styles>
|
||||||
<Style Selector="ComboBox.Write">
|
<Style Selector="ComboBox.Write">
|
||||||
<Setter Property="MinWidth" Value="264" />
|
<Setter Property="MinWidth" Value="296" />
|
||||||
<Setter Property="IsVisible" Value="True" />
|
<Setter Property="IsVisible" Value="True" />
|
||||||
</Style>
|
</Style>
|
||||||
<Style Selector="ComboBox.Read">
|
<Style Selector="ComboBox.Read">
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
<MaskedTextBox Mask="{Binding Pattern}" Text="{Binding Value}">
|
<MaskedTextBox Mask="{Binding Pattern}" Text="{Binding Value}">
|
||||||
<TextBox.Styles>
|
<TextBox.Styles>
|
||||||
<Style Selector="TextBox.Write">
|
<Style Selector="TextBox.Write">
|
||||||
<Setter Property="MinWidth" Value="264" />
|
<Setter Property="MinWidth" Value="296" />
|
||||||
</Style>
|
</Style>
|
||||||
<Style Selector="TextBox.Read">
|
<Style Selector="TextBox.Read">
|
||||||
<Setter Property="MinWidth" Value="0" />
|
<Setter Property="MinWidth" Value="0" />
|
||||||
|
|||||||
@@ -6,59 +6,6 @@
|
|||||||
x:DataType="vm:TextEntryViewModel"
|
x:DataType="vm:TextEntryViewModel"
|
||||||
Header="{Binding Key}">
|
Header="{Binding Key}">
|
||||||
<SettingsExpander.Footer>
|
<SettingsExpander.Footer>
|
||||||
<TextBox Text="{Binding Value}">
|
<DatePicker />
|
||||||
<TextBox.Styles>
|
|
||||||
<Style Selector="TextBox.Write">
|
|
||||||
<Setter Property="MinWidth" Value="264" />
|
|
||||||
</Style>
|
|
||||||
<Style Selector="TextBox.Read">
|
|
||||||
<Setter Property="MinWidth" Value="0" />
|
|
||||||
<Setter Property="IsReadOnly" Value="True" />
|
|
||||||
<Setter Property="BorderBrush" Value="Transparent" />
|
|
||||||
<Setter Property="Background" Value="Transparent" />
|
|
||||||
<Setter Property="Foreground">
|
|
||||||
<Setter.Value>
|
|
||||||
<SolidColorBrush Opacity="0.7" Color="{DynamicResource TextFillColorPrimary}" />
|
|
||||||
</Setter.Value>
|
|
||||||
</Setter>
|
|
||||||
<Style Selector="^:pointerover">
|
|
||||||
<Setter Property="Foreground">
|
|
||||||
<Setter.Value>
|
|
||||||
<SolidColorBrush Opacity="0.7" Color="{DynamicResource TextFillColorPrimary}" />
|
|
||||||
</Setter.Value>
|
|
||||||
</Setter>
|
|
||||||
<Style Selector="^ /template/ Border#PART_BorderElement">
|
|
||||||
<Setter Property="BorderBrush" Value="Transparent" />
|
|
||||||
<Setter Property="Background" Value="Transparent" />
|
|
||||||
</Style>
|
|
||||||
</Style>
|
|
||||||
<Style Selector="^:focus">
|
|
||||||
<Setter Property="Foreground">
|
|
||||||
<Setter.Value>
|
|
||||||
<SolidColorBrush Opacity="0.7" Color="{DynamicResource TextFillColorPrimary}" />
|
|
||||||
</Setter.Value>
|
|
||||||
</Setter>
|
|
||||||
<Style Selector="^ /template/ Border#PART_BorderElement">
|
|
||||||
<Setter Property="Background" Value="Transparent" />
|
|
||||||
<Setter Property="BorderBrush" Value="Transparent" />
|
|
||||||
</Style>
|
|
||||||
</Style>
|
|
||||||
</Style>
|
|
||||||
</TextBox.Styles>
|
|
||||||
<Interaction.Behaviors>
|
|
||||||
<DataTriggerBehavior Binding="{Binding State}" Value="{x:Static vm:ItemState.Read}">
|
|
||||||
<AddClassAction ClassName="Read" RemoveIfExists="True" />
|
|
||||||
<RemoveClassAction ClassName="Write" />
|
|
||||||
</DataTriggerBehavior>
|
|
||||||
<DataTriggerBehavior Binding="{Binding State}" Value="{x:Static vm:ItemState.New}">
|
|
||||||
<AddClassAction ClassName="Write" RemoveIfExists="True" />
|
|
||||||
<RemoveClassAction ClassName="Read" />
|
|
||||||
</DataTriggerBehavior>
|
|
||||||
<DataTriggerBehavior Binding="{Binding State}" Value="{x:Static vm:ItemState.Write}">
|
|
||||||
<AddClassAction ClassName="Write" RemoveIfExists="True" />
|
|
||||||
<RemoveClassAction ClassName="Read" />
|
|
||||||
</DataTriggerBehavior>
|
|
||||||
</Interaction.Behaviors>
|
|
||||||
</TextBox>
|
|
||||||
</SettingsExpander.Footer>
|
</SettingsExpander.Footer>
|
||||||
</SettingsExpander>
|
</SettingsExpander>
|
||||||
|
|||||||
@@ -16,7 +16,8 @@ public partial class DropdownEntryViewModel :
|
|||||||
ItemEntryConfiguration configuration,
|
ItemEntryConfiguration configuration,
|
||||||
string key,
|
string key,
|
||||||
object value,
|
object value,
|
||||||
DropdownValueViewModel selectedItem) : base(provider, factory, mediator, publisher, subscriber, disposer, items, state, configuration, key, value)
|
double width,
|
||||||
|
DropdownValueViewModel selectedItem) : base(provider, factory, mediator, publisher, subscriber, disposer, items, state, configuration, key, value, width)
|
||||||
{
|
{
|
||||||
SelectedItem = selectedItem;
|
SelectedItem = selectedItem;
|
||||||
}
|
}
|
||||||
@@ -31,7 +32,8 @@ public partial class DropdownEntryViewModel :
|
|||||||
ItemState state,
|
ItemState state,
|
||||||
ItemEntryConfiguration configuration,
|
ItemEntryConfiguration configuration,
|
||||||
string key,
|
string key,
|
||||||
object value) : base(provider, factory, mediator, publisher, subscriber, disposer, items, state, configuration, key, value)
|
object value,
|
||||||
|
double width) : base(provider, factory, mediator, publisher, subscriber, disposer, items, state, configuration, key, value, width)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -17,11 +17,12 @@ public class DropdownEntryViewModelHandler(IServiceFactory serviceFactory) :
|
|||||||
}
|
}
|
||||||
|
|
||||||
string? label = configuration.Label;
|
string? label = configuration.Label;
|
||||||
object? value = configuration.Value;
|
object? value = configuration.Value ?? "";
|
||||||
|
double? width = configuration.Width;
|
||||||
|
|
||||||
DropdownValueViewModel? selected = values.FirstOrDefault(x => x.Value is not null && x.Value.Equals($"{value}"));
|
DropdownValueViewModel? selected = values.FirstOrDefault(x => x.Value is not null && x.Value.Equals($"{value}"));
|
||||||
|
|
||||||
if (serviceFactory.Create<DropdownEntryViewModel>([values, .. args.Parameters, configuration, label, value ?? "", selected])
|
if (serviceFactory.Create<DropdownEntryViewModel>([values, .. args.Parameters, configuration, label, value, width, selected])
|
||||||
is DropdownEntryViewModel viewModel)
|
is DropdownEntryViewModel viewModel)
|
||||||
{
|
{
|
||||||
return Task.FromResult<IItemEntryViewModel?>(viewModel);
|
return Task.FromResult<IItemEntryViewModel?>(viewModel);
|
||||||
|
|||||||
@@ -26,12 +26,19 @@ public partial class ItemEntryCollectionViewModel<TItem> :
|
|||||||
ItemState state,
|
ItemState state,
|
||||||
ItemEntryConfiguration configuration,
|
ItemEntryConfiguration configuration,
|
||||||
string key,
|
string key,
|
||||||
object value) : base(provider, factory, mediator, publisher, subscriber, disposer, key, value)
|
object value,
|
||||||
|
double width) : base(provider, factory, mediator, publisher, subscriber, disposer, key, value)
|
||||||
{
|
{
|
||||||
this.configuration = configuration;
|
this.configuration = configuration;
|
||||||
|
|
||||||
State = state;
|
State = state;
|
||||||
|
Width = width;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[ObservableProperty]
|
||||||
|
private double width;
|
||||||
|
|
||||||
|
|
||||||
public ItemEntryCollectionViewModel(IServiceProvider provider,
|
public ItemEntryCollectionViewModel(IServiceProvider provider,
|
||||||
IServiceFactory factory,
|
IServiceFactory factory,
|
||||||
IMediator mediator,
|
IMediator mediator,
|
||||||
@@ -42,10 +49,13 @@ public partial class ItemEntryCollectionViewModel<TItem> :
|
|||||||
ItemState state,
|
ItemState state,
|
||||||
ItemEntryConfiguration configuration,
|
ItemEntryConfiguration configuration,
|
||||||
string key,
|
string key,
|
||||||
object value) : base(provider, factory, mediator, publisher, subscriber, disposer, items, key, value)
|
object value,
|
||||||
|
double width) : base(provider, factory, mediator, publisher, subscriber, disposer, items, key, value)
|
||||||
{
|
{
|
||||||
this.configuration = configuration;
|
this.configuration = configuration;
|
||||||
|
|
||||||
State = state;
|
State = state;
|
||||||
|
Width = width;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnValueChanged()
|
protected override void OnValueChanged()
|
||||||
|
|||||||
@@ -22,4 +22,7 @@ public record ItemEntryConfiguration :
|
|||||||
|
|
||||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||||
public object? Value { get; set; }
|
public object? Value { get; set; }
|
||||||
|
|
||||||
|
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||||
|
public double? Width { get; set; } = 296;
|
||||||
}
|
}
|
||||||
@@ -12,7 +12,8 @@ public partial class ItemEntryViewModel(IServiceProvider provider,
|
|||||||
ItemState state,
|
ItemState state,
|
||||||
ItemEntryConfiguration configuration,
|
ItemEntryConfiguration configuration,
|
||||||
string key,
|
string key,
|
||||||
object value) :
|
object value,
|
||||||
|
double width) :
|
||||||
Observable<string, object>(provider, factory, mediator, publisher, subscriber, disposer, key, value),
|
Observable<string, object>(provider, factory, mediator, publisher, subscriber, disposer, key, value),
|
||||||
IItemEntryViewModel,
|
IItemEntryViewModel,
|
||||||
INotificationHandler<UpdateEventArgs<Item>>,
|
INotificationHandler<UpdateEventArgs<Item>>,
|
||||||
@@ -22,8 +23,8 @@ public partial class ItemEntryViewModel(IServiceProvider provider,
|
|||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
private ItemState state = state;
|
private ItemState state = state;
|
||||||
|
|
||||||
protected override void OnValueChanged() =>
|
[ObservableProperty]
|
||||||
configuration.Value = Value;
|
private double width = width;
|
||||||
|
|
||||||
public Task Handle(UpdateEventArgs<Item> args) =>
|
public Task Handle(UpdateEventArgs<Item> args) =>
|
||||||
Task.FromResult(State = ItemState.Write);
|
Task.FromResult(State = ItemState.Write);
|
||||||
@@ -43,4 +44,7 @@ public partial class ItemEntryViewModel(IServiceProvider provider,
|
|||||||
State = ItemState.Read;
|
State = ItemState.Read;
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void OnValueChanged() =>
|
||||||
|
configuration.Value = Value;
|
||||||
}
|
}
|
||||||
@@ -13,7 +13,8 @@ public partial class MaskedTextEntryViewModel(IServiceProvider provider,
|
|||||||
ItemEntryConfiguration configuration,
|
ItemEntryConfiguration configuration,
|
||||||
string pattern,
|
string pattern,
|
||||||
string key,
|
string key,
|
||||||
object value) : ItemEntryViewModel(provider, factory, mediator, publisher, subscriber, disposer, state, configuration, key, value)
|
object value,
|
||||||
|
double width) : ItemEntryViewModel(provider, factory, mediator, publisher, subscriber, disposer, state, configuration, key, value, width)
|
||||||
{
|
{
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
private string pattern = pattern;
|
private string pattern = pattern;
|
||||||
|
|||||||
@@ -10,7 +10,11 @@ public class MaskedTextEntryViewModelHandler(IServiceFactory serviceFactory) :
|
|||||||
{
|
{
|
||||||
if (args.Value is MaskedTextEntryConfiguration configuration)
|
if (args.Value is MaskedTextEntryConfiguration configuration)
|
||||||
{
|
{
|
||||||
if (serviceFactory.Create<MaskedTextEntryViewModel>([.. args.Parameters, configuration, configuration.Pattern, configuration.Label, configuration.Value])
|
string? label = configuration.Label;
|
||||||
|
object? value = configuration.Value ?? "";
|
||||||
|
double? width = configuration.Width;
|
||||||
|
|
||||||
|
if (serviceFactory.Create<MaskedTextEntryViewModel>([.. args.Parameters, configuration, configuration.Pattern, label, value, width])
|
||||||
is MaskedTextEntryViewModel viewModel)
|
is MaskedTextEntryViewModel viewModel)
|
||||||
{
|
{
|
||||||
return Task.FromResult<IItemEntryViewModel?>(viewModel);
|
return Task.FromResult<IItemEntryViewModel?>(viewModel);
|
||||||
|
|||||||
@@ -11,5 +11,6 @@ public partial class MultilineTextEntryViewModel(IServiceProvider provider,
|
|||||||
ItemState state,
|
ItemState state,
|
||||||
ItemEntryConfiguration configuration,
|
ItemEntryConfiguration configuration,
|
||||||
string key,
|
string key,
|
||||||
object value) : ItemEntryViewModel(provider, factory, mediator, publisher, subscriber, disposer, state, configuration, key, value);
|
object value,
|
||||||
|
double width) : ItemEntryViewModel(provider, factory, mediator, publisher, subscriber, disposer, state, configuration, key, value, width);
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,11 @@ public class MultilineTextEntryViewModelHandler(IServiceFactory serviceFactory)
|
|||||||
{
|
{
|
||||||
if (args.Value is MultilineTextEntryConfiguration configuration)
|
if (args.Value is MultilineTextEntryConfiguration configuration)
|
||||||
{
|
{
|
||||||
if (serviceFactory.Create<MultilineTextEntryViewModel>([.. args.Parameters, configuration, configuration.Label, configuration.Value ?? ""])
|
string? label = configuration.Label;
|
||||||
|
object? value = configuration.Value ?? "";
|
||||||
|
double? width = configuration.Width;
|
||||||
|
|
||||||
|
if (serviceFactory.Create<MultilineTextEntryViewModel>([.. args.Parameters, configuration, label, value, width])
|
||||||
is MultilineTextEntryViewModel viewModel)
|
is MultilineTextEntryViewModel viewModel)
|
||||||
{
|
{
|
||||||
return Task.FromResult<IItemEntryViewModel?>(viewModel);
|
return Task.FromResult<IItemEntryViewModel?>(viewModel);
|
||||||
|
|||||||
@@ -11,4 +11,5 @@ public partial class PasswordEntryViewModel(IServiceProvider provider,
|
|||||||
ItemState state,
|
ItemState state,
|
||||||
ItemEntryConfiguration configuration,
|
ItemEntryConfiguration configuration,
|
||||||
string key,
|
string key,
|
||||||
object value) : ItemEntryViewModel(provider, factory, mediator, publisher, subscriber, disposer, state, configuration, key, value);
|
object value,
|
||||||
|
double width) : ItemEntryViewModel(provider, factory, mediator, publisher, subscriber, disposer, state, configuration, key, value, width);
|
||||||
@@ -10,7 +10,11 @@ public class PasswordEntryViewModelHandler(IServiceFactory serviceFactory) :
|
|||||||
{
|
{
|
||||||
if (args.Value is PasswordEntryConfiguration configuration)
|
if (args.Value is PasswordEntryConfiguration configuration)
|
||||||
{
|
{
|
||||||
if (serviceFactory.Create<PasswordEntryViewModel>([.. args.Parameters, configuration, configuration.Label, configuration.Value ?? ""])
|
string? label = configuration.Label;
|
||||||
|
object? value = configuration.Value ?? "";
|
||||||
|
double? width = configuration.Width;
|
||||||
|
|
||||||
|
if (serviceFactory.Create<PasswordEntryViewModel>([.. args.Parameters, configuration, label, value, width])
|
||||||
is PasswordEntryViewModel viewModel)
|
is PasswordEntryViewModel viewModel)
|
||||||
{
|
{
|
||||||
return Task.FromResult<IItemEntryViewModel?>(viewModel);
|
return Task.FromResult<IItemEntryViewModel?>(viewModel);
|
||||||
|
|||||||
@@ -11,4 +11,5 @@ public partial class TextEntryViewModel(IServiceProvider provider,
|
|||||||
ItemState state,
|
ItemState state,
|
||||||
ItemEntryConfiguration configuration,
|
ItemEntryConfiguration configuration,
|
||||||
string key,
|
string key,
|
||||||
object value) : ItemEntryViewModel(provider, factory, mediator, publisher, subscriber, disposer, state, configuration, key, value);
|
object value,
|
||||||
|
double width) : ItemEntryViewModel(provider, factory, mediator, publisher, subscriber, disposer, state, configuration, key, value, width);
|
||||||
@@ -10,7 +10,11 @@ public class TextEntryViewModelHandler(IServiceFactory serviceFactory) :
|
|||||||
{
|
{
|
||||||
if (args.Value is TextEntryConfiguration configuration)
|
if (args.Value is TextEntryConfiguration configuration)
|
||||||
{
|
{
|
||||||
if (serviceFactory.Create<TextEntryViewModel>([.. args.Parameters, configuration, configuration.Label, configuration.Value ?? ""])
|
string? label = configuration.Label;
|
||||||
|
object? value = configuration.Value ?? "";
|
||||||
|
double? width = configuration.Width;
|
||||||
|
|
||||||
|
if (serviceFactory.Create<TextEntryViewModel>([.. args.Parameters, configuration, label, value, width])
|
||||||
is TextEntryViewModel viewModel)
|
is TextEntryViewModel viewModel)
|
||||||
{
|
{
|
||||||
return Task.FromResult<IItemEntryViewModel?>(viewModel);
|
return Task.FromResult<IItemEntryViewModel?>(viewModel);
|
||||||
|
|||||||
Reference in New Issue
Block a user