public void SetUp()
        {
            this.serviceLocator = new Mock <IServiceLocator>();
            ServiceLocator.SetLocatorProvider(() => this.serviceLocator.Object);
            this.serviceLocator.Setup(x => x.GetInstance <IThingCreator>()).Returns(Mock.Of <IThingCreator>());

            this.diagramControl = new DiagramControl();

            this.elementDefinition = new ElementDefinition();
            this.parameter1        = new Parameter {
                ParameterType = new SimpleQuantityKind()
            };
            this.parameter2 = new Parameter {
                ParameterType = new SimpleQuantityKind()
            };
            this.elementDefinition.Parameter.Add(this.parameter1);
            this.elementDefinition.Parameter.Add(this.parameter2);

            this.diagramObject = new DiagramObject
            {
                DepictedThing = this.elementDefinition
            };

            this.session = Mock.Of <ISession>();

            this.diagramContentItem = new DiagramContentItem();

            this.cdp4DiagramOrgChartBehavior = new Cdp4DiagramOrgChartBehavior();

            this.diagramDropInfo = new Mock <IDiagramDropInfo>();
            this.dropTarget      = new Mock <IDropTarget>();
            this.iDropTarget     = new Mock <IIDropTarget>();
            this.iDropTarget.Setup(x => x.DropTarget).Returns(this.dropTarget.Object);
        }
Beispiel #2
0
        void AddItemsInLine <T>(IEnumerable <T> itemsSource, Point startPosition, Size itemSize, double margin, Action <T, DiagramContentItem> itemAction)
        {
            Point position = startPosition;

            foreach (var dataItem in itemsSource)
            {
                var diagramItem = new DiagramContentItem()
                {
                    Width = itemSize.Width, Height = itemSize.Height
                };
                diagramItem.CanCopy  = diagramItem.CanDelete = false;
                diagramItem.Content  = dataItem;
                diagramItem.Position = position;
                diagramItem.FontSize = 11;
                position.Offset(0, itemSize.Height + margin);
                diagramControl.Items.Add(diagramItem);
                itemAction(dataItem, diagramItem);
            }
        }
        void CreateRelationshipDiagram()
        {
            Dictionary <Employee, DiagramItem> employeeToDiagramItemCache = new Dictionary <Employee, DiagramItem>();
            var diagramItems = ViewModel.Employees.Select(employee => {
                var item = new DiagramContentItem()
                {
                    CustomStyleId = "employeeStyle", Content = employee, FontSize = 12, CanDelete = false, CanCopy = false
                };
                employeeToDiagramItemCache[employee] = item;
                return(item);
            }).ToArray();
            var diagramConnectors = ViewModel.Relationships.
                                    Select(employeeRelation => CreateDiagramConnector(employeeToDiagramItemCache[employeeRelation.Item1], employeeToDiagramItemCache[employeeRelation.Item2], employeeRelation.Item3)).ToArray();

            Array.ForEach <DiagramItem>(diagramConnectors, item => diagramControl.Items.Add(item));
            Array.ForEach <DiagramItem>(diagramItems, item => diagramControl.Items.Add(item));
            diagramControl.UpdateLayout();
            DiagramDemoHelper.LayoutCircleDiagramItems(diagramItems, diagramControl.PageSize, 300);
            diagramControl.SelectItem(diagramItems.First());
        }
Beispiel #4
0
        public void VerifyThatGenerateRelationDeepWorks()
        {
            this.diagram.DiagramElement.Clear();
            this.diagram.DiagramElement.Add(this.diagramObject1);

            var relationship0 = new BinaryRelationship(Guid.NewGuid(), this.cache, this.uri);

            relationship0.Category.Add(this.relationshipCat);
            relationship0.Source = this.diagramObject1.DepictedThing;
            relationship0.Target = this.diagramObject2.DepictedThing;
            this.iteration.Relationship.Add(relationship0);

            var relationship1 = new BinaryRelationship(Guid.NewGuid(), this.cache, this.uri);

            relationship1.Category.Add(this.relationshipCat);
            relationship1.Source = this.diagramObject2.DepictedThing;
            relationship1.Target = this.diagramObject3.DepictedThing;
            this.iteration.Relationship.Add(relationship1);

            var viewModel = new DiagramEditorViewModel(this.diagram, this.session.Object, this.thingDialogNavigationService.Object, this.panelNavigationService.Object, null, this.pluginSettingsService.Object)
            {
                Behavior = this.mockDiagramBehavior.Object
            };

            viewModel.UpdateProperties();
            Assert.AreEqual(1, viewModel.ThingDiagramItems.Count);

            var contentItem = new DiagramContentItem()
            {
                Content = viewModel.ThingDiagramItems.FirstOrDefault()
            };

            viewModel.SelectedItems.Clear();
            viewModel.SelectedItems.Add(contentItem);

            viewModel.ExecuteGenerateDiagramCommand(true);
            Assert.AreEqual(3, viewModel.ThingDiagramItems.Count);
            Assert.AreEqual(3, viewModel.DiagramConnectorCollection.Count);
            viewModel.Dispose();
        }