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.GetFirstComponentByType(componentType);
                component.UISerializationInfo.AddValue("componentVisible", true);

                platform_ActiveComponentAddedEvent(component, false);
                return;
            }

            if (componentType.IsSubclassOf(typeof(Expert)))
            {
                component          = new LocalExpertHost(UserFriendlyNameAttribute.GetTypeAttributeName(componentType), componentType);
                showPropertiesForm = 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);
        }
        void SetComponentMenuItemDropDownItems(ToolStripItemCollection items, Type parentingType,
                                               bool includeParentingType, string creationTitle, Image creationImage, Type[] constructorTypes)
        {
            if (_platform == null)
            {
                return;
            }

            if (constructorTypes != null)
            {// AddElement types available for creation
                List <Type> resultingTypes = ReflectionHelper.GatherTypeChildrenTypesFromAssemblies(parentingType,
                                                                                                    false, false, ReflectionHelper.GetApplicationEntryAssemblyAndReferencedAssemblies(), constructorTypes);
                if (includeParentingType && parentingType.IsAbstract == false)
                {
                    resultingTypes.Add(parentingType);
                }

                foreach (Type componentType in resultingTypes)
                {
                    if (componentType.IsAbstract)
                    {
                        continue;
                    }

                    string name = parentingType.Name;
                    UserFriendlyNameAttribute.GetTypeAttributeValue(componentType, ref name);

                    // Prepare names for showing in a menu.
                    name = name.Replace("&", "&&");

                    ToolStripMenuItem newItem = new ToolStripMenuItem(creationTitle + name, creationImage);
                    newItem.Tag    = componentType;
                    newItem.Click += new EventHandler(createItem_Click);

                    if (_platform.CanAcceptComponent(componentType) == false)
                    {     // Maybe component is invisible mandatory, and we should be able to show it.
                        if (ComponentManagementAttribute.GetTypeAttribute(componentType).IsMandatory)
                        { // Look to see if mandatory UI already created.
                            List <PlatformComponent> components = _platform.GetComponentsByType(componentType);
                            foreach (PlatformComponent component in components)
                            {
                                bool visible = false;
                                // For the button to be enabled, component must have assigned visibility flag and also its value to false.
                                newItem.Enabled = component.UISerializationInfo.TryGetValue <bool>("componentVisible", ref visible) &&
                                                  visible == false;
                            }
                        }
                        else
                        {
                            newItem.Enabled = false;
                        }
                    }
                    else
                    {
                        newItem.Enabled = true;
                    }

                    items.Add(newItem);
                }
            }

            //// Also check the UI components that are stand alone (have no platform component).
            //foreach (TabPage page in tabControl.TabPages)
            //{
            //    if (((PlatformComponentControl)page.Tag).Component == null ||
            //        ((PlatformComponentControl)page.Tag).Component is PlatformComponent == false)
            //    {
            //        if (parentingType.IsInstanceOfType((CommonBaseControl)page.Tag))
            //        {// Found existing standalone component.
            //            string name = ((CommonBaseControl)page.Tag).Name;
            //            ToolStripMenuItem newItem = new ToolStripMenuItem("Remove " + name, ForexPlatformFrontEnd.Properties.Resources.DELETE2);
            //            newItem.Tag = ((CommonBaseControl)page.Tag);
            //            newItem.Click += new EventHandler(removeItem_Click);
            //            item.DropDownItems.AddElement(newItem);
            //        }
            //    }
            //}
        }