示例#1
0
        public static HBox ComboBox(string fieldName, string[] values, int initialValueIndex, EventHandler callback, bool deferred = false)
        {
            HBox box = new HBox(false, 20);

            Label label = new Label(fieldName);

            box.PackStart(label, false, false, 0);
            label.Show();

            ComboBox dropdown = new ComboBox(values);

            dropdown.WidthRequest = 200;
            dropdown.Active       = initialValueIndex;
            box.PackStart(dropdown, false, false, 0);
            if (deferred)
            {
                DeferredEventHelper h = new DeferredEventHelper(callback, DeferredEvents, ValueType.None);
                dropdown.Changed += h.Fired;
                DeferredEvents.Add(h);
            }
            else
            {
                dropdown.Changed += callback;
            }
            dropdown.Show();

            return(box);
        }
示例#2
0
        public static HBox TextEntryField(string fieldName, string value, EventHandler callback, bool deferred = false, ValueType valType = ValueType.Str)
        {
            HBox box = new HBox(false, 20);

            Label label = new Label(fieldName);

            box.PackStart(label, false, false, 0);
            label.Show();

            Entry entry = new Entry();

            entry.WidthRequest = 200;
            box.PackStart(entry, false, false, 0);
            entry.Text = value;

            if (valType != ValueType.Str)
            {
                deferred = true;
            }

            if (deferred)
            {
                DeferredEventHelper h = new DeferredEventHelper(callback, DeferredEvents, valType);
                entry.Changed += h.Fired;
            }
            else
            {
                entry.Changed += callback;
            }
            entry.Show();

            return(box);
        }