Selaa lähdekoodia

Moved Dimensions to PRS.Shared

Kenric Nugteren 2 vuotta sitten
vanhempi
commit
20d21e45d2

+ 2 - 2
InABox.Core/DataTable.cs

@@ -78,9 +78,9 @@ namespace InABox.Core
 
         //private DynamicObject rowObject;
 
-        public Dictionary<string, object> ToDictionary(string[] exclude)
+        public Dictionary<string, object?> ToDictionary(string[] exclude)
         {
-            var result = new Dictionary<string, object>();
+            var result = new Dictionary<string, object?>();
             foreach (var column in Table.Columns.Where(x => !exclude.Contains(x.ColumnName)))
                 result[column.ColumnName] = this[column.ColumnName];
             return result;

+ 0 - 118
InABox.Core/Dimensions/DimensionUnit.cs

@@ -1,118 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-
-namespace InABox.Core
-{
-    public abstract class DimensionUnit : Entity, IRemotable, IPersistent, ISequenceable, IDimensionUnit
-    {
-        
-        [UniqueCodeEditor(Visible = Visible.Default, Editable = Editable.Enabled)]
-        [EditorSequence(1)]
-        public virtual String Code { get; set; }
-        
-        [TextBoxEditor]
-        [EditorSequence(2)]
-        public virtual String Description { get; set; }
-        
-        [CheckBoxEditor]
-        [EditorSequence(3)]
-        public virtual bool HasQuantity { get; set; }
-        
-        [CheckBoxEditor]
-        [EditorSequence(4)]
-        public virtual bool HasLength { get; set; }
-        
-        [CheckBoxEditor]
-        [EditorSequence(5)]
-        public virtual bool HasWidth { get; set; }
-        
-        [CheckBoxEditor]
-        [EditorSequence(6)]
-        public virtual bool HasHeight { get; set; }
-        
-        [CheckBoxEditor]
-        [EditorSequence(7)]
-        public virtual bool HasWeight { get; set; }
-
-        [ExpressionEditor(null, typeof(DimensionsExpressionModelGenerator))]
-        [EditorSequence(8)]
-        public virtual string Formula { get; set; }        
-        
-        [ExpressionEditor(null, typeof(DimensionsExpressionModelGenerator))]
-        [EditorSequence(9)]
-        public virtual string Format { get; set; }
-
-        [NullEditor]
-        public long Sequence { get; set; }
-        
-        protected override void Init()
-        {
-            base.Init();
-            HasQuantity = false;
-            HasLength = false;
-            HasWidth = false;
-            HasHeight = false;
-            HasWeight = false;
-            Formula = "1";
-            Format = "\"EACH\"";
-        }
-
-        public bool Validate(List<String> errors)
-        {
-            bool result = true;
-
-            var variables = new Dictionary<string, object?>()
-            {
-                { "Quantity", 1.00F },
-                { "Length", 1.00F },
-                { "Width", 1.00F },
-                { "Height", 1.00F },
-                { "Weight", 1.00F }
-            };
-            
-            try
-            {
-                var expr = new CoreExpression(Formula);
-                expr.Evaluate(variables);
-                result = true;
-            }
-            catch (Exception e)
-            {
-                errors.Add($"{Code}: Formula [{Formula}] =>  {e.Message}");
-                result = false;
-            }
-            
-            try
-            {
-                var expr = new CoreExpression(Format);
-                expr.Evaluate(variables);
-                result = true;
-            }
-            catch (Exception e)
-            {
-                errors.Add($"{Code}: Format [{Format}] =>  {e.Message}");
-                result = false;
-            }
-
-            return result;
-        }
-
-        private class DimensionsExpressionModelGenerator : IExpressionModelGenerator
-        {
-            public List<string> GetVariables(object?[] items)
-            {
-                var dimensionUnits = items.Select(x => x as IDimensionUnit).Where(x => x != null).Cast<IDimensionUnit>();
-                var variables = new List<string>();
-
-                if (dimensionUnits.All(x => x.HasQuantity)) variables.Add("Quantity");
-                if (dimensionUnits.All(x => x.HasLength)) variables.Add("Length");
-                if (dimensionUnits.All(x => x.HasWidth)) variables.Add("Width");
-                if (dimensionUnits.All(x => x.HasHeight)) variables.Add("Height");
-                if (dimensionUnits.All(x => x.HasWeight)) variables.Add("Weight");
-
-                return variables;
-            }
-        }
-    }
-}

+ 0 - 55
InABox.Core/Dimensions/DimensionUnitLink.cs

@@ -1,55 +0,0 @@
-using System;
-
-namespace InABox.Core
-{
-    public abstract class DimensionUnitLink<T> : EntityLink<T>, IDimensionUnit where T : DimensionUnit, new()
-    {
-        protected DimensionUnitLink()
-        {
-        }
-
-        protected DimensionUnitLink(Func<BaseObject>? entity) : base(entity)
-        {
-        }
-
-        [RequiredColumn]
-        public override Guid ID { get; set; }
-        
-        [EditorSequence(1)]
-        [CodeEditor(Visible = Visible.Default, Editable = Editable.Hidden)]
-        public string Code { get; set; }
-        
-        [EditorSequence(2)]
-        [TextBoxEditor(Visible = Visible.Optional, Editable = Editable.Hidden)]
-        public string Description { get; set; }
-
-        [NullEditor]
-        [RequiredColumn]
-        public bool HasQuantity { get; set; }
-
-        [NullEditor]
-        [RequiredColumn]
-        public bool HasLength { get; set; }
-
-        [NullEditor]
-        [RequiredColumn]
-        public bool HasWidth { get; set; }
-
-        [NullEditor]
-        [RequiredColumn]
-        public bool HasHeight { get; set; }
-
-        [NullEditor]
-        [RequiredColumn]
-        public bool HasWeight { get; set; }
-
-        [NullEditor]
-        [RequiredColumn]
-        public string Formula { get; set; }
-
-        [NullEditor]
-        [RequiredColumn]
-        public string Format { get; set; }
-        
-    }
-}

+ 0 - 10
InABox.Core/Dimensions/DimensionedEntity.cs

@@ -1,10 +0,0 @@
-namespace InABox.Core
-{
-    public abstract class DimensionedEntity<TDimensions> : Entity, IDimensioned<TDimensions>
-        where TDimensions : IDimensions
-    {
-        public abstract TDimensions Dimensions { get; set; }
-        
-        IDimensions IDimensioned.Dimensions => Dimensions;
-    }
-}

+ 0 - 218
InABox.Core/Dimensions/Dimensions.cs

@@ -1,218 +0,0 @@
-using System;
-using System.Collections.Generic;
-
-namespace InABox.Core
-{
-
-    public abstract class Dimensions<TLink,TUnit> : EnclosedEntity, IDimensions 
-        where TLink : DimensionUnitLink<TUnit>, new() 
-        where TUnit : DimensionUnit, new()
-    {
-
-        public Dimensions() : base() { }
-        
-        public Dimensions(Func<BaseObject> entity) : base(entity) { }
-
-        [EditorSequence(1)]
-        [RequiredColumn]
-        [Caption("Sizing", IncludePath = false)]
-        public abstract TLink Unit { get; set; }
-
-        public IDimensionUnit GetUnit() => Unit;
-        
-        [DoubleEditor(Visible = Visible.Hidden)]
-        [EditorSequence(2)]
-        [Caption("Quantity", IncludePath = false)]
-        [RequiredColumn]
-        public abstract double Quantity { get; set; }
-        
-        [DoubleEditor(Visible = Visible.Hidden)]
-        [EditorSequence(3)]
-        [Caption("Length", IncludePath = false)]
-        [RequiredColumn]
-        public abstract double Length { get; set; }
-        
-        [DoubleEditor(Visible = Visible.Hidden)]
-        [EditorSequence(4)]
-        [Caption("Width", IncludePath = false)]
-        [RequiredColumn]
-        public abstract double Width { get; set; }
-        
-        [DoubleEditor(Visible = Visible.Hidden)]
-        [EditorSequence(5)]
-        [Caption("Height", IncludePath = false)]
-        [RequiredColumn]
-        public abstract double Height { get; set; }
-        
-        [DoubleEditor(Visible = Visible.Hidden)]
-        [EditorSequence(6)]
-        [Caption("Weight", IncludePath = false)]
-        [RequiredColumn]
-        public abstract double Weight { get; set; }
-        
-        [DoubleEditor(Visible = Visible.Optional, Editable = Editable.Hidden)]
-        [Caption("Value", IncludePath = false)]
-        [EditorSequence(7)]
-        [RequiredColumn]
-        public abstract double Value { get; set; }
-        
-        [TextBoxEditor(Visible = Visible.Default, Editable=Editable.Hidden)]
-        [EditorSequence(8)]
-        [Caption("Unit Size", IncludePath = false)]
-        [RequiredColumn]
-        public abstract String UnitSize { get; set; }
-        
-        protected override void Init()
-        {
-            base.Init();
-            Unit = Activator.CreateInstance(typeof(TLink), new object[] { new Func<BaseObject>(LinkedEntity) }) as TLink;
-            Unit.PropertyChanged += (s, e) =>
-            {
-                if(e.PropertyName == "ID")
-                {
-                    DoPropertyChanged("Unit." + e.PropertyName, OriginalValues.GetValueOrDefault("Unit." + e.PropertyName), Unit.ID);
-                }
-                else if(e.PropertyName == "Formula")
-                {
-                    DoPropertyChanged("Unit." + e.PropertyName, OriginalValues.GetValueOrDefault("Unit." + e.PropertyName), Unit.Formula);
-                }
-                else if(e.PropertyName == "Format")
-                {
-                    DoPropertyChanged("Unit." + e.PropertyName, OriginalValues.GetValueOrDefault("Unit." + e.PropertyName), Unit.Format);
-                }
-            };
-        }
-        
-        private bool bCalculating = false;
-
-        private static Column<Dimensions<TLink,TUnit>> unitid = new Column<Dimensions<TLink,TUnit>>(x => x.Unit.ID);
-        private static Column<Dimensions<TLink,TUnit>> quantity = new Column<Dimensions<TLink,TUnit>>(x => x.Quantity);
-        private static Column<Dimensions<TLink,TUnit>> length = new Column<Dimensions<TLink,TUnit>>(x => x.Length);
-        private static Column<Dimensions<TLink,TUnit>> width = new Column<Dimensions<TLink,TUnit>>(x => x.Width);
-        private static Column<Dimensions<TLink,TUnit>> height = new Column<Dimensions<TLink,TUnit>>(x => x.Height);
-        private static Column<Dimensions<TLink,TUnit>> weight = new Column<Dimensions<TLink,TUnit>>(x => x.Weight);
-        private static Column<Dimensions<TLink,TUnit>> sizeformula = new Column<Dimensions<TLink,TUnit>>(x => x.Unit.Formula);
-        private static Column<Dimensions<TLink,TUnit>> sizeformat = new Column<Dimensions<TLink,TUnit>>(x => x.Unit.Format);
-        
-        protected override void DoPropertyChanged(string name, object? before, object? after)
-        {
-            base.DoPropertyChanged(name, before, after);
-
-            if (bCalculating)
-                return;
-            
-            bCalculating = true;
-            
-            try
-            {
-                
-                if (unitid.IsEqualTo(name))
-                    Calculate(Quantity, Length, Width, Height, Weight, Unit.Formula, Unit.Format);
-                else if (quantity.IsEqualTo(name))
-                    Calculate(after, Length, Width, Height, Weight, Unit.Formula, Unit.Format);
-                else if (length.IsEqualTo(name))
-                    Calculate(Quantity, after, Width, Height, Weight, Unit.Formula, Unit.Format);
-                else if (width.IsEqualTo(name))
-                    Calculate(Quantity, Length, after, Height, Weight, Unit.Formula, Unit.Format);
-                else if (height.IsEqualTo(name))
-                    Calculate(Quantity, Length, Width, after, Weight, Unit.Formula, Unit.Format);
-                else if (weight.IsEqualTo(name))
-                    Calculate(Quantity, Length, Width, Height, after, Unit.Formula, Unit.Format);
-                else if (sizeformula.IsEqualTo(name))
-                    Calculate(Quantity, Length, Width, Height, Weight, after as string, Unit.Format);
-                else if (sizeformat.IsEqualTo(name))
-                    Calculate(Quantity, Length, Width, Height, Weight, Unit.Formula, after as string);
-            }
-            finally
-            {
-                bCalculating = false;
-            }
-        }
-
-        public void Set(IDimensionUnit unit, double quantity, double length, double width, double height, double weight)
-        {
-            bCalculating = true;
-            try
-            {
-                Unit.ID = unit.ID;
-                Unit.HasQuantity = unit.HasQuantity;
-                Unit.HasLength = unit.HasLength;
-                Unit.HasWidth = unit.HasWidth;
-                Unit.HasHeight = unit.HasHeight;
-                Unit.HasWeight = unit.HasWeight;
-                Unit.Code = unit.Code;
-                Unit.Description = unit.Description;
-                Unit.Formula = unit.Formula;
-                Unit.Format = unit.Format;
-                Quantity = quantity;
-                Length = length;
-                Width = width;
-                Height = height;
-                Weight = weight;
-                Calculate(quantity, length, width, height, weight, unit.Formula, unit.Format);
-            }
-            finally
-            {
-                bCalculating = false;                
-            }
-        }
-
-        
-        private void Calculate(object? quantity, object? length, object? width, object? height, object? weight, string? formula, string? format)
-        {
-            if (Evaluate<double>(formula, quantity, length, width, height, weight, out double value))
-                Value = value;
-            if (Evaluate<String>(format, quantity, length, width, height, weight, out string unitsize))
-                UnitSize = unitsize;
-        }
-
-        private bool Evaluate<T>(string? formula, object? quantity, object? length, object? width, object? height, object? weight, out T result)
-        {
-            
-            if (!String.IsNullOrWhiteSpace(formula))
-            {
-                var variables = new Dictionary<string, object?>()
-                {
-                    { "Quantity", Convert.ToDouble(quantity) },
-                    { "Length", Convert.ToDouble(length) },
-                    { "Width", Convert.ToDouble(width) },
-                    { "Height", Convert.ToDouble(height) },
-                    { "Weight", Convert.ToDouble(weight) }
-                };
-                try
-                {
-                    var expr = new CoreExpression(formula);
-                    var eval = expr.Evaluate(variables);
-                    result = (T)CoreUtils.ChangeType(eval,typeof(T));
-                    return true;
-                }
-                catch (Exception e)
-                {
-                    Logger.Send(LogType.Information, "", String.Format("Error in Formula: [{0}] ({1})", formula, e.Message));
-                    result = default(T);
-                    return false;
-                }
-            }
-
-            result = default(T);
-            return true;
-        }
-
-        public void CopyFrom(IDimensions source, bool observing = false)
-        {
-            if (!observing)
-                SetObserving(false);
-            Unit.ID = source.GetUnit().ID;
-            Unit.Synchronise(source.GetUnit());
-            Quantity = source.Quantity;
-            Length = source.Length;
-            Width = source.Width;
-            Height = source.Height;
-            Weight = source.Weight;
-            Value = source.Value;
-            UnitSize = source.UnitSize;
-            if (!observing)
-                SetObserving(true);
-        }
-    }
-}

+ 0 - 17
InABox.Core/Dimensions/IDimensionUnit.cs

@@ -1,17 +0,0 @@
-using System;
-
-namespace InABox.Core
-{
-    public interface IDimensionUnit : IEntity
-    {
-        String Code { get; set; }
-        String Description { get; set; }
-        bool HasQuantity { get; set; }
-        bool HasLength { get; set; }
-        bool HasWidth { get; set; }
-        bool HasHeight { get; set; }
-        bool HasWeight { get; set; }
-        String Formula { get; set; }
-        String Format { get; set; }
-    }
-}

+ 0 - 13
InABox.Core/Dimensions/IDimensioned.cs

@@ -1,13 +0,0 @@
-namespace InABox.Core
-{
-    public interface IDimensioned
-    {
-        IDimensions Dimensions { get; }
-    }
-
-    public interface IDimensioned<out TDimensions> : IDimensioned where TDimensions : IDimensions
-    {
-        TDimensions Dimensions { get; }
-    }
-
-}

+ 0 - 19
InABox.Core/Dimensions/IDimensions.cs

@@ -1,19 +0,0 @@
-using System;
-
-namespace InABox.Core
-{
-    public interface IDimensions
-    {
-        IDimensionUnit GetUnit();
-        double Quantity { get; set; }
-        double Length { get; set; }
-        double Width { get; set; }
-        double Height { get; set; }
-        double Weight { get; set; }
-        double Value { get; set; }
-        String UnitSize { get; set; }
-
-        void Set(IDimensionUnit unit, double quantity, double length, double width, double height, double weight);
-        void CopyFrom(IDimensions source, bool observing = false);
-    }
-}

+ 0 - 30
InABox.Core/Editors/DimensionsEditor.cs

@@ -1,30 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace InABox.Core
-{
-    public class DimensionsEditor : BaseEditor
-    {
-        public Type DimensionsType { get; set; }
-
-        public bool AllowEditingUnit { get; set; } = true;
-
-        public DimensionsEditor(Type dimensionsType)
-        {
-            if (!typeof(IDimensions).IsAssignableFrom(dimensionsType))
-            {
-                throw new ArgumentException("Type must be an IDimensions", nameof(dimensionsType));
-            }
-            DimensionsType = dimensionsType;
-        }
-
-        protected override BaseEditor DoClone()
-        {
-            return new DimensionsEditor(DimensionsType)
-            {
-                AllowEditingUnit = AllowEditingUnit
-            };
-        }
-    }
-}

+ 1 - 1
InABox.Core/ICoreRow.cs

@@ -16,7 +16,7 @@ namespace InABox.Core
         TType Get<TSource, TType>(Expression<Func<TSource, TType>> expression, bool usedefault = true);
         void Set<T>(string columnname, T value);
         void Set<TSource, TType>(Expression<Func<TSource, TType>> expression, TType value);
-        Dictionary<string, object> ToDictionary(string[] exclude);
+        Dictionary<string, object?> ToDictionary(string[] exclude);
         BaseObject ToObject(Type t);
         T ToObject<T>() where T : BaseObject, new();
     }

