Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        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();
        }
Esempio n. 3
0
 public DrawingConnectionViewModel(DocumentViewModel documentViewModel) : base(documentViewModel)
 {
     BaseElement = new VisualElement();
 }
Esempio n. 4
0
 protected BaseConnectionViewModel(DocumentViewModel documentViewModel) : base(documentViewModel)
 {
 }
Esempio n. 5
0
 public TrackerViewModel(DocumentViewModel documentViewModel) : base(documentViewModel)
 {
     ApplicableTypes = new HashSet <Type>();
     BaseElement     = new VisualElement();
 }
Esempio n. 6
0
 protected PoolElementViewModel(DocumentViewModel documentViewModel) : base(documentViewModel)
 {
     this.ElementDeleted += PoolElementViewModel_ElementDeleted;
 }
Esempio n. 7
0
 public DocumentViewModelBuilder(DocumentViewModel viewModel)
 {
     DocumentViewModel = viewModel;
 }
Esempio n. 8
0
 public PoolViewModel(DocumentViewModel documentViewModel) : base(documentViewModel)
 {
     ApplicableTypes  = new HashSet <Type>();
     LocationChanged += PoolViewModel_LocationChanged;
 }
Esempio n. 9
0
 public SelectionViewModel(DocumentViewModel documentViewModel) : base(documentViewModel)
 {
     BaseElement = new VisualElement();
 }