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
        private DiagramObject CreateSide(Diagram diagram, BlockSideEnum side, double x, double y, double containerWidth, double containerHeight)
        {
            Geometry lineGeometry = null;

            if (side == BlockSideEnum.West)
            {
                lineGeometry = GeometryBuilder.StraightLine(x, y, x, y + containerHeight);
            }
            else if (side == BlockSideEnum.North)
            {
                lineGeometry = GeometryBuilder.StraightLine(x, y + containerHeight, x + containerWidth, y + containerHeight);
            }
            else if (side == BlockSideEnum.East)
            {
                lineGeometry = GeometryBuilder.StraightLine(x + containerWidth, y, x + containerWidth, y + containerHeight);
            }
            else if (side == BlockSideEnum.South)
            {
                lineGeometry = GeometryBuilder.StraightLine(x, y, x + containerWidth, y);
            }

            var containerSide = new DiagramObject(diagram)
            {
                Style        = "NodeContainerSide" + side.ToString(),
                Geometry     = lineGeometry,
                DrawingOrder = 700
            };

            containerSide.SetReference(_nodeContainerViewModel.NodeContainer.Id, "NodeContainer");

            return(containerSide);
        }
Beispiel #3
0
 public static IEADiagramObject Wrap(DiagramObject native)
 {
     if (null == native)
     {
         throw new ArgumentNullException("native");
     }
     return(new EADiagramObject(native));
 }
Beispiel #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ThingDiagramContentItem"/> class.
 /// </summary>
 /// <param name="diagramThing">
 /// The diagramThing contained</param>
 /// <param name="containerViewModel">
 /// The view model container of kind <see cref="IDiagramEditorViewModel"/></param>
 protected ThingDiagramContentItem(DiagramObject diagramThing, IDiagramEditorViewModel containerViewModel)
 {
     this.containerViewModel = containerViewModel;
     this.Thing        = diagramThing.DepictedThing;
     this.Content      = diagramThing.DepictedThing;
     this.DiagramThing = diagramThing;
     this.InitializeSubscriptions();
 }
Beispiel #5
0
        private DiagramObject CreateSpanEquipmentTypeLabel(Diagram diagram, double x, double y)
        {
            var labelDiagramObject = new DiagramObject(diagram)
            {
                Style        = "SpanEquipmentLabel",
                Label        = _spanEquipmentViewModel.GetConduitEquipmentLabel(),
                Geometry     = GeometryBuilder.Point(x, y),
                DrawingOrder = 1000
            };

            return(labelDiagramObject);
        }
Beispiel #6
0
        private DiagramObject CreateTypeLabel(Diagram diagram, double x, double y)
        {
            var labelDiagramObject = new DiagramObject(diagram)
            {
                Style        = "NodeContainerLabel",
                Label        = _nodeContainerViewModel.GetNodeContainerTypeLabel(),
                Geometry     = GeometryBuilder.Point(x, y),
                DrawingOrder = 1000
            };

            return(labelDiagramObject);
        }
        /// <summary>
        /// Adds the element to diagram.
        /// </summary>
        /// <param name="pdDiagram">The pd diagram.</param>
        /// <param name="element">The element.</param>
        /// <returns>a diagramobject</returns>
        private static DiagramObject AddElementToDiagram(Diagram pdDiagram, Element element)
        {
            object objDObj = pdDiagram.DiagramObjects.AddNew("", "");

            if (!Equals(objDObj, null))
            {
                DiagramObject diaObj = (DiagramObject)objDObj;
                diaObj.ElementID = element.ElementID;
                diaObj.Update();
                pdDiagram.Update();
                return(diaObj);
            }
            return(null);
        }
