Esempio n. 1
0
        private void loadCalculationsButton_Click(object sender, EventArgs e)
        {
            if (calculationsComboBox.SelectedItem == null)
            {
                MessageBox.Show("You dind't choose any calculation to perform!");
                return;
            }

            CalculationsModel chosenCalculation = new CalculationsModel();

            chosenCalculation = (CalculationsModel)calculationsComboBox.SelectedItem;

            List <SolutionModel> solutions = new List <SolutionModel>();

            chosenCalculation.PrepareCalculationsSet(solutions);

            List <SolutionModel> results = new List <SolutionModel>();

            solutions.SelectSolutions(results);

            ResultsViewer frm = new ResultsViewer(results);

            frm.Show();
        }
        private void calculateButton_Click(object sender, EventArgs e)
        {
            if (!ValidateData())
            {
                return;
            }

            fixationPoints.Clear();

            calculation = new CalculationsModel();

            FixationPointModel fixationPointOne   = new FixationPointModel();
            FixationPointModel fixationPointTwo   = new FixationPointModel();
            FixationPointModel fixationPointThree = new FixationPointModel();
            FixationPointModel fixationPointFour  = new FixationPointModel()
            {
                Chosen = false
            };

            CompressorModel compressorModel = new CompressorModel();

            fixationPointOne.XPosition       = double.Parse(pointOnePositionXTextBox.Text);
            fixationPointOne.YPosition       = double.Parse(pointOnePositionYTextBox.Text);
            fixationPointOne.UpperSpringBool = upperSpringOneCheckBox.Checked;
            fixationPointOne.LowerSpringBool = lowerSpringOneChceckBox.Checked;
            fixationPointOne.Parts           = (PartSetModel)otherPartsSizeOneComboBox.SelectedItem;
            fixationPointOne.Chosen          = true;

            fixationPointTwo.XPosition       = double.Parse(pointTwoPositionXTextBox.Text);
            fixationPointTwo.YPosition       = double.Parse(pointTwoPositionYTextBox.Text);
            fixationPointTwo.UpperSpringBool = upperSpringTwoCheckBox.Checked;
            fixationPointTwo.LowerSpringBool = lowerSpringTwoChceckBox.Checked;
            fixationPointTwo.Parts           = (PartSetModel)otherPartsSizeTwoComboBox.SelectedItem;
            fixationPointTwo.Chosen          = true;


            fixationPointThree.XPosition       = double.Parse(pointThreePositionXTextBox.Text);
            fixationPointThree.YPosition       = double.Parse(pointThreePositionYTextBox.Text);
            fixationPointThree.UpperSpringBool = upperSpringThreeCheckBox.Checked;
            fixationPointThree.LowerSpringBool = lowerSpringThreeChceckBox.Checked;
            fixationPointThree.Parts           = (PartSetModel)otherPartsSizeTwoComboBox.SelectedItem;
            fixationPointThree.Chosen          = true;


            if (fourFixationPointsRadioButton.Checked == true)
            {
                fixationPointFour.XPosition       = double.Parse(pointFourPositionXTextBox.Text);
                fixationPointFour.YPosition       = double.Parse(pointFourPositionYTextBox.Text);
                fixationPointFour.UpperSpringBool = upperSpringFourCheckBox.Checked;
                fixationPointFour.LowerSpringBool = lowerSpringFourChceckBox.Checked;
                fixationPointFour.Parts           = (PartSetModel)otherPartsSizeTwoComboBox.SelectedItem;
                fixationPointFour.Chosen          = true;
            }

            compressorModel.Mass = double.Parse(compressorMassTextBox.Text);

            compressorModel.XCorrection = double.Parse(xCorrectionTextBox.Text);
            compressorModel.YCorrection = double.Parse(yCorrectionTextBox.Text);

            compressorModel.CogDistToPistX = double.Parse(cogDistToPistXTextBox.Text);
            compressorModel.CogDistToIzolZ = double.Parse(cogDistToIzolZTextBox.Text);

            fixationPoints.Add(fixationPointOne);
            fixationPoints.Add(fixationPointTwo);
            fixationPoints.Add(fixationPointThree);
            if (fourFixationPointsRadioButton.Checked == true)
            {
                fixationPoints.Add(fixationPointFour);
            }

            calculation.Name                = calculationNameTextBox.Text;
            calculation.Compressor          = compressorModel;
            calculation.Points              = fixationPoints;
            calculation.AllowedSpringNumber = int.Parse((string)allowedSpringNumberComboBox.SelectedItem);

            TextConnector.CreateCalculation(calculation);

            List <SolutionModel> solutions = new List <SolutionModel>();

            calculation.PrepareCalculationsSet(solutions);

            List <SolutionModel> results = new List <SolutionModel>();

            solutions.SelectSolutions(results);

            ResultsViewer frm = new ResultsViewer(results);

            frm.Show();
        }