Beispiel #1
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            MSChartSeries series   = tvChart.SelectedNode.Tag as MSChartSeries;
            string        areaName = series.SeriesSettings.ChartArea;

            if (areaName != "Default")
            {
                // delete non-default area exclusively owned by deleted series
                ChartArea area = ChartObject.Chart.ChartAreas.FindByName(areaName);
                ChartObject.Chart.ChartAreas.Remove(area);
                area.Dispose();
            }
            else
            {
                // delete this area and make the next area default one.
                if (ChartObject.Chart.ChartAreas.Count > 1)
                {
                    ChartArea area = ChartObject.Chart.ChartAreas.FindByName(areaName);
                    ChartObject.Chart.ChartAreas.Remove(area);
                    area.Dispose();
                    area      = ChartObject.Chart.ChartAreas[0];
                    area.Name = "Default";
                }
            }

            ChartObject.DeleteSeries(ChartObject.Series.IndexOf(series));
            PopulateSeriesTree(ChartObject);
            RefreshSample();
        }
Beispiel #2
0
 private void Dispose(bool disposing)
 {
     if (!disposing)
     {
         return;
     }
     _chart?.Dispose();
     _actualSeries?.Dispose();
     _expectedSeries?.Dispose();
     _failSeries?.Dispose();
     _area?.Dispose();
 }
        // Notes on ApplyXXX methods:
        // Chart elements should be configured before they are added to the chart, otherwise there
        // will be some rendering problems.
        // We must catch all exceptions when configuring chart elements and dispose of them manually
        // if they have not been added to the chart yet, otherwise FxCop will complain.

        private void ApplyChartArea(UI.DataVisualization.Charting.Chart chart)
        {
            ChartArea chartArea = new ChartArea("Default");

            try
            {
                ApplyAxis(chartArea.AxisX, _xAxis);
                ApplyAxis(chartArea.AxisY, _yAxis);
                chart.ChartAreas.Add(chartArea);
            }
            catch
            {
                // This is to appease FxCop
                chartArea.Dispose();
                throw;
            }
        }
