Ejemplo n.º 1
0
 /// <summary>
 /// Поиск по примерной площади
 /// </summary>
 private void StartSearchAreaApr()
 {
     try
     {
         foreach (var row in _figures)
         {
             if (row.FigureArea <
                     1.05 * Convert.ToDouble(SearchTextBox.Text)&
                     row.FigureArea>
                 0.95 * Convert.ToDouble(SearchTextBox.Text))
             {
                 _figuresFilter.Add(row);
             }
             if (Convert.ToDouble(SearchTextBox.Text) < 0)
             {
                 StandartMethods.GiveStandartMessageBox(
                     $"Enter non-negative decimal number!");
             }
         }
     }
     catch
     {
         StandartMethods.GiveStandartMessageBox(
             $"\nEnter decimal number (separator - comma)!");
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Загрузка листа
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void LoadButton_Click(object sender, EventArgs e)
        {
            using (OpenFileDialog openFileDialog = new OpenFileDialog())
            {
                //TODO: Вопрос с абсолютным путём - решено
                string path = Environment.GetFolderPath(
                    Environment.SpecialFolder.MyDocuments);
                openFileDialog.InitialDirectory = path;
                openFileDialog.Filter           = "figcalc files " +
                                                  "(*.figcalc)|*.figcalc|All files (*.*)|*.*";
                openFileDialog.FilterIndex      = 1;
                openFileDialog.RestoreDirectory = true;

                //TODO: мой, трайкетч сверху загрузки, вдруг файл поврежден - решено
                if (openFileDialog.ShowDialog() == DialogResult.OK)
                {
                    var formatter = new BinaryFormatter();
                    //TODO: Переписать на использование системной библиотеки - решено
                    var fileLoad = openFileDialog.FileName;

                    if (Path.GetExtension(fileLoad) == ".figcalc")
                    {
                        try
                        {
                            using (var fileStream = new FileStream(
                                       fileLoad, FileMode.OpenOrCreate))
                            {
                                var newFigures = (BindingList <IFigure>)
                                                 formatter.Deserialize(fileStream);

                                _figures.Clear();

                                foreach (var figure in newFigures)
                                {
                                    _figures.Add(figure);
                                }

                                GiveStandartPositiveMessageBox(
                                    "File loaded!");
                            }
                        }
                        catch
                        {
                            StandartMethods.GiveStandartMessageBox(
                                "File is corrupted, unable to load!");
                        }
                    }
                    else
                    {
                        StandartMethods.GiveStandartMessageBox(
                            "Incorrect file format (not *.figcalc)!");
                    }
                }
            }
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Поиск по фигуре
 /// </summary>
 private void StartSearchFigure()
 {
     try
     {
         foreach (var row in _figures)
         {
             if (row.NameFigure == SearchTextBox.Text)
             {
                 _figuresFilter.Add(row);
             }
         }
     }
     catch (Exception exception)
     {
         StandartMethods.GiveStandartMessageBox(
             $"{exception}\nEnter the string!");
     }
 }