예제 #1
0
        /// <summary>
        /// Клик по кнопке "построить"
        /// </summary>
        /// <param name="sender">Объект, вызвавший событие</param>
        /// <param name="e">Параметры события</param>
        private void BuildButton_Click(object sender, EventArgs e)
        {
            ShimSettings shimSettings = null;

            shimSettings = InitializeShimSettings(shimSettings);

            if (shimSettings != null)
            {
                _kompasWrapper.StartKompas();
                _kompasWrapper.BuildShim(shimSettings);
            }
        }
예제 #2
0
        /// <summary>
        /// Обработчик кнопки "Построить деталь"
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void BuildButton_Click(object sender, EventArgs e)
        {
            try
            {
                Bushing bushing = null;

                double newTotalLength     = double.Parse(TotalLengthTextBox.Text);
                double newTopLength       = double.Parse(TopLengthTextBox.Text);
                double newTopDiametr      = double.Parse(TopDiametrTextBox.Text);
                double newOuterDiametr    = double.Parse(OuterDiametrTextBox.Text);
                double newInnerDiametr    = double.Parse(InnerDiametrTextBox.Text);
                int    newNumberHoles     = int.Parse(NumberHolesTextBox.Text);
                double newHolesDiametr    = double.Parse(HolesDiametrTextBox.Text);
                double newLocationDiametr = double.Parse(LocationDiametrTextBox.Text);

                if (EngravingCheckBox.Checked)
                {
                    string newEngravingText = Convert.ToString(EngravingTextBox.Text);
                    bushing = new Bushing(newTotalLength, newTopLength,
                                          newTopDiametr, newOuterDiametr, newInnerDiametr,
                                          newNumberHoles, newHolesDiametr, newLocationDiametr,
                                          newEngravingText);
                }
                else
                {
                    bushing = new Bushing(newTotalLength, newTopLength,
                                          newTopDiametr, newOuterDiametr, newInnerDiametr,
                                          newNumberHoles, newHolesDiametr, newLocationDiametr);
                }

                if (bushing._listError.Count > 0)
                {
                    ShowError(bushing._listError);
                }
                else
                {
                    _kompasWrapper.StartKompas();
                    _kompasWrapper.BuildBushing(bushing);
                }
            }
            catch
            {
                MessageBox.Show("Невозможно построить деталь!", "Ошибка",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
예제 #3
0
        /// <summary>
        /// Кнопка построить деталь
        /// </summary>
        /// <param name="sender">Объект, вызвавший событие</param>
        /// <param name="e">Параметры события</param>
        private void BuildButton_Click(object sender, EventArgs e)
        {
            // Создадим конфетну форму

            CandySettings candySettings = null;

            try
            {
                int    candyCount        = Convert.ToInt32(CandyCountTextBox.Text);
                double formDepthByLength =
                    Convert.ToDouble(FormDepthByLengthTextBox.Text);
                double formDepthByWidth =
                    Convert.ToDouble(FormDepthByWidthTextBox.Text);
                double formDepthByHeight =
                    Convert.ToDouble(FormDepthByHeightTextBox.Text);

                candySettings = new CandySettings(candyCount,
                                                  formDepthByLength, formDepthByWidth, formDepthByHeight);
            }
            catch (CandyCountException exception)
            {
                ShowErrorMessage(CandyCountLabel, exception.Message);
            }
            catch (FormDepthByLengthException exception)
            {
                ShowErrorMessage(FormDepthByLengthLabel, exception.Message);
            }
            catch (FormDepthByWidthException exception)
            {
                ShowErrorMessage(FormDepthByWidthLabel, exception.Message);
            }
            catch (FormDepthByHeightException exception)
            {
                ShowErrorMessage(FormDepthByHeightLabel, exception.Message);
            }
            catch (FormatException)
            {
                ShowErrorMessage(null,
                                 "Невозможно построить деталь. "
                                 + "В параметрах допущена ошибка.");
            }

            // Создадим конфету

            CandyBase candy = null;

            try
            {
                switch (CandyType.SelectedIndex)
                {
                case 0:
                    candy = BuildRectCandy();
                    break;

                case 1:
                    candy = BuildSphereCandy();
                    break;

                case 2:
                    candy = BuildCylinderCandy();
                    break;
                }
            }
            catch (CandyHeightException exception)
            {
                ShowErrorMessage(RectCandyHeightLabel, exception.Message);
            }
            catch (CandyLengthException exception)
            {
                Label label = (CandyType.SelectedIndex == 0)
                    ? RectCandyLengthLabel : CylinderCandyLengthLabel;
                ShowErrorMessage(label, exception.Message);
            }
            catch (CandyRadiusException exception)
            {
                Label label = (CandyType.SelectedIndex == 1)
                    ? SphereCandyRadiusLabel : CylinderCandyRadiusLabel;
                ShowErrorMessage(label, exception.Message);
            }
            catch (CandyWidthException exception)
            {
                ShowErrorMessage(RectCandyWidthLabel, exception.Message);
            }
            catch (FormatException)
            {
                ShowErrorMessage(null,
                                 "Невозможно построить деталь. "
                                 + "В параметрах допущена ошибка.");
            }

            if (candySettings != null && candy != null)
            {
                _kompasWrapper.StartKompas();
                _kompasWrapper.BuildCandySettings(candySettings, candy);
            }
        }