void control_SelectedSymbolsChangedEvent(SymbolSelectControl control)
        {
            Dictionary <Symbol, string> failedSymbols = new Dictionary <Symbol, string>();

            if (control.SelectedSymbols.Count > 0 && control.SelectedDataSourceId.HasValue)
            {
                foreach (Symbol symbol in control.SelectedSymbols)
                {
                    string operationResultMessage;
                    if (Component.AddSymbol(control.SelectedDataSourceId.Value, symbol, out operationResultMessage) == false)
                    {
                        failedSymbols.Add(symbol, operationResultMessage);
                    }
                }
            }

            if (failedSymbols.Count > 0)
            {
                string message = "Failed to add symbols: " + Environment.NewLine;
                foreach (Symbol symbol in failedSymbols.Keys)
                {
                    message += symbol.Name + " [" + failedSymbols[symbol] + "]" + Environment.NewLine;
                }

                MessageBox.Show(message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void addToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SymbolSelectControl control = new SymbolSelectControl();
            HostingForm form = new HostingForm("Select symbol", control);
            control.ShowSelectButton = true;
            control.Host = Component;
            control.SelectedSymbolsChangedEvent += new SymbolSelectControl.SelectedSymbolChangedDelegate(control_SelectedSymbolsChangedEvent);

            form.Show();
        }
        private void addToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SymbolSelectControl control = new SymbolSelectControl();
            HostingForm         form    = new HostingForm("Select symbol", control);

            control.ShowSelectButton             = true;
            control.Host                         = Component;
            control.SelectedSymbolsChangedEvent += new SymbolSelectControl.SelectedSymbolChangedDelegate(control_SelectedSymbolsChangedEvent);

            form.Show();
        }
        private void symbolSelectControl_SelectedSymbolChangedEvent(SymbolSelectControl control)
        {
            _orderExecutionSourcesIds.Clear();
            _orderExecutionSourcesCompatibilities.Clear();
            comboBoxOrderExecutionSources.Items.Clear();

            comboBoxOrderExecutionSources.Enabled = symbolSelectControl.SelectedDataSourceId.HasValue;

            if (comboBoxOrderExecutionSources.Enabled)
            {
                SortedDictionary <int, List <ComponentId> > compatibleSources = GetCompatibleOrderExecutionSources();

                foreach (int value in compatibleSources.Keys)
                {
                    if (value > 0)
                    {
                        foreach (ComponentId id in compatibleSources[value])
                        {
                            _orderExecutionSourcesIds.Insert(0, id);
                            _orderExecutionSourcesCompatibilities.Insert(0, value);

                            if (_host.Platform.Settings.DeveloperMode)
                            {// Print some more orderInfo for developers.
                                comboBoxOrderExecutionSources.Items.Insert(0, id.Name + " (Compatibility: " + value.ToString() + ")");
                            }
                            else
                            {
                                comboBoxOrderExecutionSources.Items.Insert(0, id.Name);
                            }

                            if (comboBoxOrderExecutionSources.Items.Count > 0)
                            {
                                comboBoxOrderExecutionSources.SelectedIndex = 0;
                            }
                        }
                    }
                }
            }

            buttonCreateSession.Enabled = symbolSelectControl.SelectedSymbols.Count == 1 &&
                                          (comboBoxOrderExecutionSources.Visible == false || comboBoxOrderExecutionSources.SelectedIndex >= 0) &&
                                          symbolSelectControl.SelectedDataSourceId.HasValue;
        }
        void control_SelectedSymbolsChangedEvent(SymbolSelectControl control)
        {
            Dictionary<Symbol, string> failedSymbols = new Dictionary<Symbol, string>();

            if (control.SelectedSymbols.Count > 0 && control.SelectedDataSourceId.HasValue)
            {
                foreach (Symbol symbol in control.SelectedSymbols)
                {
                    string operationResultMessage;
                    if (Component.AddSymbol(control.SelectedDataSourceId.Value, symbol, out operationResultMessage) == false)
                    {
                        failedSymbols.Add(symbol, operationResultMessage);
                    }
                }
            }

            if (failedSymbols.Count > 0)
            {
                string message = "Failed to add symbols: " + Environment.NewLine;
                foreach (Symbol symbol in failedSymbols.Keys)
                {
                    message += symbol.Name + " [" + failedSymbols[symbol] + "]" + Environment.NewLine;
                }

                MessageBox.Show(message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void symbolSelectControl_SelectedSymbolChangedEvent(SymbolSelectControl control)
        {
            _orderExecutionSourcesIds.Clear();
            _orderExecutionSourcesCompatibilities.Clear();
            comboBoxOrderExecutionSources.Items.Clear();

            comboBoxOrderExecutionSources.Enabled = symbolSelectControl.SelectedDataSourceId.HasValue;

            if (comboBoxOrderExecutionSources.Enabled)
            {
                SortedDictionary<int, List<ComponentId>> compatibleSources = GetCompatibleOrderExecutionSources();

                foreach (int value in compatibleSources.Keys)
                {
                    if (value > 0)
                    {
                        foreach (ComponentId id in compatibleSources[value])
                        {
                            _orderExecutionSourcesIds.Insert(0, id);
                            _orderExecutionSourcesCompatibilities.Insert(0, value);

                            if (_host.Platform.Settings.DeveloperMode)
                            {// Print some more orderInfo for developers.
                                comboBoxOrderExecutionSources.Items.Insert(0, id.Name + " (Compatibility: " + value.ToString() + ")");
                            }
                            else
                            {
                                comboBoxOrderExecutionSources.Items.Insert(0, id.Name);
                            }

                            if (comboBoxOrderExecutionSources.Items.Count > 0)
                            {
                                comboBoxOrderExecutionSources.SelectedIndex = 0;
                            }
                        }
                    }
                }
            }

            buttonCreateSession.Enabled = symbolSelectControl.SelectedSymbols.Count == 1
                && (comboBoxOrderExecutionSources.Visible == false || comboBoxOrderExecutionSources.SelectedIndex >= 0)
                && symbolSelectControl.SelectedDataSourceId.HasValue;
        }