Beispiel #8
0
        // 図から必要な要素を取得し、リストを作成する
        internal void LoadDeployDiagramObjectsInformation(EA.Repository Repository)
        {
            // ノードの配置に関するモデルの作成,親をたどることにより必要な情報を入手
            // 配置図の要素を環境、デバイス、ノード、コンポーネントのリストに格納
            EA.Diagram diagram = Repository.GetCurrentDiagram();
            var        TmpCommunicationList = new List <Communication>();

            for (short i = 0; i < diagram.DiagramObjects.Count; i++)
            {
                DiagramObject diagramObject = diagram.DiagramObjects.GetAt(i);
                Element       element       = Repository.GetElementByID(diagramObject.ElementID);
                var           ConnectorList = new List <Connector>();
                var           xdoc          = element.Notes.ToXDocument();
                switch (element.MetaType)
                {
                case "ExecutionEnvironment":
                    ExecutionEnvironmentList.Add(new ExecutionEnvironment(element.Name, element.ElementID, element.ParentID, xdoc));
                    break;

                case "Device":
                    // デバイスが保持している接続を取得
                    for (short j = 0; j < element.Connectors.Count; j++)
                    {
                        Connector connector = element.Connectors.GetAt(j);
                        ConnectorList.Add(connector);
                        TmpCommunicationList.Add(new Communication(connector.Name, connector.ConnectorID, connector.DiagramID, connector.Notes.ToXDocument()));
                    }

                    DeviceList.Add(new Device(element.Name, element.ElementID, element.ParentID, xdoc, element.Stereotype, ConnectorList));
                    break;

                case "Node":
                    NodeList.Add(new Node(element.Name, element.ElementID, element.ParentID, xdoc));
                    break;

                case "Component":
                    ComponentList.Add(new Component(element.Name, element.ElementID, element.ParentID, xdoc));
                    break;
                }
            }

            TmpCommunicationList.GroupBy(communication => communication.Name)
            .Select(x => x.FirstOrDefault())
            .ToList()
            .ForEach(Communication => CommunicationList.Add(Communication));
        }
        /// <summary>
        ///     Implements IEADiagram.RemoveElement(IEAElement element)
        /// </summary>
        /// <param name="element"></param>
        public void RemoveElement(IEAElement element)
        {
            for (short i = 0; i < _native.DiagramObjects.Count; i++)
            {
                DiagramObject obj = _native.DiagramObjects.GetAt(i);
                if (obj.ElementID.Equals(element.ID))
                {
                    _native.DiagramObjects.Delete(i);
                    _native.DiagramObjects.Refresh();

                    Repository nativeRepository = EARepository.Instance.Native;
                    nativeRepository.ReloadDiagram(_native.DiagramID);
                    nativeRepository.SaveDiagram(_native.DiagramID);
                    break;
                }
            }
        }
