Ejemplo n.º 1
0
        private static void TranslateRibbonControl(RibbonControl ribbonControl)
        {
            foreach (RibbonPage page in ribbonControl.Pages)
            {
                string name = ribbonControl.FindForm().Name + "." + ribbonControl.Name + "." + page.Name;
                page.Text = TranslateString(name, page.Text);

                foreach (RibbonPageGroup g in page.Groups)
                {
                    string gname = ribbonControl.FindForm().Name + "." + ribbonControl.Name + "." + page.Name + "." + g.Name;
                    g.Text = TranslateString(gname, g.Text);

                    foreach (BarItemLink i in g.ItemLinks)
                    {
                        string iname = ribbonControl.FindForm().Name + "." + ribbonControl.Name + "." + page.Name + "." + g.Name + "." + i.Item.Name;
                        i.Caption = TranslateString(iname, i.Caption);

                        if (i.Item is BarSubItem)
                        {
                            var sub = i.Item as BarSubItem;

                            foreach (BarItemLink y in sub.ItemLinks)
                            {
                                string name2 = ribbonControl.FindForm().Name + "." + ribbonControl.Name + "." + page.Name + "." + g.Name + "." + i.Item.Name + y.Item.Name;
                                y.Caption = TranslateString(name2, y.Caption);
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 从插件方案中查找RibbonControl对应的插件,加载插件
        /// </summary>
        /// <param name="ribbonCtrl"></param>
        /// <param name="pluginPlan"></param>
        /// <param name="cmdData">插件命令的传入参数,泛型对象</param>
        public static void LoadPlugins <TCmdData>(this RibbonControl ribbonCtrl, IPluginPlan pluginPlan, TCmdData cmdData)
        {
            var form      = ribbonCtrl.FindForm();
            var view      = pluginPlan.QueryViews(form);        //找到窗体对应的插件视图
            var container = QueryContainer(view, ribbonCtrl);   //找到控件对应的插件容器

            container.LoadPluginContainer(ribbonCtrl);          //向控件加载插件容器包含的插件
            container.LoadPluginCommands(cmdData);              //创建容器包含的插件对应的命令
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 向插件窗口的RibbonControl控件加载插件
        /// </summary>
        /// <param name="container"></param>
        /// <param name="ribbonCtrl"></param>
        private static void LoadPluginContainer(this IPluginContainer container, RibbonControl ribbonCtrl)
        {
            var form            = ribbonCtrl.FindForm();
            var imageCollection = ribbonCtrl.Images == null ? new ImageCollection() : (ImageCollection)ribbonCtrl.LargeImages;

            ribbonCtrl.LargeImages = imageCollection;
            foreach (var pageContainer in container.SubContainers)
            {
                var page = new RibbonPage {
                    Text = pageContainer.Text, Name = pageContainer.Name
                };
                ribbonCtrl.DefaultPageCategory.Pages.Add(page);
                foreach (var groupContainer in pageContainer.SubContainers)
                {
                    var group = new RibbonPageGroup {
                        Text = groupContainer.Text, Name = groupContainer.Name
                    };
                    page.Groups.Add(group);
                    var plugins = groupContainer.Plugins.OrderBy(v => v.Index);
                    foreach (var plugin in plugins)
                    {
                        var image      = plugin.GetImage();
                        int imageIndex = image == null ? -1 : imageCollection.Images.Add(image);
                        var item       = new BarButtonItem
                        {
                            Caption         = plugin.Text,
                            SuperTip        = SuperTipsEx.CreateSuperTips(plugin.Tips, plugin.Text),
                            RibbonStyle     = RibbonItemStyles.All,
                            LargeImageIndex = imageIndex,
                            Tag             = plugin
                        };
                        if (!string.IsNullOrWhiteSpace(plugin.ShortcutKeys))
                        {
                            item.ItemShortcut = new BarShortcut((Keys)Enum.Parse(typeof(Keys), plugin.ShortcutKeys));
                        }

                        item.ItemClick += (sender, e) => plugin.Command.Invoke(form);
                        group.ItemLinks.Add(item);
                    }
                }
            }
        }
Ejemplo n.º 4
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(DevExpress.MailClient.Win.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 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);
            }
        }
Ejemplo n.º 5
0
        //public void ChangeGroup(NavBarGroup group, object moduleData)
        public void ChangeNavBarGroup(NavBarGroupTagObject groupObject)
        {
            if (groupObject == null)
            {
                return;
            }

            bool firstShow = groupObject.Module == null;

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


                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();
                }
            }

            ConstructorInfo constructorInfoObj = groupObject.ModuleType.GetConstructor(Type.EmptyTypes);

            if (constructorInfoObj != null)
            {
                groupObject.Module = constructorInfoObj.Invoke(null) as BaseModule;
                // groupObject.Module.InitModule(ribbon, null);
            }


            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);
                //tabbedMdiManager.MdiParent = groupObject.Module;
                //XtraMdiTabPage page = tabbedMdiManager.SelectedPage;

                //tabbedMdiManager.SelectedPage = page;

                groupObject.Module.Dock = DockStyle.Fill;
                groupObject.Module.BaseModuleControl(ribbon);
                //groupObject.Module.ShowModule(false);
            }
        }
Ejemplo n.º 6
0
        public void ChangeSelectedItem(NavBarItemLink link, object moduleData)
        {
            bool allowSetVisiblePage         = true;
            NavBarGroupTagObject groupObject = link.Item.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(DevExpress.ProductsDemo.Win.Forms.wfMain), false, true);
                }
                ConstructorInfo constructorInfoObj = groupObject.ModuleType.GetConstructor(Type.EmptyTypes);
                if (constructorInfoObj != null)
                {
                    try {
                        groupObject.Module = constructorInfoObj.Invoke(null) as BaseModule;
                        groupObject.Module.InitModule(ribbon, moduleData);
                        _currentModuleName = link.Caption;
                    } catch (Exception e) {
                        var    entryAsm = Assembly.GetEntryAssembly();
                        string msg      = string.Format("Error on Showing Module: {0}\r\nPrevModule: {1}\r\nStartUp: {2}",
                                                        link.Caption, _currentModuleName, (entryAsm != null ? entryAsm.Location : string.Empty));
                        throw new ApplicationException(msg, e);
                    }
                }
                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();
                    }
                }
            }
            ribbon.ColorScheme = groupObject.RibbonScheme;
            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);
            }
        }