Exemple #1
0
        private void ByPropertySelectionChanged(object sender, RoutedPropertyChangedEventArgs <object> e)
        {
            if (lbItems == null)
            {
                return;
            }
            lbItems.Items.Clear();
            TreeViewItem selected = tvByProperty.SelectedItem as TreeViewItem;

            if (selected?.Tag == null)
            {
                return;
            }
            DDOItemProperty ip = selected.Tag as DDOItemProperty;

            if (selected.HasItems)
            {
                PopulateItemListForProperty(ip, SlotType.None);
            }
            else
            {
                string type = selected.Header.ToString();
                type = type.Substring(0, type.IndexOf(" ("));

                foreach (var item in ip.Items)
                {
                    ListBoxItem lbi = new ListBoxItem();
                    TextBlock   tb  = new TextBlock();
                    lbi.Content = tb;
                    lbi.Tag     = item;
                    tb.Inlines.Add(new Run {
                        Text = item.Name, FontWeight = FontWeights.Bold
                    });
                    tb.Inlines.Add(" (" + item.Slot + ") (");
                    bool first = true;
                    foreach (var p in item.Properties)
                    {
                        if (p.Options != null && !p.HideOptions)
                        {
                            foreach (var op in p.Options)
                            {
                                if (op.Property == ip.Property && (op.Type == type || (type == "untyped" && string.IsNullOrWhiteSpace(op.Type))))
                                {
                                    if (first)
                                    {
                                        first = false;
                                    }
                                    else
                                    {
                                        tb.Inlines.Add(", ");
                                    }
                                    tb.Inlines.Add(string.IsNullOrWhiteSpace(op.Type) ? "untyped" : op.Type);
                                    tb.Inlines.Add(" " + op.Value);
                                }
                            }
                        }
                        else if (p.Property == ip.Property && (p.Type == type || (type == "untyped" && string.IsNullOrWhiteSpace(p.Type))))
                        {
                            if (first)
                            {
                                first = false;
                            }
                            else
                            {
                                tb.Inlines.Add(", ");
                            }
                            tb.Inlines.Add(string.IsNullOrWhiteSpace(p.Type) ? "untyped" : p.Type);
                            tb.Inlines.Add(" " + p.Value);
                        }
                    }
                    if (!first)
                    {
                        tb.Inlines.Add(")");
                        lbItems.Items.Add(lbi);
                    }
                }
            }
        }
Exemple #2
0
        void PopulateItemListForProperty(DDOItemProperty ip, SlotType slot)
        {
            foreach (var item in ip.Items)
            {
                if (!QuestSourceManager.IsItemAllowed(item))
                {
                    continue;
                }
                if (slot != SlotType.None && item.Slot != slot)
                {
                    continue;
                }

                ListBoxItem lbi = new ListBoxItem();
                TextBlock   tb  = new TextBlock();
                lbi.Content = tb;
                lbi.Tag     = item;
                tb.Inlines.Add(new Run {
                    Text = item.Name, FontWeight = FontWeights.Bold
                });
                tb.Inlines.Add(" (" + item.Slot + ") (");
                bool first = true;
                foreach (var p in item.Properties)
                {
                    if (p.Options != null && !p.HideOptions)
                    {
                        foreach (var op in p.Options)
                        {
                            if (op.Property == ip.Property)
                            {
                                if (first)
                                {
                                    first = false;
                                }
                                else
                                {
                                    tb.Inlines.Add(", ");
                                }
                                tb.Inlines.Add(string.IsNullOrWhiteSpace(op.Type) ? "untyped" : op.Type);
                                tb.Inlines.Add(" " + op.Value);
                            }
                        }
                    }
                    else if (p.Property == ip.Property)
                    {
                        if (first)
                        {
                            first = false;
                        }
                        else
                        {
                            tb.Inlines.Add(", ");
                        }
                        tb.Inlines.Add(string.IsNullOrWhiteSpace(p.Type) ? "untyped" : p.Type);
                        tb.Inlines.Add(" " + p.Value);
                    }
                }
                tb.Inlines.Add(")");
                lbItems.Items.Add(lbi);
            }
        }