/// <summary> /// Creates ElementsConnectionViewModel and add model connection /// </summary> /// <param name="documentViewModel"></param> /// <param name="start"></param> /// <param name="end"></param> public ElementsConnectionViewModel(DocumentViewModel documentViewModel, ConnectorViewModel start, ConnectorViewModel end) : base(documentViewModel) { BaseElement = new VisualElement(); _start = start; _end = end; StartPoint = start.Position; EndPoint = end.Position; From = start.Parent; To = end.Parent; start.PropertyChanged += Start_PropertyChanged; end.PropertyChanged += End_PropertyChanged; start.Parent.ElementDeleted += ElementDeleted; end.Parent.ElementDeleted += ElementDeleted; start.Parent.SetConnection(this); end.Parent.SetConnection(this); Hooks = new List <Hook>(); Model = new ConnectionElement(start.Parent.BaseElement, end.Parent.BaseElement); ModelHelper.AddModelConnection(this); CalculatePath(); }