|
@@ -37,16 +37,16 @@ namespace PRS.Shared
|
|
|
where TUnit : DimensionUnit, new()
|
|
|
{
|
|
|
|
|
|
- private Grid Grid;
|
|
|
- private ComboBox Combo;
|
|
|
+ private Grid Grid = null!; // Late-initialized in CreateEditor
|
|
|
+ private ComboBox Combo = null!; // Late-initialized in CreateEditor
|
|
|
|
|
|
- private DoubleTextBox Quantity;
|
|
|
- private DoubleTextBox Length;
|
|
|
- private DoubleTextBox Width;
|
|
|
- private DoubleTextBox Height;
|
|
|
- private DoubleTextBox Weight;
|
|
|
+ private DoubleTextBox QuantityBox = null!; // Late-initialized in CreateEditor
|
|
|
+ private DoubleTextBox LengthBox = null!; // Late-initialized in CreateEditor
|
|
|
+ private DoubleTextBox WidthBox = null!; // Late-initialized in CreateEditor
|
|
|
+ private DoubleTextBox HeightBox = null!; // Late-initialized in CreateEditor
|
|
|
+ private DoubleTextBox WeightBox = null!; // Late-initialized in CreateEditor
|
|
|
|
|
|
- private List<Tuple<string, TUnit>> Units;
|
|
|
+ private List<Tuple<string, TUnit>> Units = null!; // Late-initialized in CreateEditor
|
|
|
|
|
|
public override int DesiredHeight()
|
|
|
{
|
|
@@ -60,11 +60,11 @@ namespace PRS.Shared
|
|
|
|
|
|
public override void SetColor(Color color)
|
|
|
{
|
|
|
- Quantity.Background = new SolidColorBrush(color);
|
|
|
- Length.Background = new SolidColorBrush(color);
|
|
|
- Width.Background = new SolidColorBrush(color);
|
|
|
- Height.Background = new SolidColorBrush(color);
|
|
|
- Weight.Background = new SolidColorBrush(color);
|
|
|
+ QuantityBox.Background = new SolidColorBrush(color);
|
|
|
+ LengthBox.Background = new SolidColorBrush(color);
|
|
|
+ WidthBox.Background = new SolidColorBrush(color);
|
|
|
+ HeightBox.Background = new SolidColorBrush(color);
|
|
|
+ WeightBox.Background = new SolidColorBrush(color);
|
|
|
}
|
|
|
|
|
|
public override void SetFocus()
|
|
@@ -112,11 +112,11 @@ namespace PRS.Shared
|
|
|
Combo.ItemsSource = Units;
|
|
|
Combo.SelectionChanged += Combo_SelectionChanged;
|
|
|
|
|
|
- Quantity = AddDimension("Quantity: ", 1);
|
|
|
- Length = AddDimension("Length: ", 2);
|
|
|
- Width = AddDimension("Width: ", 3);
|
|
|
- Height = AddDimension("Height: ", 4);
|
|
|
- Weight = AddDimension("Weight: ", 5);
|
|
|
+ QuantityBox = AddDimension("Quantity: ", 1);
|
|
|
+ LengthBox = AddDimension("Length: ", 2);
|
|
|
+ WidthBox = AddDimension("Width: ", 3);
|
|
|
+ HeightBox = AddDimension("Height: ", 4);
|
|
|
+ WeightBox = AddDimension("Weight: ", 5);
|
|
|
|
|
|
return Grid;
|
|
|
}
|
|
@@ -191,11 +191,11 @@ namespace PRS.Shared
|
|
|
if (Combo.SelectedItem is not Tuple<string, TUnit> tuple) return;
|
|
|
var unit = tuple.Item2;
|
|
|
|
|
|
- UpdateColumn(1, unit.HasQuantity, Quantity);
|
|
|
- UpdateColumn(2, unit.HasLength, Length);
|
|
|
- UpdateColumn(3, unit.HasWidth, Width);
|
|
|
- UpdateColumn(4, unit.HasHeight, Height);
|
|
|
- UpdateColumn(5, unit.HasWeight, Weight);
|
|
|
+ UpdateColumn(1, unit.HasQuantity, QuantityBox);
|
|
|
+ UpdateColumn(2, unit.HasLength, LengthBox);
|
|
|
+ UpdateColumn(3, unit.HasWidth, WidthBox);
|
|
|
+ UpdateColumn(4, unit.HasHeight, HeightBox);
|
|
|
+ UpdateColumn(5, unit.HasWeight, WeightBox);
|
|
|
|
|
|
foreach(var property in DatabaseSchema.Properties(typeof(TUnit)))
|
|
|
{
|
|
@@ -211,11 +211,11 @@ namespace PRS.Shared
|
|
|
if (!property.StartsWith($"{ColumnName}.")) return null;
|
|
|
property = property[(ColumnName.Length + 1)..];
|
|
|
|
|
|
- if (property == "Quantity") return Quantity.Value ?? 0.0;
|
|
|
- if (property == "Length") return Length.Value ?? 0.0;
|
|
|
- if (property == "Width") return Width.Value ?? 0.0;
|
|
|
- if (property == "Height") return Height.Value ?? 0.0;
|
|
|
- if (property == "Weight") return Weight.Value ?? 0.0;
|
|
|
+ if (property == "Quantity") return QuantityBox.Value ?? 0.0;
|
|
|
+ if (property == "Length") return LengthBox.Value ?? 0.0;
|
|
|
+ if (property == "Width") return WidthBox.Value ?? 0.0;
|
|
|
+ if (property == "Height") return HeightBox.Value ?? 0.0;
|
|
|
+ if (property == "Weight") return WeightBox.Value ?? 0.0;
|
|
|
if (property == "Unit.ID") return Combo.SelectedValue is Guid guid ? guid : Guid.Empty;
|
|
|
|
|
|
return null;
|
|
@@ -224,11 +224,11 @@ namespace PRS.Shared
|
|
|
{
|
|
|
var values = new Dictionary<string, object?>
|
|
|
{
|
|
|
- {$"{ColumnName}.Quantity", Quantity.Value ?? 0.0},
|
|
|
- {$"{ColumnName}.Length", Length.Value ?? 0.0},
|
|
|
- {$"{ColumnName}.Width", Width.Value ?? 0.0},
|
|
|
- {$"{ColumnName}.Height", Height.Value ?? 0.0},
|
|
|
- {$"{ColumnName}.Weight", Weight.Value ?? 0.0},
|
|
|
+ {$"{ColumnName}.Quantity", QuantityBox.Value ?? 0.0},
|
|
|
+ {$"{ColumnName}.Length", LengthBox.Value ?? 0.0},
|
|
|
+ {$"{ColumnName}.Width", WidthBox.Value ?? 0.0},
|
|
|
+ {$"{ColumnName}.Height", HeightBox.Value ?? 0.0},
|
|
|
+ {$"{ColumnName}.Weight", WeightBox.Value ?? 0.0},
|
|
|
{$"{ColumnName}.Unit.ID", Combo.SelectedValue is Guid guid ? guid : Guid.Empty }
|
|
|
};
|
|
|
return values;
|
|
@@ -247,11 +247,11 @@ namespace PRS.Shared
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- if (property == "Quantity") Quantity.Value = (double)value;
|
|
|
- if (property == "Length") Length.Value = (double)value;
|
|
|
- if (property == "Width") Width.Value = (double)value;
|
|
|
- if (property == "Height") Height.Value = (double)value;
|
|
|
- if (property == "Weight") Weight.Value = (double)value;
|
|
|
+ if (property == "Quantity") QuantityBox.Value = (double)value;
|
|
|
+ if (property == "Length") LengthBox.Value = (double)value;
|
|
|
+ if (property == "Width") WidthBox.Value = (double)value;
|
|
|
+ if (property == "Height") HeightBox.Value = (double)value;
|
|
|
+ if (property == "Weight") WeightBox.Value = (double)value;
|
|
|
}
|
|
|
|
|
|
}
|