예제 #1
0
        void Display(ContextMenuEvent contextMenuEvent)
        {
            if (_event != null)
            {
                Close();
            }

            if (contextMenuEvent == null)
            {
                return;
            }

            _event      = contextMenuEvent;
            _uiPosition = contextMenuEvent.UiPosition;

            var optionElements         = new List <IUiElement>();
            ContextMenuGroup?lastGroup = null;

            foreach (var option in _event.Options)
            {
                lastGroup ??= option.Group;
                if (lastGroup != option.Group)
                {
                    optionElements.Add(new Spacing(0, 2));
                }
                lastGroup = option.Group;

                var option1 = option;
                optionElements.Add(new Button(option.Text).OnClick(() => OnButton(option1, option1.Disabled)));
            }

            var elements = new List <IUiElement>
            {
                new Spacing(0, 2),
                new HorizontalStack(new Spacing(5, 0), new BoldHeader(_event.Heading), new Spacing(5, 0)),
                new Divider(CommonColor.Yellow3),
                new Padding(new VerticalStack(optionElements), 0, 2)
            };

            var frame = new DialogFrame(new VerticalStack(elements));

            AttachChild(frame);
            Raise(new PushInputModeEvent(InputMode.ContextMenu));
        }
예제 #2
0
 void Close()
 {
     RemoveAllChildren();
     _event = null;
     Raise(new PopInputModeEvent());
 }