Ejemplo n.º 1
0
        private void UpdateOperatorAndValue()
        {
            if (PropertySelectorStack.Count == 0)
            {
                operatorCombo.Visible = false;
                valueComboBox.Visible = false;
                valueTextBox.Visible  = false;
                return;
            }
            var pc = PropertySelectorStack.Peek();

            operatorCombo.Visible = pc.isProp || pc.isCustom;
            valueComboBox.Visible = pc.isProp && pc.selectedProp.IsEnum;
            var vtVisible = (pc.isProp && !pc.isObject && !pc.selectedProp.IsEnum && pc.selectedProp != typeof(bool)) || pc.isCustom;

            operatorCombo.Items.Clear();

            Node.PropertyPath.Peek().Member = pc.isProp ? pc.objectType.GetProperty(pc.selectedValue) : null;

            if (!Node.IsBlank)
            {
                operatorCombo.Items.AddRange(Node.ValidOperators.AsNames());

                operatorCombo.SelectedItem = Node.Op.GetName();
                if (operatorCombo.SelectedItem == null)
                {
                    operatorCombo.SelectedItem = operatorCombo.Items[0];
                }

                Node.Op   = OperatorHelper.Parse(operatorCombo.SelectedItem.ToString());
                vtVisible = vtVisible && !Node.Op.IsUnary();

                operatorCombo.Width         = CalcWidth(operatorCombo.SelectedItem.ToString());
                operatorCombo.DropDownWidth = SuggestedOperatorComboBoxWidth();

                if (Node.CriteriaType.IsEnum)
                {
                    valueComboBox.Items.Clear();
                    if (Node.Value == null || !(Node.Value is Enum))
                    {
                        Node.Value = Enum.GetValues(Node.CriteriaType).GetValue(0);
                    }
                    valueComboBox.Width = CalcWidth(Enum.GetName(Node.CriteriaType, Node.Value));
                    valueComboBox.Items.AddRange(Enum.GetNames(Node.CriteriaType));
                    valueComboBox.SelectedItem = Enum.GetName(Node.CriteriaType, Node.Value);
                }
            }

            valueCaseSensitivity.Visible = pc.isProp && pc.selectedProp == typeof(string) && Node.Op.CaseSensitivity();
            valueTextBox.Visible         = vtVisible;

            pc.combo.Width = CalcWidth(pc.selectedValue);
        }
Ejemplo n.º 2
0
        private void OperatorChanged(object sender, EventArgs e)
        {
            var pc = PropertySelectorStack.Peek();

            Node.Op                      = OperatorHelper.Parse(operatorCombo.SelectedItem.ToString());
            operatorCombo.Width          = CalcWidth(operatorCombo.SelectedItem.ToString());
            valueTextBox.Visible         = !Node.Op.IsUnary();
            valueCaseSensitivity.Visible = pc.selectedProp == typeof(string) && Node.Op.CaseSensitivity();
            if (valueTextBox.Visible)
            {
                valueTextBox.Focus();
            }
        }