예제 #1
0
        void update_list()
        {
            List <MagicItem> selection = new List <MagicItem>();

            List <MagicItem> items = Session.MagicItems;

            foreach (MagicItem item in items)
            {
                if ((item.Level >= LevelRangePanel.MinimumLevel) && (item.Level <= LevelRangePanel.MaximumLevel) && match(item, LevelRangePanel.NameQuery))
                {
                    selection.Add(item);
                }
            }

            BinarySearchTree <string> bst = new BinarySearchTree <string>();

            foreach (MagicItem item in selection)
            {
                if (item.Type != "")
                {
                    bst.Add(item.Type);
                }
            }

            List <string> cats = bst.SortedList;

            cats.Add("Miscellaneous Items");
            foreach (string cat in cats)
            {
                ItemList.Groups.Add(cat, cat);
            }

            List <ListViewItem> list_items = new List <ListViewItem>();

            foreach (MagicItem item in selection)
            {
                ListViewItem lvi = new ListViewItem(item.Name);
                lvi.SubItems.Add(item.Info);
                lvi.Tag = item;

                if (item.Type != "")
                {
                    lvi.Group = ItemList.Groups[item.Type];
                }
                else
                {
                    lvi.Group = ItemList.Groups["Miscellaneous Items"];
                }

                list_items.Add(lvi);
            }

            ItemList.BeginUpdate();
            ItemList.Items.Clear();
            ItemList.Items.AddRange(list_items.ToArray());
            ItemList.EndUpdate();
        }
예제 #2
0
        void update_list()
        {
            List <Artifact> artifacts = new List <Artifact>();

            foreach (Artifact a in Session.Artifacts)
            {
                if (match(a, NameBox.Text))
                {
                    artifacts.Add(a);
                }
            }

            ListViewGroup lvg_heroic  = ItemList.Groups.Add("Heroic Tier", "Heroic Tier");
            ListViewGroup lvg_paragon = ItemList.Groups.Add("Paragon Tier", "Paragon Tier");
            ListViewGroup lvg_epic    = ItemList.Groups.Add("Epic Tier", "Epic Tier");

            List <ListViewItem> list_items = new List <ListViewItem>();

            foreach (Artifact item in artifacts)
            {
                ListViewItem lvi = new ListViewItem(item.Name);
                lvi.SubItems.Add(item.Tier + " Tier");
                lvi.Tag = item;

                switch (item.Tier)
                {
                case Tier.Heroic:
                    lvi.Group = lvg_heroic;
                    break;

                case Tier.Paragon:
                    lvi.Group = lvg_paragon;
                    break;

                case Tier.Epic:
                    lvi.Group = lvg_epic;
                    break;
                }

                list_items.Add(lvi);
            }

            ItemList.BeginUpdate();
            ItemList.Items.Clear();
            ItemList.Items.AddRange(list_items.ToArray());
            ItemList.EndUpdate();
        }
예제 #3
0
/// <summary>
/// When check state changes update the display to reflect
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>

        private void ItemList_ItemCheck(object sender, DevExpress.XtraEditors.Controls.ItemCheckEventArgs e)
        {
            if (InSetup)
            {
                return;
            }

            InSetup = true;
            ItemList.BeginUpdate();

            CheckedListBoxItemCollection items = ItemList.Items;
            string txt       = items[e.Index].Description;
            bool   isChecked = (e.State == CheckState.Checked);

            if (txt == "(All)")             // check/uncheck everything
            {
                foreach (CheckedListBoxItem i in items)
                {
                    i.CheckState = e.State;
                }
            }

            else if (txt == "(Non blanks)")
            {
                foreach (CheckedListBoxItem i in items)
                {
                    if (i.Description == "(All)" || i.Description == "(Blanks)")
                    {
                        continue;
                    }
                    i.CheckState = e.State;
                }
            }

            else if (e.State == CheckState.Unchecked)             // turned item off; turn off All & Non blanks as well
            {
                items[AllPos].CheckState = CheckState.Unchecked;
                if (NonBlanksPos >= 0 && txt != "(Blanks)")
                {
                    items[NonBlanksPos].CheckState = CheckState.Unchecked;
                }
            }

            if (BlanksPos >= 0)             // if blanks allowed set (All) based on Blanks/Non blanks settings
            {
                if (items[BlanksPos].CheckState == CheckState.Checked &&
                    items[NonBlanksPos].CheckState == CheckState.Checked)
                {
                    items[AllPos].CheckState = CheckState.Checked;
                }
                else
                {
                    items[AllPos].CheckState = CheckState.Unchecked;
                }
            }

            ItemList.EndUpdate();
            InSetup = false;

// Generate new criteria from set of checks

            QueryColumn qc = ColInfo.Qc;

            if (items[AllPos].CheckState == CheckState.Checked)             // everything
            {
                qc.SecondaryCriteria        = qc.MetaColumn.Name + " in ('(All)')";
                qc.SecondaryCriteriaDisplay = qc.ActiveLabel + " in list (All)";
            }

            //else if (NonBlanksPos >= 0 && items[NonBlanksPos].CheckState == CheckState.Checked)
            //{ // just non-null
            //  qc.SecondaryCriteria = qc.MetaColumn.Name + " is not null";
            //  qc.SecondaryCriteriaDisplay = qc.ActiveLabel + " is not null";
            //}

            else             // build list of checked items possibly including "(Blanks)" and "(Non blanks)"
            {
                int itemsChecked = 0;
                qc.SecondaryCriteria = qc.MetaColumn.Name + " in (";

                foreach (CheckedListBoxItem i in items)
                {
                    string normalizedString;

                    if (i.CheckState != CheckState.Checked)
                    {
                        continue;
                    }

                    if (itemsChecked > 0)
                    {
                        qc.SecondaryCriteria += ", ";
                    }

                    normalizedString = i.Description;
                    if (i.Description == "(All)" || i.Description == "(Blanks)" || i.Description == "(Non blanks)")
                    {
                    }                       // these are always ok as is
                    else if (qc.MetaColumn.DataType == MetaColumnType.CompoundId ||
                             qc.MetaColumn.DataType == MetaColumnType.Date)
                    {                     // store these in internal format
                        MobiusDataType mdt = MobiusDataType.New(qc.MetaColumn.DataType, i.Description);
                        normalizedString = mdt.FormatForCriteria();
                    }
                    qc.SecondaryCriteria += Lex.AddSingleQuotes(normalizedString);
                    itemsChecked++;
                }

                qc.SecondaryCriteria       += ")";
                qc.SecondaryCriteriaDisplay = qc.ActiveLabel + " in list";
            }

            qc.SecondaryFilterType = FilterType.CheckBoxList;

            QueryManager.QueryResultsControl.UpdateFiltering(ColInfo);
            FilterBasicCriteriaControl.SyncBaseQuerySecondaryCriteria(qc);             // sync any base query

            return;
        }