コード例 #1
0
ファイル: Global.cs プロジェクト: LuisYang0215/SparkleXrm-1
        public static void GetRunningActivities(CommandProperties commandProperties)
        {
            // Get a list of all running activities
            // TODO: This list could be filtered to only 'billable' activities
            EntityCollection  runningActivities = OrganizationServiceProxy.RetrieveMultiple(Queries.CurrentOpenActivitesWithSessions);
            RibbonMenuSection section           = new RibbonMenuSection("dev1.Activities.Section", "Activities", 1, RibbonDisplayMode.Menu16);
            int i = 0;

            foreach (Dictionary activity in runningActivities.Entities)
            {
                string image = "WebResources/dev1_/images/start.gif";

                bool isRunning = activity["isRunning"] != null && (activity["isRunning"].ToString() == "1");
                if (isRunning)
                {
                    image = "WebResources/dev1_/images/stop.gif";
                }


                section.AddButton(
                    new RibbonButton("dev1.Activity." + activity["a.activityid"].ToString(),
                                     i,
                                     activity["a.subject"].ToString(),
                                     "dev1.ApplicationRibbon.StartStopActivity.Command",
                                     image,
                                     image));
                i++;
            }

            RibbonMenu activities = new RibbonMenu("dev1.Activities").AddSection(section);



            commandProperties.PopulationXML = activities.SerialiseToRibbonXml();
        }
コード例 #2
0
ファイル: RibbonHost.cs プロジェクト: vczh-codeplex/vlpp
        private RibbonMenu CreateStartMenu()
        {
            RibbonMenu menu = new RibbonMenu();

            {
                RibbonMenuButton button = new RibbonMenuButton();
                button.SmallImage = StartImages.New;
                button.Name       = "新建文档";
                menu.MenuItems.Add(button);
            }
            {
                RibbonMenuButton button = new RibbonMenuButton();
                button.SmallImage = StartImages.Open;
                button.Name       = "打开文档";
                button.Enabled    = false;
                menu.MenuItems.Add(button);
            }
            {
                RibbonMenuButton button = new RibbonMenuButton();
                button.SmallImage = StartImages.Save;
                button.Name       = "保存文档";
                menu.MenuItems.Add(button);
            }
            {
                RibbonMenuButton button = new RibbonMenuButton();
                button.Name = "关闭";
                menu.MenuItems.Add(button);
            }
            return(menu);
        }
コード例 #3
0
ファイル: Ribbon.cs プロジェクト: LuisYang0215/SparkleXrm-1
        private static void GetFormTabs(RibbonMenu quickNav)
        {
            SELECT_TAB_COMMAND_PREFIX = uniquePrefix + "QuickNav.Tabs.";
            if (Page.Ui != null && Page.Ui.FormSelector != null)
            {
                FormSelectorItem form            = Page.Ui.FormSelector.GetCurrentItem();
                string           formSectionName = "Form";
                if (form != null)
                {
                    formSectionName = form.GetLabel();
                }

                RibbonMenuSection tabsSection = new RibbonMenuSection(uniquePrefix + "QuickNav.Tabs", formSectionName, 1, RibbonDisplayMode.Menu16);
                quickNav.AddSection(tabsSection);
                int i = 0;
                // Get the tabs and sections on the form
                Page.Ui.Tabs.ForEach(delegate(TabItem tab, int index)
                {
                    if (tab.GetVisible())
                    {
                        RibbonButton button = new RibbonButton(SELECT_TAB_COMMAND_PREFIX + tab.GetName(), i, tab.GetLabel(), "dev1.QuickNav.SelectTab", "/_imgs/FormEditorRibbon/Subgrid_16.png", "");
                        tabsSection.AddButton(button);
                        i++;
                    }
                    return(true);
                });
            }
        }
コード例 #4
0
ファイル: ribboncontrols.cs プロジェクト: lightman2/skiaming
        // 当菜单将动态属性
        // 设置为 true 并且用户单击下拉菜单时会激发“菜单项正在加载”事件。这允许在运行时动态
        // 添加菜单项。
        private void mDynamicMenu_ItemsLoading(object sender, RibbonControlEventArgs e)
        {
            mDynamicMenu.Items.Clear();

            if (cbButton.Checked)
            {
                RibbonButton tmp = this.Factory.CreateRibbonButton();
                tmp.Label = "Button";
                mDynamicMenu.Items.Add(tmp);
            }

            if (cbSeparator.Checked)
            {
                RibbonSeparator tmp = this.Factory.CreateRibbonSeparator();
                tmp.Title = "Menu Separator";
                mDynamicMenu.Items.Add(tmp);
            }

            if (cbSubMenu.Checked)
            {
                RibbonButton subButton = this.Factory.CreateRibbonButton();
                subButton.Label         = "SubMenu Button";
                subButton.OfficeImageId = "_3DMaterialMetal";
                subButton.Description   = "Large Button in a Sub Menu";

                RibbonMenu mSubMenu = this.Factory.CreateRibbonMenu();
                mSubMenu.ItemSize = Microsoft.Office.Core.RibbonControlSize.RibbonControlSizeLarge;
                mSubMenu.Label    = "Sub Menu";

                mSubMenu.Items.Add(subButton);
                mDynamicMenu.Items.Add(mSubMenu);
            }
        }
