public void AddTrainer(GuitarTrainer tr) { if (tr.TrainerIndex.IsNull()) { tr.TrainerIndex = Messages.Trainers.Count(x => x.TrainerType == tr.TrainerType) + 1; tr.Start.SetDownEvent(Insert(tr.Start.AbsoluteTicks, new MetaMessage(MetaType.Text, tr.StartText))); if (tr.Loopable) { tr.Norm.SetDownEvent(Insert(tr.Norm.AbsoluteTicks, new MetaMessage(MetaType.Text, tr.NormText))); } tr.End.SetDownEvent(Insert(tr.End.AbsoluteTicks, new MetaMessage(MetaType.Text, tr.EndText))); Messages.Add(tr); } }
public IEnumerable <GuitarTrainer> LoadTrainers(GuitarMessageList owner, IEnumerable <GuitarTextEvent> textEventList) { var ret = new List <GuitarTrainer>(); try { var trainerEvents = textEventList.Where(v => v.IsTrainerEvent).ToList(); var validTrainerEvents = trainerEvents.Where(x => x.Text.GetTrainerEventIndex().IsNotNull()); var invalidTrainerEvents = trainerEvents.Where(v => v.Text.GetTrainerEventIndex().IsNull()); invalidTrainerEvents.ToList().ForEach(x => x.DeleteAll()); var removeEvents = new List <GuitarMessage>(); var groups = validTrainerEvents.ToList().GroupBy(v => v.TrainerType.IsTrainerGuitar()); foreach (var group in groups) { var indexGroups = group.OrderBy(v => v.Text.GetTrainerEventIndex()).GroupBy(v => v.Text.GetTrainerEventIndex()); foreach (var trainer in indexGroups.ToList()) { var index = trainer.Key; var begin = trainer.Where(v => v.TrainerType.IsTrainerBegin()); var end = trainer.Where(v => v.TrainerType.IsTrainerEnd()); var norm = trainer.Where(v => v.TrainerType.IsTrainerNorm()); if (begin.Any() && end.Any()) { var trainerType = group.Key == true ? GuitarTrainerType.ProGuitar : GuitarTrainerType.ProBass; var startEv = begin.First(); var endEv = end.First(); var normEv = norm.FirstOrDefault(); var gt = new GuitarTrainer(owner, new TickPair(startEv.AbsoluteTicks, endEv.AbsoluteTicks), trainerType, startEv, endEv, normEv); ret.Add(gt); removeEvents.AddRange(begin.Skip(1).ToList()); removeEvents.AddRange(end.Skip(1).ToList()); if (norm.Any()) { removeEvents.AddRange(norm.Skip(1).ToList()); } } else { removeEvents.AddRange(trainer.ToList()); } } } removeEvents.ToList().ForEach(x => x.DeleteAll()); } catch { } return(ret.Where(v => v.IsDeleted == false).ToList()); }
public void AddTrainer(GuitarTrainer tr) { if (tr.TrainerIndex.IsNull()) { tr.TrainerIndex = Messages.Trainers.Count(x => x.TrainerType == tr.TrainerType) + 1; tr.Start.SetDownEvent(Insert(tr.Start.AbsoluteTicks, new MetaMessage(MetaType.Text, tr.StartText))); if (tr.Loopable) { tr.Norm.SetDownEvent(Insert(tr.Norm.AbsoluteTicks, new MetaMessage(MetaType.Text, tr.NormText))); } tr.End.SetDownEvent(Insert(tr.End.AbsoluteTicks, new MetaMessage(MetaType.Text, tr.EndText))); Messages.Add(tr); } }
public IEnumerable<GuitarTrainer> LoadTrainers(GuitarMessageList owner, IEnumerable<GuitarTextEvent> textEventList) { var ret = new List<GuitarTrainer>(); try { var trainerEvents = textEventList.Where(v => v.IsTrainerEvent).ToList(); var validTrainerEvents = trainerEvents.Where(x => x.Text.GetTrainerEventIndex().IsNotNull()); var invalidTrainerEvents = trainerEvents.Where(v => v.Text.GetTrainerEventIndex().IsNull()); invalidTrainerEvents.ToList().ForEach(x => x.DeleteAll()); var removeEvents = new List<GuitarMessage>(); var groups = validTrainerEvents.ToList().GroupBy(v => v.TrainerType.IsTrainerGuitar()); foreach (var group in groups) { var indexGroups = group.OrderBy(v => v.Text.GetTrainerEventIndex()).GroupBy(v => v.Text.GetTrainerEventIndex()); foreach (var trainer in indexGroups.ToList()) { var index = trainer.Key; var begin = trainer.Where(v => v.TrainerType.IsTrainerBegin()); var end = trainer.Where(v => v.TrainerType.IsTrainerEnd()); var norm = trainer.Where(v => v.TrainerType.IsTrainerNorm()); if (begin.Any() && end.Any()) { var trainerType = group.Key == true ? GuitarTrainerType.ProGuitar : GuitarTrainerType.ProBass; var startEv = begin.First(); var endEv = end.First(); var normEv = norm.FirstOrDefault(); var gt = new GuitarTrainer(owner, new TickPair(startEv.AbsoluteTicks, endEv.AbsoluteTicks), trainerType, startEv, endEv, normEv); ret.Add(gt); removeEvents.AddRange(begin.Skip(1).ToList()); removeEvents.AddRange(end.Skip(1).ToList()); if (norm.Any()) { removeEvents.AddRange(norm.Skip(1).ToList()); } } else { removeEvents.AddRange(trainer.ToList()); } } } removeEvents.ToList().ForEach(x => x.DeleteAll()); } catch { } return ret.Where(v => v.IsDeleted == false).ToList(); }
public void CreateTrainer(GuitarMessageList list, GuitarTrainerType type, TickPair ticks, bool loopable) { try { var gt = new GuitarTrainer(list, ticks, type, loopable); gt.IsNew = true; gt.CreateEvents(); EditorPro.SetCreationStateIdle(); EditorPro.SetSelectionStateIdle(); RefreshTextEvents(); RefreshTrainers(); } catch { } }