Beispiel #10
0
        private JObject CreatePropertiesJsonObject(DiagramObject diagramObject)
        {
            JObject jsonProperties = new JObject();

            jsonProperties.Add(new JProperty("rowid", _rowId));
            _rowId++;

            jsonProperties.Add(new JProperty("Style", diagramObject.Style));

            jsonProperties.Add(new JProperty("Label", diagramObject.Label));

            if (diagramObject.IdentifiedObject != null)
            {
                jsonProperties.Add(new JProperty("RefId", diagramObject.IdentifiedObject.RefId));
                jsonProperties.Add(new JProperty("RefClass", diagramObject.IdentifiedObject.RefClass));
            }

            return(jsonProperties);
        }
        public void SetUp()
        {
            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>();
        }
        /// <summary>
        ///     Implements IEADiagram.AddElement(IEAElement element)
        /// </summary>
        /// <param name="element"></param>
        public void AddElement(IEAElement element)
        {
            //check if element already exists on diagram
            if (null != GetElements().FirstOrDefault(dobj => dobj.ElementID.Equals(element.ID)))
            {
                return;
            }

            DiagramObject diaObj = _native.DiagramObjects.AddNew("l=10;r=110;t=-20;b=-80", "");

            diaObj.ElementID = element.ID;
            diaObj.Update();
            _native.DiagramObjects.Refresh();
            _native.Update();
            Repository nativeRepository = EARepository.Instance.Native;

            nativeRepository.ReloadDiagram(_native.DiagramID);
            nativeRepository.SaveDiagram(_native.DiagramID);
        }
        /// <summary>
        /// Serialize the <see cref="DiagramObject"/>
        /// </summary>
        /// <param name="diagramObject">The <see cref="DiagramObject"/> to serialize</param>
        /// <returns>The <see cref="JObject"/></returns>
        private JObject Serialize(DiagramObject diagramObject)
        {
            var jsonObject = new JObject();

            jsonObject.Add("bounds", this.PropertySerializerMap["bounds"](diagramObject.Bounds));
            jsonObject.Add("classKind", this.PropertySerializerMap["classKind"](Enum.GetName(typeof(CDP4Common.CommonData.ClassKind), diagramObject.ClassKind)));
            jsonObject.Add("depictedThing", this.PropertySerializerMap["depictedThing"](diagramObject.DepictedThing));
            jsonObject.Add("diagramElement", this.PropertySerializerMap["diagramElement"](diagramObject.DiagramElement.OrderBy(x => x, this.guidComparer)));
            jsonObject.Add("documentation", this.PropertySerializerMap["documentation"](diagramObject.Documentation));
            jsonObject.Add("excludedDomain", this.PropertySerializerMap["excludedDomain"](diagramObject.ExcludedDomain.OrderBy(x => x, this.guidComparer)));
            jsonObject.Add("excludedPerson", this.PropertySerializerMap["excludedPerson"](diagramObject.ExcludedPerson.OrderBy(x => x, this.guidComparer)));
            jsonObject.Add("iid", this.PropertySerializerMap["iid"](diagramObject.Iid));
            jsonObject.Add("localStyle", this.PropertySerializerMap["localStyle"](diagramObject.LocalStyle));
            jsonObject.Add("modifiedOn", this.PropertySerializerMap["modifiedOn"](diagramObject.ModifiedOn));
            jsonObject.Add("name", this.PropertySerializerMap["name"](diagramObject.Name));
            jsonObject.Add("resolution", this.PropertySerializerMap["resolution"](diagramObject.Resolution));
            jsonObject.Add("revisionNumber", this.PropertySerializerMap["revisionNumber"](diagramObject.RevisionNumber));
            jsonObject.Add("sharedStyle", this.PropertySerializerMap["sharedStyle"](diagramObject.SharedStyle));
            jsonObject.Add("thingPreference", this.PropertySerializerMap["thingPreference"](diagramObject.ThingPreference));
            return(jsonObject);
        }
    public static void Main()
    {
        DiagramObject[] dArray = new DiagramObject[100];

        dArray[0] = new DiagramObject();
        dArray[1] = new TextObject("Text Dude");
        dArray[2] = new TextObject("Text Backup");

        // array gets initialized here, with classes that
        // derive from DiagramObject. Some of them implement
        // IScalable.

        foreach (DiagramObject d in dArray)
        {
            IScalable scalable = d as IScalable;
            if (scalable != null)
            {
                scalable.ScaleX(0.1F);
                scalable.ScaleY(10.0F);
            }
        }
    }
        public EditingForm(DiagramObject obj) : this()
        {
            // Grab the properties of the object.
            Properties = new Dictionary <string, object>();
            var p = obj.GetEditableParameters();

            Editable = obj;

            foreach (string key in p.Keys)
            {
                Properties.Add(key, p[key]);
            }

            foreach (string key in Properties.Keys)
            {
                PropertyList.Items.Add(key);
            }

            ObjectLocal = obj;
            ID          = obj.DiagramID;
            ObjectType  = obj.ObjectID;
            Header.Text = $"Editing object with ID {ID} ({ObjectType.ToString()})";
        }
