Beispiel #1
0
        private void AddPlanetButton_Click(object sender, EventArgs e)
        {
            try
            {
                string _namePlanet = FormsUtils.Enter("Укажите название планеты", "Информация планеты");
                int    _massPlanet = Convert.ToInt32(FormsUtils.Enter("Укажите массу планеты", "Информация планеты"));
                int    _period     = Convert.ToInt32(FormsUtils.Enter("Укажите период вращения планеты", "Информация планеты"));
                int    _count      = Convert.ToInt32(FormsUtils.Enter("Укажите кол-во спутников планеты", "Информация планеты"));


                string SatelliteInf = null;


                if (_count > 0)
                {
                    for (int i = 0; i < _count; i++)
                    {
                        string _nameSatellite = FormsUtils.Enter("Укажите название спутника", "Информация спутника");
                        string _massSatellite = FormsUtils.Enter("Укажите массу спутника", "Информация спутника");
                        string _People        = FormsUtils.Enter("Укажите открываателя", "Информация спутника");
                        string _Year          = FormsUtils.Enter("Укажите год открытия", "Информация спутника");

                        SatelliteInf += " " + _nameSatellite + " " + _massSatellite + " " + _People + " " + _Year;
                    }
                }

                SpaceObjects.AddPlanet(_massPlanet, _namePlanet, _count, _period, SatelliteInf);
            }
            catch
            {
                FormsUtils.ErrorMessageBox("Error");
            }
        }
Beispiel #2
0
 private void CountPlanetButton_Click(object sender, EventArgs e)
 {
     try
     {
         string count = Convert.ToString(SpaceObjects.CountPlanets());
         FormsUtils.ShowMessage(count);
     }
     catch
     {
         FormsUtils.ErrorMessageBox("Error");
     }
 }
Beispiel #3
0
 private void AddStarButton_Click(object sender, EventArgs e)
 {
     try
     {
         string _nameStar = FormsUtils.Enter("Укажите название звезды", "Информация звезды");
         int    _massStar = Convert.ToInt32(FormsUtils.Enter("Укажите массу звезды", "Информация звезды"));
         SpaceObjects.AddStar(_massStar, _nameStar);
     }
     catch
     {
         FormsUtils.ErrorMessageBox("Error");
     }
 }
Beispiel #4
0
 private void Go_Click(object sender, EventArgs e)
 {
     try
     {
         int[,] arr2 = DataGridViewUtils.GridToArray2 <int>(arr2FromDataGridView);
         Nine logic = new Nine(arr2);
         DataGridViewUtils.ArrayToGrid(arr2ToDataGridView, logic.Process());
     }
     catch (Exception except)
     {
         FormsUtils.ErrorMessageBox(except);
     }
 }
 private void FileChooseButton_Click(object sender, EventArgs e)
 {
     if (openFileDialog.ShowDialog() == DialogResult.OK)
     {
         try
         {
             Logic.ReadFile(openFileDialog.FileName, stack);
         }
         catch (Exception except)
         {
             FormsUtils.ErrorMessageBox(except);
         }
     }
 }
Beispiel #6
0
 private void ReadButton_Click(object sender, EventArgs e)
 {
     if (inputOpenFileDialog.ShowDialog() == DialogResult.OK)
     {
         try
         {
             io.Text = io.ReadFromFile(inputOpenFileDialog.FileName);
             DataGridViewUtils.ArrayToGrid(InDGV, io.Text);
         }
         catch (Exception except)
         {
             FormsUtils.ErrorMessageBox(except);
         }
     }
 }
 private void inputButton_Click(object sender, EventArgs e)
 {
     if (openFileDialog.ShowDialog() == DialogResult.OK)
     {
         try
         {
             Logic.ReadFile(openFileDialog.FileName, list);
         }
         catch (Exception except)
         {
             FormsUtils.ErrorMessageBox(except);
         }
     }
     PrintListToListTextBox();
 }
 private void RunButton_Click(object sender, EventArgs e)
 {
     if (saveFileDialog.ShowDialog() == DialogResult.OK)
     {
         try
         {
             saveFileDialog.InitialDirectory = Path.GetDirectoryName(saveFileDialog.FileName);
             Logic.WriteFile(saveFileDialog.FileName, stack);
         }
         catch (Exception except)
         {
             FormsUtils.ErrorMessageBox(except);
         }
     }
 }
Beispiel #9
0
 private void SerializeButton_Click(object sender, EventArgs e)
 {
     if (inputOpenFileDialog.ShowDialog() == DialogResult.OK)
     {
         try
         {
             inputOpenFileDialog.InitialDirectory = Path.GetDirectoryName(inputOpenFileDialog.FileName);
             io.WriteForSerialization(inputOpenFileDialog.FileName);
         }
         catch (Exception except)
         {
             FormsUtils.ErrorMessageBox(except);
         }
     }
 }
Beispiel #10
0
 private void Info_btn_Click(object sender, EventArgs e)
 {
     try
     {
         InfoTextBox.Text = "";
         string[] phonesInfo = phones.PrintInfo();
         for (int i = 0; i < phonesInfo.Length; i++)
         {
             InfoTextBox.AppendText(phonesInfo[i]);
         }
     }
     catch
     {
         FormsUtils.ErrorMessageBox("Error");
     }
 }
