using StructureHelper.Windows.Forces;
using StructureHelper.Windows.ViewModels;
using StructureHelperCommon.Models.Forces;

namespace StructureHelper.Windows.BeamShears
{
    public class ConcentratedForceViewModel : OkCancelViewModelBase
    {
        private readonly IConcentratedForce concenratedForce;
        public string Name
        {
            get => concenratedForce.Name;
            set
            {
                concenratedForce.Name = value;
            }
        }
        public double ForceCoordinate
        {
            get => concenratedForce.ForceCoordinate;
            set
            {
                concenratedForce.ForceCoordinate = value;
            }
        }
        public double ForceValue
        {
            get => concenratedForce.ForceValue.Qy;
            set
            {
                concenratedForce.ForceValue.Qy = value;
            }
        }
        public double LoadRatio
        {
            get => concenratedForce.LoadRatio;
            set
            {
                concenratedForce.LoadRatio = value;
            }
        }
        public double RelativeLevel
        {
            get => concenratedForce.RelativeLoadLevel;
            set
            {
                if (value > 0.5d)
                {
                    concenratedForce.RelativeLoadLevel = 0.5;
                    return;
                }
                if (value < -0.5d)
                {
                    concenratedForce.RelativeLoadLevel = -0.5;
                    return;
                }
                concenratedForce.RelativeLoadLevel = value;
            }
        }

        public FactoredCombinationPropertyVM CombinationProperty { get; }

        public ConcentratedForceViewModel(IConcentratedForce concenratedForce)
        {
            this.concenratedForce = concenratedForce;
            CombinationProperty = new(this.concenratedForce.CombinationProperty);
        }
    }
}
