Example #1
0
        private void ButtonExponentialSmoothingMethod_Click(object sender, RoutedEventArgs e)
        {
            if (AllDataTimeSeries.SelectedRow == -1)
            {
                WindowError windowError = new WindowError("Данные не выбраны");
                windowError.Show();
                return;
            }

            double a;

            try
            {
                a = Convert.ToDouble(SmoothingIntervalExp.Text);
            }
            catch
            {
                WindowError windowError = new WindowError("Некорректно задан параметр, диапазон от 0 до 1");
                windowError.Show();
                return;
            }

            if (a < 0 || a > 1)
            {
                WindowError windowError = new WindowError("Некорректно задан параметр, диапазон от 0 до 1");
                windowError.Show();
                return;
            }

            WindowGraphicView windowTest = new WindowGraphicView(AllDataTimeSeries.ExponentialSmoothingMethod(a), AllDataTimeSeries.ListTimeSeries[AllDataTimeSeries.SelectedRow].GetColor());

            windowTest.Show();
        }
Example #2
0
        private void ButtonMethodLeastSquares_Click(object sender, RoutedEventArgs e)
        {
            if (AllDataTimeSeries.SelectedRow == -1 || QuantityPredictLeastSquares.Text == "")
            {
                WindowError windowError = new WindowError("Данные не выбраны");
                windowError.Show();
                return;
            }

            int m;

            try
            {
                m = Convert.ToInt32(QuantityPredictLeastSquares.Text);
            }
            catch
            {
                WindowError windowError = new WindowError("Неудалось распознать значение (требуется int)");
                windowError.Show();
                return;
            }

            if (m < 0)
            {
                WindowError windowError = new WindowError("Количество предсказываемых значений \nдолжно быть не отрицательным");
                windowError.Show();
                return;
            }
            bool flag = TypeMethodLeastSquares.IsChecked.GetValueOrDefault();
            WindowGraphicView windowTest = new WindowGraphicView(AllDataTimeSeries.LeastSquareMethod(m, flag), AllDataTimeSeries.ListTimeSeries[AllDataTimeSeries.SelectedRow].GetColor());

            windowTest.Show();
        }
Example #3
0
        private void ButtonFFT_Click(object sender, RoutedEventArgs e)
        {
            if (AllDataTimeSeries.SelectedRow == -1)
            {
                WindowError windowError = new WindowError("Данные не выбраны");
                windowError.Show();
                return;
            }

            WindowGraphicView windowTest = new WindowGraphicView(AllDataTimeSeries.FFT(), AllDataTimeSeries.ListTimeSeries[AllDataTimeSeries.SelectedRow].GetColor());

            windowTest.Show();
        }
Example #4
0
        private void ButtonAutocorrelation_Click(object sender, RoutedEventArgs e)
        {
            if (AllDataTimeSeries.SelectedRow == -1)
            {
                WindowError windowError = new WindowError("Данные не выбраны");
                windowError.Show();
                return;
            }
            //добавить создание нового ряда
            WindowGraphicView windowTest = new WindowGraphicView(AllDataTimeSeries.Autocorrelation(), AllDataTimeSeries.ListTimeSeries[AllDataTimeSeries.SelectedRow].GetColor());

            windowTest.Show();
        }
Example #5
0
        private void ButtonDeleteSelectedRow(object sender, RoutedEventArgs e)
        {
            if (AllDataTimeSeries.SelectedRow == -1)
            {
                WindowError windowError = new WindowError("Не выбран временной ряд");
                windowError.Show();
                return;
            }

            AllDataTimeSeries.ListTimeSeries.RemoveAt(AllDataTimeSeries.SelectedRow);
            AllDataTimeSeries.SelectedRow = -1;
            test_1.Text = "";
            this.ButtonUpdate_Click(sender, e);
        }