コード例 #5
0
ファイル: ribboncontrols.cs プロジェクト: lightman2/skiaming
        // 当菜单将动态属性
        // 设置为 true 并且用户单击下拉菜单时会激发“菜单项正在加载”事件。这允许在运行时动态
        // 添加菜单项。
        private void mDynamicMenu_ItemsLoading(object sender, RibbonControlEventArgs e)
        {
            mDynamicMenu.Items.Clear();

            if (cbButton.Checked)
            {
                mDynamicMenu.Items.Add(new RibbonButton {
                    Label = "Button"
                });
            }

            if (cbSeparator.Checked)
            {
                mDynamicMenu.Items.Add(new RibbonSeparator {
                    Title = "Menu Separator"
                });
            }

            if (cbSubMenu.Checked)
            {
                RibbonButton subButton = new RibbonButton {
                    Label         = "SubMenu Button",
                    OfficeImageId = "_3DMaterialMetal",
                    Description   = "Large Button in a Sub Menu"
                };
                RibbonMenu mSubMenu = new RibbonMenu {
                    ItemSize = Microsoft.Office.Core.RibbonControlSize.RibbonControlSizeLarge,
                    Label    = "Sub Menu"
                };
                mSubMenu.Items.Add(subButton);
                mDynamicMenu.Items.Add(mSubMenu);
            }
        }
コード例 #6
0
ファイル: Ribbon1.cs プロジェクト: toreal/Violet
        void addByName(RibbonControl uiobj, String name)
        {
            if (uiobj != null)
            {
                foreach (RibbonGroup gr in  tab1.Groups)
                {
                    if (gr.Label == name)
                    {
                        gr.SuspendLayout();
                        gr.Items.Add(uiobj);
                        gr.ResumeLayout(false);
                        gr.PerformLayout();
                        break;
                    }


                    foreach (RibbonControl rc in gr.Items)
                    {
                        if (rc is RibbonMenu)
                        {
                            RibbonMenu rm = (RibbonMenu)rc;
                            if (rm.Label == name)
                            {
                                rm.SuspendLayout();
                                rm.Items.Add(uiobj);
                                rm.ResumeLayout(false);
                                rm.PerformLayout();
                                break;
                            }
                        }
                    }
                }
            }
        }
コード例 #7
0
ファイル: Ribbon1.cs プロジェクト: toreal/Violet
        //create form


        public void Construt(ShapeObj obj)
        {
            ArrayList list = obj.getMenuItem();

            //  RibbonGroup group3 = this.Factory.CreateRibbonGroup();
            // RibbonTab tab = Factory.CreateRibbonTab();

            foreach (shapeUI ui in list)
            {
                switch (ui.uitype)
                {
                case shapeUIType.RibbonBigButton:
                    RibbonButton uiobj = this.Factory.CreateRibbonButton();
                    uiobj.Click      += (RibbonControlEventHandler)ui.click;
                    uiobj.Label       = ui.label;
                    uiobj.Image       = ui.image;
                    uiobj.ControlSize = Microsoft.Office.Core.RibbonControlSize.RibbonControlSizeLarge;

                    addByName(uiobj, ui.belong);
                    break;

                case shapeUIType.RibbonSmallButton:
                    RibbonButton uisobj = this.Factory.CreateRibbonButton();
                    uisobj.Click += (RibbonControlEventHandler)ui.click;

                    if (ui.image != null)
                    {
                        uisobj.ShowImage = true;
                        uisobj.Name      = ui.label;
                    }
                    else
                    {
                        uisobj.Label = ui.label;
                    }

                    uisobj.Image       = ui.image;
                    uisobj.ControlSize = Microsoft.Office.Core.RibbonControlSize.RibbonControlSizeRegular;

                    addByName(uisobj, ui.belong);
                    break;

                case shapeUIType.RibbonGroup:
                    RibbonGroup uig = this.Factory.CreateRibbonGroup();
                    uig.Label = ui.label;
                    tab1.Groups.Add(uig);

                    break;

                case shapeUIType.RibbonMenu:
                    RibbonMenu rim = Factory.CreateRibbonMenu();
                    rim.Label = ui.label;
                    rim.Image = ui.image;
                    addByName(rim, ui.belong);
                    break;
                }
            }

            //tab.Groups.Add(group3);
            //Tabs.Add(tab);
        }
コード例 #8
0
        private void BtnExport_Click(object sender, RibbonControlEventArgs e)
        {
            ExcelHelper.ToggleExcelEvents(Globals.ThisAddIn.excelApplication, false);
            Cursor.Current = Cursors.WaitCursor;
            RibbonMenu ribbonMenu   = (RibbonMenu)dynamicMenuAdd;
            string     addMenuLabel = ribbonMenu.Label;

            InitializeVariables.InitializeDatabaseTables();
            if (backgroundWorker1.IsBusy != true)
            {
                alert = new ProgressBarForm();
                switch (addMenuLabel)
                {
                case "Fields":
                    alert.Text = "Validating and Exporting Fields Data";
                    break;

                case "Dropdowns":
                    alert.Text = "Exporting dropdown data";
                    break;

                case "Descriptions":
                    alert.Text = "Exporting translated descriptions";
                    break;

                case "Fields and Dropdowns":
                    alert.Text = "Validating Fields and Exporting Fields and Dropdowns data";
                    break;
                }
                alert.Show();
                backgroundWorker1.RunWorkerAsync();
            }
            Cursor.Current = Cursors.Default;
            ExcelHelper.ToggleExcelEvents(Globals.ThisAddIn.excelApplication, true);
        }
