Esempio n. 1
0
        static VisualElement BuildSearcherEnumEditor(Enum value, Type enumType, Action <Enum> onNewEnumValue)
        {
            var enumEditor = new Button {
                text = value.ToString()
            };

            enumEditor.clickable.clickedWithEventInfo += e =>
            {
                SearcherService.ShowEnumValues("Pick a value", enumType, e.originalMousePosition, (v, i) =>
                {
                    enumEditor.text = v.ToString();
                    onNewEnumValue(v);
                });
            };
            return(enumEditor);
        }
        public static VisualElement BuildEnumEditor(this IConstantEditorBuilder builder, EnumConstantNodeModel enumConstant)
        {
            var enumEditor = new Button {
                text = enumConstant.EnumValue.ToString()
            };                                                                        // TODO use a bindable element

            enumEditor.clickable.clickedWithEventInfo += e =>
            {
                SearcherService.ShowEnumValues("Pick a value", enumConstant.EnumType.Resolve(enumConstant.GraphModel.Stencil), e.originalMousePosition, (v, i) =>
                {
                    enumConstant.value.Value = Convert.ToInt32(v);
                    enumEditor.text          = v.ToString();
                    builder.OnValueChanged?.Invoke(null);
                });
            };
            enumEditor.SetEnabled(!enumConstant.IsLocked);
            return(enumEditor);
        }
 public static GraphElement CreateUnaryOperator(this INodeBuilder builder, Store store, UnaryOperatorNodeModel model)
 {
     return(new Node(model, store, builder.GraphView)
     {
         CustomSearcherHandler = (node, nStore, pos, _) =>
         {
             SearcherService.ShowEnumValues("Pick a new operator type", typeof(UnaryOperatorKind), pos, (pickedEnum, __) =>
             {
                 if (pickedEnum != null)
                 {
                     ((UnaryOperatorNodeModel)node.model).Kind = (UnaryOperatorKind)pickedEnum;
                     nStore.Dispatch(new RefreshUIAction(UpdateFlags.GraphTopology));
                 }
             });
             return true;
         }
     });
 }
Esempio n. 4
0
        public static IGraphElement CreateUnaryOperator(this ElementBuilder elementBuilder, IStore store, UnaryOperatorNodeModel model)
        {
            var ui = new Node();

            ui.Setup(model, store, elementBuilder.GraphView);
            ui.CustomSearcherHandler = (node, nStore, pos, _) =>
            {
                SearcherService.ShowEnumValues("Pick a new operator type", typeof(UnaryOperatorKind), pos, (pickedEnum, __) =>
                {
                    if (pickedEnum != null)
                    {
                        ((UnaryOperatorNodeModel)node.NodeModel).Kind = (UnaryOperatorKind)pickedEnum;
                        nStore.Dispatch(new RefreshUIAction(UpdateFlags.GraphTopology));
                    }
                });
                return(true);
            };
            return(ui);
        }