Beispiel #1
0
 public NavBarGroupTagObject(string name, Type moduleType)
 {
     this.name       = name;
     this.moduleType = moduleType;
     module          = null;
 }
Beispiel #2
0
        public void ChangeGroup(NavBarGroup group, object moduleData)
        {
            bool allowSetVisiblePage         = true;
            NavBarGroupTagObject groupObject = group.Tag as NavBarGroupTagObject;

            if (groupObject == null)
            {
                return;
            }
            List <RibbonPage> deferredPagesToShow = new List <RibbonPage>();

            foreach (RibbonPage page in ribbon.Pages)
            {
                if (!string.IsNullOrEmpty(string.Format("{0}", page.Tag)))
                {
                    bool isPageVisible = groupObject.Name.Equals(page.Tag);
                    if (isPageVisible != page.Visible && isPageVisible)
                    {
                        deferredPagesToShow.Add(page);
                    }
                    else
                    {
                        page.Visible = isPageVisible;
                    }
                }
                if (page.Visible && allowSetVisiblePage)
                {
                    //page.Text = "Home";
                    ribbon.SelectedPage = page;
                    allowSetVisiblePage = false;
                }
            }
            bool firstShow = groupObject.Module == null;

            if (firstShow)
            {
                if (SplashScreenManager.Default == null)
                {
                    //SplashScreenManager.ShowForm(ribbon.FindForm(), typeof(MailEfirm.Forms.wfMain), false, true);
                    SplashScreenManager.ShowForm(ribbon.FindForm(), typeof(string), false, true);
                }
                ///arreglar
                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)
                    {
                        SplashScreenManager.CloseForm(false, 2000, frm);
                    }
                    else
                    {
                        SplashScreenManager.CloseForm();
                    }
                }
            }

            foreach (RibbonPage page in deferredPagesToShow)
            {
                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)
                {
                    BaseModule currentModule = panel.Controls[0] as BaseModule;
                    if (currentModule != null)
                    {
                        currentModule.HideModule();
                    }
                }
                panel.Controls.Clear();
                panel.Controls.Add(groupObject.Module);
                groupObject.Module.Dock = DockStyle.Fill;
                groupObject.Module.ShowModule(firstShow);
            }
        }