Esempio n. 1
0
 public void Remove()
 {
     if (Child != null)
     {
         PropertyBox temp = Child;
         Child = null;
         temp.Remove();
     }
     Parent.Controls.Remove(this);
 }
Esempio n. 2
0
        protected override void OnSelectedIndexChanged(EventArgs e)
        {
            Graphics g = CreateGraphics();

            Width = (int)g.MeasureString(Text, Font).Width + 20;
            g.Dispose();

            if (!SelectedItem.Equals(""))
            {
                SelectedProperty = SelectedItem as SearchProperty;
            }
            else
            {
                SelectedProperty = null;
            }

            if (Child != null)
            {
                PropertyBox temp = Child;
                Child = null;
                temp.Remove();
            }

            //if listproperties only and subproperties contains other lists or !list
            if (!ListPropertiesOnly && SelectedProperty != null && (!ListPropertiesOnly && SelectedProperty.SubProperties.Any() || ListPropertiesOnly && SelectedProperty.SubProperties.Count(property => property.SubProperties.Count > 0) > 0))
            {
                Child = new PropertyBox
                {
                    _parentProperty    = this,
                    ParentType         = (SelectedItem as SearchProperty).Type,
                    ListPropertiesOnly = ListPropertiesOnly,
                    Location           = new Point(Right + 0, Top)
                };
                Parent.Controls.Add(Child);
            }
            if (Parent.GetType() == typeof(CriteriaLine))
            {
                (Parent as CriteriaLine).GetComparers();
                (Parent as CriteriaLine).ValueSelect.ResetText();
                (Parent as CriteriaLine).GetValueOptions();
                (Parent as CriteriaLine).ResizeSelf();
            }

            base.OnSelectedIndexChanged(e);
        }
Esempio n. 3
0
        private void SelectList_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (SelectProperties != null) SelectProperties.Remove();
            SelectProperties = new PropertyBox();
            SelectProperties.Location = new Point(SelectList.Right + 3, SelectList.Top);
            SelectProperties.ListPropertiesOnly = true;
            SelectProperties.SelectedIndexChanged += new EventHandler(SelectSubListChanged);
            this.Controls.Add(SelectProperties);

            switch (SelectList.SelectedItem.ToString())
            {
                case "Historical Figures": 
                    SearchList = new SearchList<HistoricalFigure>(World.HistoricalFigures);
                    SelectProperties.ParentType = typeof(HistoricalFigure);
                    break;
                case "Entities":
                    SearchList = new SearchList<Entity>(World.Entities);
                    SelectProperties.ParentType = typeof(Entity);
                    break;
                case "Sites": 
                    SearchList = new SearchList<Site>(World.Sites);
                    SelectProperties.ParentType = typeof(Site);
                    break;
                case "Regions":
                    SearchList = new SearchList<WorldRegion>(World.Regions);
                    SelectProperties.ParentType = typeof(WorldRegion);
                    break;
                case "Underground Regions":
                    SearchList = new SearchList<UndergroundRegion>(World.UndergroundRegions);
                    SelectProperties.ParentType = typeof(UndergroundRegion);
                    break;
                case "Wars":
                    SearchList = new SearchList<War>(World.Wars);
                    SelectProperties.ParentType = typeof(War);
                    break;
                case "Battles":
                    SearchList = new SearchList<Battle>(World.Battles);
                    SelectProperties.ParentType = typeof(Battle);
                    break;
                case "Conquerings":
                    SearchList = new SearchList<SiteConquered>(World.EventCollections.OfType<SiteConquered>().ToList());
                    SelectProperties.ParentType = typeof(SiteConquered);
                    break;
                case "Beast Attacks":
                    SearchList = new SearchList<BeastAttack>(World.BeastAttacks);
                    SelectProperties.ParentType = typeof(BeastAttack);
                    break;
                case "Artifacts":
                    SearchList = new SearchList<Artifact>(World.Artifacts);
                    SelectProperties.ParentType = typeof(Artifact);
                    break;
            }

            if (SelectProperties.ParentType == typeof(Site) || SelectProperties.ParentType == typeof(Battle)) btnMapResults.Visible = true;

            SelectionPanel.Clear();

            SelectionPanel.CriteriaType = SearchList.GetMainListType();
            SearchPanel.CriteriaType = SelectProperties.GetLowestPropertyType();
            OrderByPanel.CriteriaType = SelectProperties.GetLowestPropertyType();

            SelectSubListChanged(this, null);


            //lblSelectCriteria.Text = "Select " + SelectList.Text + " Where:";
            //lblSearchCriteria.Text = "Search " + SelectList.Text + " Where:";
            //lblOrderCriteria.Text = "Order " + SelectList.Text + " By:";
        }