コード例 #9
0
        private void AddRibbonInsertTextButton(RibbonMenu menu, string text)
        {
            var btn = new RibbonButton(text);

            btn.Tag = s_rbnInsertTextTag;
            menu.Items.Add(btn);
        }
コード例 #10
0
        // creates a RibbonMenu and initializes it using a unique ID string and
        // a list of items that may contain strings or RibbonElement objects.
        internal static RibbonMenu CreateMenu(string id, params object[] items)
        {
            RibbonMenu menu = new RibbonMenu();

            SetItemProperties(menu, id);
            AddSubItems(menu.Items, items);
            return(menu);
        }
コード例 #11
0
 public void UpdateUI()
 {
     // throw new NotImplementedException();
     if (RibbonMenu != null)
     {
         RibbonMenu.UpdateMenu();
     }
 }
コード例 #12
0
 public bool UpdateContextMenu()
 {
     if (RibbonMenu.GetContextMenuVisible())
     {
         return(false);
     }
     RibbonMenu.SetContextMenu(MainView.MapControlContainer);
     return(true);
 }
コード例 #13
0
 private void _clearSubMenus(RibbonMenu rParent, C1CommandMenu cParent)
 {
     foreach (RibbonMenu rmnu in rParent.Items)
     {
         rmnu.Items.Clear();
     }
     foreach (C1CommandLink cl in cParent.CommandLinks)
     {
         ((C1CommandMenu)cl.Command).CommandLinks.ClearAll();
     }
     _clearMenus(rParent, cParent);
 }
コード例 #14
0
ファイル: Ribbon.cs プロジェクト: LuisYang0215/SparkleXrm-1
        public static void Populate(CommandProperties commandProperties)
        {
            _resources           = (Dictionary <string, string>)Script.Literal("window.top._quickNav__resources");
            _userPriviledgeNames = (Dictionary <string, string>)Script.Literal("window.top._quickNav__userPriviledgeNames");
            _siteMap             = (SiteMap)Script.Literal("window.top._quickNav__siteMap");

            uniquePrefix = "dev1_" + DateTime.Now.GetTime().ToString() + "|";
            bool isOnForm = (Page.Ui != null);

            LoadResources();

            RibbonMenu        quickNav   = new RibbonMenu("dev1.QuickNav");
            RibbonMenuSection topSection = new RibbonMenuSection("dev1.SiteMapMenuSection", "", 2, RibbonDisplayMode.Menu16);

            quickNav.AddSection(topSection);

            // Only show Sitemap in web client
            if (Page.Context.Client.GetClient() == ClientType.Web)
            {
                if (isOnForm)
                {
                    RibbonFlyoutAnchor siteMapMenuFlyout = new RibbonFlyoutAnchor(uniquePrefix + "SiteMapButton", 1, ReplaceResourceToken("$Site_Map"), "Mscrm.Enabled", "/_imgs/FormEditorRibbon/Subgrid_16.png", null);
                    topSection.AddButton((RibbonButton)(object)siteMapMenuFlyout);

                    siteMapMenuFlyout.Menu = new RibbonMenu("dev1.SiteMapButton.Menu");

                    RibbonMenuSection siteMapMenuFlyoutSection = new RibbonMenuSection(uniquePrefix + "SiteMapButton.Menu.Section", "", 1, RibbonDisplayMode.Menu16);
                    siteMapMenuFlyout.Menu.AddSection(siteMapMenuFlyoutSection);
                    GetSiteMap(siteMapMenuFlyoutSection);
                }
                else
                {
                    GetSiteMap(topSection);
                }
            }

            // Add Advanced Find
            RibbonButton advFind = new RibbonButton("dev1.OpenAdvancedFind.Button", 1, ReplaceResourceToken("$Advanced_Find"), "dev1.OpenAdvancedFind", "/_imgs/ribbon/AdvancedFind_16.png", null);

            topSection.AddButton(advFind);

            GetFormTabs(quickNav);

            GetFormNav(quickNav);

            commandProperties.PopulationXML = quickNav.SerialiseToRibbonXml();

            // Store for next time
            Script.Literal("window.top._quickNav__resources={0}", _resources);
            Script.Literal("window.top._quickNav__userPriviledgeNames={0}", _userPriviledgeNames);
            Script.Literal("window.top._quickNav__siteMap={0}", _siteMap);
        }