Beispiel #16
0
        public void Setup()
        {
            this.session                     = new Mock <ISession>();
            this.assembler                   = new Assembler(this.uri);
            this.permissionService           = new Mock <IPermissionService>();
            this.mockExtendedDiagramBehavior = new Mock <IExtendedDiagramOrgChartBehavior>();
            this.mockDiagramBehavior         = new Mock <ICdp4DiagramOrgChartBehavior>(MockBehavior.Strict);
            this.session.Setup(x => x.PermissionService).Returns(this.permissionService.Object);
            this.thingDialogNavigationService = new Mock <IThingDialogNavigationService>();
            this.panelNavigationService       = new Mock <IPanelNavigationService>();
            this.pluginSettingsService        = new Mock <IPluginSettingsService>();
            this.dropinfo = new Mock <IDiagramDropInfo>();
            this.cache    = this.assembler.Cache;

            this.sitedir    = new SiteDirectory(Guid.NewGuid(), this.cache, this.uri);
            this.srdl       = new SiteReferenceDataLibrary(Guid.NewGuid(), this.cache, this.uri);
            this.modelsetup = new EngineeringModelSetup(Guid.NewGuid(), this.cache, this.uri)
            {
                Name = "model"
            };
            this.iterationsetup = new IterationSetup(Guid.NewGuid(), this.cache, this.uri);
            this.person         = new Person(Guid.NewGuid(), this.cache, this.uri);
            this.domain         = new DomainOfExpertise(Guid.NewGuid(), this.cache, this.uri)
            {
                Name = "domain"
            };

            this.participant = new Participant(Guid.NewGuid(), this.cache, this.uri)
            {
                Person         = this.person,
                SelectedDomain = this.domain
            };

            this.diagram = new DiagramCanvas(Guid.NewGuid(), this.cache, this.uri)
            {
                Name = "model"
            };
            this.sitedir.Model.Add(this.modelsetup);
            this.sitedir.SiteReferenceDataLibrary.Add(this.srdl);
            this.sitedir.Person.Add(this.person);
            this.sitedir.Domain.Add(this.domain);
            this.modelsetup.IterationSetup.Add(this.iterationsetup);
            this.modelsetup.Participant.Add(this.participant);

            this.model = new EngineeringModel(Guid.NewGuid(), this.cache, this.uri)
            {
                EngineeringModelSetup = this.modelsetup
            };

            this.iteration = new Iteration(Guid.NewGuid(), this.cache, this.uri)
            {
                IterationSetup = this.iterationsetup
            };
            this.iteration.DiagramCanvas.Add(this.diagram);
            this.model.Iteration.Add(this.iteration);

            this.specCat         = new Category(Guid.NewGuid(), this.cache, this.uri);
            this.relationshipCat = new Category(Guid.NewGuid(), this.cache, this.uri);

            this.spec1 = new RequirementsSpecification(Guid.NewGuid(), this.cache, this.uri);
            this.spec2 = new RequirementsSpecification(Guid.NewGuid(), this.cache, this.uri);
            this.spec3 = new RequirementsSpecification(Guid.NewGuid(), this.cache, this.uri);

            this.link1 = new BinaryRelationship(Guid.NewGuid(), this.cache, this.uri)
            {
                Source = this.spec1,
                Target = this.spec2
            };

            this.link1.Category.Add(this.relationshipCat);
            this.spec1.Category.Add(this.specCat);
            this.spec2.Category.Add(this.specCat);
            this.spec3.Category.Add(this.specCat);

            this.srdl.DefinedCategory.Add(this.specCat);
            this.srdl.DefinedCategory.Add(this.relationshipCat);

            this.iteration.RequirementsSpecification.Add(this.spec1);
            this.iteration.RequirementsSpecification.Add(this.spec2);
            this.iteration.RequirementsSpecification.Add(this.spec3);
            this.iteration.Relationship.Add(this.link1);


            var tuple = new Tuple <DomainOfExpertise, Participant>(this.domain, this.participant);

            var openedIterations = new Dictionary <Iteration, Tuple <DomainOfExpertise, Participant> >
            {
                {
                    this.iteration, tuple
                }
            };

            this.diagramObject1 = new DiagramObject(Guid.NewGuid(), this.cache, this.uri)
            {
                DepictedThing = this.spec1
            };
            this.diagramObject2 = new DiagramObject(Guid.NewGuid(), this.cache, this.uri)
            {
                DepictedThing = this.spec2
            };
            this.diagramObject3 = new DiagramObject(Guid.NewGuid(), this.cache, this.uri)
            {
                DepictedThing = this.spec3
            };

            this.connector = new DiagramEdge(Guid.NewGuid(), this.cache, this.uri)
            {
                Source        = this.diagramObject1,
                Target        = this.diagramObject2,
                DepictedThing = this.link1
            };
            this.elementDefinition = new ElementDefinition()
            {
                Name = "WhyNot", ShortName = "WhyNot"
            };
            this.bound1 = new Bounds(Guid.NewGuid(), this.cache, this.uri)
            {
                X      = 1,
                Y      = 1,
                Height = 12,
                Width  = 10
            };

            this.bound2 = new Bounds(Guid.NewGuid(), this.cache, this.uri)
            {
                X      = 1,
                Y      = 1,
                Height = 12,
                Width  = 10
            };

            this.diagramObject1.Bounds.Add(this.bound1);
            this.diagramObject2.Bounds.Add(this.bound2);

            this.diagram.DiagramElement.Add(this.diagramObject1);
            this.diagram.DiagramElement.Add(this.diagramObject2);
            this.diagram.DiagramElement.Add(this.connector);

            this.session.Setup(x => x.RetrieveSiteDirectory()).Returns(this.sitedir);
            this.session.Setup(x => x.ActivePerson).Returns(this.person);
            this.session.Setup(x => x.OpenIterations).Returns(openedIterations);
            this.session.Setup(x => x.Assembler).Returns(this.assembler);
            this.permissionService.Setup(x => x.CanWrite(It.IsAny <Thing>())).Returns(true);
            this.mockExtendedDiagramBehavior.Setup(x => x.GetDiagramPositionFromMousePosition(It.IsAny <Point>())).Returns(new Point());
            this.mockDiagramBehavior.Setup(x => x.GetDiagramPositionFromMousePosition(It.IsAny <Point>())).Returns(new Point());
            this.mockDiagramBehavior.Setup(x => x.ItemPositions).Returns(new Dictionary <object, Point>());
            this.mockDiagramBehavior.Setup(x => x.ApplyChildLayout(It.IsAny <DiagramItem>()));

            this.cache.TryAdd(new CacheKey(this.iteration.Iid, null), new Lazy <Thing>(() => this.iteration));
        }
