Exemplo n.º 1
0
        private void AddPropCombo(Control parent, string selectedValue, Type objectType)
        {
            var pc = new PropertySelector {
                objectType = objectType
            };
            var props = PropCache.Get(objectType);

            PropertySelectorStack.Push(pc);

            pc.combo = new ComboBox()
            {
                Margin        = new Padding(2, MarginTop, 2, 0),
                Text          = selectedValue,
                Width         = CalcWidth(selectedValue),
                DropDownWidth = 150,
                Tag           = pc
            };
            pc.combo.Items.AddRange(props.Keys.OrderBy(n => n).ToArray());
            pc.combo.SelectedItem              = selectedValue;
            pc.combo.SelectionChangeCommitted += PropComboSelectionChanged;
            pc.UpdateTooltip();

            pc.expand = new Button()
            {
                Margin  = new Padding(-2, MarginTop - 1, -2, MarginTop),
                Text    = "\u2022",
                Width   = 18,
                Tag     = pc,
                Visible = selectedValue != null && props.ContainsKey(selectedValue) && props[selectedValue].IsClass && props[selectedValue] != typeof(string)
            };

            pc.expand.Click += Expand_Click;

            var operatorIndex = parent.Controls.IndexOf(operatorCombo);

            parent.Controls.Add(pc.combo);
            if (operatorIndex >= 0)
            {
                parent.Controls.SetChildIndex(pc.combo, operatorIndex);
            }
            parent.Controls.Add(pc.expand);
            if (operatorIndex >= 0)
            {
                parent.Controls.SetChildIndex(pc.expand, operatorIndex + 1);
            }
        }