Exemple #1
0
        /// <summary>
        /// NB! click handler is not copied
        /// </summary>
        public virtual ChartIcon MakeCopy()
        {
            var cpy = new ChartIcon(null)
            {
                key = key, State = State, Size = Size, Position = Position
            };

            return(cpy);
        }
Exemple #2
0
        private static void SetupChartIcons()
        {
            // забубенить кнопкам картинки
            var imageKeyByName = new Dictionary <string, string[]>
            {
                { ChartIcon.ChartIcon.chartButtonStatByTicker, new [] { "ico_calculator.png" } },
                { ChartIcon.ChartIcon.chartButtonDealByTicker, new [] { "ico_black_orders.png" } },
                { ChartIcon.ChartIcon.chartButtonFastBuy, new [] { "ico_black_up.png" } },
                { ChartIcon.ChartIcon.chartButtonFastSell, new [] { "ico_black_down.png" } },
                { ChartIcon.ChartIcon.chartButtonFavIndicators, new [] { "ico_black_favourite.png" } },
                { ChartIcon.ChartIcon.chartButtonIndexAutoScroll, new [] { "ico_black_forward.png", "ico_black_pause.png" } },
                { ChartIcon.ChartIcon.chartButtonIndicators, new [] { "ico_black_indicator.png" } },
                { ChartIcon.ChartIcon.chartButtonNewOrder, new [] { "ico_black_dollar.png" } },
                { ChartIcon.ChartIcon.chartButtonPatchQuotes, new [] { "ico_black_synch.png" } },
                { ChartIcon.ChartIcon.chartButtonQuoteArchive, new [] { "ico_black_archive.png" } },
                { ChartIcon.ChartIcon.chartVisualSettings, new [] { "ico_makeup.png" } },
                { ChartIcon.ChartIcon.chartProfitByTicker, new [] { "ico_profit_ticker.png" } },
                { ChartIcon.ChartIcon.chartRobot, new [] { "ico_robot.png" } },
            };

            foreach (var img in imageKeyByName)
            {
                var imgCollection = new ChartIcon.ChartIcon.ButtonImageCollection
                {
                    images = new Bitmap[2, img.Value.Length]
                };

                for (var i = 0; i < img.Value.Length; i++)
                {
                    // загрузить картинку и создать ее инверсную копию
                    var    fullName = "Candlechart.images." + img.Value[i];
                    Bitmap imgNormal, imgInverse;
                    LoadImageFromResxAndMakeInverseCopy(fullName, out imgNormal, out imgInverse);
                    imgCollection.images[0, i] = imgNormal;
                    imgCollection.images[1, i] = imgInverse;
                }
                ChartIcon.ChartIcon.AddButtonImages(img.Key, imgCollection);
            }

            var iconStatByTicker = new ChartIconDropDownDialog
            {
                key = ChartIcon.ChartIcon.chartButtonStatByTicker
            };
            var iconAscroll = new ChartIconCheckBox(null)
            {
                key = ChartIcon.ChartIcon.chartButtonIndexAutoScroll
            };
            var iconIndi = new ChartIcon.ChartIcon((obj, e) => { })
            {
                key = ChartIcon.ChartIcon.chartButtonIndicators
            };
            var iconOrder = new ChartIcon.ChartIcon((obj, e) => { })
            {
                key = ChartIcon.ChartIcon.chartButtonNewOrder
            };
            var iconArchive = new ChartIcon.ChartIcon((obj, e) => { })
            {
                key = ChartIcon.ChartIcon.chartButtonQuoteArchive
            };
            var iconPatchQuotes = new ChartIcon.ChartIcon((obj, e) => { })
            {
                key = ChartIcon.ChartIcon.chartButtonPatchQuotes
            };
            var iconFavIndi = new ChartIconDropDown
            {
                key = ChartIcon.ChartIcon.chartButtonFavIndicators
            };
            var iconFastSell = new ChartIconDropDown
            {
                key = ChartIcon.ChartIcon.chartButtonFastSell
            };
            var iconFastBuy = new ChartIconDropDown
            {
                key = ChartIcon.ChartIcon.chartButtonFastBuy
            };
            var iconFastOrders = new ChartIconDropDown
            {
                key = ChartIcon.ChartIcon.chartButtonDealByTicker
            };
            var iconVisual = new ChartIcon.ChartIcon((obj, e) => { })
            {
                key = ChartIcon.ChartIcon.chartVisualSettings
            };
            var iconProfitByTicker = new ChartIcon.ChartIcon((obj, e) => { })
            {
                key = ChartIcon.ChartIcon.chartProfitByTicker
            };
            var iconRobots = new ChartIconDropDown
            {
                key = ChartIcon.ChartIcon.chartRobot
            };

            iconFastOrders.listControl.columns = new List <FastColumn>
            {
                new FastColumn("")
                {
                    ColumnWidth = 38
                },
                new FastColumn("")
                {
                    ColumnWidth = 72
                },
                new FastColumn("")
                {
                    ColumnWidth = 48
                },
                new FastColumn("")
                {
                    ColumnWidth = 73
                },
                new FastColumn("")
                {
                    ColumnWidth = 73
                }
            };
            iconFastOrders.listControl.MinWidth      = iconFastOrders.listControl.columns.Sum(c => c.ColumnWidth);
            iconFastOrders.listControl.MaxWidth      = iconFastOrders.listControl.MinWidth;
            iconFastOrders.listControl.Width         = iconFastOrders.listControl.MinWidth;
            iconFastOrders.listControl.CalcWidthAuto = false;

            // добавить все в массив
            allChartIcons.Add(iconStatByTicker);
            allChartIcons.Add(iconFastOrders);
            allChartIcons.Add(iconAscroll);
            allChartIcons.Add(iconIndi);
            allChartIcons.Add(iconOrder);
            allChartIcons.Add(iconArchive);
            allChartIcons.Add(iconFavIndi);
            allChartIcons.Add(iconFastSell);
            allChartIcons.Add(iconFastBuy);
            allChartIcons.Add(iconPatchQuotes);
            allChartIcons.Add(iconVisual);
            allChartIcons.Add(iconProfitByTicker);
            allChartIcons.Add(iconRobots);

            allChartIcons.ForEach(i =>
            {
                i.Size = new Size(22, 22);
            });
        }
        private static void SetupChartIcons()
        {
            // забубенить кнопкам картинки
            var imageKeyByName = new Dictionary<string, string[]>
                {
                    { ChartIcon.ChartIcon.chartButtonStatByTicker, new [] { "ico_calculator.png" } },
                    { ChartIcon.ChartIcon.chartButtonDealByTicker, new [] { "ico_black_orders.png" } },
                    { ChartIcon.ChartIcon.chartButtonFastBuy, new [] { "ico_black_up.png" } },
                    { ChartIcon.ChartIcon.chartButtonFastSell, new [] { "ico_black_down.png" } },
                    { ChartIcon.ChartIcon.chartButtonFavIndicators, new [] { "ico_black_favourite.png" } },
                    { ChartIcon.ChartIcon.chartButtonIndexAutoScroll, new [] { "ico_black_forward.png", "ico_black_pause.png" } },
                    { ChartIcon.ChartIcon.chartButtonIndicators, new [] { "ico_black_indicator.png" } },
                    { ChartIcon.ChartIcon.chartButtonNewOrder, new [] { "ico_black_dollar.png" } },
                    { ChartIcon.ChartIcon.chartButtonPatchQuotes, new [] { "ico_black_synch.png" } },
                    { ChartIcon.ChartIcon.chartButtonQuoteArchive, new [] { "ico_black_archive.png" } },
                    { ChartIcon.ChartIcon.chartVisualSettings, new [] { "ico_makeup.png" } },
                    { ChartIcon.ChartIcon.chartProfitByTicker, new [] { "ico_profit_ticker.png" } },
                    { ChartIcon.ChartIcon.chartRobot, new [] { "ico_robot.png" } },
                };

            foreach (var img in imageKeyByName)
            {
                var imgCollection = new ChartIcon.ChartIcon.ButtonImageCollection
                    {
                        images = new Bitmap[2,img.Value.Length]
                    };

                for (var i = 0; i < img.Value.Length; i++)
                {
                    // загрузить картинку и создать ее инверсную копию
                    var fullName = "Candlechart.images." + img.Value[i];
                    Bitmap imgNormal, imgInverse;
                    LoadImageFromResxAndMakeInverseCopy(fullName, out imgNormal, out imgInverse);
                    imgCollection.images[0, i] = imgNormal;
                    imgCollection.images[1, i] = imgInverse;
                }
                ChartIcon.ChartIcon.AddButtonImages(img.Key, imgCollection);
            }

            var iconStatByTicker = new ChartIconDropDownDialog
            {
                key = ChartIcon.ChartIcon.chartButtonStatByTicker
            };
            var iconAscroll = new ChartIconCheckBox(null)
            {
                key = ChartIcon.ChartIcon.chartButtonIndexAutoScroll
            };
            var iconIndi = new ChartIcon.ChartIcon((obj, e) => { })
            {
                key = ChartIcon.ChartIcon.chartButtonIndicators
            };
            var iconOrder = new ChartIcon.ChartIcon((obj, e) => { })
            {
                key = ChartIcon.ChartIcon.chartButtonNewOrder
            };
            var iconArchive = new ChartIcon.ChartIcon((obj, e) => { })
            {
                key = ChartIcon.ChartIcon.chartButtonQuoteArchive
            };
            var iconPatchQuotes = new ChartIcon.ChartIcon((obj, e) => { })
            {
                key = ChartIcon.ChartIcon.chartButtonPatchQuotes
            };
            var iconFavIndi = new ChartIconDropDown
            {
                key = ChartIcon.ChartIcon.chartButtonFavIndicators
            };
            var iconFastSell = new ChartIconDropDown
            {
                key = ChartIcon.ChartIcon.chartButtonFastSell
            };
            var iconFastBuy = new ChartIconDropDown
            {
                key = ChartIcon.ChartIcon.chartButtonFastBuy
            };
            var iconFastOrders = new ChartIconDropDown
            {
                key = ChartIcon.ChartIcon.chartButtonDealByTicker
            };
            var iconVisual = new ChartIcon.ChartIcon((obj, e) => { })
            {
                key = ChartIcon.ChartIcon.chartVisualSettings
            };
            var iconProfitByTicker = new ChartIcon.ChartIcon((obj, e) => { })
            {
                key = ChartIcon.ChartIcon.chartProfitByTicker
            };
            var iconRobots = new ChartIconDropDown
            {
                key = ChartIcon.ChartIcon.chartRobot
            };
            iconFastOrders.listControl.columns = new List<FastColumn>
                {
                    new FastColumn("") {ColumnWidth = 38},
                    new FastColumn("") {ColumnWidth = 72},
                    new FastColumn("") {ColumnWidth = 48},
                    new FastColumn("") {ColumnWidth = 73},
                    new FastColumn("") {ColumnWidth = 73}
                };
            iconFastOrders.listControl.MinWidth = iconFastOrders.listControl.columns.Sum(c => c.ColumnWidth);
            iconFastOrders.listControl.MaxWidth = iconFastOrders.listControl.MinWidth;
            iconFastOrders.listControl.Width = iconFastOrders.listControl.MinWidth;
            iconFastOrders.listControl.CalcWidthAuto = false;

            // добавить все в массив
            allChartIcons.Add(iconStatByTicker);
            allChartIcons.Add(iconFastOrders);
            allChartIcons.Add(iconAscroll);
            allChartIcons.Add(iconIndi);
            allChartIcons.Add(iconOrder);
            allChartIcons.Add(iconArchive);
            allChartIcons.Add(iconFavIndi);
            allChartIcons.Add(iconFastSell);
            allChartIcons.Add(iconFastBuy);
            allChartIcons.Add(iconPatchQuotes);
            allChartIcons.Add(iconVisual);
            allChartIcons.Add(iconProfitByTicker);
            allChartIcons.Add(iconRobots);

            allChartIcons.ForEach(i =>
                {
                    i.Size = new Size(22, 22);
                });
        }
        /// <summary>
        /// назначить кнопкам действия
        /// указать текущее состояние кнопок
        /// </summary>        
        private void SetupChartIconsHandlers(ChartIcon.ChartIcon[] iconButtons)
        {
            foreach (var btn in iconButtons)
            {
                if (btn is ChartIconDropDown)
                {
                    var dropList = (ChartIconDropDown) btn;
                    dropList.Owner = chart;
                    dropList.BeforeDropDown += (sender, args) =>
                        {
                            var maxHeight = Height - dropList.Position.Y - 60;
                            if (maxHeight < 100)
                                maxHeight = 100;
                            dropList.listControl.MaxLines =
                                (int) Math.Ceiling(maxHeight/(double) dropList.listControl.CellHeight);
                        };
                }

                if (btn.key == ChartIcon.ChartIcon.chartButtonIndicators)
                    // показать индикаторы
                    btn.click += (sender, args) => ShowIndicatorsWindow();
                else if (btn.key == ChartIcon.ChartIcon.chartButtonIndexAutoScroll)
                {
                    // автопрокрутка включена - выключена
                    ((ChartIconCheckBox)btn).getStateFromChart = c => c.StockSeries.AutoScroll;
                    ((ChartIconCheckBox)btn).clickHandler += (ChartIcon.ChartIcon sender, out bool state) =>
                                                                  {
                                                                      chart.StockSeries.AutoScroll = !chart.StockSeries.AutoScroll;
                                                                      state = chart.StockSeries.AutoScroll;
                                                                  };
                }
                else if (btn.key == ChartIcon.ChartIcon.chartButtonNewOrder)
                    // диалог ордера
                    btn.click += (sender, args) =>
                                     {
                                         if (newOrder != null) newOrder(Symbol);
                                     };
                else if (btn.key == ChartIcon.ChartIcon.chartButtonQuoteArchive)
                    // архив котировок
                    btn.click += (sender, args) =>
                                    {
                                        if (showQuoteArchive != null) showQuoteArchive(Symbol);
                                    };
                else if (btn.key == ChartIcon.ChartIcon.chartButtonFavIndicators)
                    // список избранных индикаторов
                {
                    var favIndiCtrl = ((ChartIconDropDown) btn);
                    favIndiCtrl.BeforeDropDown += (sender, args) => SetupFavIndicatorsList(favIndiCtrl);
                    favIndiCtrl.listControl.cellClicked += (obj, text) =>
                                                               {
                                                                   var indiDesc = (IndicatorDescription) obj;
                                                                   var ind = (IChartIndicator)Activator.CreateInstance(indiDesc.indicatorType);
                                                                   AddNewIndicator(ind);
                                                                   // открыть окно настройки индикатора
                                                                   new IndicatorSettingsWindow { Indi = ind }.ShowDialog();
                                                               };
                }
                else if (btn.key == ChartIcon.ChartIcon.chartButtonFastBuy || btn.key == ChartIcon.ChartIcon.chartButtonFastSell)
                    // быстро продать или купить
                {
                    var buySell = ((ChartIconDropDown)btn);
                    SetupFastTradeButton(buySell);
                }
                else if (btn.key == ChartIcon.ChartIcon.chartButtonPatchQuotes)
                    // предложить актуализировать график
                {
                    btn.click += (sender, args) => SyncQuotes();
                }
                else if (btn.key == ChartIcon.ChartIcon.chartButtonDealByTicker)
                {
                    // сделки по валютной паре
                    var dealsBtn = ((ChartIconDropDown)btn);
                    dealsBtn.BeforeDropDown += FillButtonDealByTickerList;
                    dealsBtn.listControl.cellClicked += (obj, text) =>
                        {
                            var order = (ChartIconDealTableRow) obj;
                            if (order.Id == 0) return;
                            CallShowWindowEditMarketOrder(new MarketOrder { ID = order.Id });
                        };
                }
                else if (btn.key == ChartIcon.ChartIcon.chartVisualSettings)
                {
                    btn.click += (sender, args) =>
                        {
                            if (visualSettingsSetupCalled != null)
                                visualSettingsSetupCalled();
                        };
                }
                else if (btn.key == ChartIcon.ChartIcon.chartButtonStatByTicker)
                {
                    // статистика по валютной паре
                    var statBtn = ((ChartIconDropDownDialog)btn);
                    statBtn.Owner = chart;
                }
                else if (btn.key == ChartIcon.ChartIcon.chartProfitByTicker)
                {
                    btn.click += (sender, args) =>
                    {
                        if (profitByTickerRequested != null)
                            profitByTickerRequested(Symbol);
                    };
                }
                else if (btn.key == ChartIcon.ChartIcon.chartRobot)
                {   // нажата кнопка Роботы - открыть диалог выбора робота из портфеля,
                    // привязанного к текущему тикеру
                    // по клику на роботе открыть его его настройки или окно состояния робота
                    var btnRobot = (ChartIconDropDown) btn;
                    btnRobot.listControl.CalcWidthAuto = true;
                    btnRobot.BeforeDropDown += (sender, args) =>
                        {
                            btnRobot.listControl.Values = getRobotsByTicker(Symbol).Cast<object>().ToList();
                        };
                    btnRobot.listControl.cellClicked += (obj, text) => onRobotSelected(text);
                }
            }
        }
Exemple #5
0
 /// <summary>
 /// NB! click handler is not copied
 /// </summary>        
 public virtual ChartIcon MakeCopy()
 {
     var cpy = new ChartIcon(null) {key = key, State = State, Size = Size, Position = Position};
     return cpy;
 }