Ejemplo n.º 1
0
        public SearchProperty GetLowestProperty()
        {
            if (Child == null)
            {
                return(SelectedProperty);
            }

            SearchProperty property = Child.GetLowestProperty();

            if (property == null)
            {
                return(SelectedProperty);
            }

            return(property);
        }
Ejemplo n.º 2
0
        public void GetValueOptions()
        {
            object previousSelection = ValueSelect.SelectedItem;

            ValueSelect.Items.Clear();
            ValueSelect.DropDownStyle = ComboBoxStyle.DropDown;
            Type           selectedType = PropertySelect.GetLowestPropertyType();
            SearchProperty selected     = PropertySelect.GetLowestProperty();

            if (selected == null)
            {
                return;
            }

            if (selectedType == typeof(bool))
            {
                ValueSelect.Items.Add(true);
                ValueSelect.Items.Add(false);
            }
            //else if (selectedType == typeof(DeathCause))
            //{
            //ValueSelect.Items.AddRange(Enum.GetValues(typeof(DeathCause)).Cast<object>().ToArray());
            //    ValueSelect.Items.AddRange(World.DeathCauses.Cast<object>().ToArray());
            //}
            //else if (selectedType == typeof(SiteConqueredType))
            //{
            //    ValueSelect.Items.AddRange(Enum.GetValues(typeof(SiteConqueredType)).Cast<object>().OrderBy(type => type.GetDescription()).ToArray());
            //}
            //else if (selectedType == typeof(BattleOutcome))
            //{
            //    ValueSelect.Items.AddRange(Enum.GetValues(typeof(BattleOutcome)).Cast<object>().OrderBy(outcome => outcome.GetDescription()).ToArray());
            //}
            //else if (selectedType == typeof(HFState))
            //{
            //    ValueSelect.Items.AddRange(Enum.GetValues(typeof(HFState)).Cast<object>().OrderBy(state => state.GetDescription()).ToArray());
            //}
            else //if (!selected.Type.IsGenericType)// && selected.Type != typeof(int) && selected.Type != typeof(double))// && PropertySelect.GetLowestProperty().Name != "Name")
            {
                IEnumerable <object> options;
                if (SelectCriteria)
                {
                    options = (Parent.Parent as QueryControl).SearchSelection(this);
                }
                else
                {
                    options = (Parent.Parent as QueryControl).Search(this);
                }

                SearchInfo available = BuildSearchInfo(true);
                if (available != null)
                {
                    options = available.Select(options);
                    options = options.GroupBy(option => option).Select(option => option.Key);
                    if (options.FirstOrDefault() != null && (options.First().GetType() == typeof(int) || options.First().GetType() == typeof(double)))
                    {
                        options = options.OrderBy(option => option);
                    }
                    else
                    {
                        options = options.OrderBy(option => option.GetDescription()).ToList();
                    }

                    ValueSelect.Items.AddRange(options.ToArray());
                }
            }

            if (selectedType == typeof(bool) || selectedType.IsEnum)
            {
                ValueSelect.DropDownStyle = ComboBoxStyle.DropDownList;
                if (ValueSelect.Items.Count > 0)
                {
                    ValueSelect.SelectedIndex = 0;
                }
            }

            if (PropertySelect.GetLowestProperty().Name == "Name")
            {
                ValueSelect.AutoCompleteMode   = AutoCompleteMode.SuggestAppend;
                ValueSelect.AutoCompleteSource = AutoCompleteSource.ListItems;
            }
            else
            {
                ValueSelect.AutoCompleteMode = AutoCompleteMode.None;
            }

            if (previousSelection != null && ValueSelect.Items.Contains(previousSelection))
            {
                ValueSelect.SelectedItem = previousSelection;
            }
            (Parent as CriteriaPanel).UpdateValueSelects(this);
        }