void uiThread_ActiveComponentUpdateEvent(PlatformComponent component, bool added, bool isInitial)
        {
            if (added)
            {
                bool visible = true;
                if (component.UISerializationInfo.ContainsValue("componentVisible"))
                {
                    visible = component.UISerializationInfo.GetBoolean("componentVisible");
                }

                if (visible)
                {
                    CommonBaseControl control = CommonBaseControl.CreateCorrespondingControl(component, true);
                    AddComponentControl(control, isInitial == false);
                }
            }
            else
            {
                CommonBaseControl control = combinedContainerControl.GetControlByTag(component);
                if (control != null)
                {
                    combinedContainerControl.RemoveControl(control);
                }
            }

            UpdateComponentsMenues();
        }
        void SetControlFloat(LocalExpertHost host)
        {
            CommonBaseControl control = MasterForm.combinedContainerControl.GetControlByTag(host);

            if (control != null)
            {
                MasterForm.combinedContainerControl.SetControlFloating(control);
            }
            else
            {
                SystemMonitor.Error("Failed to find host control to float.");
            }
        }
        /// <summary>
        /// Helper function to create a new properly assigned tab page for the given component control.
        /// </summary>
        void AddComponentControl(CommonBaseControl componentControl, bool focus)
        {
            combinedContainerControl.AddControl(componentControl);

            if (componentControl is PlatformComponentControl)
            {
                ((PlatformComponentControl)componentControl).SetApplicationStatusStrip(this.statusStripMain);
            }

            if (focus)
            {
                combinedContainerControl.ChangeCheckedControl(componentControl);
            }
        }
示例#4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="expertHost"></param>
        void Initialize(ExpertHost expertHost)
        {
            this.Name = expertHost.Name;

            _expertHost = expertHost;
            _expertHost.OperationalStateChangedEvent += new OperationalStateChangedDelegate(expertHost_OperationalStatusChangedEvent);

            // Create early here, to be able to use the image name.
            _expertControl = CommonBaseControl.CreateCorrespondingControl(_expertHost.Expert, true);
            this.ImageName = _expertControl.ImageName;

            //_host.SessionsUpdateEvent += new GeneralHelper.GenericDelegate<ISourceManager>(_expertHost_SessionsUpdateEvent);
            //_host.SourcesUpdateEvent += new GeneralHelper.GenericDelegate<ISourceManager>(_expertHost_SourcesUpdateEvent);
            //DoUpdateUI();
        }
 void combinedContainerControl_FocusedControlChangedEvent(CombinedContainerControl containerControl, CommonBaseControl control)
 {
     WinFormsHelper.BeginFilteredManagedInvoke(this, TimeSpan.FromMilliseconds(250), new GeneralHelper.GenericDelegate <PlatformComponent>(UpdateFormText), control != null ? control.Tag as PlatformComponent : null);
 }
        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);
        }