public T AddLink <T>(T link, PortModel source, PortModel?target = null) where T : LinkModel { link.Type = Options.Links.DefaultLinkType; source.AddLink(link); if (target == null) { link.OnGoingPosition = new Point(source.Position.X + source.Size.Width / 2, source.Position.Y + source.Size.Height / 2); } else { target.AddLink(link); } source.Refresh(); target?.Refresh(); source.Parent.Group?.Refresh(); target?.Parent.Group?.Refresh(); LinkAdded?.Invoke(link); Changed?.Invoke(); return(link); }
public SensorBoneLink CreateLink(Bone bone, Sensor sensor) { if (links.ContainsKey(bone)) { var removedLink = links[bone]; links.Remove(bone); LinkRemoved?.Invoke(removedLink); } var link = new SensorBoneLink(bone, sensor); links.Add(bone, link); LinkAdded?.Invoke(link); return(link); }
public T AddLink <T>(PortModel source, PortModel?target = null) where T : LinkModel { var link = (T)Activator.CreateInstance(typeof(T), source, target); link.Type = Options.DefaultLinkType; source.AddLink(link); if (target == null) { link.OnGoingPosition = new Point(source.Position.X + source.Size.Width / 2, source.Position.Y + source.Size.Height / 2); } else { target.AddLink(link); } LinkAdded?.Invoke(link); Changed?.Invoke(); return(link); }