Example #6
0
        private void TableView_Click(object sender, RoutedEventArgs e)
        {
            if (AllDataTimeSeries.SelectedRow == -1)
            {
                WindowError windowError = new WindowError("Данные не выбраны");
                windowError.Show();
                return;
            }

            TimeSeries temp = new TimeSeries();

            temp.Set_flag_sequence(AllDataTimeSeries.ListTimeSeries[AllDataTimeSeries.SelectedRow].Get_flag_sequence());
            temp.SetNameTimeSeries(AllDataTimeSeries.ListTimeSeries[AllDataTimeSeries.SelectedRow].GetNameTimeSeries());
            temp.SetColor(AllDataTimeSeries.ListTimeSeries[AllDataTimeSeries.SelectedRow].GetColor());

            List <Dimension> dimensions = AllDataTimeSeries.ListTimeSeries[AllDataTimeSeries.SelectedRow].GetTimeSeries();

            for (int i = 0; i < dimensions.Count(); i++)
            {
                temp.AddDimensionTime(dimensions[i].Time, dimensions[i].Value);
            }


            if (GivenTime.IsChecked == true)
            {
                try
                {
                    if (temp.Get_flag_sequence() == true)
                    {
                        temp.LimitDate(new DateTime(int.Parse(StartDate.Text), 1, 1), new DateTime(int.Parse(EndDate.Text), 1, 1));
                    }
                    else
                    {
                        temp.LimitDate(DateTime.Parse(StartDate.Text), DateTime.Parse(EndDate.Text));
                    }
                }
                catch
                {
                    WindowError windowError = new WindowError("Некорректно задана дата");
                    windowError.Show();
                    return;
                }
            }

            WindowTableView window = new WindowTableView(temp.GetTimeSeries());

            window.Show();
        }
        public void Parcer(OptionsParcerDataTable options)
        {
            timeSeries_.ClearTimeSeries();

            Microsoft.Office.Interop.Excel.Application ObjExcel    = new Microsoft.Office.Interop.Excel.Application();
            Microsoft.Office.Interop.Excel.Workbook    ObjWorkbook = ObjExcel.Workbooks.Open(FileName, 0, false, 5, "", "", false, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "", true, false, 0, true, false, false);;
            Microsoft.Office.Interop.Excel.Worksheet   ObjWorkSheet;
            ObjWorkSheet = ObjWorkbook.Sheets[options.Get_number_list()];

            for (int i = options.number_line_start_information; i <= options.number_line_end_information; i++)
            {
                Microsoft.Office.Interop.Excel.Range range_time  = ObjWorkSheet.get_Range(options.Get_name_column_time() + i.ToString(), options.Get_name_column_time() + i.ToString());
                Microsoft.Office.Interop.Excel.Range range_value = ObjWorkSheet.get_Range(options.Get_name_column_value() + i.ToString(), options.Get_name_column_value() + i.ToString());

                if (range_time.Text.ToString() == "" || range_value.Text.ToString() == "")
                {
                    //обнаружена пустая клетка
                    ObjExcel.Quit();
                    WindowError windowError = new WindowError("В файле присутствуют пустые поля");
                    windowError.Show();
                    return;
                }

                timeSeries_.Set_flag_sequence(options.flag_simplified_date);
                if (options.flag_simplified_date == true)
                {
                    timeSeries_.AddDimensionTime(new DateTime(int.Parse(range_time.Text), 1, 1), Double.Parse(range_value.Text));
                }
                else
                {
                    timeSeries_.AddDimensionTime(DateTime.Parse(range_time.Text), Double.Parse(range_value.Text));
                }
            }
            ObjExcel.Quit();
            timeSeries_.Sort();

            timeSeries_.SetColor(options.Get_color());
            timeSeries_.SetNameTimeSeries(options.Get_name());

            timeSeries_.CalculateAvg();
            timeSeries_.CalculateMax();
            timeSeries_.CalculateMin();
            timeSeries_.CalculateAvgSquareDeviation();

            ResultParcer = true;
        }
