Ejemplo n.º 1
0
        private async Task LoadData()
        {
            IsBusy = true;

            while (CurIteamId == 0)
            {
                await Task.Delay(1000);
            }

            if (CurIteamId == 0)
            {
                return;
            }

            var tradition = await _censusService.GetTradition(CurIteamId);

            if (tradition != null)
            {
                if (tradition.DoorheadPhotos.FirstOrDefault() != null)
                {
                    ThumbnailPhotoUrl = tradition.DoorheadPhotos.FirstOrDefault().StoragePath;
                }

                Tradition = tradition;
            }
            else
            {
                Tradition = new Tradition();
            }
            IsBusy = false;
        }
Ejemplo n.º 2
0
        public Task <RequestResult> AddTradition(Tradition tradition)
        {
            var builder = new UriBuilder(GlobalSettings.AuthenticationEndpoint);

            builder.Path = $"api/Census/AddTradition";
            var uri = builder.ToString();

            return(_requestProvider.PostAsync <Tradition, RequestResult>(uri, tradition));
        }
        public Tradition_Card_Page1ViewModel(INavigationService navigationService,
                                             ICensusService censusService,
                                             IImageEditor imageEditor,
                                             IMediaPickerService mediaPickerService,
                                             IDialogService dialogService) : base(navigationService, dialogService)
        {
            _navigationService  = navigationService;
            _dialogService      = dialogService;
            _censusService      = censusService;
            _mediaPickerService = mediaPickerService;
            _imageEditor        = imageEditor;


            //普查步骤
            var steps = new Dictionary <int, string> {
                { 0, "基础信息" }, { 1, "经营信息" }, { 2, "销售信息" }
            };

            Steps = steps;
            Step  = 1;
            Title = "添加传统终端普查-基础信息";

            GlobalSettings.EventDate = DateTime.Now;

            EndPointNumber_Tip    = "请定义终端编号";
            SaleRegion_Tip        = "请输入所在大区";
            SalesDepartment_Tip   = "请输入业务部";
            City_Tip              = "请确定你所在城市";
            DistrictOrCounty_Tip  = "请输入你所在区/县";
            CityOrTown_Tip        = "请输入城区/乡镇";
            EndPointStorsName_Tip = "请输入终端店名";
            EndPointTelphone_Tip  = "固话,填\"区号+号码\"(不加\"-\"),如0293248123";
            EndPointAddress_Tip   = "终端地址(详细街道/门牌号)";

            Tradition = new Tradition()
            {
                UserId    = Settings.UserId.ToString(),
                Latitude  = GlobalSettings.CurrtntCoordinate != null ? GlobalSettings.CurrtntCoordinate.Latitude : 0,
                Longitude = GlobalSettings.CurrtntCoordinate != null ? GlobalSettings.CurrtntCoordinate.Longitude : 0,
                Location  = GlobalSettings.CurrentAddComp != null ? GlobalSettings.CurrentAddComp.City : ""
            };

            BaseInfo = new TraditionBaseInfo()
            {
                EndPointNumber  = string.Format("{0}_{1}", "CT", CommonHelper.GetTimeStamp(DateTime.Now, 13)),
                SaleRegion      = Settings.SaleRegion,
                SalesDepartment = Settings.SalesDepartment
            };
        }