Esempio n. 4
0
        private void SelectList_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (SelectProperties != null)
            {
                SelectProperties.Remove();
            }
            SelectProperties                       = new PropertyBox();
            SelectProperties.Location              = new Point(SelectList.Right + 3, SelectList.Top);
            SelectProperties.ListPropertiesOnly    = true;
            SelectProperties.SelectedIndexChanged += new EventHandler(SelectSubListChanged);
            this.Controls.Add(SelectProperties);

            switch (SelectList.SelectedItem.ToString())
            {
            case "Historical Figures":
                SearchList = new SearchList <HistoricalFigure>(World.HistoricalFigures);
                SelectProperties.ParentType = typeof(HistoricalFigure);
                break;

            case "Entities":
                SearchList = new SearchList <Entity>(World.Entities);
                SelectProperties.ParentType = typeof(Entity);
                break;

            case "Sites":
                SearchList = new SearchList <Site>(World.Sites);
                SelectProperties.ParentType = typeof(Site);
                break;

            case "Regions":
                SearchList = new SearchList <WorldRegion>(World.Regions);
                SelectProperties.ParentType = typeof(WorldRegion);
                break;

            case "Underground Regions":
                SearchList = new SearchList <UndergroundRegion>(World.UndergroundRegions);
                SelectProperties.ParentType = typeof(UndergroundRegion);
                break;

            case "Wars":
                SearchList = new SearchList <War>(World.Wars);
                SelectProperties.ParentType = typeof(War);
                break;

            case "Battles":
                SearchList = new SearchList <Battle>(World.Battles);
                SelectProperties.ParentType = typeof(Battle);
                break;

            case "Conquerings":
                SearchList = new SearchList <SiteConquered>(World.EventCollections.OfType <SiteConquered>().ToList());
                SelectProperties.ParentType = typeof(SiteConquered);
                break;

            case "Beast Attacks":
                SearchList = new SearchList <BeastAttack>(World.BeastAttacks);
                SelectProperties.ParentType = typeof(BeastAttack);
                break;

            case "Artifacts":
                SearchList = new SearchList <Artifact>(World.Artifacts);
                SelectProperties.ParentType = typeof(Artifact);
                break;
            }

            if (SelectProperties.ParentType == typeof(Site) || SelectProperties.ParentType == typeof(Battle))
            {
                btnMapResults.Visible = true;
            }

            SelectionPanel.Clear();

            SelectionPanel.CriteriaType = SearchList.GetMainListType();
            SearchPanel.CriteriaType    = SelectProperties.GetLowestPropertyType();
            OrderByPanel.CriteriaType   = SelectProperties.GetLowestPropertyType();

            SelectSubListChanged(this, null);


            //lblSelectCriteria.Text = "Select " + SelectList.Text + " Where:";
            //lblSearchCriteria.Text = "Search " + SelectList.Text + " Where:";
            //lblOrderCriteria.Text = "Order " + SelectList.Text + " By:";
        }
