Пример #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)!");
     }
 }
Пример #2
0
        /// <summary>
        /// Загрузка формы
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void SearchForm_Load(object sender, EventArgs e)
        {
            //TODO: Дублируется - решено
            StandartMethods.LoadDataGrid(
                DataFiguresGridView, _figuresFilter);

            FigureRadioButton.Checked = true;
        }
Пример #3
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)!");
                    }
                }
            }
        }
Пример #4
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!");
     }
 }
Пример #5
0
        /// <summary>
        /// Расширение формы при большом содержимом
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void RefreshButton_Click(object sender, EventArgs e)
        {
            //TODO: Дублируется - частично решено?

            StandartMethods.RefreshForm(CloseLabel, MinimazeLabel);

            var fallPoint = StandartMethods.FallPointsSearch(
                DataFiguresGridView);

            this.Width = 22 + fallPoint;
            DataFiguresGridView.Width = fallPoint;
            int buffer = SearchTextBox.Width;

            SearchTextBox.Width = fallPoint;
            SearchButton.Width  = SearchButton.Width +
                                  SearchTextBox.Width - buffer;

            CloseLabel.Location    = new Point(fallPoint - 3, 3);
            MinimazeLabel.Location = new Point(fallPoint - 33, 3);

            fallPoint = 0;
        }
Пример #6
0
        /// <summary>
        /// Расширение формы при большом содержимом
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void RefreshButton_Click(object sender, EventArgs e)
        {
            StandartMethods.RefreshForm(CloseLabel, MinimazeLabel);

            var fallPoint = StandartMethods.FallPointsSearch(
                DataFiguresGridView);

            this.Width = 22 + fallPoint;
            int buffer = DataFiguresGridView.Width;

            DataFiguresGridView.Width = fallPoint;
            SaveButton.Width          = SaveButton.Width +
                                        DataFiguresGridView.Width - buffer;
            LoadButton.Width = LoadButton.Width +
                               DataFiguresGridView.Width - buffer;


            CloseLabel.Location    = new Point(fallPoint - 3, 3);
            MinimazeLabel.Location = new Point(fallPoint - 33, 3);

            fallPoint = 0;
        }
Пример #7
0
 /// <summary>
 /// Загрузка формы
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void MainForm_Load(object sender, EventArgs e)
 {
     StandartMethods.LoadDataGrid(DataFiguresGridView, _figures);
 }