Ejemplo n.º 1
0
        private void OnResetClick(object sender, EventArgs e)
        {
            Series copy = SeriesAssist.GetCopy(Curve);

            Curve.Points.Clear();
            SeriesAssist.CopyPoints(Curve, copy, Originals);
            GridAssist.PopulateColumn(uiGrid_db_grid, y.Name, SeriesAssist.GetValues(Curve), VALUES_DECIMAL_PLACES);
            UpdateUiByRefreshingChart();
            UpdateUiByPanelStateInfo(PanelStateInformation.ValuesRestored);
            log.Info(MethodBase.GetCurrentMethod().Name + "()");
        }
Ejemplo n.º 2
0
        private void OnShowDataSetClick(object sender, EventArgs e)
        {
            DataSetCurveType curveType = (DataSetCurveType)UiControls.TryGetSelectedIndex(uiPnlMod_CrvT_ComBx);
            int    curveIndex          = UiControls.TryGetValue <int>(uiPnlMod_CrvIdx_Num);
            string signature           = MethodBase.GetCurrentMethod().Name + '(' + curveType + ',' + curveIndex + ')';

            switch (curveType)
            {
            case DataSetCurveType.Ideal:
            case DataSetCurveType.Modified:
            case DataSetCurveType.Average:
                break;

            default:
                log.Info(signature);
                AppMessages.MainWindow.AsteriskOfCurveTypeNotSelected();
                return;
            }

            Series curveSeries = SpecifyCurveSeries(curveType, curveIndex);

            if (curveSeries == null || curveSeries.Points.Count == 0)
            {
                log.Info(MethodBase.GetCurrentMethod().Name + '(' + nameof(curveSeries) + ')');
                AppMessages.MainWindow.ExclamationOfSeriesSelection();
                return;
            }

            using (var dialog = new GridPreviewer(SeriesAssist.GetCopy(curveSeries))) {
                dialog.Height = Settings.Dimensions.GridPreviewer.Height;
                dialog.Width  = Settings.Dimensions.GridPreviewer.Width;
                UiControls.TryShowDialog(dialog, this);

                try {
                    if (dialog.DialogResult == DialogResult.OK)
                    {
                        DataChart.AlterCurve(dialog.Curve, curveType, curveIndex);
                        ChartAssist.Refresh(dialog.Curve, Color.Indigo, uiCharts_Crv);
                    }
                }
                catch (InvalidOperationException ex) {
                    log.Error(signature, ex);
                    AppMessages.MainWindow.ErrorOfChartRefreshing();
                }
                catch (Exception ex) {
                    log.Fatal(signature, ex);
                }
            }

            log.Info(signature);
        }
Ejemplo n.º 3
0
        public void GetCopy1()
        {
            // given
            Series series1 = TestObjects.GetSeries();
            Series series2 = TestObjects.GetSeries(new List <double>()
            {
                -1, 0, 1
            });

            // when
            Series result1 = SeriesAssist.GetCopy(series1, 0, false);
            Series result2 = SeriesAssist.GetCopy(series2);

            // then
            Assertions.SameValues(series1, result1);
            Assertions.SameValues(series2, result2);
        }
Ejemplo n.º 4
0
        private void OnPerformClick(object sender, EventArgs e)
        {
            Operation @operator = (Operation)UiControls.TryGetSelectedIndex(uiPnl_OperT_ComBx);
            double?   userValue = (@operator == Operation.Positive || @operator == Operation.Negative) ? default(double) : Strings.TryGetValue(uiPnl_Val2_TxtBx.Text);

            if (userValue == null || Curve == null)
            {
                log.Info(MethodBase.GetCurrentMethod().Name + '(' + userValue + ',' + Curve + ')');
                UpdateUiByPanelStateInfo(PanelStateInformation.InvalidUserValue);
                AppMessages.GridPreviewer.ExclamationOfImproperUserValue();
                return;
            }

            int       startIndex = UiControls.TryGetValue <int>(uiPnl_StartIdx_Num);
            int       endIndex   = UiControls.TryGetValue <int>(uiPnl_EndIdx_Num);
            Series    seriesCopy = SeriesAssist.GetCopy(Curve);
            Operation operation  = (Operation)uiPnl_OperT_ComBx.SelectedIndex;
            string    signature  = string.Empty;

            try {
                signature = MethodBase.GetCurrentMethod().Name + '(' + startIndex + ',' + endIndex + ',' + operation + ',' + userValue.Value + ')';
                SeriesAssist.Alter(operation, userValue.Value, seriesCopy, startIndex, endIndex);
            }
            catch (NotFiniteNumberException ex) {
                log.Error(signature, ex);
                UpdateUiByPanelStateInfo(PanelStateInformation.OperationRevoked);
                AppMessages.GridPreviewer.ErrorOfInvalidCurvePoints();
                return;
            }
            catch (Exception ex) {
                log.Fatal(signature, ex);
                UpdateUiByPanelStateInfo(PanelStateInformation.OperationRejected);
                AppMessages.GridPreviewer.ErrorOfPerformOperation();
                return;
            }

            Curve.Points.Clear();
            SeriesAssist.CopyPoints(seriesCopy, Curve);
            GridAssist.PopulateColumn(uiGrid_db_grid, y.Name, SeriesAssist.GetValues(Curve), VALUES_DECIMAL_PLACES);
            UpdateUiByRefreshingChart();
            UpdateUiByPanelStateInfo(PanelStateInformation.PerformedAndRefreshed);
            log.Info(signature);
        }