Ejemplo n.º 1
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);
            }
        }