Esempio n. 5
0
        private List <SearchInfo> BuildQuery(List <CriteriaLine> inputCriteria)
        {
            List <SearchInfo> criteria = new List <SearchInfo>();
            Type genericSearch         = typeof(SearchInfo <>);

            foreach (CriteriaLine line in inputCriteria.Where(line => line.IsComplete()))
            {
                PropertyBox currentProperty = line.PropertySelect;
                Type        searchType      = genericSearch.MakeGenericType(line.PropertySelect.ParentType);
                SearchInfo  newCriteria     = Activator.CreateInstance(searchType) as SearchInfo;
                if (line == inputCriteria.First(line1 => line1.IsComplete()))
                {
                    newCriteria.Operator = QueryOperator.Or;
                }
                else
                {
                    newCriteria.Operator = QueryOperator.And;
                }
                criteria.Add(newCriteria);
                if (line.OrderByCriteria)
                {
                    if (line.OrderBySelect.Text == "Descending")
                    {
                        newCriteria.OrderByDescending = true;
                    }
                }

                while (currentProperty != null)
                {
                    if (currentProperty.Child == null || currentProperty.Child.SelectedProperty == null)
                    {
                        if (currentProperty.SelectedProperty != null)
                        {
                            newCriteria.PropertyName = currentProperty.SelectedProperty.Name;
                        }
                        if (currentProperty.SelectedProperty != null && currentProperty.SelectedProperty.Type.IsGenericType && currentProperty.SelectedProperty.Type.GetGenericTypeDefinition() == typeof(List <>))
                        {
                            newCriteria.Comparer = QueryComparer.Count;
                            newCriteria.Value    = 0;
                            SearchInfo temp           = newCriteria;
                            Type       nextSearchType = genericSearch.MakeGenericType(currentProperty.SelectedProperty.Type.GetGenericArguments()[0]);
                            newCriteria          = Activator.CreateInstance(nextSearchType) as SearchInfo;
                            temp.Next            = newCriteria;
                            newCriteria.Previous = temp;
                            if (line.OrderByCriteria)
                            {
                                newCriteria.Comparer = QueryComparer.All;
                            }
                        }

                        if (newCriteria.Comparer != QueryComparer.All)
                        {
                            newCriteria.Comparer = SearchProperty.StringToComparer(line.ComparerSelect.Text);
                        }
                        if (currentProperty.SelectedProperty != null && currentProperty.SelectedProperty.Type == typeof(string))
                        {
                            if (newCriteria.Comparer == QueryComparer.Equals)
                            {
                                newCriteria.Comparer = QueryComparer.StringEquals;
                            }
                            else if (newCriteria.Comparer == QueryComparer.NotEqual)
                            {
                                newCriteria.Comparer = QueryComparer.StringNotEqual;
                            }
                        }

                        if (currentProperty.SelectedProperty != null && (currentProperty.SelectedProperty.Type == typeof(int) || currentProperty.SelectedProperty.Type == typeof(List <int>)))
                        {
                            newCriteria.Value = Convert.ToInt32(line.ValueSelect.Text);
                        }
                        else
                        {
                            newCriteria.Value = line.ValueSelect.Text;
                        }
                    }
                    else
                    {
                        newCriteria.Comparer     = QueryComparer.Count;
                        newCriteria.PropertyName = currentProperty.SelectedProperty.Name;
                        SearchInfo temp = newCriteria;
                        Type       nextSearchType;
                        if (currentProperty.Child.ParentType.IsGenericType)
                        {
                            nextSearchType = genericSearch.MakeGenericType(currentProperty.Child.ParentType.GetGenericArguments()[0]);
                        }
                        else
                        {
                            nextSearchType = genericSearch.MakeGenericType(currentProperty.Child.ParentType);
                        }
                        newCriteria          = Activator.CreateInstance(nextSearchType) as SearchInfo;
                        temp.Next            = newCriteria;
                        newCriteria.Previous = temp;
                    }
                    if (newCriteria.Previous != null)
                    {
                        newCriteria.Operator = QueryOperator.Or;
                    }
                    currentProperty = currentProperty.Child;
                }
            }
            return(criteria);
        }
Esempio n. 6
0
 public void Remove()
 {
     if (Child != null)
     {
         PropertyBox temp = Child;
         Child = null;
         temp.Remove();
     }
     Parent.Controls.Remove(this);
 }
