public void AddPhase() { var ret = new PhaseItemModel(Phases); Phases.Add(ret); Selection = ret; RaisePropertyChanged("Phases"); }
public void AddPhase() { var ret = new PhaseItemViewModel() { ItemSource = Phases }; Phases.Add(ret); Selection = ret; RaisePropertyChanged("Phases"); }
private void GetPhases(int startOfCycle) { foreach (var a in SignalModel.Approaches) { Phases.Add(new Phase(a, StartDate, EndDate, EventCodes, startOfCycle, false)); if (a.PermissivePhaseNumber != null && a.PermissivePhaseNumber > 0) { Phases.Add(new Phase(a, StartDate, EndDate, EventCodes, startOfCycle, true)); } } }
public void Open(string schemafile) { Phases.Clear(); FileStream fs = null; try { SchemaSrc = new FileInfo(schemafile); string tmppath = Path.Combine(_workdir, SchemaSrc.Name); SchemaSrc.CopyTo(tmppath, true); SchemaTmp = new FileInfo(tmppath); if (!SchemaTmp.Exists) { throw new FileNotFoundException(SchemaTmp.FullName); } fs = SchemaTmp.Open(FileMode.Open, FileAccess.Read, FileShare.Read); fs.Position = 0; XDocument xdoc = XDocument.Load(fs, LoadOptions.None); foreach (XElement e1 in xdoc.Descendants().Where(p => p.Name.LocalName == "phase")) { XAttribute id = e1.Attribute("id"); Phase phase = new Phase(); phase.Id = id?.Value ?? ""; foreach (XElement e2 in e1.Descendants().Where(p => p.Name.LocalName == "active")) { XAttribute pattern = e2.Attribute("pattern"); if (pattern != null) { phase.Patterns.Add(pattern.Value); } } if (phase.IsEnabled) { Phases.Add(phase); } } } catch (Exception ex) { throw ex; } finally { fs?.Dispose(); } }
public bool AddPhase(uint phaseId, PhaseFlags flags, List <Condition> areaConditions, int references = 1) { var phase = new PhaseRef(phaseId, flags, null); ModifyPhasesReferences(phase, references); if (areaConditions != null) { phase.AreaConditions = areaConditions; } Phases.Add(phase); return(true); }
/// <summary> /// Adds a new phase /// </summary> /// <param name="phase"></param> /// <returns></returns> private UMLPhase AddPhase(UMLPhase phase) { foreach (UMLPhase p in Phases) { if (phase.Name == p.Name) { return(p); } } phase.Stereotype = Constants.UMLPhase.STEREOTYPE; Phases.Add(phase); return(phase); }
public bool AddPhase(uint phaseId, PhaseFlags flags, List <Condition> areaConditions, int references = 1) { bool newPhase = false; if (!Phases.ContainsKey(phaseId)) { newPhase = true; Phases.Add(phaseId, new PhaseRef(flags, null)); } var phase = Phases.LookupByKey(phaseId); ModifyPhasesReferences(phaseId, phase, references); if (areaConditions != null) { phase.AreaConditions = areaConditions; } return(newPhase); }
public Stage(int number) : this() { switch (number) { case 1: Phases.Add(new Phase(PhaseName.A)); Phases.Add(new Phase(PhaseName.B)); Duration = new List <TimeSpan> { new TimeSpan(15), new TimeSpan(5) }; break; case 2: Phases.Add(new Phase(PhaseName.C)); Phases.Add(new Phase(PhaseName.D)); Duration = new List <TimeSpan> { new TimeSpan(15), new TimeSpan(5) }; break; } }
public static async void Load() { if (!Directory.Exists(GetPath())) { Trace.WriteLine($"DBC folder \"{ GetPath() }\" not found"); return; } else { Trace.WriteLine($"DBC folder \"{ GetPath() }\" found"); } Trace.WriteLine("File name LoadTime Record count"); Trace.WriteLine("---------------------------------------------------------------------"); Parallel.ForEach(typeof(DBC).GetProperties(BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic), dbc => { Type type = dbc.PropertyType.GetGenericArguments()[0]; if (!type.IsClass) { return; } var startTime = DateTime.Now; var attr = type.GetCustomAttribute <DBFileAttribute>(); if (attr == null) { return; } var times = new List <long>(); var instanceType = typeof(Storage <>).MakeGenericType(type); var countGetter = instanceType.GetProperty("Count").GetGetMethod(); var instance = Activator.CreateInstance(instanceType, $"{ GetPath(attr.FileName) }.db2"); var recordCount = (int)countGetter.Invoke(instance, new object[] { }); try { dbc.SetValue(dbc.GetValue(null), instance); } catch (TargetInvocationException tie) { if (tie.InnerException is ArgumentException) { throw new ArgumentException($"Failed to load {attr.FileName}.db2: {tie.InnerException.Message}"); } throw; } var endTime = DateTime.Now; var span = endTime.Subtract(startTime); Trace.WriteLine($"{ attr.FileName.PadRight(33) } { TimeSpan.FromTicks(span.Ticks).ToString().PadRight(28) } { recordCount.ToString().PadRight(19) }"); }); await Task.WhenAll(Task.Run(() => { if (AreaTable != null) { foreach (var db2Info in AreaTable) { if (db2Info.Value.ParentAreaID != 0 && !Zones.ContainsKey(db2Info.Value.ParentAreaID)) { Zones.Add(db2Info.Value.ParentAreaID, db2Info.Value.ZoneName); } } } }), Task.Run(() => { if (MapDifficulty != null) { foreach (var mapDifficulty in MapDifficulty) { int difficultyID = 1 << mapDifficulty.Value.DifficultyID; if (MapSpawnMaskStores.ContainsKey(mapDifficulty.Value.MapID)) { MapSpawnMaskStores[mapDifficulty.Value.MapID] |= difficultyID; } else { MapSpawnMaskStores.Add(mapDifficulty.Value.MapID, difficultyID); } if (!MapDifficultyStores.ContainsKey(mapDifficulty.Value.MapID)) { MapDifficultyStores.Add(mapDifficulty.Value.MapID, new List <int>() { mapDifficulty.Value.DifficultyID }); } else { MapDifficultyStores[mapDifficulty.Value.MapID].Add(mapDifficulty.Value.DifficultyID); } } } }), Task.Run(() => { if (CriteriaTree != null && Achievement != null) { ICollection <AchievementEntry> achievementLists = Achievement.Values; var achievements = achievementLists.GroupBy(achievement => achievement.CriteriaTree) .ToDictionary(group => group.Key, group => group.ToList()); foreach (var criteriaTree in CriteriaTree) { string result = ""; uint criteriaTreeID = criteriaTree.Value.Parent > 0 ? criteriaTree.Value.Parent : (uint)criteriaTree.Key; List <AchievementEntry> achievementList; if (achievements.TryGetValue(criteriaTreeID, out achievementList)) { foreach (var achievement in achievementList) { result = $"AchievementID: {achievement.ID} Description: \"{ achievement.Description }\""; } } if (!CriteriaStores.ContainsKey((ushort)criteriaTree.Value.CriteriaID)) { if (criteriaTree.Value.Description != string.Empty) { result += $" - CriteriaDescription: \"{criteriaTree.Value.Description }\""; } CriteriaStores.Add((ushort)criteriaTree.Value.CriteriaID, result); } else { CriteriaStores[(ushort)criteriaTree.Value.CriteriaID] += $" / CriteriaDescription: \"{ criteriaTree.Value.Description }\""; } } } }), Task.Run(() => { if (Faction != null && FactionTemplate != null) { foreach (var factionTemplate in FactionTemplate) { if (Faction.ContainsKey(factionTemplate.Value.Faction)) { FactionStores.Add((uint)factionTemplate.Key, Faction[factionTemplate.Value.Faction]); } } } }), Task.Run(() => { if (SpellEffect != null) { foreach (var effect in SpellEffect) { var tuple = Tuple.Create((uint)effect.Value.SpellID, (uint)effect.Value.EffectIndex); SpellEffectStores[tuple] = effect.Value; } } }), Task.Run(() => { if (PhaseXPhaseGroup != null) { foreach (var phase in PhaseXPhaseGroup) { if (!Phases.ContainsKey(phase.Value.PhaseGroupID)) { Phases.Add(phase.Value.PhaseGroupID, new List <ushort>() { phase.Value.PhaseID }); } else { Phases[phase.Value.PhaseGroupID].Add(phase.Value.PhaseID); } } } })); }
/// <summary> /// Adds a phase to the collection of phases /// </summary> /// <param name="phase">Phase to add</param> public virtual void AddPhase(Phase phase) { Phases.Add(phase.Name, phase); }