Ejemplo n.º 4
0
        // Rebuild the list of Spirits/Sprites based on the character's selected Tradition/Stream.
        public void RebuildSpiritList(Tradition objTradition)
        {
            if (objTradition == null)
            {
                return;
            }
            string strCurrentValue = cboSpiritName.SelectedValue?.ToString() ?? _objSpirit.Name;

            XmlDocument objXmlDocument = _objSpirit.EntityType == SpiritType.Spirit ? XmlManager.Load("traditions.xml") : XmlManager.Load("streams.xml");

            HashSet <string> lstLimitCategories = new HashSet <string>();

            foreach (Improvement improvement in _objSpirit.CharacterObject.Improvements.Where(x => x.ImproveType == Improvement.ImprovementType.LimitSpiritCategory && x.Enabled))
            {
                lstLimitCategories.Add(improvement.ImprovedName);
            }

            List <ListItem> lstCritters = new List <ListItem>();

            if (objTradition.IsCustomTradition)
            {
                string strSpiritCombat       = objTradition.SpiritCombat;
                string strSpiritDetection    = objTradition.SpiritDetection;
                string strSpiritHealth       = objTradition.SpiritHealth;
                string strSpiritIllusion     = objTradition.SpiritIllusion;
                string strSpiritManipulation = objTradition.SpiritManipulation;

                if ((lstLimitCategories.Count == 0 || lstLimitCategories.Contains(strSpiritCombat)) && !string.IsNullOrWhiteSpace(strSpiritCombat))
                {
                    XmlNode objXmlCritterNode = objXmlDocument.SelectSingleNode("/chummer/spirits/spirit[name = \"" + strSpiritCombat + "\"]");
                    lstCritters.Add(new ListItem(strSpiritCombat, objXmlCritterNode?["translate"]?.InnerText ?? strSpiritCombat));
                }

                if ((lstLimitCategories.Count == 0 || lstLimitCategories.Contains(strSpiritDetection)) && !string.IsNullOrWhiteSpace(strSpiritDetection))
                {
                    XmlNode objXmlCritterNode = objXmlDocument.SelectSingleNode("/chummer/spirits/spirit[name = \"" + strSpiritDetection + "\"]");
                    lstCritters.Add(new ListItem(strSpiritDetection, objXmlCritterNode?["translate"]?.InnerText ?? strSpiritDetection));
                }

                if ((lstLimitCategories.Count == 0 || lstLimitCategories.Contains(strSpiritHealth)) && !string.IsNullOrWhiteSpace(strSpiritHealth))
                {
                    XmlNode objXmlCritterNode = objXmlDocument.SelectSingleNode("/chummer/spirits/spirit[name = \"" + strSpiritHealth + "\"]");
                    lstCritters.Add(new ListItem(strSpiritHealth, objXmlCritterNode?["translate"]?.InnerText ?? strSpiritHealth));
                }

                if ((lstLimitCategories.Count == 0 || lstLimitCategories.Contains(strSpiritIllusion)) && !string.IsNullOrWhiteSpace(strSpiritIllusion))
                {
                    XmlNode objXmlCritterNode = objXmlDocument.SelectSingleNode("/chummer/spirits/spirit[name = \"" + strSpiritIllusion + "\"]");
                    lstCritters.Add(new ListItem(strSpiritIllusion, objXmlCritterNode?["translate"]?.InnerText ?? strSpiritIllusion));
                }

                if ((lstLimitCategories.Count == 0 || lstLimitCategories.Contains(strSpiritManipulation)) && !string.IsNullOrWhiteSpace(strSpiritManipulation))
                {
                    XmlNode objXmlCritterNode = objXmlDocument.SelectSingleNode("/chummer/spirits/spirit[name = \"" + strSpiritManipulation + "\"]");
                    lstCritters.Add(new ListItem(strSpiritManipulation, objXmlCritterNode?["translate"]?.InnerText ?? strSpiritManipulation));
                }
            }
            else
            {
                if (objTradition.GetNode()?.SelectSingleNode("spirits/spirit[. = \"All\"]") != null)
                {
                    if (lstLimitCategories.Count == 0)
                    {
                        using (XmlNodeList xmlSpiritList = objXmlDocument.SelectNodes("/chummer/spirits/spirit"))
                            if (xmlSpiritList != null)
                            {
                                foreach (XmlNode objXmlCritterNode in xmlSpiritList)
                                {
                                    string strSpiritName = objXmlCritterNode["name"]?.InnerText;
                                    lstCritters.Add(new ListItem(strSpiritName, objXmlCritterNode["translate"]?.InnerText ?? strSpiritName));
                                }
                            }
                    }
                    else
                    {
                        foreach (string strSpiritName in lstLimitCategories)
                        {
                            XmlNode objXmlCritterNode = objXmlDocument.SelectSingleNode("/chummer/spirits/spirit[name = \"" + strSpiritName + "\"]");
                            lstCritters.Add(new ListItem(strSpiritName, objXmlCritterNode?["translate"]?.InnerText ?? strSpiritName));
                        }
                    }
                }
                else
                {
                    using (XmlNodeList xmlSpiritList = objTradition.GetNode()?.SelectSingleNode("spirits")?.ChildNodes)
                        if (xmlSpiritList != null)
                        {
                            foreach (XmlNode objXmlSpirit in xmlSpiritList)
                            {
                                string strSpiritName = objXmlSpirit.InnerText;
                                if (lstLimitCategories.Count == 0 || lstLimitCategories.Contains(strSpiritName))
                                {
                                    XmlNode objXmlCritterNode = objXmlDocument.SelectSingleNode("/chummer/spirits/spirit[name = \"" + strSpiritName + "\"]");
                                    lstCritters.Add(new ListItem(strSpiritName, objXmlCritterNode?["translate"]?.InnerText ?? strSpiritName));
                                }
                            }
                        }
                }
            }

            if (_objSpirit.CharacterObject.RESEnabled)
            {
                // Add any additional Sprites the character has Access to through improvements.
                lstCritters.AddRange(from objImprovement in _objSpirit.CharacterObject.Improvements
                                     .Where(imp => imp.ImproveType == Improvement.ImprovementType.AddSprite && imp.Enabled)
                                     let objXmlCritterNode = objXmlDocument.SelectSingleNode("/chummer/spirits/spirit[name = \"" + objImprovement.ImprovedName + "\"]")
                                                             select new ListItem(objImprovement.ImprovedName, objXmlCritterNode?["translate"]?.InnerText ?? objImprovement.ImprovedName));
            }
            if (_objSpirit.CharacterObject.MAGEnabled)
            {
                // Add any additional Spirits the character has Access to through improvements.
                lstCritters.AddRange(from objImprovement in _objSpirit.CharacterObject.Improvements
                                     .Where(imp => imp.ImproveType == Improvement.ImprovementType.AddSpirit && imp.Enabled)
                                     let objXmlCritterNode = objXmlDocument.SelectSingleNode("/chummer/spirits/spirit[name = \"" + objImprovement.ImprovedName + "\"]")
                                                             select new ListItem(objImprovement.ImprovedName, objXmlCritterNode?["translate"]?.InnerText ?? objImprovement.ImprovedName));
            }

            cboSpiritName.BeginUpdate();
            cboSpiritName.DisplayMember = "Name";
            cboSpiritName.ValueMember   = "Value";
            cboSpiritName.DataSource    = lstCritters;

            // Set the control back to its original value.
            cboSpiritName.SelectedValue = strCurrentValue;
            cboSpiritName.EndUpdate();
        }
