private IActionSet CreateActions()
        {
            var toolType = typeof(CustomizeViewerActionModelTool);
            var resolver = new ActionResourceResolver(toolType);

            var idPrefix       = toolType.FullName + ":";
            var mainMenuAction = new MenuAction(idPrefix + _mainMenuCustomizeId,
                                                new ActionPath("global-menus/MenuTools/MenuCustomizeActionModels", resolver),
                                                ClickActionFlags.None, resolver)
            {
                GroupHint  = new GroupHint(_groupHint),
                Label      = SR.MenuCustomizeActionModels,
                Persistent = true
            };

            mainMenuAction.SetClickHandler(Customize);

            var contextMenuAction = new ContextMenuAction(idPrefix + _contextMenuCustomizeId,
                                                          new ActionPath(ImageViewerComponent.ContextMenuSite + "/MenuCustomizeActionModels", resolver),
                                                          ClickActionFlags.None, resolver)
            {
                GroupHint  = new GroupHint(_groupHint),
                Label      = SR.MenuCustomizeActionModels,
                Persistent = true
            };

            contextMenuAction.SetClickHandler(Customize);
            contextMenuAction.Initialize(mainMenuAction);

            return(new ActionSet(new[] { mainMenuAction, contextMenuAction }));
        }
예제 #2
0
 public ContextMenuItem(Texture2D icon,
                        string name,
                        string tooltip,
                        ContextMenuAction action)
 {
     Icon    = icon;
     Action  = action;
     Name    = name;
     Tooltip = tooltip;
 }
예제 #3
0
 public bool Check(GUIControl control)
 {
     if ((Button != null) && (control == Button))
     {
         Button.IsFocused = false;
         ContextMenuAction ret = Function();
         return(ret != ContextMenuAction.Continue);
     }
     return(false);
 }
예제 #4
0
        public ContextMenuAction Show()
        {
            GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU);

            if (dlg == null)
            {
                return(PreviousMenu ? ContextMenuAction.PreviousMenu : ContextMenuAction.Exit);
            }
            do
            {
                dlg.Reset();
                if (!string.IsNullOrEmpty(Title))
                {
                    dlg.SetHeading(Title);
                }
                foreach (IMenuItem m in this)
                {
                    dlg.Add(m.Caption);
                }
                if (SelectedLabel != -1)
                {
                    dlg.SelectedLabel = SelectedLabel;
                }
                dlg.DoModal(GUIWindowManager.ActiveWindow);
                if ((dlg.SelectedLabel >= 0) && (dlg.SelectedLabel < Count))
                {
                    IMenuItem obj = this[dlg.SelectedLabel];
                    if (obj is MenuItem)
                    {
                        ContextMenuAction act = ((MenuItem)obj).Function();
                        if (act != ContextMenuAction.Continue)
                        {
                            if (act == ContextMenuAction.PreviousMenu)
                            {
                                return(ContextMenuAction.Continue);
                            }
                            return(act);
                        }
                    }
                    else if (obj is VoidMenuItem)
                    {
                        ((VoidMenuItem)obj).Function();
                        return(ContextMenuAction.Exit);
                    }
                }
                else
                {
                    return(PreviousMenu ? ContextMenuAction.Continue : ContextMenuAction.Exit);
                }
            } while (true);
        }
예제 #5
0
        private static void AddMenuItem(ItemsControl menu, FormattedText label, ContextMenuAction action, bool enabled)
        {
            if (menu == null)
            {
                return;
            }

            MenuItem newItem = new MenuItem();

            newItem.IsEnabled = enabled;
            newItem.Header    = label.GetContent();
            if (action != null)
            {
                newItem.Click += delegate {
                    action();
                };
            }

            menu.Items.Insert(0, newItem);
        }
예제 #6
0
 private void InvokeContextMenuLuaAction(ContextMenuAction action, Character character)
 {
     FunctionsManager.Furniture.Call(action.Parameter, this, character);
 }
예제 #7
0
 private void InvokeContextMenuLuaAction(ContextMenuAction action, Character character)
 {
     FunctionsManager.RoomBehavior.Call(action.Parameter, this, character);
 }
예제 #8
0
        /// <summary>
        /// Add a context menu option to the control.
        /// </summary>
        /// <param name="control">FrameworkContentElement to add option to.</param>
        /// <param name="label">Text of the added option.</param>
        /// <param name="action">Action to be performed by option.</param>
        public static void AddContextMenuItem(FrameworkContentElement control, string label, ContextMenuAction action, bool enabled = true)
        {
            if (string.IsNullOrEmpty(label))
            {
                return;
            }

            AddContextMenuItem(control, new FormattedText(label), action, enabled);
        }
예제 #9
0
        /// <summary>
        /// Add a context menu option to the control.
        /// </summary>
        /// <param name="control">FrameworkContentElement to add option to.</param>
        /// <param name="label">Text of the added option.</param>
        /// <param name="action">Action to be performed by option.</param>
        public static void AddContextMenuItem(FrameworkContentElement control, TextBlock label, ContextMenuAction action, bool enabled = true)
        {
            if (label == null)
            {
                return;
            }

            AddContextMenuItem(control, new FormattedText(label), action, enabled);
        }
예제 #10
0
        /// <summary>
        /// Add a context menu option to the control.
        /// </summary>
        /// <param name="control">FrameworkElement to add option to.</param>
        /// <param name="label">Span of the added option.</param>
        /// <param name="action">Action to be performed by option.</param>
        public static void AddContextMenuItem(FrameworkElement control, FormattedText label, ContextMenuAction action, bool enabled = true)
        {
            if (!CheckContextMenu(control))
            {
                return;
            }

            AddMenuItem(control.ContextMenu, label, action, enabled);
        }
예제 #11
0
        private IActionSet CreateActions()
        {
            var toolType = typeof (CustomizeViewerActionModelTool);
            var resolver = new ActionResourceResolver(toolType);

            var idPrefix = toolType.FullName + ":";
            var mainMenuAction = new MenuAction(idPrefix + _mainMenuCustomizeId,
                                                new ActionPath("global-menus/MenuTools/MenuCustomizeActionModels", resolver),
                                                ClickActionFlags.None, resolver)
                                     {
                                         GroupHint = new GroupHint(_groupHint),
                                         Label = SR.MenuCustomizeActionModels,
                                         Persistent = true
                                     };
            mainMenuAction.SetClickHandler(Customize);

            var contextMenuAction = new ContextMenuAction(idPrefix + _contextMenuCustomizeId,
                                                   new ActionPath(ImageViewerComponent.ContextMenuSite +"/MenuCustomizeActionModels", resolver),
                                                   ClickActionFlags.None, resolver)
                                        {
                                            GroupHint = new GroupHint(_groupHint),
                                            Label = SR.MenuCustomizeActionModels,
                                            Persistent = true
                                        };

            contextMenuAction.SetClickHandler(Customize);
            contextMenuAction.Initialize(mainMenuAction);

            return new ActionSet(new[] {mainMenuAction, contextMenuAction});
        }
예제 #12
0
 private void InvokeContextMenuLuaAction(ContextMenuAction action, GameCharacter character)
 {
     FunctionsManager.Utility.Call(action.Parameter, this, character);
 }
예제 #13
0
 private void InvokeContextMenuLuaAction(ContextMenuAction action, Character character)
 {
     FunctionsManager.NestedObject.Call(action.Parameter, this, character);
 }