コード例 #15
0
        RibbonGroup CreatePageSetupGroup()
        {
            RibbonGroup g = new RibbonGroup();

            g.Text = g.ID = "Page Setup";
            g.HasLauncherButton    = true;
            g.DialogLauncherClick += pageSetup_DialogLauncherClick;

            g.Items.Add(CreateMenu("Margins",
                                   CreateButton("MarginNormal", "Margins"),
                                   CreateButton("MarginNarrow", "Margins"),
                                   CreateButton("MarginModerate", "Margins"),
                                   CreateButton("MarginWide", "Margins"),
                                   CreateButton("MarginOffice", "Margins"),
                                   new RibbonSeparator(),
                                   CreateButton("CustomMargins")));

            g.Items.Add(CreateMenu("Orientation",
                                   CreateButton("Portrait"),
                                   CreateButton("Landscape")));

            RibbonMenu mPaperSize = CreateMenu("Size");

            foreach (PaperSize ps in new PrinterSettings().PaperSizes)
            {
                RibbonButton btn = CreateButton(ps.PaperName);
                btn.Tag = ps;
                mPaperSize.Items.Add(btn);
            }
            mPaperSize.MaxDropDownItems  = 12;
            mPaperSize.GripHandleVisible = true;
            g.Items.Add(mPaperSize);

            foreach (RibbonItem mainItem in g.Items)
            {
                RibbonMenu m = mainItem as RibbonMenu;
                if (m != null)
                {
                    foreach (RibbonItem item in m.Items)
                    {
                        RibbonButton btn = item as RibbonButton;
                        if (btn != null)
                        {
                            btn.SupportedGroupSizing = SupportedGroupSizing.LargeImageOnly;
                        }
                    }
                }
            }

            return(g);
        }
コード例 #16
0
        private void _addSubMenus(RibbonMenu rParent, C1CommandMenu cParent, string menuName, string[] texts)
        {
            rParent.Enabled = cParent.Enabled = true;
            RibbonMenu rMenu = new RibbonMenu();

            rMenu.Text = menuName;
            C1CommandMenu cMenu = new C1CommandMenu();

            cMenu.Text = menuName;
            chMain.Commands.Add(cMenu);
            _addMenus(rMenu, cMenu, texts);
            rParent.Items.Add(rMenu);
            cParent.CommandLinks.Add(new C1CommandLink(cMenu));
        }
コード例 #17
0
 private void _addMenus(RibbonMenu rMenu, C1CommandMenu cMenu, string[] texts)
 {
     if (texts == null || texts.Length == 0)
     {
         rMenu.Enabled = rMenu.Items.Count > 0;
         cMenu.Enabled = cMenu.CommandLinks.Count > 0;
     }
     else
     {
         rMenu.Enabled = cMenu.Enabled = true;
         foreach (string text in texts)
         {
             AddRibbonInsertTextButton(rMenu, text);
             AddCommandMenuItem(cMenu, text);
         }
     }
 }
コード例 #18
0
        public bool SetCurrentTool(string toolName)
        {
            ITool oldTool = MainView.CurrentTool;

            _oldToolName = oldTool == null ? string.Empty : ((YutaiTool)oldTool).Name;

            BarItem item = RibbonMenu.SubItems.FindItem(toolName);

            if (item != null)
            {
                MainView.CurrentTool = (YutaiTool)item.Tag;
                RibbonMenu.ChangeCurrentTool(_oldToolName, toolName);
            }


            return(true);
        }
コード例 #19
0
        public bool SetCurrentTool(YutaiTool tool)
        {
            if (tool.ItemType == RibbonItemType.Tool)
            {
                ITool oldTool = MainView.CurrentTool;
                _oldToolName         = oldTool == null ? string.Empty : ((YutaiTool)oldTool).Name;
                MainView.CurrentTool = (YutaiTool)tool;
                CurrentToolName      = tool.Name;
                RibbonMenu.ChangeCurrentTool(_oldToolName, tool.Name);
                if (tool is IToolContextMenu)
                {
                    RibbonMenu.SetContextMenu(MainView.MapControlContainer);
                }

                return(true);
            }
            return(false);
        }
コード例 #20
0
ファイル: RibbonHost.cs プロジェクト: vczh-codeplex/vlpp
        private RibbonMenu CreateSortMenu()
        {
            RibbonMenu menu = new RibbonMenu();

            {
                RibbonMenuButton button = new RibbonMenuButton();
                button.SmallImage = ToolImages.SortAscending;
                button.Name       = "我还是不知道为什么要排序";
                menu.MenuItems.Add(button);
            }
            {
                RibbonMenuButton button = new RibbonMenuButton();
                button.SmallImage = ToolImages.SortDescending;
                button.Name       = "我还是不知道为什么要反着排序";
                menu.MenuItems.Add(button);
            }
            return(menu);
        }
コード例 #21
0
ファイル: Ribbon.cs プロジェクト: LuisYang0215/SparkleXrm-1
        private static void GetFormNav(RibbonMenu quickNav)
        {
            SELECT_NAV_COMMAND_PREFIX = uniquePrefix + "QuickNav.Nav";
            if (Page.Ui != null && Page.Ui.Navigation != null)
            {
                RibbonMenuSection navSection = new RibbonMenuSection(uniquePrefix + "QuickNav.Nav", "Related", 1, RibbonDisplayMode.Menu16);
                quickNav.AddSection(navSection);
                int i = 0;
                Page.Ui.Navigation.Items.ForEach(delegate(NavigationItem nav, int index)
                {
                    RibbonButton button = new RibbonButton(SELECT_NAV_COMMAND_PREFIX + nav.GetId(), i, nav.GetLabel(), "dev1.QuickNav.SelectNav", "/_imgs/FormEditorRibbon/Subgrid_16.png", "");
                    navSection.AddButton(button);

                    i++;
                    return(true);
                });
            }
        }
