public static BaseElementViewModel GetViewModel(Type elementType, DocumentViewModel documentViewModel, bool setModelData = true) { ElementViewModelAttribute attribute = (ElementViewModelAttribute)Attribute.GetCustomAttribute(elementType, typeof(ElementViewModelAttribute)); if (attribute == null) { throw new NotSupportedException(string.Format("Not supported type {0}. Does not have ElementViewModelAttribute", elementType)); } Type viewModelType = attribute.ViewModelType; BaseElementViewModel viewModel = (BaseElementViewModel)Activator.CreateInstance(viewModelType, documentViewModel); if (setModelData) { viewModel.BaseElement = viewModel.CreateElement(); viewModel.Height = attribute.InitialSize.Height; viewModel.Width = attribute.InitialSize.Width; } return(viewModel); }
public ElementsConnectionViewModel(DocumentViewModel documentViewModel, ConnectionElement model, BaseElementViewModel start, BaseElementViewModel end, Point startPoint, Point endPoint) : base(documentViewModel) { BaseElement = new VisualElement(); var startConenctor = start.GetNearestConnector(startPoint); var endConnector = end.GetNearestConnector(endPoint); _start = startConenctor; _end = endConnector; StartPoint = startConenctor.Position; EndPoint = endConnector.Position; From = startConenctor.Parent; To = endConnector.Parent; startConenctor.PropertyChanged += Start_PropertyChanged; endConnector.PropertyChanged += End_PropertyChanged; startConenctor.Parent.ElementDeleted += ElementDeleted; endConnector.Parent.ElementDeleted += ElementDeleted; startConenctor.Parent.SetConnection(this); endConnector.Parent.SetConnection(this); Hooks = new List <Hook>(); Model = model; CalculatePath(); }
public DrawingConnectionViewModel(DocumentViewModel documentViewModel) : base(documentViewModel) { BaseElement = new VisualElement(); }
protected BaseConnectionViewModel(DocumentViewModel documentViewModel) : base(documentViewModel) { }
public TrackerViewModel(DocumentViewModel documentViewModel) : base(documentViewModel) { ApplicableTypes = new HashSet <Type>(); BaseElement = new VisualElement(); }
protected PoolElementViewModel(DocumentViewModel documentViewModel) : base(documentViewModel) { this.ElementDeleted += PoolElementViewModel_ElementDeleted; }
public DocumentViewModelBuilder(DocumentViewModel viewModel) { DocumentViewModel = viewModel; }
public PoolViewModel(DocumentViewModel documentViewModel) : base(documentViewModel) { ApplicableTypes = new HashSet <Type>(); LocationChanged += PoolViewModel_LocationChanged; }
public SelectionViewModel(DocumentViewModel documentViewModel) : base(documentViewModel) { BaseElement = new VisualElement(); }