public void FindActionTest1() { MenuActionManager target = Init(); string resourceKey = "MenuEdit"; IMenuAction expected = target.Edit; IMenuAction actual; actual = target.FindAction(resourceKey); Assert.AreEqual(expected, actual); actual = target.FindAction("AbsentMenu"); Assert.AreEqual(null, actual); var actionHC = new MenuAction(target, target.Reports, "", 1); actionHC.Caption = "human reports"; var actionVC = new MenuAction(target, target.Reports, "", 2); actionHC.Caption = "vet reports"; var action = new MenuAction(target, target.Reports, "MenuLogout", 3); action = new MenuAction(target, actionHC, "MenuExit", 1); actual = target.FindAction("MenuExit"); Assert.AreEqual(action, actual); actual = target.FindAction(actionHC.Caption); Assert.AreEqual(actionHC, actual); actual = target.FindAction("AbsentMenu"); Assert.AreEqual(null, actual); }
public IMenuAction RegisterAction(IMenuAction a, IMenuAction parent = null) { a.Manager = this; if (parent != null) { a.Parent = parent; } if (a.Order == 0) { m_ItemOrder++; a.Order = m_ItemOrder; } else { m_ItemOrder = a.Order; } if (a.Parent == null) { MenuItems.Add(a); } else { a.Parent.Items.Add(a); } return(a); }
protected IMenuAction FindAction(IEnumerable <IMenuAction> actions, string resourceKey) { if (actions == null) { return(null); } foreach (IMenuAction action in actions) { if (string.IsNullOrEmpty(action.ResourceKey)) { if (resourceKey == action.Caption) { return(action); } } else if (resourceKey == action.ResourceKey) { return(action); } IMenuAction found = FindAction(action.Items, resourceKey); if (found != null) { return(found); } } return(null); }
public IMenuAction RegisterAllAvrReports() { AvrReportsCategory.SmallIconIndex = (int)MenuIconsSmall.LaunchAVR; string avrPermissions = PermissionHelper.SelectPermission(EIDSSPermissionObject.AVRReport); if (EidssUserContext.User.HasPermission(avrPermissions)) { int order = 0; foreach (KeyValuePair <long, string> pair in GetAvrQueries()) { order += 100; long queryId = pair.Key; string queryName = pair.Value; EidssUserContext.CheckUserLoggedIn(); List <AvrTreeElement> layouts = AvrQueryLayoutTreeDbHelper.ReLoadLayouts(true, queryId); List <AvrTreeElement> readOnlyLayouts = layouts.Where(l => l.ReadOnly).ToList(); if (readOnlyLayouts.Count == 0) { continue; } List <AvrTreeElement> folders = AvrQueryLayoutTreeDbHelper.ReLoadFolders(true, queryId); DeleteAvrEmptyFolders(readOnlyLayouts, folders); IMenuAction queryMenuAction = AddEmptyAvrMenuAction(AvrReportsCategory, queryName, order); CreateAvrFoldersLayoutsMenu(queryMenuAction, readOnlyLayouts, folders); } } return(AvrReportsCategory); }
public MenuAction(MenuActionManager manager, IMenuAction parent, string resourceKey, int order, bool showInToolbar = false, int smallImageIndex = -1, int bigImageIndex = -1) : base(manager, parent, resourceKey, order, showInToolbar) { SelectPermission = "Always"; BaseInit(smallImageIndex, bigImageIndex); Activate = null; ActivateAction = null; }
public void Attach(CommandBarControl ctrl, IMenuAction action) { var events = (CommandBarEvents)_applicationObject.Events.get_CommandBarEvents(ctrl); events.Click += new _dispCommandBarControlEvents_ClickEventHandler(events_Click); _events.Add(events); _actions[ctrl] = action; }
public ActionExecuteWnd(IMenuAction action) { MenuAction = action; MenuAction.ProgressChanged += MenuAction_ProgressChanged; MenuAction.ActionDone += MenuAction_ActionDone; InitializeComponent(); Title = "Execute action : " + MenuAction.Title; ServiceProvider.Settings.ApplyTheme(this); }
public void Execute(object parameter) { IMenuAction action = parameter as IMenuAction; if (action != null) { ActionExecuteWnd wnd = new ActionExecuteWnd(action); wnd.ShowDialog(); } }
public static MenuItem ToMenuItem(this IMenuAction action) { var menuItem = new MenuItem() { Header = action.Name }; menuItem.Click += (s, e) => action.Perform(); return(menuItem); }
public MenuActionBase(IMenuActionManager manager, IMenuAction parent, string resourceKey, int order, bool showInToolbar) { ResourceKey = resourceKey; ShowInToolbar = showInToolbar; ShowInMenu = true; Order = order; Group = 0; if (manager != null) { manager.RegisterAction(this, parent); } }
public void PerformAction(IMenuAction action, Entity subject, Entity obj) { MoveComponent comp = this.GetComponent <MoveComponent> (); comp.MoveEntity(obj.Model.ActionPosition, (bool success) => { if (success == false) { Console.WriteLine("Can't do that"); return; } action.Activate(GameViewController.CurrentScene.Player, obj); }); }
public MenuAction FindAction(string resourceKey, IMenuAction parent, int order, int smallImageIndex, int bigImageIndex) { MenuAction action = FindAction(MenuItems, resourceKey) as MenuAction ?? new MenuAction(this, parent, resourceKey, order); if (bigImageIndex >= 0 && action.BigIconIndex != bigImageIndex) { action.BigIconIndex = bigImageIndex; } if (smallImageIndex >= 0 && action.SmallIconIndex != smallImageIndex) { action.SmallIconIndex = smallImageIndex; } return(action); }
public void LoadAssemblyActionsTest() { MenuActionManager target = Init(); MenuActionManager.Instance = target; IMenuAction action = target.FindAction("MenuExit"); Assert.IsNull(action); string assemblyName = Utils.GetAssemblyLocation(Assembly.GetAssembly(GetType())); target.LoadAssemblyActions(assemblyName); action = target.FindAction("MenuExit"); Assert.IsNotNull(action); }
public void Execute(object parameter) { if (!ServiceProvider.Settings.SelectedBitmap.FileItem.IsRaw) { MessageBox.Show("Raw file is needed for this action"); return; } IMenuAction action = parameter as IMenuAction; if (action != null) { ActionExecuteWnd wnd = new ActionExecuteWnd(action); wnd.ShowDialog(); } }
public void Execute(object parameter) { EnfuseSettingsWnd wnds = new EnfuseSettingsWnd { DataContext = _settings }; if (wnds.ShowDialog() == true) { IMenuAction action = parameter as IMenuAction; if (action != null) { ActionExecuteWnd wnd = new ActionExecuteWnd(action); wnd.ShowDialog(); } } }
internal void CreateAvrFoldersLayoutsMenu (IMenuAction queryMenuAction, IEnumerable <AvrTreeElement> layouts, ICollection <AvrTreeElement> folders) { int order = 1; var menuActions = new Dictionary <long, IMenuAction>(); for (int index = 0; index < folders.Count + 1; index++) { var processedFolders = new List <AvrTreeElement>(); foreach (AvrTreeElement folder in folders) { IMenuAction parentMenuAction = (folder.ParentID.HasValue && menuActions.ContainsKey(folder.ParentID.Value)) ? menuActions[folder.ParentID.Value] : queryMenuAction; if (parentMenuAction != null) { order++; IMenuAction childMenuAction = AddEmptyAvrMenuAction(parentMenuAction, folder.NationalName, order); menuActions.Add(folder.ID, childMenuAction); processedFolders.Add(folder); } } foreach (AvrTreeElement folder in processedFolders) { folders.Remove(folder); } if (folders.Count == 0) { break; } } foreach (AvrTreeElement layout in layouts) { IMenuAction parentMenuAction = queryMenuAction; if (layout.ParentID.HasValue) { if (!menuActions.TryGetValue(layout.ParentID.Value, out parentMenuAction)) { parentMenuAction = queryMenuAction; } } order++; AddAvrMenuAction(parentMenuAction, layout.NationalName, layout.QueryID, layout.ID, order, true); } }
private static void AssertMenuActionManager(MenuManagerBase actionManager) { Assert.IsTrue(actionManager.Reports.Items.Count > 0); IMenuAction standardReportMenu = actionManager.Reports.Items.Find(m => m.ResourceKey == "menuStndReports"); Assert.IsNotNull(standardReportMenu); Assert.IsTrue(standardReportMenu.Items.Count > 2); IMenuAction humanSubmenu = standardReportMenu.Items.Find(m => m.ResourceKey == "MenuHumanReports"); Assert.IsNotNull(humanSubmenu); IMenuAction vetSubmenu = standardReportMenu.Items.Find(m => m.ResourceKey == "MenuVetReports"); Assert.IsNotNull(vetSubmenu); IMenuAction admSubmenu = standardReportMenu.Items.Find(m => m.ResourceKey == "MenuAdministrativeReports"); Assert.IsNotNull(admSubmenu); Assert.AreEqual(1, admSubmenu.Items.Count); Assert.AreEqual("ReportsAdmEventLog", admSubmenu.Items[0].ResourceKey); }
void OnClicked(NSNotification note) { var entity = (Entity)note.Object; if (CustomClickHandler != null) { CustomClickHandler(entity); return; } List <MenuDescription> mds = new List <MenuDescription> (); foreach (var c in entity.Components) { IMenuAction action = c as IMenuAction; if (action == null) { continue; } if (action.OnlyIfCollected) { continue; } MenuDescription md = new MenuDescription { Label = action.Label }; md.Activated += (object sender, EventArgs e) => { GameViewController.CurrentScene.Player.PerformAction(action, null, entity); }; mds.Add(md); } if (mds.Count == 0) { return; } DisplayMenu(mds); }
private void addLinkItems(WinformMenu groupMenu, RibbonPageGroup pageGroup, IList <MenuOrderSetting> menuOrderSettings) { if (groupMenu.Children != null && groupMenu.Children.Count > 0) { var buts = getOrderedMenus(groupMenu.Children.ToList(), menuOrderSettings); foreach (WinformMenu button in buts) { if (button.IsNavigation) { BarSubItem subItem = new BarSubItem { Name = button.Name, Caption = button.DisplayName }; SetSubItemImage4Default(button, subItem); pageGroup.ItemLinks.Add(subItem); } else { BarButtonItem newButton = new BarButtonItem { Name = button.Name, Caption = button.DisplayName }; SetSubItemImage4Default(button, newButton); if (button.MenuActionType != null) { newButton.ItemClick += (object sender, ItemClickEventArgs e) => { IMenuAction winformAction = iocManager.Resolve(button.MenuActionType.Type) as IMenuAction; winformAction.SenderMenu = button; winformAction.Excute(); }; } pageGroup.ItemLinks.Add(newButton); } } } }
public void AddAction(IMenuAction action) { _actions.Add(action.key, action); }
protected abstract IMenuAction AddAvrMenuAction (IMenuAction parent, string name, long queryId, long layoutId, int order, bool hasAction);
public MenuBuilder Action(IMenuAction action) { _actions.Add(action); return(this); }
public MenuAction FindAction(string resourceKey, IMenuAction parent, int order) { MenuAction action = FindAction(MenuItems, resourceKey) as MenuAction ?? new MenuAction(this, parent, resourceKey, order); return(action); }
public MenuActionWeb(IMenuActionManager manager, IMenuAction parent, string resourceKey, int order, bool showInToolbar = false) : base(manager, parent, resourceKey, order, showInToolbar) { }
protected abstract void RegisterStandartReport(IMenuAction category, MenuReportDescriptionAttribute attribute, MethodInfo info);
protected abstract IMenuAction RegisterSubMenu (IMenuAction category, string resourceKey, EIDSSPermissionObject permission, int order);
protected IMenuAction AddEmptyAvrMenuAction(IMenuAction parent, string name, int order) { return(AddAvrMenuAction(parent, name, -1, -1, order, false)); }
public static UIViewController DisplayMenuForItem(Entity item, UIViewController parentController, EntityClickHandler clickHandler) { if (item.Components.Length == 0) { return(null); } var alert = UIAlertController.Create("", "", UIAlertControllerStyle.ActionSheet); foreach (var c in item.Components) { IMenuAction action = c as IMenuAction; if (action == null) { continue; } if (action.OnlyIfDropped) { continue; } MenuDescription md = new MenuDescription { Label = action.Label }; md.Activated += (object sender, EventArgs e) => { if (action.NumberOfEntitiesNeeded == 1) { GameViewController.CurrentScene.Player.PerformAction(action, null, item); } else { clickHandler.WaitingForEntityClick = true; clickHandler.CustomClickHandler = (obj) => { GameViewController.CurrentScene.Player.PerformAction(action, item, obj); clickHandler.CustomClickHandler = null; clickHandler.WaitingForEntityClick = false; }; } /* * MoveComponent comp = (MoveComponent)GameViewController.CurrentScene.Player.GetComponent (typeof (MoveComponent)); * comp.MoveEntity (item.Model.ActionPosition, (bool success) => { * if (success == false) { * Console.WriteLine ("Can't do that"); * return; * } * if (action.NumberOfEntitiesNeeded == 1) { * action.Activate (GameViewController.CurrentScene.Player, null); * * } else { * clickHandler.WaitingForEntityClick = true; * clickHandler.CustomClickHandler = (obj) => { * action.Activate (GameViewController.CurrentScene.Player, obj); * clickHandler.CustomClickHandler = null; * clickHandler.WaitingForEntityClick = false; * }; * } * }); */ }; var a = UIAlertAction.Create(md.Label, 0, (obj) => md.OnActivated()); alert.AddAction(a); } var cancelItem = UIAlertAction.Create("Cancel", UIAlertActionStyle.Cancel, null); alert.AddAction(cancelItem); parentController.PresentViewController(alert, false, null); return(alert); }
/// <summary> /// Adds new IMenuAction interface /// </summary> /// <param name="action">name of the new action that will be assigend</param> public void AddMenuAction(IMenuAction action) { this.MenuAction = action; }
protected bool TryGetSubMenuCategory(ReportSubMenu subMenu, out IMenuAction category) { category = null; switch (subMenu) { case ReportSubMenu.StandardReports: if (!EidssUserContext.User.HasPermission(PermissionHelper.SelectPermission(EIDSSPermissionObject.Report))) { return(false); } category = StandardReportsCategory; break; case ReportSubMenu.Admin: if (!EidssUserContext.User.HasPermission(PermissionHelper.SelectPermission(EIDSSPermissionObject.EventLog))) { return(false); } category = AdminCategory; break; case ReportSubMenu.Human: if (!EidssUserContext.User.HasPermission(PermissionHelper.SelectPermission(EIDSSPermissionObject.HumanCase))) { return(false); } category = HumanCategory; break; case ReportSubMenu.HumanGGOldRevision: if (!EidssUserContext.User.HasPermission(PermissionHelper.SelectPermission(EIDSSPermissionObject.HumanCase))) { return(false); } category = HumanGGOldRevisionCategory; break; case ReportSubMenu.Lab: if (!EidssUserContext.User.HasPermission(PermissionHelper.SelectPermission(EIDSSPermissionObject.Sample))) { return(false); } category = LabCategory; break; case ReportSubMenu.Vet: if (!EidssUserContext.User.HasPermission(PermissionHelper.SelectPermission(EIDSSPermissionObject.VetCase))) { return(false); } category = VetCategory; break; case ReportSubMenu.Aberration: if (!EidssUserContext.User.HasPermission(PermissionHelper.SelectPermission(EIDSSPermissionObject.Report))) { return(false); } category = AberrationCategory; break; case ReportSubMenu.Zoonotic: if (!EidssUserContext.User.HasPermission(PermissionHelper.SelectPermission(EIDSSPermissionObject.Report))) { return(false); } category = ZoonoticCategory; break; case ReportSubMenu.Simplified: if (!EidssUserContext.User.HasPermission(PermissionHelper.SelectPermission(EIDSSPermissionObject.Report))) { return(false); } category = SimplifiedCategory; break; default: throw new ArgumentException(string.Format("{0} is not supportedtype of submenu", subMenu)); } return(true); }