protected void RegisterPoupMenuItem(string commandName, string formatName, string imageName, Action <object> action) { var localizedCaption = GetLocalizedCaption(commandName); if (formatName != "") { localizedCaption = string.Format(GetLocalizedCaption(formatName), localizedCaption); } var buttonItem = new BarButtonItemEx(imageName, null) { Caption = localizedCaption }; buttonItem.ItemClick += (s, e) => { var focusedObject = EntityGridView.GetRow(EntityGridView.FocusedRowHandle); if (formatName != "") { action(commandName); } else { action(focusedObject); } }; popupMenu.AddItem(buttonItem); }
private void RegisterRelatedEntityCommand() { var allRelationshipRoles = MetadataProvider.Instance.EntityRelationshipRoles; var relationshipRoles = allRelationshipRoles.Where( role => role.Entity.PhysicalName == EntityName && role.NavPanelDisplayOption == 1); if (relationshipRoles.Any()) { var relatedEntityButtons = new List <BarButtonItemEx>(); foreach (var relationshipRole in relationshipRoles) { var entityRelation = relationshipRole.EntityRelationship; var relatedRole = entityRelation.EntityRelationshipRoles .FirstOrDefault(r => r != relationshipRole && r.RelationshipRoleType == (int)RelationshipRoleType.ManyToOne); if (relatedRole == null) { continue; } var name = relatedRole.Entity.PhysicalName; if (!AuthorizationManager.CheckAccess(name, "Read")) { continue; } var relationship = entityRelation.EntityRelationshipRelationships.First().Relationship; var localizedCaption = Properties.Resources.ResourceManager.GetString(name); var buttonItem = new BarButtonItemEx(name, "Search") { Caption = localizedCaption }; buttonItem.ItemClick += (s, e) => { ShowRelatedEntityList(relationship, name); }; buttonItem.Name = name; if (relationshipRoles.Count() > 1) { buttonItem.RibbonStyle = DevExpress.XtraBars.Ribbon.RibbonItemStyles.SmallWithText | DevExpress.XtraBars.Ribbon.RibbonItemStyles.SmallWithoutText; } buttonItem.ButtonStyle = BarButtonStyle.Check; relatedEntityButtons.Add(buttonItem); } if (relatedEntityButtons.Any()) { var generalGroup = UIExtensionSites["DetailHomePage"].Add(new RibbonPageGroup(GetLocalizedCaption("Related"))); UIExtensionSites.RegisterSite("DetailRelatedGroup", generalGroup); foreach (var button in relatedEntityButtons) { UIExtensionSites["DetailRelatedGroup"].Add(button); } } } }
private void InitSearchButton(string groupName, RibbonPageGroup ribbonGroup) { var buttonItem = new BarButtonItemEx("Search", null) { Caption = GetLocalizedCaption("Search") }; buttonItem.ItemClick += (sender, e) => { var overviewCollection = GetOpportunityOverviewCollection(); View.Bind(overviewCollection); }; ribbonGroup.ItemLinks.Add(buttonItem, true); WorkItem.Items.Add(buttonItem); }
private void RegisterCommand(string groupName, string commandName, string imageName, string overlay, string caption) { var localizedCaption = Properties.Resources.ResourceManager.GetString(caption); var buttonItem = new BarButtonItemEx(imageName, overlay) { Caption = localizedCaption }; if (WorkItem.Commands[commandName] != null) { WorkItem.Commands[commandName].AddInvoker(buttonItem, "ItemClick"); } buttonItem.Name = commandName; WorkItem.UIExtensionSites[groupName].Add(buttonItem); }
private void RegisterCommand(string groupName, string commandName, string imageName, string overlay, string caption) { var localizedCaption = GetLocalizedCaption(caption); var buttonItem = new BarButtonItemEx(imageName, overlay) { Caption = localizedCaption }; if (WorkItem.Commands[commandName] != null) { WorkItem.Commands[commandName].AddInvoker(buttonItem, "ItemClick"); } buttonItem.Name = commandName; buttonItem.ButtonStyle = DevExpress.XtraBars.BarButtonStyle.Check; WorkItem.UIExtensionSites[groupName].Add(buttonItem); }
private void RegisterCommand(string groupName, string commandName, string imageName, string overlay, string caption) { var localizedCaption = Properties.Resources.ResourceManager.GetString(caption); var buttonItem = new BarButtonItemEx(imageName, overlay) { Caption = localizedCaption }; if (WorkItem.Commands[commandName] != null) { WorkItem.Commands[commandName].AddInvoker(buttonItem, "ItemClick"); } if (commandName == "ShowNoteInDetail") { buttonItem.ButtonStyle = DevExpress.XtraBars.BarButtonStyle.Check; } buttonItem.Name = commandName; WorkItem.UIExtensionSites[groupName].Add(buttonItem); }
public void RegisterGenearlCommand(string groupName, string commandName, string imageName, string overlay, string caption) { var localizedCaption = GetLocalizedCaption(caption); var buttonItem = new BarButtonItemEx(imageName, overlay) { Caption = localizedCaption }; if (imageName != "Save") { buttonItem.ButtonStyle = BarButtonStyle.Check; } if (Commands[commandName] != null) { Commands[commandName].AddInvoker(buttonItem, "ItemClick"); } buttonItem.Name = commandName; UIExtensionSites[groupName].Add(buttonItem); }
private void InitConvert() { List <ColumnMapping> mappingList = MetadataProvider.Instance.MappingList .Where(c => c.SourceEntityName == EntityName).ToList(); var toConverList = mappingList.Select(c => c.TargetEntityName).Distinct(); if (toConverList.Any()) { var convertEntityButtons = new List <BarButtonItemEx>(); foreach (string commandName in toConverList) { if (!AuthorizationManager.CheckAccess(commandName, "Write")) { continue; } var localizedCaption = GetLocalizedCaption(commandName); var buttonItem = new BarButtonItemEx(commandName, "convert") { Caption = localizedCaption }; buttonItem.Name = commandName; if (toConverList.Count() > 1) { buttonItem.RibbonStyle = DevExpress.XtraBars.Ribbon.RibbonItemStyles.SmallWithText | DevExpress.XtraBars.Ribbon.RibbonItemStyles.SmallWithoutText; } buttonItem.ItemClick += (s, e) => { ShowRelatedEntityDetail(e.Item.Name, Guid.Empty, EntityDetailWorkingMode.Convert); }; convertEntityButtons.Add(buttonItem); } if (convertEntityButtons.Count > 0) { var convertGroup = UIExtensionSites["DetailHomePage"].Add(new RibbonPageGroup(GetLocalizedCaption("ConvertTitle"))); UIExtensionSites.RegisterSite("DetailConvertGroup", convertGroup); foreach (var button in convertEntityButtons) { UIExtensionSites["DetailConvertGroup"].Add(button); } } } }
protected void RegisterCommandInvoker(string commandName, string imageName, string overlay, string pageGroup, bool isSmall, int shortCut) { var localizedCaption = GetLocalizedCaption(commandName); var buttonItem = new BarButtonItemEx(imageName, overlay) { Caption = localizedCaption }; if (shortCut != 0) { buttonItem.ItemShortcut = new DevExpress.XtraBars.BarShortcut(( Keys.Alt | (Keys)shortCut)); } if (isSmall) { buttonItem.RibbonStyle = DevExpress.XtraBars.Ribbon.RibbonItemStyles.SmallWithText | DevExpress.XtraBars.Ribbon.RibbonItemStyles.SmallWithoutText; } buttonItem.Name = commandName; Commands[commandName].AddInvoker(buttonItem, "ItemClick"); UIExtensionSites[pageGroup].Add(buttonItem); }
public override void Initialize() { base.Initialize(); var showGroup = UIExtensionSites["DetailHomePage"].Add(new RibbonPageGroup(GetLocalizedCaption("Show"))); UIExtensionSites.RegisterSite(ExtensionSiteNames.DetailShowRibbonPageGroup, showGroup); RegisterGenearlCommand("CopyAndNew", "Save", "Copy"); RegisterShowCommand("ShowGeneral", EntityName, null, "General"); var addGroup = UIExtensionSites["DetailHomePage"].Add(new RibbonPageGroup(GetLocalizedCaption("Add"))); UIExtensionSites.RegisterSite(ExtensionSiteNames.DetailAddGroup, addGroup); InitConvert(); RegisterRelatedEntityCommand(); Workspaces[WorkspaceNames.DetailContentWorkspace].SmartPartActivated += (sender, e) => { PropertyInfo property = e.SmartPart.GetType().GetProperty("EntityName"); if (property == null) { return; } if (property.GetValue(e.SmartPart, null) == null) { return; } string smartEntityName = property.GetValue(e.SmartPart, null).ToString(); if (smartEntityName == EntityName) { smartEntityName = "ShowGeneral"; } foreach (var site in UIExtensionSites["DetailHomePage"]) { RibbonPageGroup pageGroup = site as RibbonPageGroup; if (pageGroup == null) { continue; } foreach (var itemLink in pageGroup.ItemLinks) { BarButtonItemLink barItemLink = itemLink as BarButtonItemLink; if (barItemLink == null) { continue; } BarButtonItemEx itemEx = barItemLink.Item as BarButtonItemEx; if (itemEx == null && itemEx.ButtonStyle != BarButtonStyle.Check) { continue; } if (itemEx.Name.Contains(smartEntityName)) { itemEx.Down = true; } else { itemEx.Down = false; } } } }; }