public void RefreshListBox() { //vars = new ObservableCollection<CommonEventRef>(MainViewModel.MainViewModelStatic.CommonEvents.Where(a => a.Name.ToLower().Contains(searchText.Text.ToLower())).Select(a => new CommonEventRef(a.Id))); vars = new ObservableCollection <Tuple <string, ObservableCollection <GenericRef <StatusEffect> > > >(); foreach (var a in MainViewModel.MainViewModelStatic.StatusEffectGroups.Groups) { bool included = false; ObservableCollection <GenericRef <StatusEffect> > StatusEffects = new ObservableCollection <GenericRef <StatusEffect> >(); foreach (var b in a.Item2) { if (b.Name.ToLower().Contains(searchText.Text.ToLower()) && (Overrides == null || Overrides.Where(c => c.Ref == b.Id).Count() > 0)) { included = true; var statusEffect = GenericRef <StatusEffect> .GetStatusEffectRef(); statusEffect.Ref = b.Id; StatusEffects.Add(statusEffect); } } if (included) { vars.Add(Tuple.Create <string, ObservableCollection <GenericRef <StatusEffect> > >(a.Item1, StatusEffects)); } } this.treeItems.ItemsSource = vars; //vars[0].Item2[0].LinkedCommonEvent.Name ExpandAll(treeItems, true); //this.lstItems.ItemsSource = vars; //if (SelectedItem != null && lstItems.Items.Contains(SelectedItem)) //{ // lstItems.SelectedItem = SelectedItem; //} }
public static StatusEffectWrapper FromXML(XElement xml, Game g) { var seRef = GenericRef <StatusEffect> .GetStatusEffectRef(); seRef.Ref = Guid.Parse(xml.Element("LinkedStatusEffect").Value); StatusEffectWrapper wrapper = new StatusEffectWrapper(seRef, g); foreach (var tempVariableXml in xml.Element("TempVariables").Elements()) { var tempVariable = VariableWrapper.FromXML(tempVariableXml, g, g.VarById[Guid.Parse(tempVariableXml.Element("Id").Value)].VariableBase); foreach (var a in wrapper.TempVariables) { if (a.VariableBase.Id == tempVariable.VariableBase.Id) { a.CurrentCommonEventValue = tempVariable.CurrentCommonEventValue; a.CurrentDateTimeValue = tempVariable.CurrentDateTimeValue; a.CurrentItemValue = tempVariable.CurrentItemValue; a.CurrentNumberValue = tempVariable.CurrentNumberValue; a.CurrentStringValue = tempVariable.CurrentStringValue; } } } foreach (var a in xml.Element("Arguments").Elements("Argument")) { Guid id = Guid.Parse(a.Element("Id").Value); if (a.Element("Type").Value == "number") { wrapper.numberArguments.Add(new ScriptStatusEffectArgumentValue { IsNumber = true, Id = id, NumberValue = Convert.ToInt32(a.Element("Value").Value) }); } else { wrapper.stringArguments.Add(new ScriptStatusEffectArgumentValue { IsString = true, Id = id, StringValue = a.Element("Value").Value }); } } return(wrapper); }