コード例 #22
0
        //</Snippet5>

        //<Snippet6>
        private void PopulateSalesOrderInfo()
        {
            String[] tempArray = comboBox1.Text.Split(new Char[] { '|' });
            menu1.Items.Clear();

            orderTable        = nwDataSet.Orders;
            orderDetailsTable = nwDataSet.Order_Details;
            productsTable     = nwDataSet.Products;

            ordersTableAdapter.Fill(orderTable);
            detailsTableAdapter.Fill(orderDetailsTable);
            productsTableAdapter.Fill(productsTable);

            var orderQuery = from orders in orderTable.AsEnumerable()
                             where orders.Field <string>("Customer ID") == tempArray[1]
                             select new { OrderID = orders.Field <int>("Order ID") };

            foreach (var orderItem in orderQuery)
            {
                menu1.Items.Add(CreateRibbonMenu());

                RibbonMenu orderMenu = (RibbonMenu)menu1.Items.Last();
                orderMenu.Dynamic = true;
                orderMenu.Label   = orderItem.OrderID.ToString();
                orderMenu.Tag     = orderItem.OrderID;

                var productQuery = from orderDetail in orderDetailsTable.AsEnumerable()
                                   join product in productsTable.AsEnumerable() on
                                   orderDetail.Field <int>("Product ID")
                                   equals product.Field <int>("Product ID")
                                       where orderDetail.Field <int>("Order ID") ==
                                   orderItem.OrderID
                                   select new { ProductName = product.Field <string>("Product Name") };

                foreach (var productItem in productQuery)
                {
                    RibbonButton button = CreateRibbonButton();
                    button.Label = productItem.ProductName;
                    orderMenu.Items.Add(button);
                }
            }
        }
コード例 #23
0
 private void OnModuleButton_Click(object sender, RibbonControlEventArgs e)
 {
     try
     {
         ExcelHelper.ToggleExcelEvents(Globals.ThisAddIn.excelApplication, false);
         RibbonButton rb = (RibbonButton)sender;
         RibbonMenu   rm = (RibbonMenu)rb.Parent;
         rm.Label = rb.Label;
         dynamicMenuAdd.Enabled = true;
         foreach (RibbonButton addButton in dynamicMenuAdd.Items)
         {
             addButton.Click += OnAddButton_Click;
         }
         ExcelHelper.ToggleExcelEvents(Globals.ThisAddIn.excelApplication, true);
     }
     catch (Exception ex)
     {
         throw (ex);
     }
 }
コード例 #24
0
ファイル: TurtleIdeForm.cs プロジェクト: vczh-codeplex/vlpp
        private RibbonDropDownMenu CreateOpenMenu(RibbonContainer container)
        {
            string[] resources = typeof(TurtleIdeForm).Assembly.GetManifestResourceNames()
                                 .Where(s => s.EndsWith(".turtle.txt"))
                                 .ToArray();
            RibbonMenu menu = new RibbonMenu();

            foreach (string resource in resources)
            {
                RibbonMenuButton button = new RibbonMenuButton();
                button.SmallImage = TurtleIdeRibbon.New;
                button.Name       = resource.Substring("VlTurtle.Sample.NativeX.".Length);
                button.Executed  += new EventHandler(ribbonOpenSample_Click);
                menu.MenuItems.Add(button);
            }
            return(new RibbonDropDownMenu(container)
            {
                Menu = menu
            });
        }
コード例 #25
0
ファイル: RibbonHost.cs プロジェクト: vczh-codeplex/vlpp
        private RibbonMenu CreateAlignMenu()
        {
            RibbonMenu menu = new RibbonMenu();

            {
                RibbonMenuButton button = new RibbonMenuButton();
                button.SmallImage = ToolImages.AlignLeft;
                button.Name       = "左对齐";
                menu.MenuItems.Add(button);
            }
            {
                RibbonMenuButton button = new RibbonMenuButton();
                button.SmallImage = ToolImages.AlignCenter;
                button.Name       = "中间对齐";
                button.DropDown   = new RibbonDropDownMenu(this.Ribbon)
                {
                    Menu = CreateSortMenu()
                };
                menu.MenuItems.Add(button);
            }
            {
                RibbonMenuButton button = new RibbonMenuButton();
                button.SmallImage = ToolImages.AlignRight;
                button.Name       = "右对齐";
                menu.MenuItems.Add(button);
            }
            {
                RibbonMenuButton button = new RibbonMenuButton();
                button.SmallImage = ToolImages.AlignFull;
                button.Name       = "全部对齐";
                menu.MenuItems.Add(button);
            }
            {
                RibbonMenuButton button = new RibbonMenuButton();
                button.SmallImage = ToolImages.AlignExpand;
                button.Name       = "不知道是什么对齐";
                menu.MenuItems.Add(button);
            }
            return(menu);
        }