Ejemplo n.º 5
0
        // Rebuild the list of Spirits/Sprites based on the character's selected Tradition/Stream.
        public void RebuildSpiritList(Tradition objTradition)
        {
            if (objTradition == null)
            {
                return;
            }
            string strCurrentValue = cboSpiritName.SelectedValue?.ToString() ?? _objSpirit.Name;

            XPathNavigator objXmlDocument = _objSpirit.CharacterObject.LoadDataXPath(_objSpirit.EntityType == SpiritType.Spirit
                    ? "traditions.xml"
                    : "streams.xml");

            HashSet <string> lstLimitCategories = new HashSet <string>();

            foreach (Improvement objImprovement in _objSpirit.CharacterObject.Improvements)
            {
                if (objImprovement.ImproveType == Improvement.ImprovementType.LimitSpiritCategory && objImprovement.Enabled)
                {
                    lstLimitCategories.Add(objImprovement.ImprovedName);
                }
            }

            List <ListItem> lstCritters = new List <ListItem>(30);

            if (objTradition.IsCustomTradition)
            {
                string strSpiritCombat       = objTradition.SpiritCombat;
                string strSpiritDetection    = objTradition.SpiritDetection;
                string strSpiritHealth       = objTradition.SpiritHealth;
                string strSpiritIllusion     = objTradition.SpiritIllusion;
                string strSpiritManipulation = objTradition.SpiritManipulation;

                if ((lstLimitCategories.Count == 0 || lstLimitCategories.Contains(strSpiritCombat)) && !string.IsNullOrWhiteSpace(strSpiritCombat))
                {
                    XPathNavigator objXmlCritterNode = objXmlDocument.SelectSingleNode("/chummer/spirits/spirit[name = " + strSpiritCombat.CleanXPath() + "]");
                    lstCritters.Add(new ListItem(strSpiritCombat, objXmlCritterNode?.SelectSingleNode("translate")?.Value ?? strSpiritCombat));
                }

                if ((lstLimitCategories.Count == 0 || lstLimitCategories.Contains(strSpiritDetection)) && !string.IsNullOrWhiteSpace(strSpiritDetection))
                {
                    XPathNavigator objXmlCritterNode = objXmlDocument.SelectSingleNode("/chummer/spirits/spirit[name = " + strSpiritDetection.CleanXPath() + "]");
                    lstCritters.Add(new ListItem(strSpiritDetection, objXmlCritterNode?.SelectSingleNode("translate")?.Value ?? strSpiritDetection));
                }

                if ((lstLimitCategories.Count == 0 || lstLimitCategories.Contains(strSpiritHealth)) && !string.IsNullOrWhiteSpace(strSpiritHealth))
                {
                    XPathNavigator objXmlCritterNode = objXmlDocument.SelectSingleNode("/chummer/spirits/spirit[name = " + strSpiritHealth.CleanXPath() + "]");
                    lstCritters.Add(new ListItem(strSpiritHealth, objXmlCritterNode?.SelectSingleNode("translate")?.Value ?? strSpiritHealth));
                }

                if ((lstLimitCategories.Count == 0 || lstLimitCategories.Contains(strSpiritIllusion)) && !string.IsNullOrWhiteSpace(strSpiritIllusion))
                {
                    XPathNavigator objXmlCritterNode = objXmlDocument.SelectSingleNode("/chummer/spirits/spirit[name = " + strSpiritIllusion.CleanXPath() + "]");
                    lstCritters.Add(new ListItem(strSpiritIllusion, objXmlCritterNode?.SelectSingleNode("translate")?.Value ?? strSpiritIllusion));
                }

                if ((lstLimitCategories.Count == 0 || lstLimitCategories.Contains(strSpiritManipulation)) && !string.IsNullOrWhiteSpace(strSpiritManipulation))
                {
                    XPathNavigator objXmlCritterNode = objXmlDocument.SelectSingleNode("/chummer/spirits/spirit[name = " + strSpiritManipulation.CleanXPath() + "]");
                    lstCritters.Add(new ListItem(strSpiritManipulation, objXmlCritterNode?.SelectSingleNode("translate")?.Value ?? strSpiritManipulation));
                }
            }
            else
            {
                if (objTradition.GetNode()?.SelectSingleNode("spirits/spirit[. = \"All\"]") != null)
                {
                    if (lstLimitCategories.Count == 0)
                    {
                        foreach (XmlNode objXmlCritterNode in objXmlDocument.Select("/chummer/spirits/spirit"))
                        {
                            string strSpiritName = objXmlCritterNode["name"]?.InnerText;
                            lstCritters.Add(new ListItem(strSpiritName, objXmlCritterNode["translate"]?.InnerText ?? strSpiritName));
                        }
                    }
                    else
                    {
                        foreach (string strSpiritName in lstLimitCategories)
                        {
                            XPathNavigator objXmlCritterNode = objXmlDocument.SelectSingleNode("/chummer/spirits/spirit[name = " + strSpiritName.CleanXPath() + "]");
                            lstCritters.Add(new ListItem(strSpiritName, objXmlCritterNode?.SelectSingleNode("translate")?.Value ?? strSpiritName));
                        }
                    }
                }
                else
                {
                    using (XmlNodeList xmlSpiritList = objTradition.GetNode()?.SelectSingleNode("spirits")?.ChildNodes)
                    {
                        if (xmlSpiritList != null)
                        {
                            foreach (XmlNode objXmlSpirit in xmlSpiritList)
                            {
                                string strSpiritName = objXmlSpirit.InnerText;
                                if (lstLimitCategories.Count == 0 || lstLimitCategories.Contains(strSpiritName))
                                {
                                    XPathNavigator objXmlCritterNode = objXmlDocument.SelectSingleNode("/chummer/spirits/spirit[name = " + strSpiritName.CleanXPath() + "]");
                                    lstCritters.Add(new ListItem(strSpiritName, objXmlCritterNode?.SelectSingleNode("translate")?.Value ?? strSpiritName));
                                }
                            }
                        }
                    }
                }
            }

            if (_objSpirit.CharacterObject.MAGEnabled || _objSpirit.CharacterObject.RESEnabled)
            {
                // Add any additional Spirits and Sprites the character has Access to through improvements.
                foreach (Improvement objImprovement in _objSpirit.CharacterObject.Improvements)
                {
                    if (((objImprovement.ImproveType == Improvement.ImprovementType.AddSpirit && _objSpirit.CharacterObject.MAGEnabled) ||
                         (objImprovement.ImproveType == Improvement.ImprovementType.AddSprite && _objSpirit.CharacterObject.RESEnabled)) &&
                        !string.IsNullOrEmpty(objImprovement.ImprovedName) && objImprovement.Enabled)
                    {
                        lstCritters.Add(new ListItem(objImprovement.ImprovedName,
                                                     objXmlDocument.SelectSingleNode("/chummer/spirits/spirit[name = " + objImprovement.ImprovedName.CleanXPath() + "]/translate")?.Value
                                                     ?? objImprovement.ImprovedName));
                    }
                }
            }

            cboSpiritName.BeginUpdate();
            cboSpiritName.DataSource    = null;
            cboSpiritName.DataSource    = lstCritters;
            cboSpiritName.DisplayMember = nameof(ListItem.Name);
            cboSpiritName.ValueMember   = nameof(ListItem.Value);

            // Set the control back to its original value.
            cboSpiritName.SelectedValue = strCurrentValue;
            cboSpiritName.EndUpdate();
        }
