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