Example #8
0
        private void ButtonMovingAverageMethod_Click(object sender, RoutedEventArgs e)
        {
            if (AllDataTimeSeries.SelectedRow == -1 || SmoothingInterval.Text == "")
            {
                WindowError windowError = new WindowError("Данные не выбраны");
                windowError.Show();
                return;
            }

            int n, m;

            try
            {
                n = Convert.ToInt32(SmoothingInterval.Text);
                m = Convert.ToInt32(QuantityPredict.Text);
            }
            catch
            {
                WindowError windowError = new WindowError("Неудалось распознать значение (требуется int)");
                windowError.Show();
                return;
            }

            if (n < 3 || n % 2 == 0)
            {
                WindowError windowError = new WindowError("Величина интервала сглаживания должна быть не меньше 3\n и нечетное");
                windowError.Show();
                return;
            }

            if (m < 0)
            {
                WindowError windowError = new WindowError("Количество предсказываемых значений \nдолжно быть не отрицательным");
                windowError.Show();
                return;
            }



            WindowGraphicView windowTest = new WindowGraphicView(AllDataTimeSeries.MovingAverageMethod(n, m), AllDataTimeSeries.ListTimeSeries[AllDataTimeSeries.SelectedRow].GetColor());

            windowTest.Show();
        }
        private void OpenConfiguration(object sender, RoutedEventArgs e)
        {
            Microsoft.Win32.OpenFileDialog fileDialog = new Microsoft.Win32.OpenFileDialog();
            fileDialog.Filter = "Файлы txt|*.txt";

            if (fileDialog.ShowDialog() == true)
            {
                string Path = fileDialog.FileName;

                try
                {
                    using (StreamReader sr = new StreamReader(Path, System.Text.Encoding.Default))
                    {
                        ParcerDataTable = new ParcerDataTable(sr.ReadLine());                           //путь к xlsx
                        Checked_name_column_value.Text             = sr.ReadLine();
                        Checked_name_column_time.Text              = sr.ReadLine();
                        Checked_number_list.Text                   = sr.ReadLine();
                        Checked_number_line_start_information.Text = sr.ReadLine();
                        Checked_number_line_end_information.Text   = sr.ReadLine();
                        Checked_color_series.Text                  = sr.ReadLine();
                        NameSeries.Text = sr.ReadLine();
                        if (sr.ReadLine() == "true")
                        {
                            Checked_flag_simplified_date.IsChecked = true;
                        }
                        else
                        {
                            Checked_flag_simplified_date.IsChecked = false;
                        }
                        TextBoxNotFoundFile.Text = "Файл выбран";
                    }
                }
                catch
                {
                    TextBoxNotFoundFile.Text = "Файл не выбран";
                    WindowError windowError = new WindowError("Не удалось прочитать файл");
                    windowError.Show();
                    return;
                }
            }
        }
        private void SaveConfiguration(object sender, RoutedEventArgs e)
        {
            Microsoft.Win32.SaveFileDialog saveFileDialog = new Microsoft.Win32.SaveFileDialog();
            saveFileDialog.Filter = "Файлы txt|*.txt";

            if (saveFileDialog.ShowDialog() == true)
            {
                Stream stream = saveFileDialog.OpenFile();
                try
                {
                    using (StreamWriter sw = new StreamWriter(stream))
                    {
                        sw.WriteLine(ParcerDataTable.GetFileName());
                        sw.WriteLine(Checked_name_column_value.Text);
                        sw.WriteLine(Checked_name_column_time.Text);
                        sw.WriteLine(Checked_number_list.Text);
                        sw.WriteLine(Checked_number_line_start_information.Text);
                        sw.WriteLine(Checked_number_line_end_information.Text);
                        sw.WriteLine(Checked_color_series.Text);
                        sw.WriteLine(NameSeries.Text);
                        if (Checked_flag_simplified_date.IsChecked == true)
                        {
                            sw.WriteLine("true");
                        }
                        else
                        {
                            sw.WriteLine("false");
                        }
                    }
                }
                catch
                {
                    WindowError windowError = new WindowError("Не удалось сохранить файл");
                    windowError.Show();
                }
            }
        }
        private void FileProcessing_Click(object sender, RoutedEventArgs e)
        {
            if (Checked_name_column_time.Text == "" || Checked_name_column_value.Text == "" ||
                Checked_number_line_end_information.Text == "" ||
                Checked_number_line_end_information.Text == "" || Checked_number_list.Text == "")
            {
                WindowError windowError = new WindowError("Присутствуют незаполненные поля");
                windowError.Show();
                return;
            }

            if (NameSeries.Text == "" || NameSeries.Text.IndexOf(",") != -1)
            {
                WindowError windowError = new WindowError("Имя ряда не пустое поле, не содержащее запятую");
                windowError.Show();
                return;
            }

            try
            {
                if (ParcerDataTable.CheckedFile() == false)
                {
                    WindowError windowError = new WindowError("Не найден выбранный файл");
                    windowError.Show();
                    return;
                }
            }
            catch
            {
                WindowError windowError = new WindowError("Не выбран файл");
                windowError.Show();
                return;
            }

            OptionsParcerDataTable optionsParcerDataTable = new OptionsParcerDataTable();

            try
            {
                optionsParcerDataTable.Set_flag_simplified_date(Checked_flag_simplified_date.IsChecked.GetValueOrDefault());
                optionsParcerDataTable.Set_name_column_time(Checked_name_column_time.Text);
                optionsParcerDataTable.Set_name_column_value(Checked_name_column_value.Text);
                optionsParcerDataTable.Set_number_line_end_information(Checked_number_line_end_information.Text);
                optionsParcerDataTable.Set_number_line_start_information(Checked_number_line_start_information.Text);
                optionsParcerDataTable.Set_number_list(Checked_number_list.Text);
                optionsParcerDataTable.Set_color(Checked_color_series.Text);
                optionsParcerDataTable.Set_name(NameSeries.Text);

                if (AllDataTimeSeries.CheckedUniqueNameTimeSeries(NameSeries.Text) == false)
                {
                    WindowError windowError = new WindowError("Необходимо уникальное имя для временного ряда");
                    windowError.Show();
                    return;
                }
            }
            catch
            {
                WindowError windowError = new WindowError("Некорректно заполнены поля");
                windowError.Show();
                return;
            }

            try
            {
                ParcerDataTable.Parcer(optionsParcerDataTable);
            }
            catch
            {
                WindowError windowError = new WindowError("Не удалось прочитать файл по указанным параметрам");
                windowError.Show();
                return;
            }

            if (ParcerDataTable.CheckedResultParcer() == true)
            {
                AllDataTimeSeries.AddNewTimeSeries(ParcerDataTable.GetTimeSeries());
                this.Close();
            }
        }