Beispiel #17
0
 /// <summary>
 /// Initialize a new DiagramPortViewModel
 /// </summary>
 /// <param name="diagramObject"></param>
 /// <param name="session"></param>
 /// <param name="containerViewModel"></param>
 public DiagramPortViewModel(DiagramObject diagramObject, ISession session, DiagramEditorViewModel containerViewModel) : base(diagramObject, session, containerViewModel)
 {
     this.ContainerBounds = diagramObject.Bounds.FirstOrDefault();
     this.Position        = new System.Windows.Point(this.ContainerBounds?.X ?? 0D, this.ContainerBounds?.Y ?? 0D);
 }
Beispiel #18
0
 /// <summary>
 /// Initialize a new <see cref="PortContainerDiagramContentItem"/>
 /// </summary>
 /// <param name="thing">
 /// The diagramThing contained</param>
 /// <param name="container">
 /// The view model container of kind <see cref="IDiagramEditorViewModel"/></param>
 public PortContainerDiagramContentItem(DiagramObject thing, IDiagramEditorViewModel container) : base(thing, container)
 {
     this.PortCollection = new ReactiveList <IDiagramPortViewModel>();
     this.PortCollection.Changed.Subscribe(this.PortCollectionChanged);
 }
        public List <DiagramObject> CreateDiagramObjects(double offsetX, double offsetY, LineBlockTypeEnum blockType)
        {
            List <DiagramObject> result = new List <DiagramObject>();

            var terminalOffsetX = offsetX;
            var terminalOffsetY = offsetY;

            ConnectionPointX = 0;
            ConnectionPointY = 0;

            // Create terminal diagram object
            var terminalPolygon = new DiagramObject();

            if (_refClass != null)
            {
                terminalPolygon.IdentifiedObject = new IdentifiedObjectReference()
                {
                    RefId = _refId, RefClass = _refClass
                }
            }
            ;

            terminalPolygon.Style = _style == null ? "LinkBlockTerminal" : _style;

            var rectWidth  = Port.IsVertical ? Port.PortThickness + (Port.PortThickness / 2) : Length;
            var rectHeight = Port.IsVertical ? Length : Port.PortThickness + (Port.PortThickness / 2);

            if (Port.Side == BlockSideEnum.Vest)
            {
                //terminalOffsetX += (Port.PortThickness / 2);

                ConnectionPointX = offsetX;
                ConnectionPointY = offsetY + (Length / 2);
            }
            else if (Port.Side == BlockSideEnum.East)
            {
                terminalOffsetX -= (Port.PortThickness + (Port.PortThickness / 2));

                ConnectionPointX = offsetX;
                ConnectionPointY = offsetY + (Length / 2);
            }
            else if (Port.Side == BlockSideEnum.South)
            {
                terminalOffsetX -= Length;
                terminalOffsetY += (Port.PortThickness / 2);

                ConnectionPointX = offsetX + (Length / 2);
                ConnectionPointY = offsetY;
            }
            else if (Port.Side == BlockSideEnum.North)
            {
                terminalOffsetY -= (Port.PortThickness + (Port.PortThickness / 2));  // We need to start on lover y, because we're in the top

                ConnectionPointX = offsetX + (Length / 2);
                ConnectionPointY = offsetY;
            }

            if (_visible && blockType != LineBlockTypeEnum.Simple)
            {
                terminalPolygon.Geometry = GeometryBuilder.Rectangle(terminalOffsetX, terminalOffsetY, rectHeight, rectWidth);

                result.Add(terminalPolygon);

                result.Add(
                    new DiagramObject()
                {
                    Style    = "LinkBlockTerminalConnectionPoint",
                    Geometry = GeometryBuilder.Point(ConnectionPointX, ConnectionPointY)
                }
                    );
            }

            return(result);
        }
    }