Beispiel #11
0
 private void RandomButton_Click(object sender, EventArgs e)
 {
     if (outputSaveFileDialog.ShowDialog() == DialogResult.OK)
     {
         try
         {
             outputSaveFileDialog.InitialDirectory = Path.GetDirectoryName(outputSaveFileDialog.FileName);
             int size = Convert.ToInt32(SizeBox.Text);
             io.WriteToFile(outputSaveFileDialog.FileName, size);
         }
         catch (Exception except)
         {
             FormsUtils.ErrorMessageBox(except);
         }
     }
 }
Beispiel #12
0
 private void NameStarButton_Click(object sender, EventArgs e)
 {
     try
     {
         InfoTextBox.Text = "";
         string[] name = SpaceObjects.PrintNameStars();
         for (int i = 0; i < name.Length; i++)
         {
             InfoTextBox.AppendText(name[i]);
         }
     }
     catch
     {
         FormsUtils.ErrorMessageBox("Error");
     }
 }
Beispiel #13
0
 private void FileButton_Click(object sender, EventArgs e)
 {
     if (inputOpenFileDialog.ShowDialog() == DialogResult.OK)
     {
         try
         {
             inputOpenFileDialog.InitialDirectory = Path.GetDirectoryName(inputOpenFileDialog.FileName);
             mv.numbers = io.ReadFromFile(inputOpenFileDialog.FileName, mv.numbers);
         }
         catch (Exception except)
         {
             FormsUtils.ErrorMessageBox(except);
         }
     }
     FileBox.Text = io.Text;
 }
Beispiel #14
0
 private void Go_Click(object sender, EventArgs e)
 {
     try
     {
         int[,] arr2 = DataGridViewUtils.GridToArray2 <int>(arr2FromDataGridView);
         Nine logic = new Nine(arr2);
         logic.Process2(out int[,] res, out int resmin);
         DataGridViewUtils.ArrayToGrid(arr2ToDataGridView, res);
         labelres.Text = resmin.ToString();
         label3.Show();
     }
     catch (Exception except)
     {
         FormsUtils.ErrorMessageBox(except);
     }
 }
Beispiel #15
0
 private void PlanetsInfoButton_Click(object sender, EventArgs e)
 {
     try
     {
         InfoTextBox.Text = "";
         string[] planetsInfo = SpaceObjects.PrintInfoPlanets();
         for (int i = 0; i < planetsInfo.Length; i++)
         {
             InfoTextBox.AppendText(planetsInfo[i]);
         }
     }
     catch
     {
         FormsUtils.ErrorMessageBox("Error");
     }
 }
Beispiel #16
0
        private void inputToFileButton_Click(object sender, EventArgs e)
        {
            if (inputSaveFileDialog.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    inputSaveFileDialog.InitialDirectory = Path.GetDirectoryName(inputSaveFileDialog.FileName);

                    int[,] input = DataGridViewUtils.GridToArray2 <int>(arr2FromDataGridView);
                    UtilsW.WriteInputIntoFile(inputSaveFileDialog.FileName, input);
                }
                catch (Exception except)
                {
                    FormsUtils.ErrorMessageBox(except);
                }
            }
        }
Beispiel #17
0
        private void inputFromFileButton_Click(object sender, EventArgs e)
        {
            if (inputOpenFileDialog.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    inputOpenFileDialog.InitialDirectory = Path.GetDirectoryName(inputOpenFileDialog.FileName);

                    int[,] input;
                    UtilsW.ReadInputFromFile(inputOpenFileDialog.FileName, ' ', out input);
                    DataGridViewUtils.ArrayToGrid(arr2FromDataGridView, input);
                }
                catch (Exception except)
                {
                    FormsUtils.ErrorMessageBox(except);
                }
            }
        }
Beispiel #18
0
        private void outputToFileButton_Click(object sender, EventArgs e)
        {
            if (outputSaveFileDialog.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    outputSaveFileDialog.InitialDirectory = Path.GetDirectoryName(outputSaveFileDialog.FileName);
                    int[,] output = DataGridViewUtils.GridToArray2 <int>(arr2ToDataGridView);
                    UtilsW.WriteInputIntoFile(outputSaveFileDialog.FileName, output);

                    /*IList<int> output = DataGridViewUtils.GridToList<int>(arr2ToDataGridView);
                     * Nine.WriteOutputIntoFile(outputSaveFileDialog.FileName, output);
                     */
                }
                catch (Exception except)
                {
                    FormsUtils.ErrorMessageBox(except);
                }
            }
        }
Beispiel #19
0
        private void Add_btn_Click(object sender, EventArgs e)
        {
            string mark     = FormsUtils.Enter("Укажите марку телефона", "Информация о телефоне");
            string model    = FormsUtils.Enter("Укажите модель телефона", "Информация о телефоне");
            int    price    = Convert.ToInt32(FormsUtils.Enter("Укажите цену телефона", "Информация о телефоне"));
            int    memory   = Convert.ToInt32(FormsUtils.Enter("Укажите память телефона (Гб)", "Информация о телефоне"));
            int    countSIM = Convert.ToInt32(FormsUtils.Enter("Укажите кол-во SIM телефона", "Информация о телефоне"));


            if (countSIM < 2 && countSIM > -1)
            {
                MobilePhone phone = new MobilePhone(mark, model, price, memory);
                phones.AddMobilePhone(phone, null);
            }
            else if (countSIM >= 2)
            {
                PhoneModify phone = new PhoneModify(mark, model, price, memory, countSIM);
                phones.AddMobilePhone(null, phone);
            }
            else
            {
                FormsUtils.ErrorMessageBox("Некорректное значение");
            }
        }