+ 1 - 5
inabox.wpf/DynamicGrid/DynamicEditorGrid.xaml.cs

@@ -193,11 +193,7 @@ namespace InABox.DynamicGrid
 
             public void AddEditor(string columnName, BaseEditor editor)
             {
-                BaseDynamicEditorControl? element = editor switch
-                {
-                    DimensionsEditor dimensions => DimensionsEditorControl.Create(dimensions),
-                    _ => DynamicEditorControlFactory.CreateControl(editor, EditorGrid)
-                };
+                BaseDynamicEditorControl? element = DynamicEditorControlFactory.CreateControl(editor, EditorGrid);
                 
                 if (element != null)
                 {

+ 0 - 262
inabox.wpf/DynamicGrid/Editors/DimensionsEditor/DimensionsEditorControl.cs

@@ -1,262 +0,0 @@
-using InABox.Clients;
-using InABox.Core;
-using Syncfusion.Windows.Shared;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Media;
-
-namespace InABox.DynamicGrid
-{
-    public class DimensionsEditorControl
-    {
-        
-        public static BaseDynamicEditorControl? Create(DimensionsEditor editor)
-        {
-            var dimensionsType = editor.DimensionsType;
-            var dimensions = dimensionsType.GetSuperclassDefinition(typeof(Dimensions<,>));
-            if (dimensions == null) return null;
-
-            var tLink = dimensions.GenericTypeArguments[0];
-            var tUnit = dimensions.GenericTypeArguments[1];
-
-            return Activator.CreateInstance(typeof(DimensionsEditorControl<,,>).MakeGenericType(dimensionsType, tLink, tUnit), editor) as BaseDynamicEditorControl;
-        }
-    }
-
-    public class DimensionsEditorControl<TDimensions, TLink, TUnit> : DynamicEnclosedEditorControl<TDimensions, DimensionsEditor>
-        where TDimensions : Dimensions<TLink, TUnit>, new()
-        where TLink : DimensionUnitLink<TUnit>, new()
-        where TUnit : DimensionUnit, new()
-    {
-
-        private Grid Grid;
-        private ComboBox Combo;
-
-        private DoubleTextBox Quantity;
-        private DoubleTextBox Length;
-        private DoubleTextBox Width;
-        private DoubleTextBox Height;
-        private DoubleTextBox Weight;
-
-        private List<Tuple<string, TUnit>> Units;
-
-        private DimensionsEditor Editor;
-
-        public DimensionsEditorControl(DimensionsEditor editor)
-        {
-            Editor = editor;
-        }
-
-        public override int DesiredHeight()
-        {
-            return 25;
-        }
-
-        public override int DesiredWidth()
-        {
-            return int.MaxValue;
-        }
-
-        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);
-        }
-
-        public override void SetFocus()
-        {
-            Combo.Focus();
-        }
-
-        public override void Configure()
-        {
-        }
-
-        protected override FrameworkElement CreateEditor()
-        {
-            Grid = new Grid
-            {
-                VerticalAlignment = VerticalAlignment.Stretch,
-                HorizontalAlignment = HorizontalAlignment.Stretch
-            };
-            Grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(150, GridUnitType.Pixel) });
-
-            Combo = new ComboBox
-            {
-                IsEnabled = Editor.AllowEditingUnit
-            };
-            Combo.SetValue(Grid.ColumnProperty, 0);
-            Combo.SetValue(Grid.RowProperty, 0);
-
-            Grid.Children.Add(Combo);
-
-            var result = new Client<TUnit>()
-                .Query(
-                    LookupFactory.DefineFilter<TUnit>(),
-                    LookupFactory.DefineColumns<TUnit>(),
-                    LookupFactory.DefineSort<TUnit>());
-
-            Units = result.Rows.Select(row =>
-            {
-                var values = row.ToDictionary(new[] { "Display" });
-                var display = LookupFactory.FormatLookup(typeof(TUnit), values, Array.Empty<string>());
-                return new Tuple<string, TUnit>(display, row.ToObject<TUnit>());
-            }).ToList();
-
-            Combo.DisplayMemberPath = "Item1";
-            Combo.SelectedValuePath = "Item2.ID";
-            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);
-
-            return Grid;
-        }
-
-        private void UpdateColumn(int column, bool visible, DoubleTextBox box)
-        {
-            if (!visible)
-            {
-                box.Value = 0.0;
-            }
-
-            var columnDefinition = Grid.ColumnDefinitions[column * 2];
-            if (visible)
-            {
-                columnDefinition.Width = new GridLength(1, GridUnitType.Star);
-            }
-            else
-            {
-                columnDefinition.Width = new GridLength(0);
-            }
-            columnDefinition = Grid.ColumnDefinitions[column * 2 - 1];
-            if (visible)
-            {
-                columnDefinition.Width = GridLength.Auto;
-            }
-            else
-            {
-                columnDefinition.Width = new GridLength(0);
-            }
-        }
-
-        private DoubleTextBox AddDimension(string name, int column)
-        {
-            Grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(0) });
-            Grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(0) });
-
-            var label = new Label
-            {
-                Content = name,
-                VerticalAlignment = VerticalAlignment.Center,
-                VerticalContentAlignment = VerticalAlignment.Center,
-                Margin = new Thickness(5, 0, 0, 0)
-            };
-            label.SetValue(Grid.ColumnProperty, column * 2 - 1);
-
-            var box = new DoubleTextBox
-            {
-                VerticalAlignment = VerticalAlignment.Stretch,
-                VerticalContentAlignment = VerticalAlignment.Center,
-                HorizontalAlignment = HorizontalAlignment.Stretch,
-                HorizontalContentAlignment = HorizontalAlignment.Center,
-                NumberDecimalDigits = 2,
-                Margin = new Thickness(5, 0, 0, 0)
-            };
-            box.SetValue(Grid.ColumnProperty, column * 2);
-            box.ValueChanged += Box_ValueChanged;
-
-            Grid.Children.Add(label);
-            Grid.Children.Add(box);
-
-            return box;
-        }
-
-        private void Box_ValueChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
-        {
-            CheckChanged();
-        }
-
-        private void Combo_SelectionChanged(object sender, SelectionChangedEventArgs e)
-        {
-            if (Combo.SelectedValue is not Guid unitID) return;
-            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);
-
-            foreach(var property in DatabaseSchema.Properties(typeof(TUnit)))
-            {
-                var value = property.Getter()(unit);
-                OtherValues[$"{ColumnName}.Unit.{property.Name}"] = value;
-            }
-
-            CheckChanged();
-        }
-
-        public override object? GetValue(string property)
-        {
-            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 == "Unit.ID") return Combo.SelectedValue is Guid guid ? guid : Guid.Empty;
-
-            return null;
-        }
-        public override Dictionary<string, object?> GetValues()
-        {
-            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}.Unit.ID", Combo.SelectedValue is Guid guid ? guid : Guid.Empty }
-            };
-            return values;
-        }
-
-        public override void SetValue(string property, object? value)
-        {
-            if (!property.StartsWith($"{ColumnName}.")) return;
-            property = property[(ColumnName.Length + 1)..];
-
-            if (value is null) return;
-
-            if (property == "Unit.ID")
-            {
-                Combo.SelectedValue = value is Guid guid ? guid : Guid.Empty;
-                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;
-        }
-
-    }
-}