Beispiel #20
0
        /// <summary>
        /// Persist the <see cref="DiagramObject"/> containment tree to the ORM layer. Update if it already exists.
        /// This is typically used during the import of existing data to the Database.
        /// </summary>
        /// <param name="transaction">
        /// The current <see cref="NpgsqlTransaction"/> to the database.
        /// </param>
        /// <param name="partition">
        /// The database partition (schema) where the requested resource will be stored.
        /// </param>
        /// <param name="diagramObject">
        /// The <see cref="DiagramObject"/> instance to persist.
        /// </param>
        /// <returns>
        /// True if the persistence was successful.
        /// </returns>
        private bool UpsertContainment(NpgsqlTransaction transaction, string partition, DiagramObject diagramObject)
        {
            var results = new List <bool>();

            foreach (var bounds in this.ResolveFromRequestCache(diagramObject.Bounds))
            {
                results.Add(this.BoundsService.UpsertConcept(transaction, partition, bounds, diagramObject));
            }

            foreach (var diagramElement in this.ResolveFromRequestCache(diagramObject.DiagramElement))
            {
                results.Add(this.DiagramElementService.UpsertConcept(transaction, partition, diagramElement, diagramObject));
            }

            foreach (var localStyle in this.ResolveFromRequestCache(diagramObject.LocalStyle))
            {
                results.Add(this.LocalStyleService.UpsertConcept(transaction, partition, localStyle, diagramObject));
            }

            return(results.All(x => x));
        }