Example #12
0
        private void GraphicView_Click(object sender, RoutedEventArgs e)
        {
            if (CheckedNumberTimeSeries.IsChecked.GetValueOrDefault() == false)
            {
                if (AllDataTimeSeries.SelectedRow == -1)
                {
                    WindowError windowError = new WindowError("Данные не выбраны");
                    windowError.Show();
                    return;
                }

                TimeSeries temp = new TimeSeries();
                temp.Set_flag_sequence(AllDataTimeSeries.ListTimeSeries[AllDataTimeSeries.SelectedRow].Get_flag_sequence());
                temp.SetNameTimeSeries(AllDataTimeSeries.ListTimeSeries[AllDataTimeSeries.SelectedRow].GetNameTimeSeries());
                temp.SetColor(AllDataTimeSeries.ListTimeSeries[AllDataTimeSeries.SelectedRow].GetColor());

                List <Dimension> dimensions = AllDataTimeSeries.ListTimeSeries[AllDataTimeSeries.SelectedRow].GetTimeSeries();
                for (int i = 0; i < dimensions.Count(); i++)
                {
                    temp.AddDimensionTime(dimensions[i].Time, dimensions[i].Value);
                }


                if (GivenTime.IsChecked == true)
                {
                    try
                    {
                        if (temp.Get_flag_sequence() == true)
                        {
                            temp.LimitDate(new DateTime(int.Parse(StartDate.Text), 1, 1), new DateTime(int.Parse(EndDate.Text), 1, 1));
                        }
                        else
                        {
                            temp.LimitDate(DateTime.Parse(StartDate.Text), DateTime.Parse(EndDate.Text));
                        }
                    }
                    catch
                    {
                        WindowError windowError = new WindowError("Некорректно задана дата");
                        windowError.Show();
                        return;
                    }
                }

                WindowGraphicView graphicView = new WindowGraphicView(temp.GetTimeSeries(), temp.GetColor());
                graphicView.Show();
            }
            else
            {
                if (NameSelectedTimeSeries.Text == "")
                {
                    WindowError windowError = new WindowError("Ничего не выбрано");
                    windowError.Show();
                    return;
                }

                List <string>     qqqqq        = new List <string>(System.Text.RegularExpressions.Regex.Split(NameSelectedTimeSeries.Text, ","));
                List <TimeSeries> timeSeries_s = new List <TimeSeries>();
                for (int i = 0; i < qqqqq.Count(); i++)
                {
                    for (int j = 0; j < AllDataTimeSeries.ListTimeSeries.Count(); j++)
                    {
                        if (qqqqq[i] == AllDataTimeSeries.ListTimeSeries[j].GetNameTimeSeries())
                        {
                            TimeSeries temp = new TimeSeries();
                            temp.Set_flag_sequence(AllDataTimeSeries.ListTimeSeries[j].Get_flag_sequence());
                            temp.SetNameTimeSeries(AllDataTimeSeries.ListTimeSeries[j].GetNameTimeSeries());
                            temp.SetColor(AllDataTimeSeries.ListTimeSeries[j].GetColor());

                            List <Dimension> dimensions = AllDataTimeSeries.ListTimeSeries[j].GetTimeSeries();
                            for (int k = 0; k < dimensions.Count(); k++)
                            {
                                temp.AddDimensionTime(dimensions[k].Time, dimensions[k].Value);
                            }

                            timeSeries_s.Add(temp);
                        }
                    }
                }

                if (GivenTime.IsChecked == true)
                {
                    try
                    {
                        for (int i = 0; i < timeSeries_s.Count; i++)
                        {
                            if (timeSeries_s[i].Get_flag_sequence() == true)
                            {
                                timeSeries_s[i].LimitDate(new DateTime(int.Parse(StartDate.Text), 1, 1), new DateTime(int.Parse(EndDate.Text), 1, 1));
                            }
                            else
                            {
                                timeSeries_s[i].LimitDate(DateTime.Parse(StartDate.Text), DateTime.Parse(EndDate.Text));
                            }
                        }
                    }
                    catch
                    {
                        WindowError windowError = new WindowError("Некорректно задана дата");
                        windowError.Show();
                        return;
                    }
                }

                WindowGraphicView graphicView = new WindowGraphicView(timeSeries_s);
                graphicView.Show();
            }
        }
