Exemple #1
0
        /// <summary>
        /// draw a pattern on his individual chart
        /// прорисовать паттерн на его индивидуальном чарте
        /// </summary>
        private void PaintSinglePattern(IPattern pattern, ChartCandlePainter chart)
        {
            if (chart.GetChart().InvokeRequired)
            {
                chart.GetChart().Invoke(new Action <IPattern, ChartCandlePainter>(PaintSinglePattern), pattern, chart);
                return;
            }
            chart.ClearDataPointsAndSizeValue();
            chart.ClearSeries();

            if (pattern.Type == PatternType.Candle)
            {
                chart.PaintSingleCandlePattern(((PatternCandle)pattern).GetInCandle());
            }
            if (pattern.Type == PatternType.Volume)
            {
                chart.PaintSingleVolumePattern(((PatternVolume)pattern).GetInCandle());
            }
            if (pattern.Type == PatternType.Indicators)
            {
                PatternIndicators pat = (PatternIndicators)pattern;

                for (int i = 0; pat.Indicators != null && i < pat.Indicators.Count; i++)
                {
                    if (chart.IndicatorIsCreate(pat.Indicators[i].Name + "0") == false)
                    {
                        chart.CreateSeries(chart.GetChartArea(pat.Indicators[i].NameArea), pat.Indicators[i].TypeIndicator, pat.Indicators[i].NameSeries + "0");
                    }

                    chart.ProcessIndicator(pat.Indicators[i]);
                }
            }
        }
Exemple #2
0
        /// <summary>
        /// Пересобрать контекстное меню для чарта
        /// </summary>
        private void ReloadContext()
        {
            try
            {
                List <MenuItem> menuRedact = null;

                List <MenuItem> menuDelete = null;

                if (_indicatorsCandles != null)
                {
                    menuRedact = new List <MenuItem>();
                    menuDelete = new List <MenuItem>();
                    for (int i = 0; i < _indicatorsCandles.Count; i++)
                    {
                        menuRedact.Add(new MenuItem(_indicatorsCandles[i].GetType().Name));
                        menuRedact[menuRedact.Count - 1].Click += RedactContextMenu_Click;
                        if (_indicatorsCandles[i].CanDelete)
                        {
                            menuDelete.Add(new MenuItem(_indicatorsCandles[i].GetType().Name));
                            menuDelete[menuDelete.Count - 1].Click += DeleteContextMenu_Click;
                        }
                    }
                }

                if (ChartCandle.GetChartArea("TradeArea") != null)
                {
                    if (menuRedact == null)
                    {
                        menuRedact = new List <MenuItem>();
                        menuDelete = new List <MenuItem>();
                    }
                    menuDelete.Add(new MenuItem("Trades"));
                    menuDelete[menuDelete.Count - 1].Click += DeleteContextMenu_Click;
                }

                List <MenuItem> items;

                items = new List <MenuItem>();
                items.Add(new MenuItem(OsLocalization.Charts.ChartMenuItem1,
                                       new MenuItem[]
                                       { new MenuItem(OsLocalization.Charts.ChartMenuItem2,
                                                      new MenuItem[] { new MenuItem(OsLocalization.Charts.ChartMenuItem3),
                                                                       new MenuItem(OsLocalization.Charts.ChartMenuItem4) }),

                                         new MenuItem(OsLocalization.Charts.ChartMenuItem5,
                                                      new MenuItem[] {
                        new MenuItem(OsLocalization.Charts.ChartMenuItem6),
                        new MenuItem(OsLocalization.Charts.ChartMenuItem7),
                        new MenuItem(OsLocalization.Charts.ChartMenuItem8),
                        new MenuItem(OsLocalization.Charts.ChartMenuItem9)
                    }) }

                                       ));

                items[items.Count - 1].MenuItems[0].MenuItems[0].Click += ChartBlackColor_Click;
                items[items.Count - 1].MenuItems[0].MenuItems[1].Click += ChartWhiteColor_Click;

                items[items.Count - 1].MenuItems[1].MenuItems[0].Click += ChartCrossToPosition_Click;
                items[items.Count - 1].MenuItems[1].MenuItems[1].Click += ChartRombToPosition_Click;
                items[items.Count - 1].MenuItems[1].MenuItems[2].Click += ChartCircleToPosition_Click;
                items[items.Count - 1].MenuItems[1].MenuItems[3].Click += ChartTriangleToPosition_Click;

                items.Add(new MenuItem(OsLocalization.Charts.ChartMenuItem10));
                items[items.Count - 1].Click += ChartHideIndicators_Click;

                items.Add(new MenuItem(OsLocalization.Charts.ChartMenuItem11));
                items[items.Count - 1].Click += ChartShowIndicators_Click;

                if (menuRedact != null)
                {
                    items.Add(new MenuItem(OsLocalization.Charts.ChartMenuItem12, menuRedact.ToArray()));
                    items.Add(new MenuItem(OsLocalization.Charts.ChartMenuItem13, menuDelete.ToArray()));
                }

                items.Add(new MenuItem(OsLocalization.Charts.ChartMenuItem14));
                items[items.Count - 1].Click += CreateIndicators_Click;

                ContextMenu menu = new ContextMenu(items.ToArray());

                ChartCandle.GetChart().ContextMenu = menu;
            }
            catch (Exception error)
            {
                SendErrorMessage(error);
            }
        }