public ActionResult Choosen(bool withResistance) { SessionStore session = GetSession(); if (session.IsSavedProjectileMotion() && withResistance) { session.SaveProjectileMotion(null); } else if (session.IsSavedProjectileMotionWithResistance() && !withResistance) { session.SaveProjectileMotionWithResistance(null); } return(RedirectToAction("Properties", "Set", new { setWithResistance = withResistance })); }
public ActionResult Properties(bool?setWithResistance = null) { SetPropertiesModel viewModel = new SetPropertiesModel() { Layout = new LayoutModel("Set properties"), Quantities = new SetPropertiesQuantitiesModel() { InitialVelocity = 15.0, InitialHeight = 0, ElevationAngle = Math.PI / 4.0, GravAcceleration = GravAcceleration.GetGravAccelerationValue(GravAcceleration.GravAccelerations.Earth), FrontalArea = Math.Pow(new Length(12.9, UnitLength.Centimetre).GetBasicVal(), 2.0) * Math.PI, DragCoefficient = DragCoefficient.GetDragCoefficientValue(DragCoefficient.DragCoefficients.Sphere), Mass = 0.5, Density = Density.GetDensityValue(Density.Densities.Air), WithResistance = setWithResistance ?? false, }, RoundDigits = 6, PointsForTrajectory = 80, ShowMotionWithoutResistanceTrajectoryToo = false }; viewModel.HexColorOfTrajectory = viewModel.Quantities.WithResistance ? "#007bff" : "#6c757d"; SessionStore session = GetSession(); if (session.IsSavedProjectileMotionWithResistance()) { ProjectileMotionWithResistance savedMotion = session.GetSavedProjectileMotionWithResistance(); viewModel.Quantities.InitialVelocity = savedMotion.Settings.Quantities.V.Val; viewModel.Quantities.InitialHeight = savedMotion.Settings.Quantities.H.Val; viewModel.Quantities.ElevationAngle = savedMotion.Settings.Quantities.Α.Val; viewModel.Quantities.GravAcceleration = savedMotion.Settings.Quantities.G.Val; viewModel.Quantities.FrontalArea = savedMotion.Settings.Quantities.A.Val; viewModel.Quantities.DragCoefficient = savedMotion.Settings.Quantities.C.Val; viewModel.Quantities.Mass = savedMotion.Settings.Quantities.M.Val; viewModel.Quantities.Density = savedMotion.Settings.Quantities.Ρ.Val; viewModel.RoundDigits = savedMotion.Settings.RoundDigits; viewModel.Quantities.WithResistance = true; viewModel.PointsForTrajectory = savedMotion.Settings.PointsForTrajectory; viewModel.Quantities.InitialVelocityUnit = savedMotion.Settings.Quantities.V.Unit.Name; viewModel.Quantities.InitialHeightUnit = savedMotion.Settings.Quantities.H.Unit.Name; viewModel.Quantities.ElevationAngleUnit = savedMotion.Settings.Quantities.Α.Unit.Name; viewModel.Quantities.GravAccelerationUnit = savedMotion.Settings.Quantities.G.Unit.Name; viewModel.Quantities.FrontalAreaUnit = savedMotion.Settings.Quantities.A.Unit.Name; viewModel.Quantities.MassUnit = savedMotion.Settings.Quantities.M.Unit.Name; viewModel.Quantities.DensityUnit = savedMotion.Settings.Quantities.Ρ.Unit.Name; viewModel.ResultUnitAngle = savedMotion.Settings.Quantities.Units.Angle.Name; viewModel.ResultUnitArea = savedMotion.Settings.Quantities.Units.Area.Name; viewModel.ResultUnitGravAcceleration = savedMotion.Settings.Quantities.Units.GravAcceleration.Name; viewModel.ResultUnitLength = savedMotion.Settings.Quantities.Units.Length.Name; viewModel.ResultUnitTime = savedMotion.Settings.Quantities.Units.Time.Name; viewModel.ResultUnitVelocity = savedMotion.Settings.Quantities.Units.Velocity.Name; viewModel.TxtInfoFileName = savedMotion.Settings.TxtInfoFileName; viewModel.CsvDataFileName = savedMotion.Settings.CsvDataFileName; viewModel.PdfInfoFileName = savedMotion.Settings.PdfInfoFileName; viewModel.ChartFileName = savedMotion.Settings.ChartFileName; viewModel.HexColorOfTrajectory = savedMotion.Settings.HexColorOfTrajectory; viewModel.ShowMotionWithoutResistanceTrajectoryToo = savedMotion.Settings.ShowMotionWithoutResistanceTrajectoryToo; viewModel.Layout.Title = "Edit properties"; } else if (session.IsSavedProjectileMotion()) { ProjectileMotion savedMotion = session.GetSavedProjectileMotion(); viewModel.Quantities.InitialVelocity = savedMotion.Settings.Quantities.V.Val; viewModel.Quantities.InitialHeight = savedMotion.Settings.Quantities.H.Val; viewModel.Quantities.ElevationAngle = savedMotion.Settings.Quantities.Α.Val; viewModel.Quantities.GravAcceleration = savedMotion.Settings.Quantities.G.Val; viewModel.Quantities.WithResistance = false; viewModel.RoundDigits = savedMotion.Settings.RoundDigits; viewModel.PointsForTrajectory = savedMotion.Settings.PointsForTrajectory; viewModel.Quantities.InitialVelocityUnit = savedMotion.Settings.Quantities.V.Unit.Name; viewModel.Quantities.InitialHeightUnit = savedMotion.Settings.Quantities.H.Unit.Name; viewModel.Quantities.ElevationAngleUnit = savedMotion.Settings.Quantities.Α.Unit.Name; viewModel.Quantities.GravAccelerationUnit = savedMotion.Settings.Quantities.G.Unit.Name; viewModel.Quantities.Length = savedMotion.GetLength().Val; viewModel.Quantities.LengthUnit = savedMotion.GetLength().Unit.Name; viewModel.Quantities.MaxHeight = savedMotion.GetMaxHeight().Val; viewModel.Quantities.MaxHeightUnit = savedMotion.GetMaxHeight().Unit.Name; viewModel.Quantities.Duration = savedMotion.GetDur().Val; viewModel.Quantities.DurationUnit = savedMotion.GetDur().Unit.Name; viewModel.ResultUnitAngle = savedMotion.Settings.Quantities.Units.Angle.Name; viewModel.ResultUnitArea = savedMotion.Settings.Quantities.Units.Area.Name; viewModel.ResultUnitGravAcceleration = savedMotion.Settings.Quantities.Units.GravAcceleration.Name; viewModel.ResultUnitLength = savedMotion.Settings.Quantities.Units.Length.Name; viewModel.ResultUnitTime = savedMotion.Settings.Quantities.Units.Time.Name; viewModel.ResultUnitVelocity = savedMotion.Settings.Quantities.Units.Velocity.Name; viewModel.TxtInfoFileName = savedMotion.Settings.TxtInfoFileName; viewModel.CsvDataFileName = savedMotion.Settings.CsvDataFileName; viewModel.PdfInfoFileName = savedMotion.Settings.PdfInfoFileName; viewModel.ChartFileName = savedMotion.Settings.ChartFileName; viewModel.HexColorOfTrajectory = savedMotion.Settings.HexColorOfTrajectory; viewModel.ShowMotionWithoutResistanceTrajectoryToo = false; viewModel.Quantities.SelectedAssignmentType = savedMotion.Settings.Quantities.UsedAssignmentType; viewModel.Layout.Title = "Edit properties"; } else if (setWithResistance == null) { return(RedirectToAction(nameof(ChooseController.Neglection), "Choose")); } viewModel.Layout.Menu.SetWithResistance = viewModel.Quantities.WithResistance; viewModel.Layout.Menu.ActiveMenuItem = LayoutMenuModel.ActiveNavItem.Set; return(View(viewModel)); }