Example #13
0
        private void Button_Click_Normalize(object sender, RoutedEventArgs e)
        {
            if (AllDataTimeSeries.SelectedRow == -1)
            {
                WindowError windowError = new WindowError("Данные не выбраны");
                windowError.Show();
                return;
            }

            if (NewTimeSeriesChecked.IsChecked == true)
            {
                if (TextBoxName.Text == "" || TextBoxColor.Text == "")
                {
                    WindowError windowError = new WindowError("Присутствуют пустые поля");
                    windowError.Show();
                    return;
                }

                if (AllDataTimeSeries.CheckedUniqueNameTimeSeries(TextBoxName.Text) == false)
                {
                    WindowError windowError = new WindowError("Необходимо уникальное имя для временного ряда");
                    windowError.Show();
                    return;
                }

                TimeSeries temp = new TimeSeries();
                temp.Set_flag_sequence(AllDataTimeSeries.ListTimeSeries[AllDataTimeSeries.SelectedRow].Get_flag_sequence());
                temp.SetNameTimeSeries(TextBoxName.Text);
                temp.SetColor((Color)ColorConverter.ConvertFromString(TextBoxColor.Text));

                List <Dimension> dimensions = AllDataTimeSeries.ListTimeSeries[AllDataTimeSeries.SelectedRow].GetTimeSeries();
                for (int i = 0; i < dimensions.Count(); i++)
                {
                    temp.AddDimensionTime(dimensions[i].Time, dimensions[i].Value);
                }

                temp.CalculateMin();
                temp.CalculateMax();
                temp.CalculateAvg();
                temp.CalculateAvgSquareDeviation();

                int temp_selected_row = AllDataTimeSeries.SelectedRow;
                AllDataTimeSeries.AddNewTimeSeries(temp);
                AllDataTimeSeries.SetSelectedRow(AllDataTimeSeries.ListTimeSeries.Count - 1);

                if (NormalizeOn_Avg.IsChecked == true)
                {
                    AllDataTimeSeries.NormalizeOn_Avg();
                }

                if (NormalizeOn_σ.IsChecked == true)
                {
                    AllDataTimeSeries.NormalizeOn_σ();
                }

                AllDataTimeSeries.SetSelectedRow(temp_selected_row);
            }
            else
            {
                if (NormalizeOn_Avg.IsChecked == true)
                {
                    AllDataTimeSeries.NormalizeOn_Avg();
                }

                if (NormalizeOn_σ.IsChecked == true)
                {
                    AllDataTimeSeries.NormalizeOn_σ();
                }
            }
        }