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 GetArgument(StatusEffect se) { this.CurrentStatusEffect = se; SelectedArgument = new GenericRef <StatusEffectValue>((id) => { if (CurrentStatusEffect == null) { return(null); } else { var found = CurrentStatusEffect.Arguments.Where(a => a.Id == id); if (found.Count() == 0) { return(null); } else { return(found.First()); } } }, sev => { if (sev == null) { return(Guid.Empty); } else { return(sev.Id); } }); }
private void treeItems_SelectedItemChanged_1(object sender, RoutedPropertyChangedEventArgs <object> e) { if (treeItems.SelectedItem as GenericRef <VarArray> != null) { SelectedItem = treeItems.SelectedItem as GenericRef <VarArray>; } }
public StatusEffectWrapper(GenericRef <StatusEffect> se, Game g) { LinkedEffect = se; TempVariables = new List <VariableWrapper>(); foreach (var tempVar in g.VarByName.Where(a => a.Value.VariableBase.Name.StartsWith("_"))) { TempVariables.Add(new VariableWrapper(tempVar.Value.VariableBase)); } }
public static StartConversation FromXML(XElement element) { var startConversation = new StartConversation() { ConversationID = GenericRef <Conversation> .GetConversationRef() }; startConversation.ConversationID.Ref = Guid.Parse(element.Value); return(startConversation); }
public static GetAllItems FromXML(XElement xml) { var gal = new GetAllItems() { ArrayRef = GenericRef <VarArray> .GetArrayRef() }; gal.ArrayRef.Ref = Guid.Parse(xml.Value); return(gal); }
public static AddToArray FromXML(XElement xml) { var ata = new AddToArray { VarRef = new VarRef(Guid.Parse(xml.Element("VarRef").Value)), ArrayRef = GenericRef <AddToArray> .GetArrayRef() }; ata.ArrayRef.Ref = Guid.Parse(xml.Element("ArrayRef").Value); return(ata); }
public static GetAllItemsOfType FromXML(XElement xml) { GetAllItemsOfType galot = new GetAllItemsOfType { ArrayRef = GenericRef <VarArray> .GetArrayRef() }; galot.ArrayRef.Ref = Guid.Parse(xml.Element("ArrayRef").Value); galot.ItemType = new ItemRef(Guid.Parse(xml.Element("ItemType").Value)); return(galot); }
public static ForEachInArray FromXML(XElement xml, Script baseScript) { var res = new ForEachInArray(baseScript) { LinkedArray = GenericRef <VarArray> .GetArrayRef(), LinkedVar = new VarRef(Guid.Parse(xml.Element("LinkedVar").Value)), ExecutingScript = Script.FromXML(xml.Element("ExecutingScript").Element("Script"), baseScript), ClearArray = Boolean.Parse(xml.Element("ClearArray").Value) }; res.LinkedArray.Ref = Guid.Parse(xml.Element("LinkedArray").Value); return(res); }
public static ConcatenateArray FromXML(XElement xml) { var ata = new ConcatenateArray { VarRef = new VarRef(Guid.Parse(xml.Element("VarRef").Value)), ArrayRef = GenericRef <AddToArray> .GetArrayRef(), Delimiter = xml.Element("Delimiter").Value, FinalWord = xml.Element("FinalWord") != null?xml.Element("FinalWord").Value : "" }; ata.ArrayRef.Ref = Guid.Parse(xml.Element("ArrayRef").Value); return(ata); }
private static void SelectedItemChanged(DependencyObject source, DependencyPropertyChangedEventArgs e) { if (e.OldValue != e.NewValue && e.NewValue != null) { ArraySelector vsSource = source as ArraySelector; GenericRef <VarArray> newRef = e.NewValue as GenericRef <VarArray>; foreach (var a in vsSource.treeItems.Items) { GenericRef <ArraySelector> srcRef = a as GenericRef <ArraySelector>; if (newRef != null && srcRef != null && newRef.Ref == srcRef.Ref) { //vsSource.treeItems.SelectedItem = srcRef; } } } //(source as VariableSelector).lstItems.SelectedItem = (source as VariableSelector).lstItems.Items.where ((GenericRef<VarArray>)a).LinkedVarId == ((GenericRef<VarArray>)e.NewValue).LinkedVarId select a).FirstOrDefault(); }
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); }
static void Main(string[] args) { //Generic type is a string in this case GenericClass <string> genStr = new GenericClass <string>(); string name = genStr.GenericMethod("Tochukwu"); genStr.GenericProperty = "Programmer"; Console.WriteLine("{0}, {1}", name, genStr.GenericProperty); //Generic type is now an int in this case GenericClass <int> genInt = new GenericClass <int>(); int salary = genInt.GenericMethod(33000); genInt.GenericProperty = 4; Console.WriteLine("R{0} - {1}yrs", salary, genInt.GenericProperty); /*Generic class with restrictions*/ GenericRef <Person> person = new GenericRef <Person>(); GenericVal <int> number = new GenericVal <int>(); GenericPerson <Person> madu = new GenericPerson <Person>(); GenericPerson <Student> learner = new GenericPerson <Student>(); /*Generic method*/ Example example = new Example(); int wages = example.NoRestrict(33000); GenericRef <Person> someone = example.Restrict(person); Console.WriteLine(wages); Console.WriteLine(someone); example.Multiple <string, int>("Tochi", 33000); example.Multiple("Tochi", 33000); Console.ReadLine(); }
public void RefreshListBox() { //vars = new ObservableCollection<GenericRef<Conversation>>(MainViewModel.MainViewModelStatic.Conversations.Where(a => a.Name.ToLower().Contains(searchText.Text.ToLower())).Select(a => new GenericRef<Conversation>(a.Id))); vars = new ObservableCollection <Tuple <string, ObservableCollection <GenericRef <Conversation> > > >(); foreach (var a in MainViewModel.MainViewModelStatic.ConversationGroups.Groups) { bool included = false; ObservableCollection <GenericRef <Conversation> > Events = new ObservableCollection <GenericRef <Conversation> >(); 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 conversation = GenericRef <Conversation> .GetConversationRef(); conversation.Ref = b.Id; Events.Add(conversation); } } if (included) { vars.Add(Tuple.Create <string, ObservableCollection <GenericRef <Conversation> > >(a.Item1, Events)); } //Events.First().Value.Name } this.treeItems.ItemsSource = vars; //vars[0].Item2[0].LinkedConversation.Name ExpandAll(treeItems, true); //this.lstItems.ItemsSource = vars; //if (SelectedItem != null && lstItems.Items.Contains(SelectedItem)) //{ // lstItems.SelectedItem = SelectedItem; //} }
public void RefreshListBox() { if (MainViewModel.MainViewModelStatic.ArrayGroups == null) { return; } vars = new ObservableCollection <Tuple <string, ObservableCollection <GenericRef <VarArray> > > >(); foreach (var a in MainViewModel.MainViewModelStatic.ArrayGroups.Groups) { bool included = false; ObservableCollection <GenericRef <VarArray> > Arrays = new ObservableCollection <GenericRef <VarArray> >(); foreach (var b in a.Item2) { if (b.Name.ToLower().Contains(searchText.Text.ToLower())) { included = true; var arrayRef = GenericRef <VarArray> .GetArrayRef(); arrayRef.Ref = b.Id; Arrays.Add(arrayRef); } } if (included) { vars.Add(Tuple.Create <string, ObservableCollection <GenericRef <VarArray> > >(a.Item1, Arrays)); } } this.treeItems.ItemsSource = vars; //vars[0].Item2[0].LinkedCommonEvent.Name ExpandAll(treeItems, true); //var DateTimeVars = vars.Where(a => a.LinkedVariable.IsDateTime); //var StringVars = vars.Where(a => a.LinkedVariable.IsString); //var NumberVars = vars.Where(a => a.LinkedVariable.IsNumber); //var ItemVars = vars.Where(a => a.LinkedVariable.IsItem); //var CommonEventRefVars = vars.Where(a => a.LinkedVariable.IsCommonEventRef); //vars = new ObservableCollection<GenericRef<VarArray>>(); //if (ShowDateTime) //{ // foreach (var a in DateTimeVars) // { // vars.Add(a); // } //} //if (ShowNumber) //{ // foreach (var a in NumberVars) // { // vars.Add(a); // } //} //if (ShowString) //{ // foreach (var a in StringVars) // { // vars.Add(a); // } //} //if (ShowItems) //{ // foreach (var a in ItemVars) // { // vars.Add(a); // } //} //if (ShowCommonEventRefs) //{ // foreach (var a in CommonEventRefVars) // { // vars.Add(a); // } //} //this.lstItems.ItemsSource = vars.OrderBy(a => a.LinkedVariable.Name); //if (SelectedItem != null && lstItems.Items.Contains(SelectedItem)) //{ // lstItems.SelectedItem = SelectedItem; //} }