コード例 #1
0
        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);
        }
コード例 #2
0
 /// <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();
 }
コード例 #3
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);
            _start = startConenctor;
            _end   = endConnector;
            Hooks  = new List <Hook>();
            Model  = model;
            CalculatePath();
        }
コード例 #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
 public GatewayViewModel(DocumentViewModel documentViewModel) : base(documentViewModel)
 {
     ChangeTypeCommand = new RelayCommand(type => ChangeType((GatewayType)type));
 }
コード例 #7
0
 public PoolViewModel(DocumentViewModel documentViewModel) : base(documentViewModel)
 {
     //ApplicableTypes = new HashSet<Type>();
     LocationChanged += PoolViewModel_LocationChanged;
 }
コード例 #8
0
 public TaskViewModel(DocumentViewModel documentViewModel) : base(documentViewModel)
 {
     //ApplicableTypes = new HashSet<Type>() { typeof(EventElement), typeof(TaskElement), typeof(GatewayElement), typeof(CustomVisualElement) };
 }
コード例 #9
0
 public GenericViewModelAdapter(DocumentViewModel documentViewModel, Type modelType) : base(documentViewModel)
 {
     _modelType = modelType;
 }
コード例 #10
0
 public DocumentViewModelBuilder(DocumentViewModel viewModel)
 {
     DocumentViewModel = viewModel;
 }
コード例 #11
0
 protected PoolElementViewModel(DocumentViewModel documentViewModel) : base(documentViewModel)
 {
     this.ElementDeleted += PoolElementViewModel_ElementDeleted;
 }
コード例 #12
0
 public DrawingConnectionViewModel(DocumentViewModel documentViewModel) : base(documentViewModel)
 {
     BaseElement = new VisualElement();
 }
コード例 #13
0
 public SelectionViewModel(DocumentViewModel documentViewModel) : base(documentViewModel)
 {
     BaseElement = new VisualElement();
 }
コード例 #14
0
 public EventViewModel(DocumentViewModel documentViewModel) : base(documentViewModel)
 {
     ChangeTypeCommand = new RelayCommand(type => ChangeType((EventType)type));
 }