コード例 #26
0
ファイル: TurtleIdeForm.cs プロジェクト: vczh-codeplex/vlpp
        private RibbonMenu CreateStartMenu()
        {
            RibbonMenu menu = new RibbonMenu();

            {
                RibbonMenuButton button = new RibbonMenuButton();
                button.SmallImage = TurtleIdeRibbon.New;
                button.Name       = "New Turtle";
                button.Executed  += (s, e) => this.content.OperationNew();
                menu.MenuItems.Add(button);
            }
            {
                RibbonMenuButton button = new RibbonMenuButton();
                button.SmallImage = TurtleIdeRibbon.Open;
                button.Name       = "Open Turtle";
                button.Executed  += (s, e) => this.content.OperationOpen();
                menu.MenuItems.Add(button);
            }
            {
                RibbonMenuButton button = new RibbonMenuButton();
                button.SmallImage = TurtleIdeRibbon.Save;
                button.Name       = "Save Turtle";
                button.Executed  += (s, e) => this.content.OperationSave();
                menu.MenuItems.Add(button);
            }
            {
                RibbonMenuButton button = new RibbonMenuButton();
                button.SmallImage = TurtleIdeRibbon.SaveAs;
                button.Name       = "Save Turtle As";
                button.Executed  += (s, e) => this.content.OperationSaveAs();
                menu.MenuItems.Add(button);
            }
            {
                RibbonMenuButton button = new RibbonMenuButton();
                button.Name      = "Exit";
                button.Executed += (s, e) => this.Close();
                menu.MenuItems.Add(button);
            }
            return(menu);
        }
コード例 #27
0
        private void InitRibbonMenu()
        {
            RibbonMenu menu = _context.RibbonMenu as RibbonMenu;

            menu.AddHeaderTab("tabFile", "文件");
            menu.AddToolStripEx("toolStripFiles", "文件", "tabFile");

            menu.AddHeaderTab("tabView", "视图");
            menu.AddToolStripEx("toolStripView", "视图", "tabView");
            menu.AddToolStripEx("toolStripViewTools", "工具", "tabView");
            menu.AddToolStripEx("toolStripViewSelection", "选择", "tabView");


            menu.AddButton(_commands[MenuKeys.NewProject]);


            menu.AddButton(_commands[MenuKeys.OpenProject]);
            menu.AddButton(_commands[MenuKeys.SaveProject]);
            menu.AddButton(_commands[MenuKeys.SaveProjectAs]);

            menu.AddButton(_commands["reImportDXF"]);

            menu.AddButton(_commands[Common.Plugins.Menu.MenuKeys.Quit]);
        }
コード例 #28
0
ファイル: ribboncontrols.cs プロジェクト: jetlive/skiaming
        // 当菜单将动态属性
        // 设置为 true 并且用户单击下拉菜单时会激发“菜单项正在加载”事件。这允许在运行时动态
        // 添加菜单项。
        private void mDynamicMenu_ItemsLoading(object sender, RibbonControlEventArgs e)
        {
            mDynamicMenu.Items.Clear();

            if (cbButton.Checked)
            {
                mDynamicMenu.Items.Add(new RibbonButton { Label = "Button" });
            }

            if (cbSeparator.Checked)
            {
                mDynamicMenu.Items.Add(new RibbonSeparator { Title = "Menu Separator" });
            }

            if (cbSubMenu.Checked)
            {
                RibbonButton subButton = new RibbonButton {
                    Label = "SubMenu Button",
                    OfficeImageId = "_3DMaterialMetal",
                    Description = "Large Button in a Sub Menu"
                };
                RibbonMenu mSubMenu = new RibbonMenu {
                    ItemSize = Microsoft.Office.Core.RibbonControlSize.RibbonControlSizeLarge,
                    Label = "Sub Menu"
                };
                mSubMenu.Items.Add(subButton);
                mDynamicMenu.Items.Add(mSubMenu);
            }
        }
