コード例 #1
0
        protected static HtmlTag ToggleInputRender(TypedElement element, RenderContext context)
        {
            ToggleInput toggleInput = (ToggleInput)element;

            var uiElement = new HtmlTag("div")
                            .AddClass("ac-input")
                            .Style("width", "100%");

            var uiCheckboxInput = new HtmlTag("input")
                                  .Attr("type", "checkbox")
                                  .Attr("name", toggleInput.Id)
                                  .Style("display", "inline-block")
                                  .Style("vertical-align", "middle")
                                  .Style("margin", "0px");

            if (toggleInput.Value == toggleInput.ValueOn)
            {
                uiCheckboxInput.Attr("checked", string.Empty);
            }

            var uiLabel = context.Render(new TextBlock {
                Text = toggleInput.Title
            })
                          .Style("display", "inline-block")
                          .Style("margin-left", "6px")
                          .Style("vertical-align", "middle");

            return(uiElement.Append(uiCheckboxInput).Append(uiLabel));
        }
コード例 #2
0
    public override void OnInspectorGUI()
    {
        this.serializedObject.Update();

        ToggleInput bridge = (ToggleInput)target;

        GUI.enabled = false;
        EditorGUILayout.PropertyField(script, true, new GUILayoutOption[0]);
        GUI.enabled = true;
        EditorGUILayout.PropertyField(checkEdge, new GUIContent("checkEdge"));

        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.LabelField("Value", GUILayout.Width(80f));
        int index = 0;

        if (bridge.Value == true)
        {
            index = 1;
        }
        GUILayout.SelectionGrid(index, new string[] { "FALSE", "TRUE" }, 2);
        EditorGUILayout.EndHorizontal();

        if (Application.isPlaying == true)
        {
            EditorUtility.SetDirty(target);
        }

        this.serializedObject.ApplyModifiedProperties();
    }
コード例 #3
0
        public static FrameworkElement Render(TypedElement element, RenderContext context)
        {
            ToggleInput input = (ToggleInput)element;

            if (context.Config.SupportsInteractivity)
            {
                var uiToggle = new CheckBox();
#if WPF
                // TODO: Finish switch
                uiToggle.Content = input.Title;
#endif
                uiToggle.SetState(input.Value == (input.ValueOn ?? "true"));
                uiToggle.Style = context.GetStyle($"Adaptive.Input.Toggle");
                uiToggle.SetContext(input);
                context.InputBindings.Add(input.Id, () =>
                {
                    return(uiToggle.GetState() == true ? input.ValueOn ?? "true" : input.ValueOff ?? "false");
                });
                return(uiToggle);
            }
            else
            {
                Container container = TypedElementConverter.CreateElement <Container>();
                container.Separation = input.Separation;

                TextBlock textBlock = TypedElementConverter.CreateElement <TextBlock>();
                textBlock.Text = XamlUtilities.GetFallbackText(input);
                container.Items.Add(textBlock);
                if (input.Value != null)
                {
                    textBlock       = TypedElementConverter.CreateElement <TextBlock>();
                    textBlock.Text  = (input.Value == (input.ValueOn ?? "true")) ? input.ValueOn ?? "selected" : input.ValueOff ?? "not selected";
                    textBlock.Color = TextColor.Accent;
                    textBlock.Wrap  = true;
                    container.Items.Add(textBlock);
                }
                return(context.Render(container));
            }
        }
コード例 #4
0
        protected static HtmlTag ToggleInputRender(TypedElement element, RenderContext context)
        {
            ToggleInput input     = (ToggleInput)element;
            var         container = new Container {
                Separation = input.Separation
            };

            container.Items.Add(new TextBlock {
                Text = GetFallbackText(input)
            });
            if (input.Value != null)
            {
                container.Items.Add(new TextBlock
                {
                    Text =
                        input.Value == (input.ValueOn ?? "true")
                            ? input.ValueOn ?? "selected"
                            : input.ValueOff ?? "not selected",
                    Color = TextColor.Accent,
                    Wrap  = true
                });
            }
            return(context.Render(container));
        }
コード例 #5
0
 public virtual void Visit(ToggleInput inputToggle)
 {
 }