Example #1
0
        /// <summary>
        /// 加载XML,创建导航
        /// </summary>
        public void LoadXml()
        {
            BP.WF.Tabs tabs = new BP.WF.Tabs();
            tabs.RetrieveAll();

            BP.WF.GroupFuncs gs = new BP.WF.GroupFuncs();
            gs.RetrieveAll();

            BP.WF.Funcs fs = new BP.WF.Funcs();
            fs.RetrieveAll();

            this.SuspendLayout();
            this.Tabs.Clear();
            int i = 1;

            foreach (BP.WF.Tab tb in tabs)
            {
                i++;
                RibbonTab mytab = Factory.CreateRibbonTab();
                mytab.Label = tb.Name;
                mytab.Name  = "t" + tb.No + i;
                if (i == 2)
                {
                    mytab.ControlId.ControlIdType = RibbonControlIdType.Custom;
                }
                else
                {
                    mytab.ControlId.ControlIdType = RibbonControlIdType.Office;
                }

                mytab.SuspendLayout();

                foreach (BP.WF.GroupFunc g in gs)
                {
                    if (g.FK_Tab != tb.No)
                    {
                        continue;
                    }

                    RibbonGroup group = Factory.CreateRibbonGroup();
                    group.Name  = "s" + g.No;
                    group.Label = g.Name;
                    group.DialogLauncherClick += new RibbonControlEventHandler(Btn_Click);
                    group.SuspendLayout();

                    foreach (BP.WF.Func f in fs)
                    {
                        if (f.FK_Group != g.No)
                        {
                            continue;
                        }

                        switch (f.CtlType)
                        {
                        case "Btn":
                            RibbonButton btn = Factory.CreateRibbonButton();
                            btn.Name  = "Btn_" + f.No;
                            btn.Label = f.Name;
                            btn.Tag   = f;
                            try
                            {
                                if (f.IsIcon)
                                {
                                    btn.Image     = System.Drawing.Image.FromFile(BP.WF.Glo.PathOfTInstall + "\\Img\\" + f.No + ".gif");
                                    btn.ShowImage = true;
                                }
                            }
                            catch
                            {
                            }
                            btn.Click += new RibbonControlEventHandler(Btn_Click);
                            group.Items.Add(btn);
                            break;

                        default:
                            RibbonLabel lab = Factory.CreateRibbonLabel();
                            lab.Name  = "Lab_" + f.No;
                            lab.Label = f.Name;
                            lab.Tag   = f;
                            group.Items.Add(lab);
                            break;
                        }
                    }
                    group.ResumeLayout(false);
                    group.PerformLayout();
                    mytab.Groups.Add(group);
                } // End add to Group.

                mytab.ResumeLayout(false);
                mytab.PerformLayout();
                this.Tabs.Add(mytab);
            } // End add to Tab.

            this.ResumeLayout(false);
            this.RibbonType = "Microsoft.Word.Document";
            //  this.RibbonType = "Microsoft.PowerPoint.Presentation";
            this.Load += new RibbonUIEventHandler(Ribbon1_Load);
        }