void CreateComponentTab(FxpaCommonControl componentControl)
        {
            if (componentControl != null && componentControl.Title.Length > 0)
            {
                Console.WriteLine(" componentControl.Name   >>>>  " + componentControl.Name);
                TabPage newPage = new TabPage();
                tabControl.TabPages.Add(newPage);
                if (componentControl.Title == "Manual Trading")
                {
                    newPage.Name = "Analyzer Analytic";
                }
                else
                {
                    newPage.Name = componentControl.Title;
                }

                if (string.IsNullOrEmpty(componentControl.ImageName) == false)
                {
                    newPage.ImageKey = componentControl.ImageName;
                }
                else
                {
                    newPage.ImageKey = "dot.png";
                }

                componentControl.Dock    = DockStyle.Fill;
                componentControl.Parent  = newPage;
                newPage.Tag              = componentControl;
                tabControl.SelectedIndex = tabControl.TabPages.Count - 1;
            }
        }
        private void AnalyzerHostControl_Load(object sender, EventArgs e)
        {
            _expertControl = FxpaCommonControl.CreateCorrespondingControl(_host.Analyzer);
            if (_expertControl == null)
            {
                labelMain.Text = _host.AnalyzerName + ", " + _host.Analyzer.GetType().Name + " has no user interface component.";
                return;
            }

            _expertControl.Dock   = DockStyle.Fill;
            _expertControl.Parent = this;
            _expertControl.BringToFront();
        }
        private void AnalyzerHostControl_Load(object sender, EventArgs e)
        {
            _expertControl = FxpaCommonControl.CreateCorrespondingControl(_host.Analyzer);
            if (_expertControl == null)
            {
                labelMain.Text = _host.AnalyzerName + ", " + _host.Analyzer.GetType().Name + " has no user interface component.";
                return;
            }

            _expertControl.Dock = DockStyle.Fill;
            _expertControl.Parent = this;
            _expertControl.BringToFront();
        }
Example #4
0
        static public FxpaCommonControl CreateCorrespondingControl(object component)
        {
            List <Type> types = ReflectionHelper.GatherTypeChildrenTypesFromAssembliesWithMatchingConstructor(typeof(FxpaCommonControl), true, ReflectionHelper.GetReferencedAndInitialAssembly(Assembly.GetEntryAssembly()), new Type[] { component.GetType() });

            if (types.Count == 0)
            {
                //// Try also with a more relaxed type match.
                //types = ReflectionHelper.GatherTypeChildrenTypesFromAssembliesWithMatchingConstructor(typeof(CommonBaseControl), false, ReflectionHelper.GetReferencedAndInitialAssembly(Assembly.GetEntryAssembly()), new Type[] { component.GetType() });
                //if (types.Count == 0)
                //{
                return(null);
                //}
            }

            // SystemMonitor.CheckWarning(types.Count == 1, "More than 1 control found for this type of component, creating the first one.");

            // Return the first proper object.
            FxpaCommonControl control = (FxpaCommonControl)types[0].GetConstructor(new Type[] { component.GetType() }).Invoke(new object[] { component });

            control.Tag = component;
            return(control);
        }
        void uiThread_ActiveComponentUpdateEvent(IFxpaBaseCompoent component, bool added)
        {
            if (added)
            {
                FxpaCommonControl control = FxpaCommonControl.CreateCorrespondingControl(component);
                CreateComponentTab(control);
            }
            else
            {
                foreach (TabPage page in tabControl.TabPages)
                {
                    IFxpaBaseCompoent currentComponent = ((FxpaCommonControl)page.Tag).Component as IFxpaBaseCompoent;
                    if (currentComponent == component)
                    {
                        RemoveComponentTab((FxpaCommonControl)page.Tag);
                        break;
                    }
                }
            }

            UpdateTabTitles();
            UpdateComponentsMenu();
        }
        void RemoveComponentTab(FxpaCommonControl componentControl)
        {
            TabPage page = (TabPage)componentControl.Parent;

            tabControl.TabPages.Remove(page);
        }