public static BaseElementViewModel CreateStandardModel(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); }
/// <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); _startViewModel = start; _endViewModel = end; CalculatePath(); }
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); _start = startConenctor; _end = endConnector; Hooks = new List <Hook>(); Model = model; CalculatePath(); }
protected BaseConnectionViewModel(DocumentViewModel documentViewModel) : base(documentViewModel) { }
public TrackerViewModel(DocumentViewModel documentViewModel) : base(documentViewModel) { //ApplicableTypes = new HashSet<Type>(); BaseElement = new VisualElement(); }
public GatewayViewModel(DocumentViewModel documentViewModel) : base(documentViewModel) { ChangeTypeCommand = new RelayCommand(type => ChangeType((GatewayType)type)); }
public PoolViewModel(DocumentViewModel documentViewModel) : base(documentViewModel) { //ApplicableTypes = new HashSet<Type>(); LocationChanged += PoolViewModel_LocationChanged; }
public TaskViewModel(DocumentViewModel documentViewModel) : base(documentViewModel) { //ApplicableTypes = new HashSet<Type>() { typeof(EventElement), typeof(TaskElement), typeof(GatewayElement), typeof(CustomVisualElement) }; }
public GenericViewModelAdapter(DocumentViewModel documentViewModel, Type modelType) : base(documentViewModel) { _modelType = modelType; }
public DocumentViewModelBuilder(DocumentViewModel viewModel) { DocumentViewModel = viewModel; }
protected PoolElementViewModel(DocumentViewModel documentViewModel) : base(documentViewModel) { this.ElementDeleted += PoolElementViewModel_ElementDeleted; }
public DrawingConnectionViewModel(DocumentViewModel documentViewModel) : base(documentViewModel) { BaseElement = new VisualElement(); }
public SelectionViewModel(DocumentViewModel documentViewModel) : base(documentViewModel) { BaseElement = new VisualElement(); }
public EventViewModel(DocumentViewModel documentViewModel) : base(documentViewModel) { ChangeTypeCommand = new RelayCommand(type => ChangeType((EventType)type)); }