Ejemplo n.º 6
0
        private Control GetUserInputControl(SearchTag stag)
        {
            string          switchname = stag.TagName;
            string          typename   = stag.MyRuntimePropertyValue.GetType().ToString();
            FlowLayoutPanel flp        = new FlowLayoutPanel();
            TextBox         tb;
            Button          b;
            NumericUpDown   nud;
            ComboBox        cb;

            switch (typename)
            {
            case "System.Boolean":
            {
                RadioButtonListItem itrue = new RadioButtonListItem
                {
                    Text = bool.TrueString
                };
                RadioButtonListItem ifalse = new RadioButtonListItem
                {
                    Text = bool.FalseString
                };
                RadioButtonList rdb = new RadioButtonList
                {
                    Text = stag.TagName
                };
                rdb.Items.Add(itrue);
                rdb.Items.Add(ifalse);
                rdb.SelectedIndexChanged += (sender, e) =>
                {
                    PropertyInfo info = stag.MyPropertyInfo;
                    info.SetValue(stag.MyParentTag.MyRuntimePropertyValue, itrue.Checked);
                    MySetTags.Add(stag);
                    UpdateDialog();
                };
                return(rdb);
            }

            case "System.String":
            {
                tb = new TextBox();
                flp.Controls.Add(tb);
                b = new Button
                {
                    Text = "OK"
                };
                b.Click += (sender, e) =>
                {
                    PropertyInfo info = stag.MyPropertyInfo;
                    info.SetValue(stag.MyParentTag.MyRuntimePropertyValue, tb.Text);
                    MySetTags.Add(stag);
                    UpdateDialog();
                };
                flp.Controls.Add(b);
                return(flp);
            }

            case "System.Int32":
            {
                nud = new NumericUpDown
                {
                    Minimum = int.MinValue,
                    Maximum = int.MaxValue
                };
                flp.Controls.Add(nud);
                b = new Button
                {
                    Text = "OK"
                };
                b.Click += (sender, e) =>
                {
                    PropertyInfo info = stag.MyPropertyInfo;
                    info.SetValue(stag.MyParentTag.MyRuntimePropertyValue, (int)nud.Value);
                    MySetTags.Add(stag);
                    UpdateDialog();
                };
                flp.Controls.Add(b);
                return(flp);
            }

            case "Chummer.Backend.Uniques.Tradition":
            {
                var traditions = Tradition.GetTraditions(MySearchCharacter.MyCharacter);
                cb = new ComboBox
                {
                    DataSource    = traditions,
                    DropDownStyle = ComboBoxStyle.DropDownList,
                    FlatStyle     = FlatStyle.Standard,
                    DisplayMember = "Name"
                };
                cb.SelectedValueChanged += (sender, e) =>
                {
                    if (_loading)
                    {
                        return;
                    }
                    PropertyInfo info = stag.MyPropertyInfo;
                    info.SetValue(stag.MyParentTag.MyRuntimePropertyValue, cb.SelectedValue);
                    stag.TagValue = (cb.SelectedValue as Tradition)?.Name ?? string.Empty;
                    MySetTags.Add(stag);
                    UpdateDialog();
                };
                flp.Controls.Add(cb);
                return(flp);
            }
            }
            object obj = stag.MyRuntimePropertyValue;

            if (!(obj is string))
            {
                if (obj is IList)
                {
                    Type listtype = StaticUtils.GetListType(obj);
                    if (listtype != null)
                    {
                        switchname = listtype.Name;
                    }
                }
            }

            switch (switchname)
            {
            //these are sample implementations to get added one by one...
            case "Spell":
            {
                Button button = new Button
                {
                    Text = "select Spell"
                };
                button.Click += (sender, e) =>
                {
                    var frmPickSpell = new frmSelectSpell(MySearchCharacter.MyCharacter);
                    frmPickSpell.ShowDialog(Program.MainForm);
                    // Open the Spells XML file and locate the selected piece.
                    XmlDocument objXmlDocument = MySearchCharacter.MyCharacter.LoadData("spells.xml");
                    XmlNode     objXmlSpell    = objXmlDocument.SelectSingleNode("/chummer/spells/spell[id = \"" + frmPickSpell.SelectedSpell + "\"]");
                    Spell       objSpell       = new Spell(MySearchCharacter.MyCharacter);
                    if (string.IsNullOrEmpty(objSpell.Name))
                    {
                        return;
                    }
                    objSpell.Create(objXmlSpell, string.Empty, frmPickSpell.Limited, frmPickSpell.Extended, frmPickSpell.Alchemical);
                    MySearchCharacter.MyCharacter.Spells.Add(objSpell);
                    SearchTag spellsearch = new SearchTag(stag.MyPropertyInfo, stag.MyRuntimeHubClassTag)
                    {
                        MyRuntimePropertyValue = objSpell,
                        MyParentTag            = stag,
                        TagName        = objSpell.Name,
                        TagValue       = string.Empty,
                        SearchOperator = "exists"
                    };
                    MySetTags.Add(spellsearch);
                    UpdateDialog();
                };
                return(button);
            }

            case "Quality":
            {
                Button button = new Button
                {
                    Text = "select Quality"
                };
                button.Click += ((sender, e) =>
                    {
                        var frmPick = new frmSelectQuality(MySearchCharacter.MyCharacter);
                        frmPick.ShowDialog(Program.MainForm);
                        // Open the Spells XML file and locate the selected piece.
                        XmlDocument objXmlDocument = MySearchCharacter.MyCharacter.LoadData("qualities.xml");
                        XmlNode objXmlNode = objXmlDocument.SelectSingleNode("/chummer/qualities/quality[id = \"" + frmPick.SelectedQuality + "\"]");
                        Quality objQuality = new Quality(MySearchCharacter.MyCharacter);
                        List <Weapon> lstWeapons = new List <Weapon>();
                        objQuality.Create(objXmlNode, QualitySource.Selected, lstWeapons);
                        MySearchCharacter.MyCharacter.Qualities.Add(objQuality);
                        SearchTag newtag = new SearchTag(stag.MyPropertyInfo, stag.MyRuntimeHubClassTag)
                        {
                            MyRuntimePropertyValue = objQuality,
                            MyParentTag = stag,
                            TagName = objQuality.Name,
                            TagValue = string.Empty,
                            SearchOperator = "exists"
                        };
                        MySetTags.Add(newtag);
                        UpdateDialog();
                    });
                return(button);
            }
            }
            return(null);
        }