コード例 #29
0
ファイル: Ribbon.cs プロジェクト: LuisYang0215/SparkleXrm-1
        public static void GetSiteMap(RibbonMenuSection siteMapSection)
        {
            GetUserPrivs();

            //jQuery.FromHtml("<style>.commandBar-NavButton{background-color:red}</style>").AppendTo("head");



            int sequence = 1;

            foreach (Area area in _siteMap.areas)
            {
                string areaIconUrl = "/_imgs/FormEditorRibbon/Subgrid_16.png";
                if (!String.IsNullOrEmpty(area.icon))
                {
                    areaIconUrl = DecodeImageUrl(area.icon);
                }
                RibbonFlyoutAnchor areaFlyout = new RibbonFlyoutAnchor(uniquePrefix + area.id + ".Flyout", sequence++, ReplaceResourceToken(area.title), "Mscrm.Enabled", areaIconUrl, null);
                areaFlyout.Menu = new RibbonMenu(area.id + ".Flyout.Menu");
                //areaFlyout.Image16by16Class = @"commandBar-NavButton";

                //menu.AddSection(areaSection);
                siteMapSection.AddButton((RibbonButton)(object)areaFlyout);
                RibbonMenuSection areaSection = null;

                foreach (Group group in area.groups)
                {
                    RibbonMenuSection subAreaMenuSection = null;
                    RibbonMenu        subAreaParentMenu  = null;



                    if (group.title != null)
                    {
                        areaSection = new RibbonMenuSection(uniquePrefix + area.id + "|" + group.id + ".Section", ReplaceResourceToken(group.title), sequence++, RibbonDisplayMode.Menu16);

                        subAreaParentMenu  = areaFlyout.Menu;
                        subAreaMenuSection = areaSection;
                    }
                    else
                    {
                        if (areaSection == null)
                        {
                            // Create default areaSection because we don't have group titles
                            areaSection = new RibbonMenuSection(uniquePrefix + area.id + ".Section", ReplaceResourceToken(area.title), sequence++, RibbonDisplayMode.Menu16);

                            subAreaParentMenu = areaFlyout.Menu;
                        }
                        subAreaMenuSection = areaSection;
                    }

                    int subAreaSequence = 1;

                    foreach (SubArea subArea in group.subareas)
                    {
                        string subAreaIconUrl = "/_imgs/FormEditorRibbon/Subgrid_16.png";
                        if (!String.IsNullOrEmpty(subArea.icon))
                        {
                            subAreaIconUrl = DecodeImageUrl(subArea.icon);
                        }
                        else if (!string.IsNullOrEmpty(subArea.entity) && subArea.objecttypecode != 4703 && subArea.objecttypecode != 9603)
                        {
                            subAreaIconUrl = "/_imgs/ico_16_" + subArea.objecttypecode.ToString() + ".gif";
                        }


                        bool hasAccess = true;
                        // Check Privs
                        if (subArea.privileges != null && subArea.privileges.Count > 0)
                        {
                            foreach (string priv in subArea.privileges)
                            {
                                hasAccess = hasAccess && _userPriviledgeNames.ContainsKey(priv.ToLowerCase());
                                if (!hasAccess)
                                {
                                    break;
                                }
                            }
                        }
                        if (hasAccess)
                        {
                            RibbonButton button = new RibbonButton(uniquePrefix + area.id + "|" + group.id + "|" + subArea.id, subAreaSequence++, ReplaceResourceToken(subArea.title), "dev1.QuickNav.SelectSiteMapNav", subAreaIconUrl, "");
                            subAreaMenuSection.AddButton(button);
                        }
                    }
                    // Add submenu to menu if it has at least one item
                    if (subAreaMenuSection.Buttons.Count > 0)
                    {
                        subAreaParentMenu.AddSection(subAreaMenuSection);
                    }
                }
            }
        }
コード例 #30
0
        private void BackgroundWorker1_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
        {
            string addMenuLabel = string.Empty;

            try
            {
                BackgroundWorker worker     = sender as BackgroundWorker;
                bool             isExported = false;
                ExitEditMode();
                RibbonMenu ribbonMenu = (RibbonMenu)dynamicMenuAdd;
                addMenuLabel = ribbonMenu.Label;
                IHttpRequest     httpRequest      = GlobalMembers.InstanceGlobalMembers.Container.Resolve <IHttpRequest>();
                RibbonController ribbonController = new RibbonController(httpRequest);
                Excel._Worksheet worksheet        = Globals.ThisAddIn.excelApplication.ActiveSheet;
                int    colCount = worksheet.UsedRange.Columns.Count;
                int    rowCount = worksheet.Cells.Find("*", System.Reflection.Missing.Value, System.Reflection.Missing.Value, System.Reflection.Missing.Value, Microsoft.Office.Interop.Excel.XlSearchOrder.xlByRows, Excel.XlSearchDirection.xlPrevious, false, System.Reflection.Missing.Value, System.Reflection.Missing.Value).Row;
                string moduleId = ExcelHelper.GetObjectIdFromText(dynamicMenuModules);
                Dictionary <string, string> dictLanguage = GlobalMembers.InstanceGlobalMembers.DictionaryLanguageType;
                switch (addMenuLabel)
                {
                case "Fields":
                {
                    ExcelHelper.ClearLogColumnsForAllTheRows(worksheet);
                    for (int i = 4; i <= rowCount; i++)
                    {
                        if (worker.CancellationPending == true)
                        {
                            e.Cancel = true;
                            break;
                        }
                        else
                        {
                            ribbonController.ValidateExcelData(i, colCount, worksheet);
                            ribbonController.BuildAndExportFieldsJson(i, colCount, worksheet, moduleId, userId);
                        }
                        worker.ReportProgress((i * 100) / rowCount);
                    }
                    break;
                }

                case "Descriptions":
                {
                    for (int i = 3; i <= rowCount; i++)
                    {
                        if (worker.CancellationPending == true)
                        {
                            e.Cancel = true;
                            break;
                        }
                        else
                        {
                            if (!isExported)
                            {
                                ribbonController.BuildTranlatedDataJsonAndExport(worksheet, dictLanguage);
                            }
                            isExported = true;
                            worker.ReportProgress((i * 100) / rowCount);
                        }
                    }
                    break;
                }

                case "Dropdowns":
                {
                    for (int i = 3; i <= rowCount; i++)
                    {
                        if (worker.CancellationPending == true)
                        {
                            e.Cancel = true;
                            break;
                        }
                        else
                        {
                            if (!isExported)
                            {
                                ribbonController.BuildDropDownJsonAndExport(worksheet, dictLanguage);
                            }
                            isExported = true;
                            worker.ReportProgress((i * 100) / rowCount);
                        }
                    }
                    break;
                }

                case "Fields And Dropdowns":
                {
                    Excel.Workbook   workbook          = GlobalMembers.InstanceGlobalMembers.ExcelApplication.ActiveWorkbook;
                    Excel.Sheets     sheets            = workbook.Sheets;
                    Excel._Worksheet dropDownWorkSheet = HelperUtil.GetSheetNameFromGroupOfSheets(GlobalMembers.InstanceGlobalMembers.DropDownSheetName, sheets);;
                    for (int i = 4; i <= rowCount; i++)
                    {
                        if (worker.CancellationPending == true)
                        {
                            e.Cancel = true;
                            break;
                        }
                        else
                        {
                            ribbonController.ValidateExcelData(i, colCount, worksheet);
                            ribbonController.BuildAndExportFieldsJson(i, colCount, worksheet, moduleId, userId);
                            if (i == rowCount)
                            {
                                ribbonController.BuildDropDownJsonAndExport(dropDownWorkSheet, dictLanguage);
                            }
                        }
                        worker.ReportProgress((i * 100) / rowCount);
                    }
                    break;
                }
                }
            }
            catch (Exception ex)
            { throw (ex); }
        }
