Ejemplo n.º 1
0
        private void toolStripButtonSettings_Click(object sender, EventArgs e)
        {
            NewsManagerSettingsControl control = new NewsManagerSettingsControl(this);
            HostingForm form = new HostingForm("News Management Properties", control);

            form.StartPosition = FormStartPosition.WindowsDefaultLocation;
            form.ShowDialog();
        }
        private void buttonSettings_Click(object sender, EventArgs e)
        {
            if (listViewFeeds.SelectedIndices.Count == 0)
            {
                return;
            }

            if (listViewFeeds.SelectedIndices.Count > 1)
            {
                MessageBox.Show("Select only one feed to show settings for.");
                return;
            }

            EventSource source = _control.Manager.NewsSourcesUnsafe[listViewFeeds.SelectedIndices[0]];
            NewsSourceSettingsControl control = new NewsSourceSettingsControl(source);
            HostingForm form = new HostingForm("Source Settings", control);
            form.StartPosition = FormStartPosition.CenterScreen;
            form.ShowDialog();

            _control.UpdateUI();
        }
        private void buttonModifyOrder_Click(object sender, EventArgs e)
        {
            List<Order> orders = GetSelectedOrders();
            if (orders.Count > 1 || orders.Count == 0)
            {
                MessageBox.Show("Select a single order to modify.");
                return;
            }

            Order selectedOrder = orders[0];

            if (selectedOrder.IsOpenOrPending == false
                || selectedOrder.OrderExecutionProvider == null)
                //|| selectedOrder.OrderExecutionProvider.DataProvider == null
                //|| selectedOrder.OrderExecutionProvider.DataProvider.Quotes == null)
            {
                return;
            }

            ModifyOrderControl control = new ModifyOrderControl(ModifyOrderControl.ModeEnum.Modify, selectedOrder);
            control.Visible = true;

            HostingForm form = new HostingForm("Modify order", control);
            form.ShowDialog();
        }
        private void buttonCloseOrder_Click(object sender, EventArgs e)
        {
            List<Order> orders = GetSelectedOrders();
            if (orders.Count > 1 || orders.Count == 0)
            {
                MessageBox.Show("Select a single order to close.");
                return;
            }

            if (orders[0] is ActiveOrder)
            {
                ActiveOrder order = (ActiveOrder)orders[0];

                if (order.IsOpenOrPending == false)
                {
                    return;
                }

                if (order.State == OrderStateEnum.Submitted)
                {
                    string message;
                    if (order.Cancel(out message))
                    {
                        MessageBox.Show("Order canceled.", "Success", MessageBoxButtons.OK);
                    }
                    else
                    {
                        MessageBox.Show("Order cancel failed [" + message + "].", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                else
                {
                    ModifyOrderControl control = new ModifyOrderControl(ModifyOrderControl.ModeEnum.Close, order);
                    HostingForm form = new HostingForm("Modify order", control);
                    form.ShowDialog();
                }
            }
            else if (orders[0] is PassiveOrder)
            {
                PassiveOrder order = (PassiveOrder)orders[0];

                if (order.State != OrderStateEnum.Submitted)
                {
                    MessageBox.Show("Passive orders can only be canceled.");
                    return;
                }

                string operationResultMessage = string.Empty;
                if (order.CloseOrCancel(null, null, out operationResultMessage) == false)
                {
                    MessageBox.Show("Failed to cancel order [" + operationResultMessage + "].", "Order Cancel Failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }
        }
        private void buttonAddOrder_Click(object sender, EventArgs e)
        {
            if (_selectedSession == null)
            {
                MessageBox.Show("Select a session to send order to.");
                return;
            }

            if (_selectedSession.DataProvider.OperationalState != OperationalStateEnum.Operational
                || _selectedSession.OrderExecutionProvider.OperationalState != OperationalStateEnum.Operational)
            {
                MessageBox.Show("Session data or order execution provider not operational.");
                return;
            }

            NewOrderControl control = new NewOrderControl(_selectedSession.DataProvider.Quotes, _selectedSession.Info, false, false);
            control.CreatePlaceOrderEvent += new NewOrderControl.CreatePlaceOrderDelegate(SubmitPositionOrder);

            HostingForm f = new HostingForm("New Order", control);
            f.MaximizeBox = false;
            f.FormBorderStyle = FormBorderStyle.FixedSingle;
            f.ShowDialog();
            control.CreatePlaceOrderEvent -= new NewOrderControl.CreatePlaceOrderDelegate(SubmitPositionOrder);
        }
        private void buttonSettings_Click(object sender, EventArgs e)
        {
            if (listViewFeeds.SelectedIndices.Count == 0)
            {
                return;
            }

            if (listViewFeeds.SelectedIndices.Count > 1)
            {
                MessageBox.Show("Select only one feed to show settings for.");
                return;
            }

            NewsSource source = _control.Manager.NewsSourcesUnsafe[listViewFeeds.SelectedIndices[0]];
            NewsSourceSettingsControl control = new NewsSourceSettingsControl(source);
            HostingForm form = new HostingForm("Source Settings", control);
            form.StartPosition = FormStartPosition.CenterScreen;
            form.ShowDialog();

            _control.UpdateUI();
        }
 private void toolStripButtonSkipTo_Click(object sender, EventArgs e)
 {
     HostingForm form = new HostingForm("Fast Run", new TimeManagementSkipToControl(_control));
     form.FormBorderStyle = FormBorderStyle.FixedDialog;
     form.ShowDialog();
 }
        private void toolStripButtonNewOrder_Click(object sender, EventArgs e)
        {
            if (_manager == null)
            {
                return;
            }

            Position position = SelectedPosition;
            if (position == null)
            {
                MessageBox.Show("Select a position to put order to.");
                return;
            }

            if (position.DataDelivery.OperationalState != OperationalStateEnum.Operational
                || position.OrderExecutionProvider.OperationalState != OperationalStateEnum.Operational)
            {
                MessageBox.Show("Position data or order execution provider not operational.");
                return;
            }

            IQuoteProvider quotes = _manager.ObtainQuoteProvider(position.DataDelivery.SourceId, position.Symbol);
            DataSessionInfo? info = _manager.GetSymbolDataSessionInfo(position.DataDelivery.SourceId, position.Symbol);

            if (info.HasValue == false)
            {
                MessageBox.Show("Failed to establish position session.", Application.ProductName + " - Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            NewOrderControl control = new NewOrderControl(quotes, info.Value, true, true);

            control.CreatePlaceOrderEvent += new NewOrderControl.CreatePlaceOrderDelegate(SubmitPositionOrder);

            HostingForm f = new HostingForm("New Order", control);
            f.FormBorderStyle = FormBorderStyle.FixedSingle;
            f.MaximizeBox = false;
            f.ShowDialog();
            control.CreatePlaceOrderEvent -= new NewOrderControl.CreatePlaceOrderDelegate(SubmitPositionOrder);
        }
        private void toolStripButtonIndicators_Click(object sender, EventArgs e)
        {
            if (Session == null)
            {
                return;
            }

            ExpertSessionIndicatorsControl control = new ExpertSessionIndicatorsControl(_session, chartControl.Panes);
            control.AddIndicatorEvent += new ExpertSessionIndicatorsControl.AddIndicatorDelegate(control_AddIndicatorEvent);
            control.RemoveIndicatorEvent += new ExpertSessionIndicatorsControl.RemoveIndicatorDelegate(control_RemoveIndicatorEvent);
            HostingForm form = new HostingForm("Session " + _session.Info.Name + " Indicators", control);
            form.FormBorderStyle = FormBorderStyle.FixedDialog;
            form.ShowDialog();
        }
 private void toolStripButtonSettings_Click(object sender, EventArgs e)
 {
     NewsManagerSettingsControl control = new NewsManagerSettingsControl(this);
     HostingForm form = new HostingForm("News Management Properties", control);
     form.StartPosition = FormStartPosition.WindowsDefaultLocation;
     form.ShowDialog();
 }