Beispiel #1
0
 public OxyChartPainter(string name, StartProgram startProgram)
 {
     this.chart_name = name;
     start_program   = startProgram;
     color_keeper    = new ChartMasterColorKeeper(name);
     mediator        = new OxyMediator(this);
 }
        // service
        // сервис

        /// <summary>
        /// constructor
        /// конструктор
        /// </summary>
        /// <param name="name">name of the robot that owns the chart/имя робота, которому принадлежит чарт</param>
        /// <param name="startProgram">program that creates a class object/программа создающая объект класса</param>
        /// <param name="volume">volumes/объёмы</param>
        public ChartClusterPainter(string name, StartProgram startProgram, HorizontalVolume volume)
        {
            try
            {
                _volume       = volume;
                _startProgram = startProgram;
                _colorKeeper  = new ChartMasterColorKeeper(name);
                _colorKeeper.LogMessageEvent += SendLogMessage;

                CreateChart();

                _chart.Text             = name;
                _chart.AxisViewChanged += _chart_AxisViewChanged; // zoom event/событие изменения масштаба

                _chart.MouseLeave += _chart_MouseLeave;

                Thread painterThred = new Thread(PainterThreadArea);
                painterThred.IsBackground = true;
                painterThred.Name         = name + "ChartPainterThread";
                painterThred.Start();
            }
            catch (Exception error)
            {
                SendLogMessage(error.ToString(), LogMessageType.Error);
            }
        }
        private static void PaintLines(List <OptimizerFaze> fazes, Chart _chart)
        {
            ChartMasterColorKeeper _colorKeeper = new ChartMasterColorKeeper("walkForward");

            Series candleSeries = FindSeriesByNameSafe("SeriesCluster", _chart);

            DateTime firstTime = fazes[0].TimeStart;

            for (int i = 0, j = fazes.Count; i < fazes.Count; i++, j--)
            {
                decimal linePriceX = j;

                decimal clusterStartY = Convert.ToDecimal((fazes[i].TimeStart - firstTime).TotalDays);

                candleSeries.Points.AddXY(linePriceX, clusterStartY, clusterStartY + fazes[i].Days);

                DataPoint myPoint = candleSeries.Points[candleSeries.Points.Count - 1];

                if (fazes[i].TypeFaze == OptimizerFazeType.InSample)
                {
                    myPoint.Color              = Color.White;
                    myPoint.BorderColor        = Color.White;
                    myPoint.BackSecondaryColor = Color.White;
                }
                else if (fazes[i].TypeFaze == OptimizerFazeType.OutOfSample)
                {
                    myPoint.Color              = Color.Green;
                    myPoint.BorderColor        = Color.Green;
                    myPoint.BackSecondaryColor = Color.Green;
                }

                PaintSeriesSafe(candleSeries, _chart);
            }
        }
Beispiel #4
0
 public OxyChartPainter(string name, StartProgram startProgram)
 {
     this.chart_name = name;
     this.bot_name   = name.Replace("tab", ";").Split(';')[0];
     this.bot_tab    = Convert.ToInt32(name.Replace("tab", ";").Split(';')[1]);
     start_program   = startProgram;
     color_keeper    = new ChartMasterColorKeeper(name);
     mediator        = new OxyMediator(this);
 }
Beispiel #5
0
        private static Chart CreateChart()
        {
            Chart _chart = null;

            try
            {
                _chart = new Chart();
                ChartMasterColorKeeper _colorKeeper = new ChartMasterColorKeeper("chartPainter");

                _chart.Series.Clear();
                _chart.ChartAreas.Clear();
                _chart.BackColor          = _colorKeeper.ColorBackChart;
                _chart.SuppressExceptions = true;

                ChartArea prime = new ChartArea("Prime")
                {
                    CursorX         = { AxisType = AxisType.Secondary, IsUserSelectionEnabled = false, IsUserEnabled = true, IntervalType = DateTimeIntervalType.Auto, Interval = 0.00001 },
                    CursorY         = { AxisType = AxisType.Primary, IsUserEnabled = true, IntervalType = DateTimeIntervalType.Auto, Interval = 0.00001 },
                    BorderDashStyle = ChartDashStyle.Solid,
                    BorderWidth     = 2,
                    BackColor       = _colorKeeper.ColorBackChart,
                    BorderColor     = _colorKeeper.ColorBackSecond,
                };

                prime.AxisY.TitleAlignment        = StringAlignment.Near;
                prime.AxisY.TitleForeColor        = _colorKeeper.ColorBackCursor;
                prime.AxisY.ScrollBar.ButtonStyle = ScrollBarButtonStyles.SmallScroll;

                prime.AxisY.LabelAutoFitMinFontSize = 12;
                prime.AxisY.LabelAutoFitStyle       = LabelAutoFitStyles.IncreaseFont;
                foreach (var axe in prime.Axes)
                {
                    axe.LabelStyle.ForeColor = _colorKeeper.ColorText;
                }
                prime.CursorY.LineColor = _colorKeeper.ColorBackCursor;
                prime.CursorX.LineColor = _colorKeeper.ColorBackCursor;

                _chart.ChartAreas.Add(prime);

                Series series = new Series("Series");
                series.ChartType       = SeriesChartType.Line;
                series.YAxisType       = AxisType.Primary;
                series.XAxisType       = AxisType.Secondary;
                series.ChartArea       = "Prime";
                series.ShadowOffset    = 2;
                series.YValuesPerPoint = 2;

                _chart.Series.Add(series);
            }
            catch (Exception error)
            {
                System.Windows.MessageBox.Show(error.ToString());
            }

            return(_chart);
        }