コード例 #31
0
        private void OnAddButton_Click(object sender, RibbonControlEventArgs e)
        {
            RibbonButton rb           = (RibbonButton)sender;
            RibbonMenu   rm           = (RibbonMenu)rb.Parent;
            string       addMenuLabel = string.Empty;

            addMenuLabel = rb.Label;
            rm.Label     = rb.Label;
            Excel.Sheets     sheets = Globals.ThisAddIn.excelApplication.Sheets;
            Excel._Worksheet worksheet;
            Excel.Range      oRange;
            ExcelHelper.ToggleExcelEvents(Globals.ThisAddIn.excelApplication, false);
            switch (addMenuLabel)
            {
            case "Fields":
            {
                if (btnImport.Enabled)
                {
                    btnImport.Enabled = false;
                }
                worksheet = HelperUtil.GetSheetNameFromGroupOfSheets(GlobalMembers.InstanceGlobalMembers.MetaDataSheetName, sheets);
                oRange    = worksheet.UsedRange;
                oRange.ClearContents();
                worksheet.Visible = Excel.XlSheetVisibility.xlSheetVisible;
                ExcelHelper.DisplayMetaDataInformationOnSheet(worksheet, dictModules, addMenuLabel);
                break;
            }

            case "Descriptions":
            {
                if (!btnImport.Enabled)
                {
                    btnImport.Enabled = true;
                }
                worksheet = HelperUtil.GetSheetNameFromGroupOfSheets(GlobalMembers.InstanceGlobalMembers.TranslationSheetName, sheets);
                oRange    = worksheet.UsedRange;
                oRange.ClearContents();
                ExcelHelper.PopulateTranslationHeader(worksheet);
                worksheet.Visible = Excel.XlSheetVisibility.xlSheetVisible;
                worksheet.Activate();
                break;
            }

            case "Dropdowns":
            {
                if (btnImport.Enabled)
                {
                    btnImport.Enabled = false;
                }
                worksheet = HelperUtil.GetSheetNameFromGroupOfSheets(GlobalMembers.InstanceGlobalMembers.DropDownSheetName, sheets);
                oRange    = worksheet.UsedRange;
                oRange.ClearContents();
                ExcelHelper.PopulateDropDownValuesHeader(worksheet);
                worksheet.Visible = Excel.XlSheetVisibility.xlSheetVisible;
                worksheet.Activate();
                break;
            }

            case "Fields And Dropdowns":
            {
                if (btnImport.Enabled)
                {
                    btnImport.Enabled = false;
                }
                worksheet = HelperUtil.GetSheetNameFromGroupOfSheets(GlobalMembers.InstanceGlobalMembers.MetaDataSheetName, sheets);
                oRange    = worksheet.UsedRange;
                oRange.ClearContents();
                Excel._Worksheet worksheet1 = HelperUtil.GetSheetNameFromGroupOfSheets(GlobalMembers.InstanceGlobalMembers.DropDownSheetName, sheets);
                oRange = worksheet1.UsedRange;
                oRange.ClearContents();
                ExcelHelper.PopulateDropDownValuesHeader(worksheet1);
                worksheet.Visible = Excel.XlSheetVisibility.xlSheetVisible;
                ExcelHelper.DisplayMetaDataInformationOnSheet(worksheet, dictModules, addMenuLabel);
                worksheet1.Visible = Excel.XlSheetVisibility.xlSheetVisible;
                worksheet.Activate();
                break;
            }
            }

            if (!btnExport.Enabled)
            {
                btnExport.Enabled = true;
            }

            ExcelHelper.HideExcelSheetsExceptTheSelectedOne(rm.Label.ToString(), sheets);
            ExcelHelper.ToggleExcelEvents(Globals.ThisAddIn.excelApplication, true);
        }