예제 #1
0
 private object GetModuleData(NavBarGroupTagObject tag)
 {
     if (tag == null)
     {
         return(null);
     }
     if (tag.ModuleType == typeof(DeviceTags))
     {
         return(ucDevices);
     }
     if (tag.ModuleType == typeof(ServiceInfo))
     {
         return(ucServicesTree);
     }
     return(null);
 }
예제 #2
0
        public void ChangeGroup(NavBarGroup group, object moduleData)
        {
            bool allowSetVisiblePage         = true;
            NavBarGroupTagObject groupObject = group.Tag as NavBarGroupTagObject;

            if (groupObject == null)
            {
                return;
            }

            List <RibbonPage> deferredPageToShow = new List <RibbonPage>();

            foreach (RibbonPage page in ribbon.Pages)
            {
                if (!string.IsNullOrEmpty($"{page.Tag}"))
                {
                    bool isPageVisible = groupObject.Name.Equals(page.Tag);
                    if (isPageVisible != page.Visible && isPageVisible)
                    {
                        deferredPageToShow.Add(page);
                    }
                    else
                    {
                        page.Visible = isPageVisible;
                    }
                }

                if (page.Visible && allowSetVisiblePage)
                {
                    ribbon.SelectedPage = page;
                    allowSetVisiblePage = false;
                }
            }

            bool firstShow = groupObject.Module == null;

            if (firstShow)
            {
                if (SplashScreenManager.Default == null)
                {
                    SplashScreenManager.ShowForm(
                        ribbon.FindForm(),
                        typeof(Forms.wfMain),
                        false,
                        true);
                }

                ConstructorInfo constructorInfoObj =
                    groupObject.ModuleType.GetConstructor(Type.EmptyTypes);
                if (constructorInfoObj != null)
                {
                    groupObject.Module = constructorInfoObj.Invoke(null) as BaseModule;
                    groupObject.Module.InitModule(ribbon, moduleData);
                }

                if (SplashScreenManager.Default != null)
                {
                    Form frm = moduleData as Form;
                    if (frm != null)
                    {
                        if (SplashScreenManager.FormInPendingState)
                        {
                            SplashScreenManager.CloseForm();
                        }
                        else
                        {
                            SplashScreenManager.CloseForm(false, 500, frm);
                        }
                    }
                    else
                    {
                        SplashScreenManager.CloseForm();
                    }
                }
            }

            foreach (RibbonPage page in deferredPageToShow)
            {
                page.Visible = true;
            }

            foreach (RibbonPage page in ribbon.Pages)
            {
                if (page.Visible)
                {
                    ribbon.SelectedPage = page;
                    break;
                }
            }

            if (groupObject.Module != null)
            {
                if (panel.Controls.Count > 0)
                {
                    if (panel.Controls[0] is BaseModule currentModule)
                    {
                        currentModule.HideModule();
                    }
                }
                panel.Controls.Clear();
                panel.Controls.Add(groupObject.Module);
                groupObject.Module.Dock = DockStyle.Fill;
                //groupObject.Module.ShowModule(firstShow);
            }
        }