Beispiel #21
0
        public List <DiagramObject> CreateDiagramObjects(double offsetX, double offsetY, LineBlockTypeEnum blockType)
        {
            if (blockType == LineBlockTypeEnum.Simple)
            {
                _portThickness = 0;
            }

            List <DiagramObject> result = new List <DiagramObject>();

            var portOffsetX = offsetX;
            var portOffsetY = offsetY;

            // Create port diagram object
            var portPolygon = new DiagramObject();

            if (_refClass != null)
            {
                portPolygon.IdentifiedObject = new IdentifiedObjectReference()
                {
                    RefId = _refId, RefClass = _refClass
                }
            }
            ;

            if (_style != null)
            {
                portPolygon.Style = _style;
            }
            else
            {
                portPolygon.Style = "BlockPort";
            }

            var rectWidth  = IsVertical ? _portThickness : Length;
            var rectHeight = IsVertical ? Length : _portThickness;

            PortStartX = offsetX;
            PortStartY = offsetY;
            PortEndX   = IsVertical ? PortStartX : PortStartX + Length;
            PortEndY   = IsVertical ? PortStartY + Length : PortStartY;

            if (_side == BlockSideEnum.North)
            {
                portOffsetY -= _portThickness; // We need to start on lover y, because we're in the top
            }
            else if (_side == BlockSideEnum.East)
            {
                portOffsetX -= _portThickness;
            }

            if (blockType != LineBlockTypeEnum.Simple)
            {
                portPolygon.Geometry = GeometryBuilder.Rectangle(portOffsetX, portOffsetY, rectHeight, rectWidth);

                result.Add(portPolygon);
            }


            // Create terminal diagram objects
            double terminalX = offsetX;
            double terminalY = offsetY;

            if (_side == BlockSideEnum.Vest || _side == BlockSideEnum.East)
            {
                terminalY += _portMargin;
            }
            else if (_side == BlockSideEnum.North || _side == BlockSideEnum.South)
            {
                terminalX += _portMargin;
            }

            foreach (var terminal in _terminals)
            {
                double xStep = 1;
                double yStep = 1;

                if (_side == BlockSideEnum.Vest || _side == BlockSideEnum.East)
                {
                    // goes up y
                    xStep = 0;
                    yStep = terminal.Length + _spaceBetweenTerminals;
                }

                if (_side == BlockSideEnum.North || _side == BlockSideEnum.South)
                {
                    // goes right along x
                    xStep = terminal.Length + _spaceBetweenTerminals;
                    yStep = 0;
                }

                result.AddRange(terminal.CreateDiagramObjects(terminalX, terminalY, blockType));

                terminalX += xStep;
                terminalY += yStep;
            }

            return(result);
        }
Beispiel #22
0
 private EADiagramObject(DiagramObject native)
 {
     _native = native;
 }
Beispiel #23
0
 /// <summary>
 /// Initializes a new instance of the <see cref="NamedThingDiagramContentItem"/> class.
 /// </summary>
 /// <param name="diagramThing">
 /// The diagramThing contained</param>
 /// <param name="container">
 /// The view model container of kind <see cref="IDiagramEditorViewModel"/></param>
 public NamedThingDiagramContentItem(DiagramObject diagramThing, IDiagramEditorViewModel container)
     : base(diagramThing, container)
 {
     this.UpdateProperties();
 }
Beispiel #24
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DiagramObjectViewModel"/> class
 /// </summary>
 /// <param name="diagramObject">The <see cref="DiagramObject"/></param>
 /// <param name="session">The current <see cref="ISession"/></param>
 /// <param name="containerViewModel">The container view-model</param>
 public DiagramObjectViewModel(DiagramObject diagramObject, ISession session, DiagramEditorViewModel containerViewModel) : base(diagramObject, session, containerViewModel)
 {
     this.containerViewModel = containerViewModel;
     this.UpdateProperties();
     this.WhenAnyValue(x => x.Height, x => x.Width, x => x.Position).Subscribe(x => this.SetDirty());
 }