コード例 #1
0
        public static HostingForm ShowHostingForm(Control control, string controlName)
        {
            HostingForm form = CreateHostingFormControl(control, controlName);

            form.Show();
            return(form);
        }
コード例 #2
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();
        }
コード例 #3
0
        /// <summary>
        ///
        /// </summary>
        public static HostingForm CreateHostingFormControl(Control control, string controlName)
        {
            Size        requiredSize = control.Size;
            HostingForm hostingForm  = new HostingForm(controlName);

            hostingForm.Controls.Add(control);
            control.Dock     = System.Windows.Forms.DockStyle.Fill;
            hostingForm.Size = requiredSize;
            return(hostingForm);
        }
コード例 #4
0
        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();
        }
コード例 #5
0
        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();
        }
コード例 #6
0
        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();
        }
コード例 #7
0
 private void toolStripButtonSkipTo_Click(object sender, EventArgs e)
 {
     HostingForm form = new HostingForm("Fast Run", new TimeManagementSkipToControl(_control));
     form.FormBorderStyle = FormBorderStyle.FixedDialog;
     form.ShowDialog();
 }
コード例 #8
0
 void _selectedObjectsContextMenuItem_DropDownItemClicked(object sender, ToolStripItemClickedEventArgs e)
 {
     ToolStripItem item = e.ClickedItem;
     if (item.Tag is DynamicCustomObject)
     {
         DynamicCustomObject dynamicObject = (DynamicCustomObject)item.Tag;
         CustomPropertiesControl control = new CustomPropertiesControl();
         control.SelectedObject = dynamicObject;
         control.AutoSize = true;
         HostingForm form = new HostingForm("Properties", control);
         form.Width = 400;
         form.Height = 600;
         form.Show();
     }
     else
     {// Try the chart series - this is an item of theirs.
         lock (this)
         {
             foreach (ChartSeries series in _series)
             {
                 series.OnChartContextMenuItemClicked(item);
             }
         }
     }
 }
コード例 #9
0
        void seriesPropertiesMenuItem_Click(object sender, EventArgs e)
        {
            ChartSeries series = (ChartSeries)(((ToolStripItem)sender).Tag);
            CustomPropertiesControl control = new CustomPropertiesControl();
            control.SelectedObject = series;
            HostingForm form = new HostingForm(series.Name + " Properties", control);

            form.MaximizeBox = false;
            form.ShowCloseButton = true;
            form.Show();

            form.HandleDestroyed += delegate(object inSender, EventArgs inE)
            {// On close, update to catch any changes.
                this.Invalidate();
            };
        }
コード例 #10
0
        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;
                }
            }
        }
コード例 #11
0
        void createItem_Click(object sender, EventArgs e)
        {
            ToolStripMenuItem item = (ToolStripMenuItem)sender;
            Type componentType = (Type)item.Tag;

            PlatformComponent component = null;

            bool showPropertiesForm = ComponentManagementAttribute.GetTypeAttribute(componentType).RequestPreStartSetup;

            if (ComponentManagementAttribute.GetTypeAttribute(componentType).IsMandatory)
            {// Mandatory components we do not create, only show / hide.
                component = _platform.GetFirstComponent(componentType);
                component.UISerializationInfo.AddValue("componentVisible", true);

                platform_ActiveComponentAddedEvent(component, false);
                return;
            }

            if (componentType.IsSubclassOf(typeof(Expert)))
            {
                component = new LocalExpertHost(UserFriendlyNameAttribute.GetTypeAttributeName(componentType), componentType);
                showPropertiesForm = ComponentManagementAttribute.GetTypeAttribute(typeof(LocalExpertHost)).RequestPreStartSetup;
            }
            else if (componentType.IsSubclassOf(typeof(WizardControl)))
            {// Wizards are run in Hosting forms.

                ConstructorInfo info = componentType.GetConstructor(new Type[] { typeof(Platform) });

                if (info != null)
                {
                    WizardControl wizardControl = (WizardControl)info.Invoke(new object[] { _platform });
                    HostingForm hostingForm = new HostingForm(UserFriendlyNameAttribute.GetTypeAttributeName(componentType), wizardControl);
                    hostingForm.Icon = Resources.magic_wand1;
                    hostingForm.Show();
                    return;
                }
            }
            else if (componentType.IsSubclassOf(typeof(CommonBaseControl)))
            {// Tester/editor etc. controls have no components, they are standalone UI components.
                ConstructorInfo info = componentType.GetConstructor(new Type[] { });
                // If failed to find orderInfo, just fall trough to failed to create component (which remains null).
                if (info != null)
                {// Since this is a UI only component, just create and return.
                    CommonBaseControl testerControl = (CommonBaseControl)info.Invoke(new object[] { });
                    /*tabControl.SelectedTab = */AddComponentControl(testerControl, true);

                    return;
                }
            }
            else
            {
                ConstructorInfo info = componentType.GetConstructor(new Type[] { });
                if (info != null)
                {
                    component = (PlatformComponent)info.Invoke(new object[] { });
                }
            }

            // ...
            if (component == null)
            {
                MessageBox.Show("Failed to create component.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            // Set settings for component.
            if (component.SetInitialState(_platform.Settings) == false)
            {
                MessageBox.Show("Component failed to initialize from initial state.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (showPropertiesForm)
            {
                // Show properties for the user to configure.
                PropertiesForm form = new PropertiesForm("Properties", component);
                if (form.ShowDialog() != DialogResult.OK)
                {
                    return;
                }
            }

            // Register to platform.
            _platform.RegisterComponent(component);
        }
コード例 #12
0
        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);
        }
コード例 #13
0
        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();
        }
コード例 #14
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();
 }
コード例 #15
0
 private void toolStripButtonStatistics_Click(object sender, EventArgs e)
 {
     if (_executionAccount != null)
     {
         AccountStatisticsControl control = new AccountStatisticsControl(_executionAccount);
         HostingForm form = new HostingForm("Account Performance Statistics", control);
         form.Show();
     }
 }
コード例 #16
0
        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);
        }
コード例 #17
0
 /// <summary>
 /// 
 /// </summary>
 public static HostingForm CreateHostingFormControl(Control control, string controlName)
 {
     Size requiredSize = control.Size;
     HostingForm hostingForm = new HostingForm(controlName);
     hostingForm.Controls.Add(control);
     control.Dock = System.Windows.Forms.DockStyle.Fill;
     hostingForm.Size = requiredSize;
     return hostingForm;
 }
コード例 #18
0
        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 fromOnlineSourceToolStripMenuItem_Click(object sender, EventArgs e)
 {
     HostingForm form = new HostingForm("Online Sources", new OnlineDataStoresControl() { Manager = DataStoreComponent.DataStore });
     form.Show(this.ParentForm);
 }