예제 #1
0
    [AgRule("Widget", "OrdinaryQuestion")] static Control OrdinaryQuestionWidget(Ast n)
    {
        QDialog dialog = n.Dialog();

        ((Control)dialog).Enabled = true;
        EventHandler h = (object o, EventArgs a) => {
            if (!((Control)o).ContainsFocus)
            {
                return;                                          // TODO: For which reason is this check needed?
            }
            n.SetValue(dialog.GetValue());
            n.Root().Render();
        };

        dialog.AddEventHandler(h);

        var contentBox = new FlowLayoutPanel();

        contentBox.AutoSize      = true;
        contentBox.WrapContents  = false;
        contentBox.FlowDirection = FlowDirection.LeftToRight;
        var label = new Label();

        label.Text     = n.GetLabel();
        label.AutoSize = true;
        label.Anchor   = AnchorStyles.Left;
        contentBox.Controls.Add(label);
        contentBox.Controls.Add((Control)dialog);

        n.Parent().Widget().Controls.Add(contentBox);
        return(contentBox);
    }
예제 #2
0
    [AgRule("Widget", "OrdinaryQuestion")] static Box OrdinaryQuestionWidget(Ast n)
    {
        QDialog      dialog = n.Dialog();
        EventHandler h      = (object o, EventArgs a) => {
            n.SetValue(dialog.GetValue());
            n.Root().Render();
        };

        dialog.AddEventHandler(h);
        HBox box = new HBox(false, 5);

        if (!n.IsLValid())
        {
            Image warning = new Image(Stock.DialogWarning, IconSize.Button);
            box.PackStart(warning, false, false, 3);
        }
        box.PackStart(new Label(n.GetLabel()), false, false, 5);
        box.PackStart((Widget)dialog, true, true, 5);
        n.Parent().Widget().PackStart(box, false, false, 5);
        box.ShowAll();
        return(box);
    }