Пример #1
0
        private void btnAddIndicator_Click(object sender, RoutedEventArgs e)
        {
            StockChartX_IndicatorsParameters.IndicatorParameters indicator =
                cmbIndicators.SelectedItem as StockChartX_IndicatorsParameters.IndicatorParameters;
            if (indicator == null)
            {
                MessageBox.Show("Could not get indicator");
                return;
            }
            if (indicator.IndicatorType == IndicatorType.CustomIndicator)
            {
                MessageBox.Show("Custom indicator can't be added via this. Use menu point [Data/Add Custom Indicator]", "Error",
                                MessageBoxButton.OK);
                return;
            }

            //mark a flag whether a new panel was created, must update chart if it was and user pressed Cancel in indicator dialog
            _newPanelCreated = !_stockChartX.IsOverlayIndicator(indicator.IndicatorType);
            string     name  = indicator.IndicatorRealName + (_indicatorCount > 0 ? _indicatorCount.ToString() : "");
            ChartPanel panel = !_newPanelCreated?_stockChartX.GetPanelByIndex(0) : _stockChartX.AddChartPanel();

            if (panel == null)
            {
                MessageBox.Show("Chart does not have enough place for a new panel. Resize existings or remove some.",
                                "Not enough space", MessageBoxButton.OK);
                return;
            }

            if (_newPanelCreated)
            {
                panel.Background = _chartPanelsBrush;
            }

            _stockChartX.AddIndicator(indicator.IndicatorType, name, panel, true);

            _stockChartX.Update();
            _indicatorCount++;
        }
Пример #2
0
        public void AddIndicator(StockChartX_IndicatorsParameters.IndicatorParameters indicator)
        {
            if (indicator == null)
            {
                MessageBox.Show("Could not get indicator");
                return;
            }
            if (indicator.IndicatorType == IndicatorType.CustomIndicator)
            {
                MessageBox.Show("Custom indicator can't be added via this. Use menu point [Data/Add Custom Indicator]", "Error",
                                MessageBoxButton.OK);
                return;
            }

            //mark a flag whether a new panel was created, must update chart if it was and user pressed Cancel in indicator dialog
            NewPanelCreated = !_stockChartX.IsOverlayIndicator(indicator.IndicatorType);
            string     name  = indicator.IndicatorRealName + (IndicatorCount > 0 ? IndicatorCount.ToString() : "");
            ChartPanel panel = !NewPanelCreated?_stockChartX.GetPanelByIndex(0) : _stockChartX.AddChartPanel();

            if (panel == null)
            {
                MessageBox.Show("Chart does not have enough place for a new panel. Resize existings or remove some.",
                                "Not enough space", MessageBoxButton.OK);
                return;
            }

            if (NewPanelCreated)
            {
                Brush brsh   = GetGradient(ColorSettings.PanelTopColor, ColorSettings.PanelBottomColor);
                Brush fbrush = new SolidColorBrush(ColorSettings.YAxesColor);
                panel.Background      = brsh;
                panel.YAxesBackground = fbrush;
            }
            _stockChartX.AddIndicator(indicator.IndicatorType, name, panel, true);
            _stockChartX.Update();
            IndicatorCount++;
        }