Esempio n. 7
0
        protected override void OnSelectedIndexChanged(EventArgs e)
        {
            Graphics g = this.CreateGraphics();
            this.Width = (int)g.MeasureString(this.Text, this.Font).Width + 20;
            g.Dispose();

            if (!SelectedItem.Equals("")) SelectedProperty = SelectedItem as SearchProperty;
            else SelectedProperty = null;
            if (Child != null)
            {
                PropertyBox temp = Child;
                Child = null;
                temp.Remove();
            }

            //if listproperties only and subproperties contains other lists or !list
            if (!ListPropertiesOnly && SelectedProperty != null && ((!ListPropertiesOnly && SelectedProperty.SubProperties.Any()) || (ListPropertiesOnly && SelectedProperty.SubProperties.Count(property => property.SubProperties.Count > 0) > 0)))
            {
                Child = new PropertyBox();
                Child.ParentProperty = this;
                Child.ParentType = (SelectedItem as SearchProperty).Type;
                Child.ListPropertiesOnly = ListPropertiesOnly;
                Child.Location = new Point(Right + 0, Top);
                Parent.Controls.Add(Child);
            }
            if (Parent.GetType() == typeof(CriteriaLine))
            {
                (Parent as CriteriaLine).GetComparers();
                (Parent as CriteriaLine).ValueSelect.ResetText();
                (Parent as CriteriaLine).GetValueOptions();
                (Parent as CriteriaLine).ResizeSelf();
            }

            base.OnSelectedIndexChanged(e);
        }
Esempio n. 8
0
        private void SelectList_SelectedIndexChanged(object sender, EventArgs e)
        {
            _selectProperties?.Remove();

            _selectProperties = new PropertyBox
            {
                Location           = new Point(SelectList.Right + 3, SelectList.Top),
                ListPropertiesOnly = true
            };
            _selectProperties.SelectedIndexChanged += SelectSubListChanged;
            Controls.Add(_selectProperties);

            switch (SelectList.SelectedItem.ToString())
            {
            case "Historical Figures":
                _searchList = new SearchList <HistoricalFigure>(World.HistoricalFigures);
                _selectProperties.ParentType = typeof(HistoricalFigure);
                break;

            case "Entities":
                _searchList = new SearchList <Entity>(World.Entities);
                _selectProperties.ParentType = typeof(Entity);
                break;

            case "Sites":
                _searchList = new SearchList <Site>(World.Sites);
                _selectProperties.ParentType = typeof(Site);
                break;

            case "Regions":
                _searchList = new SearchList <WorldRegion>(World.Regions);
                _selectProperties.ParentType = typeof(WorldRegion);
                break;

            case "Underground Regions":
                _searchList = new SearchList <UndergroundRegion>(World.UndergroundRegions);
                _selectProperties.ParentType = typeof(UndergroundRegion);
                break;

            case "Structures":
                _searchList = new SearchList <Structure>(World.Structures);
                _selectProperties.ParentType = typeof(Structure);
                break;

            case "Wars":
                _searchList = new SearchList <War>(World.Wars);
                _selectProperties.ParentType = typeof(War);
                break;

            case "Battles":
                _searchList = new SearchList <Battle>(World.Battles);
                _selectProperties.ParentType = typeof(Battle);
                break;

            case "Conquerings":
                _searchList = new SearchList <SiteConquered>(World.EventCollections.OfType <SiteConquered>().ToList());
                _selectProperties.ParentType = typeof(SiteConquered);
                break;

            case "Rampages":
                _searchList = new SearchList <BeastAttack>(World.BeastAttacks);
                _selectProperties.ParentType = typeof(BeastAttack);
                break;

            case "Raids":
                _searchList = new SearchList <Raid>(World.EventCollections.OfType <Raid>().ToList());
                _selectProperties.ParentType = typeof(Raid);
                break;

            case "Artifacts":
                _searchList = new SearchList <Artifact>(World.Artifacts);
                _selectProperties.ParentType = typeof(Artifact);
                break;

            case "Written Content":
                _searchList = new SearchList <WrittenContent>(World.WrittenContents);
                _selectProperties.ParentType = typeof(WrittenContent);
                break;
            }

            if (_selectProperties.ParentType == typeof(Site) || _selectProperties.ParentType == typeof(Battle))
            {
                btnMapResults.Visible = true;
            }

            SelectionPanel.Clear();

            SelectionPanel.CriteriaType = _searchList.GetMainListType();
            SearchPanel.CriteriaType    = _selectProperties.GetLowestPropertyType();
            OrderByPanel.CriteriaType   = _selectProperties.GetLowestPropertyType();

            SelectSubListChanged(this, null);
        }