Ejemplo n.º 7
0
        // Rebuild the list of Spirits/Sprites based on the character's selected Tradition/Stream.
        public void RebuildSpiritList(Tradition objTradition)
        {
            if (objTradition == null)
            {
                return;
            }
            string strCurrentValue = cboSpiritName.SelectedValue?.ToString() ?? _objSpirit.Name;

            XPathNavigator objXmlDocument = _objSpirit.CharacterObject.LoadDataXPath(_objSpirit.EntityType == SpiritType.Spirit
                    ? "traditions.xml"
                    : "streams.xml");

            using (new FetchSafelyFromPool <HashSet <string> >(Utils.StringHashSetPool,
                                                               out HashSet <string> setLimitCategories))
            {
                foreach (Improvement objImprovement in ImprovementManager.GetCachedImprovementListForValueOf(
                             _objSpirit.CharacterObject, Improvement.ImprovementType.LimitSpiritCategory))
                {
                    setLimitCategories.Add(objImprovement.ImprovedName);
                }

                using (new FetchSafelyFromPool <List <ListItem> >(Utils.ListItemListPool, out List <ListItem> lstCritters))
                {
                    if (objTradition.IsCustomTradition)
                    {
                        string strSpiritCombat       = objTradition.SpiritCombat;
                        string strSpiritDetection    = objTradition.SpiritDetection;
                        string strSpiritHealth       = objTradition.SpiritHealth;
                        string strSpiritIllusion     = objTradition.SpiritIllusion;
                        string strSpiritManipulation = objTradition.SpiritManipulation;

                        if ((setLimitCategories.Count == 0 || setLimitCategories.Contains(strSpiritCombat)) &&
                            !string.IsNullOrWhiteSpace(strSpiritCombat))
                        {
                            XPathNavigator objXmlCritterNode
                                = objXmlDocument.SelectSingleNode(
                                      "/chummer/spirits/spirit[name = " + strSpiritCombat.CleanXPath() + ']');
                            lstCritters.Add(new ListItem(strSpiritCombat,
                                                         objXmlCritterNode
                                                         ?.SelectSingleNodeAndCacheExpression("translate")
                                                         ?.Value ?? strSpiritCombat));
                        }

                        if ((setLimitCategories.Count == 0 || setLimitCategories.Contains(strSpiritDetection)) &&
                            !string.IsNullOrWhiteSpace(strSpiritDetection))
                        {
                            XPathNavigator objXmlCritterNode
                                = objXmlDocument.SelectSingleNode(
                                      "/chummer/spirits/spirit[name = " + strSpiritDetection.CleanXPath() + ']');
                            lstCritters.Add(new ListItem(strSpiritDetection,
                                                         objXmlCritterNode
                                                         ?.SelectSingleNodeAndCacheExpression("translate")
                                                         ?.Value ?? strSpiritDetection));
                        }

                        if ((setLimitCategories.Count == 0 || setLimitCategories.Contains(strSpiritHealth)) &&
                            !string.IsNullOrWhiteSpace(strSpiritHealth))
                        {
                            XPathNavigator objXmlCritterNode
                                = objXmlDocument.SelectSingleNode(
                                      "/chummer/spirits/spirit[name = " + strSpiritHealth.CleanXPath() + ']');
                            lstCritters.Add(new ListItem(strSpiritHealth,
                                                         objXmlCritterNode
                                                         ?.SelectSingleNodeAndCacheExpression("translate")
                                                         ?.Value ?? strSpiritHealth));
                        }

                        if ((setLimitCategories.Count == 0 || setLimitCategories.Contains(strSpiritIllusion)) &&
                            !string.IsNullOrWhiteSpace(strSpiritIllusion))
                        {
                            XPathNavigator objXmlCritterNode
                                = objXmlDocument.SelectSingleNode(
                                      "/chummer/spirits/spirit[name = " + strSpiritIllusion.CleanXPath() + ']');
                            lstCritters.Add(new ListItem(strSpiritIllusion,
                                                         objXmlCritterNode
                                                         ?.SelectSingleNodeAndCacheExpression("translate")
                                                         ?.Value ?? strSpiritIllusion));
                        }

                        if ((setLimitCategories.Count == 0 || setLimitCategories.Contains(strSpiritManipulation)) &&
                            !string.IsNullOrWhiteSpace(strSpiritManipulation))
                        {
                            XPathNavigator objXmlCritterNode
                                = objXmlDocument.SelectSingleNode(
                                      "/chummer/spirits/spirit[name = " + strSpiritManipulation.CleanXPath() + ']');
                            lstCritters.Add(new ListItem(strSpiritManipulation,
                                                         objXmlCritterNode
                                                         ?.SelectSingleNodeAndCacheExpression("translate")
                                                         ?.Value ?? strSpiritManipulation));
                        }
                    }
                    else
                    {
                        if (objTradition.GetNodeXPath()?.SelectSingleNode("spirits/spirit[. = \"All\"]") != null)
                        {
                            if (setLimitCategories.Count == 0)
                            {
                                foreach (XPathNavigator objXmlCritterNode in objXmlDocument.SelectAndCacheExpression(
                                             "/chummer/spirits/spirit"))
                                {
                                    string strSpiritName = objXmlCritterNode.SelectSingleNodeAndCacheExpression("name")
                                                           ?.Value;
                                    lstCritters.Add(new ListItem(strSpiritName,
                                                                 objXmlCritterNode
                                                                 .SelectSingleNodeAndCacheExpression("translate")
                                                                 ?.Value
                                                                 ?? strSpiritName));
                                }
                            }
                            else
                            {
                                foreach (string strSpiritName in setLimitCategories)
                                {
                                    XPathNavigator objXmlCritterNode
                                        = objXmlDocument.SelectSingleNode(
                                              "/chummer/spirits/spirit[name = " + strSpiritName.CleanXPath() + ']');
                                    lstCritters.Add(new ListItem(strSpiritName,
                                                                 objXmlCritterNode
                                                                 ?.SelectSingleNodeAndCacheExpression("translate")
                                                                 ?.Value ?? strSpiritName));
                                }
                            }
                        }
                        else
                        {
                            XPathNodeIterator xmlSpiritList = objTradition.GetNodeXPath()?.Select("spirits/*");
                            if (xmlSpiritList != null)
                            {
                                foreach (XPathNavigator objXmlSpirit in xmlSpiritList)
                                {
                                    string strSpiritName = objXmlSpirit.Value;
                                    if (setLimitCategories.Count == 0 || setLimitCategories.Contains(strSpiritName))
                                    {
                                        XPathNavigator objXmlCritterNode
                                            = objXmlDocument.SelectSingleNode(
                                                  "/chummer/spirits/spirit[name = " + strSpiritName.CleanXPath()
                                                  + ']');
                                        lstCritters.Add(new ListItem(strSpiritName,
                                                                     objXmlCritterNode
                                                                     ?.SelectSingleNodeAndCacheExpression(
                                                                         "translate")?.Value ?? strSpiritName));
                                    }
                                }
                            }
                        }
                    }

                    // Add any additional Spirits and Sprites the character has Access to through improvements.

                    if (_objSpirit.CharacterObject.MAGEnabled)
                    {
                        foreach (Improvement objImprovement in ImprovementManager.GetCachedImprovementListForValueOf(
                                     _objSpirit.CharacterObject, Improvement.ImprovementType.AddSpirit))
                        {
                            string strImprovedName = objImprovement.ImprovedName;
                            if (!string.IsNullOrEmpty(strImprovedName))
                            {
                                lstCritters.Add(new ListItem(strImprovedName,
                                                             objXmlDocument
                                                             .SelectSingleNode(
                                                                 "/chummer/spirits/spirit[name = "
                                                                 + strImprovedName.CleanXPath() + "]/translate")
                                                             ?.Value
                                                             ?? strImprovedName));
                            }
                        }
                    }

                    if (_objSpirit.CharacterObject.RESEnabled)
                    {
                        foreach (Improvement objImprovement in ImprovementManager.GetCachedImprovementListForValueOf(
                                     _objSpirit.CharacterObject, Improvement.ImprovementType.AddSprite))
                        {
                            string strImprovedName = objImprovement.ImprovedName;
                            if (!string.IsNullOrEmpty(strImprovedName))
                            {
                                lstCritters.Add(new ListItem(strImprovedName,
                                                             objXmlDocument
                                                             .SelectSingleNode(
                                                                 "/chummer/spirits/spirit[name = "
                                                                 + strImprovedName.CleanXPath() + "]/translate")
                                                             ?.Value
                                                             ?? strImprovedName));
                            }
                        }
                    }

                    cboSpiritName.BeginUpdate();
                    cboSpiritName.PopulateWithListItems(lstCritters);
                    // Set the control back to its original value.
                    cboSpiritName.SelectedValue = strCurrentValue;
                    cboSpiritName.EndUpdate();
                }
            }
        }