void SetAttributeName(TargetAttribute attribute, IEnumerable <ProgramTarget> targets, string name) { var namedAttribute = attribute.SetName(name); if (namedAttribute is Tool) { int index = program.Tools.FindIndex(x => x == attribute as Tool); program.Tools[index] = namedAttribute as Tool; foreach (var target in targets) { if (target.Target.Tool == attribute as Tool) { target.Target = target.Target.ShallowClone(); target.Target.Tool = namedAttribute as Tool; } } } else if (namedAttribute is Frame) { int index = program.Frames.FindIndex(x => x == attribute as Frame); program.Frames[index] = namedAttribute as Frame; foreach (var target in targets) { if (target.Target.Frame == attribute as Frame) { target.Target = target.Target.ShallowClone(); target.Target.Frame = namedAttribute as Frame; } } } else if (namedAttribute is Speed) { int index = program.Speeds.FindIndex(x => x == attribute as Speed); program.Speeds[index] = namedAttribute as Speed; foreach (var target in targets) { if (target.Target.Speed == attribute as Speed) { target.Target = target.Target.ShallowClone(); target.Target.Speed = namedAttribute as Speed; } } } else if (namedAttribute is Zone) { int index = program.Zones.FindIndex(x => x == attribute as Zone); program.Zones[index] = namedAttribute as Zone; foreach (var target in targets) { if (target.Target.Zone == attribute as Zone) { target.Target = target.Target.ShallowClone(); target.Target.Zone = namedAttribute as Zone; } } } else if (namedAttribute is Command) { int index = program.Commands.FindIndex(x => x == attribute as Command); program.Commands[index] = namedAttribute as Command; for (int i = 0; i < program.InitCommands.Count; i++) { if (program.InitCommands[i] == attribute as Command) { program.InitCommands[i] = namedAttribute as Command; } } foreach (var target in targets) { var group = target.Commands; for (int i = 0; i < group.Count; i++) { if (group[i] == attribute as Command) { group[i] = namedAttribute as Command; } } } } }
void SetAttributeName(TargetAttribute attribute, IEnumerable<ProgramTarget> targets, string name) { var namedAttribute = attribute.SetName(name); if (namedAttribute is Tool) { int index = program.Tools.FindIndex(x => x == attribute as Tool); program.Tools[index] = namedAttribute as Tool; foreach (var target in targets) if (target.Target.Tool == attribute as Tool) { target.Target = target.Target.ShallowClone(); target.Target.Tool = namedAttribute as Tool; } } else if (namedAttribute is Frame) { int index = program.Frames.FindIndex(x => x == attribute as Frame); program.Frames[index] = namedAttribute as Frame; foreach (var target in targets) if (target.Target.Frame == attribute as Frame) { target.Target = target.Target.ShallowClone(); target.Target.Frame = namedAttribute as Frame; } } else if (namedAttribute is Speed) { int index = program.Speeds.FindIndex(x => x == attribute as Speed); program.Speeds[index] = namedAttribute as Speed; foreach (var target in targets) if (target.Target.Speed == attribute as Speed) { target.Target = target.Target.ShallowClone(); target.Target.Speed = namedAttribute as Speed; } } else if (namedAttribute is Zone) { int index = program.Zones.FindIndex(x => x == attribute as Zone); program.Zones[index] = namedAttribute as Zone; foreach (var target in targets) if (target.Target.Zone == attribute as Zone) { target.Target = target.Target.ShallowClone(); target.Target.Zone = namedAttribute as Zone; } } else if (namedAttribute is Command) { int index = program.Commands.FindIndex(x => x == attribute as Command); program.Commands[index] = namedAttribute as Command; for (int i = 0; i < program.InitCommands.Count; i++) if (program.InitCommands[i] == attribute as Command) program.InitCommands[i] = namedAttribute as Command; foreach (var target in targets) { var group = target.Commands; for (int i = 0; i < group.Count; i++) if (group[i] == attribute as Command) group[i] = namedAttribute as Command; } } }