예제 #1
0
        private static void TranslateAssociationConnectors(
            AssociationConnector dslAssociationConnector, DesignerModel.AssociationConnector modelAssociationConnector,
            IList <ViewModelDiagram.ShapeElement> shapesToAutoLayout)
        {
            dslAssociationConnector.ManuallyRouted = modelAssociationConnector.ManuallyRouted.Value;
            // if the EdgePoint values is an empty collection or connectors are not manually routed, add the shape element to the collections that will be autolayout.
            if (modelAssociationConnector.ManuallyRouted.Value == false ||
                modelAssociationConnector.ConnectorPoints.Count == 0)
            {
                if (shapesToAutoLayout.Contains(dslAssociationConnector) == false)
                {
                    shapesToAutoLayout.Add(dslAssociationConnector);
                }
            }
            else
            {
                var collection = new ViewModelDiagram.EdgePointCollection();
                foreach (var connectorPoint in modelAssociationConnector.ConnectorPoints)
                {
                    collection.Add(
                        new ViewModelDiagram.EdgePoint(connectorPoint.PointX.Value, connectorPoint.PointY.Value, VGPointType.Normal));
                }

                if (AreEdgePointsIdentical(dslAssociationConnector.EdgePoints, collection) == false)
                {
                    dslAssociationConnector.EdgePoints = collection;
                }
            }
        }
예제 #2
0
        private static bool AreEdgePointsIdentical(
            ViewModelDiagram.EdgePointCollection collection1, ViewModelDiagram.EdgePointCollection collection2)
        {
            Debug.Assert(collection1 != null, "EdgeCollection1 is null");
            Debug.Assert(collection2 != null, "EdgeCollection2 is null");

            if (collection1 == null ||
                collection2 == null)
            {
                throw new ArgumentException("One of the passed parameter is null");
            }

            if (collection1.Count != collection2.Count)
            {
                return(false);
            }

            for (var i = 0; i < collection1.Count; i++)
            {
                if (collection1[i].Point != collection2[i].Point)
                {
                    return(false);
                }
            }
            return(true);
        }
        private static void TranslateAssociationConnectors(
            AssociationConnector dslAssociationConnector, DesignerModel.AssociationConnector modelAssociationConnector,
            IList<ViewModelDiagram.ShapeElement> shapesToAutoLayout)
        {
            dslAssociationConnector.ManuallyRouted = modelAssociationConnector.ManuallyRouted.Value;
            // if the EdgePoint values is an empty collection or connectors are not manually routed, add the shape element to the collections that will be autolayout.
            if (modelAssociationConnector.ManuallyRouted.Value == false
                || modelAssociationConnector.ConnectorPoints.Count == 0)
            {
                if (shapesToAutoLayout.Contains(dslAssociationConnector) == false)
                {
                    shapesToAutoLayout.Add(dslAssociationConnector);
                }
            }
            else
            {
                var collection = new ViewModelDiagram.EdgePointCollection();
                foreach (var connectorPoint in modelAssociationConnector.ConnectorPoints)
                {
                    collection.Add(
                        new ViewModelDiagram.EdgePoint(connectorPoint.PointX.Value, connectorPoint.PointY.Value, VGPointType.Normal));
                }

                if (AreEdgePointsIdentical(dslAssociationConnector.EdgePoints, collection) == false)
                {
                    dslAssociationConnector.EdgePoints = collection;
                }
            }
        }