Beispiel #4
0
        private int initChartArea()
        {
            int result = 0;

            try
            {
                // グラフ領域の設定
                if (m_area != null)
                {
                    m_area.Dispose();
                    m_area = null;
                }
                m_area = new ChartArea("MainChart");

                // 横軸(日付軸)の設定
                // DateTimeのままでは使えないので
                //ToOADateメソッドでOLEオートメーション日付に変換
                m_area.AxisX.Title        = "Number";
                m_area.AxisX.IntervalType = DateTimeIntervalType.Number;
                //m_area.AxisX.Minimum = new DateTime(2010, 1, 1).ToOADate();
                //m_area.AxisX.Maximum = new DateTime(2010, 1, 10).ToOADate();

                // 縦軸(株価軸)の設定
                m_area.AxisY.Title   = "JPY";
                m_area.AxisY.Minimum = 718000;
                m_area.AxisY.Maximum = 726000;

                m_area.AxisY.Interval = 4000;

                m_area.BackColor = Color.LightGray;

                // グラフ領域の設定
                if (m_indicatorArea != null)
                {
                    m_indicatorArea.Dispose();
                    m_indicatorArea = null;
                }
                m_indicatorArea = new ChartArea("IndicatorChart");

                // 横軸(日付軸)の設定
                // DateTimeのままでは使えないので
                //ToOADateメソッドでOLEオートメーション日付に変換
                m_indicatorArea.AxisX.Title        = "Number";
                m_indicatorArea.AxisX.IntervalType = DateTimeIntervalType.Number;

                // 縦軸(株価軸)の設定
                m_indicatorArea.AxisY.Title   = "Value";
                m_indicatorArea.AxisY.Minimum = 0.0;
                m_indicatorArea.AxisY.Maximum = 100.0;

                m_indicatorArea.BackColor = Color.LightGray;


                // 既定のグラフ領域の設定をクリアした後、設定する
                this.chart1.ChartAreas.Clear();
                this.chart1.ChartAreas.Add(m_area);
                //this.chart1.ChartAreas.Add(m_indicatorArea);

                // データ系列を作成する
                if (m_series_ltp != null)
                {
                    m_series_ltp.Dispose();
                    m_series_ltp = null;
                }

                m_series_ltp           = new Series();
                m_series_ltp.ChartType = SeriesChartType.Candlestick;
                m_series_ltp.Color     = Color.LightSeaGreen;
                m_series_ltp.Name      = "OHLC";

                if (m_series_ema != null)
                {
                    m_series_ema.Dispose();
                    m_series_ema = null;
                }

                m_series_ema           = new Series();
                m_series_ema.ChartType = SeriesChartType.Line;
                m_series_ema.Color     = Color.Aqua;
                m_series_ema.Name      = "EMA";

                if (m_series_ema_sub != null)
                {
                    m_series_ema_sub.Dispose();
                    m_series_ema_sub = null;
                }

                m_series_ema_sub           = new Series();
                m_series_ema_sub.ChartType = SeriesChartType.Line;
                m_series_ema_sub.Color     = Color.Yellow;
                m_series_ema_sub.Name      = "EMA_SUB";

                if (m_series_bollHigh != null)
                {
                    m_series_bollHigh.Dispose();
                    m_series_bollHigh = null;
                }
                m_series_bollHigh           = new Series();
                m_series_bollHigh.ChartType = SeriesChartType.Line;
                m_series_bollHigh.Color     = Color.CornflowerBlue;
                m_series_bollHigh.Name      = "BOLL_HIGH";


                if (m_series_bollLow != null)
                {
                    m_series_bollLow.Dispose();
                    m_series_bollLow = null;
                }
                m_series_bollLow           = new Series();
                m_series_bollLow.ChartType = SeriesChartType.Line;
                m_series_bollLow.Color     = Color.MediumVioletRed;
                m_series_bollLow.Name      = "BOLL_LOW";

                if (m_series_bollHigh_top != null)
                {
                    m_series_bollHigh_top.Dispose();
                    m_series_bollHigh_top = null;
                }
                m_series_bollHigh_top           = new Series();
                m_series_bollHigh_top.ChartType = SeriesChartType.Line;
                m_series_bollHigh_top.Color     = Color.DarkBlue;
                m_series_bollHigh_top.Name      = "BOLL_HIGH_TOP";


                if (m_series_bollLow_top != null)
                {
                    m_series_bollLow_top.Dispose();
                    m_series_bollLow_top = null;
                }
                m_series_bollLow_top           = new Series();
                m_series_bollLow_top.ChartType = SeriesChartType.Line;
                m_series_bollLow_top.Color     = Color.DarkRed;
                m_series_bollLow_top.Name      = "BOLL_LOW_TOP";

                if (m_series_min != null)
                {
                    m_series_min.Dispose();
                    m_series_min = null;
                }

                m_series_min           = new Series();
                m_series_min.ChartType = SeriesChartType.Line;
                m_series_min.Color     = Color.Red;
                m_series_min.Name      = "MIN";

                if (m_series_max != null)
                {
                    m_series_max.Dispose();
                    m_series_max = null;
                }

                m_series_max           = new Series();
                m_series_max.ChartType = SeriesChartType.Line;
                m_series_max.Color     = Color.Blue;
                m_series_max.Name      = "MAX";

                if (m_series_body_min != null)
                {
                    m_series_body_min.Dispose();
                    m_series_body_min = null;
                }

                m_series_body_min           = new Series();
                m_series_body_min.ChartType = SeriesChartType.Line;
                m_series_body_min.Color     = Color.DarkRed;
                m_series_body_min.Name      = "BODY_MIN";

                if (m_series_body_max != null)
                {
                    m_series_body_max.Dispose();
                    m_series_body_max = null;
                }

                m_series_body_max           = new Series();
                m_series_body_max.ChartType = SeriesChartType.Line;
                m_series_body_max.Color     = Color.DarkBlue;
                m_series_body_max.Name      = "BODY_MAX";


                if (m_series_entry != null)
                {
                    m_series_entry.Dispose();
                    m_series_entry = null;
                }

                m_series_entry           = new Series();
                m_series_entry.ChartType = SeriesChartType.Line;
                m_series_entry.Color     = Color.GreenYellow;
                m_series_entry.Name      = "ENTRY";



                if (m_series_indi != null)
                {
                    m_series_indi.Dispose();
                    m_series_indi = null;
                }

                m_series_indi           = new Series();
                m_series_indi.ChartType = SeriesChartType.Line;
                m_series_indi.Color     = Color.Purple;
                m_series_indi.Name      = "Indicator";
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                result = -1;
            }
            finally
            {
            }
            return(result);
        }