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