public override void OnActionExecuting(ActionExecutingContext context) { base.OnActionExecuting(context); _handler = new MenuItemHandler(_context, _user); _categoryHandler = new CategoryHandler(_context, _user); _priceTypeHandler = new PriceTypeHandler(_context, _user); _imageHandler = new ImageHandler(_context, _user); }
public static MenuItem.ItemAction Handler(AttachmentPointId point, string thingName, bool isDelete) { var mih = new MenuItemHandler(); mih.apid = point; mih.isDelete = isDelete; mih.name = thingName; return(mih.Handle); }
internal MenuItem(string title, MenuItemHandler handler, string tag = null) { if (string.IsNullOrEmpty(title)) { throw new ArgumentNullException(); } if (null == handler) { throw new ArgumentNullException(); } Title = title; Handler = handler; return; }
public MenuItem(string name, MenuItemHandler method) { Name = name; Method = method; }
protected override void InitCustomDialog(object arg = null) { var arg_ = (Argument)arg; apid = arg_.point; isDelete = arg_.isDelete; string title = ""; switch (apid) { case AttachmentPointId.HeadTop: title = "Hat"; break; case AttachmentPointId.Head: title = "Head"; break; case AttachmentPointId.ArmLeft: title = "Left Arm"; break; case AttachmentPointId.ArmRight: title = "Right Arm"; break; case AttachmentPointId.TorsoUpper: title = "Upper Torso"; break; case AttachmentPointId.TorsoLower: title = "Lower Torso"; break; case AttachmentPointId.LegLeft: title = "Left Leg"; break; case AttachmentPointId.LegRight: title = "Right Leg"; break; } var menu = new Menu(title); menu.SetBackButton(Main.pointMenu); menu.TwoColumns = true; menu.DialogClose += Menu_DialogClose; if (isDelete) { var btnConfirmDelete = new MenuButton("confirmDelete", "Confirm"); btnConfirmDelete.Action += BtnConfirmDelete_Action; menu.Add(btnConfirmDelete); var btnCancelDelete = new MenuButton("cancelDelete", "Undo Deletion"); btnCancelDelete.TextColor = TextColor.Gold; btnCancelDelete.Action += BtnCancelDelete_Action; menu.Add(btnCancelDelete); } else { var btnSave = new MenuButton("save", "+ Save"); btnSave.TextColor = TextColor.Green; btnSave.Action += BtnSave_Action; menu.Add(btnSave); var btnDelete = new MenuButton("delete", "- Delete"); btnDelete.TextColor = TextColor.Red; btnDelete.Action += BtnDelete_Action; menu.Add(btnDelete); } var btnDetach = new MenuButton("detach", "(None)"); btnDetach.TextColor = TextColor.Blue; btnDetach.Action += BtnDetach_Action; menu.Add(btnDetach); foreach (string k in Main.config.GetListForAttachmentPoint(apid).ThingNames) { var btn = new MenuButton("attach_" + k, k); if (isDelete) { btn.TextColor = TextColor.Red; btn.Text = "- " + btn.Text; } btn.Action += MenuItemHandler.Handler(apid, k, isDelete); menu.Add(btn); } base.InitCustomDialog(menu); }