Exemplo n.º 1
0
        public void ConnectShapes(FilterSetupShapeBase source, int sourceOutputIndex, FilterSetupShapeBase destination,
                                  bool removeExistingSource = true)
        {
            DataFlowConnectionLine line = (DataFlowConnectionLine)project.ShapeTypes["DataFlowConnectionLine"].CreateInstance();

            diagramDisplay.InsertShape(line);
            diagramDisplay.Diagram.Shapes.SetZOrder(line, 100);
            line.EndCapStyle        = project.Design.CapStyles.ClosedArrow;
            line.SecurityDomainName = SECURITY_DOMAIN_FIXED_SHAPE_NO_CONNECTIONS_DELETABLE;

            if (removeExistingSource)
            {
                IEnumerable <ShapeConnectionInfo> connectionInfos =
                    destination.GetConnectionInfos(destination.GetControlPointIdForInput(0), null);
                foreach (ShapeConnectionInfo ci in connectionInfos)
                {
                    if (!ci.IsEmpty && ci.OtherShape is DataFlowConnectionLine)
                    {
                        diagramDisplay.DeleteShape(ci.OtherShape, false);
                    }
                }
            }

            line.SourceDataFlowComponentReference = new DataFlowComponentReference(source.DataFlowComponent, sourceOutputIndex);
            line.DestinationDataComponent         = destination.DataFlowComponent;
            line.Connect(ControlPointId.FirstVertex, source, source.GetControlPointIdForOutput(sourceOutputIndex));
            line.Connect(ControlPointId.LastVertex, destination, destination.GetControlPointIdForInput(0));
        }
        public override Shape Clone()
        {
            DataFlowConnectionLine result = new DataFlowConnectionLine(Type, (Template)null);

            result.CopyFrom(this);
            return(result);
        }
 public override void CopyFrom(Shape source)
 {
     base.CopyFrom(source);
     if (source is DataFlowConnectionLine)
     {
         DataFlowConnectionLine src = (DataFlowConnectionLine)source;
         SourceDataFlowComponentReference = src.SourceDataFlowComponentReference;
         DestinationDataComponent         = src.DestinationDataComponent;
     }
 }
Exemplo n.º 4
0
        private void _DeleteShapes(IEnumerable <Shape> shapes)
        {
            foreach (var shape in shapes)
            {
                DataFlowConnectionLine line = shape as DataFlowConnectionLine;
                if (line != null)
                {
                    VixenSystem.DataFlow.ResetComponentSource(line.DestinationDataComponent);
                    _RemoveShape(line);
                }

                // we COULD use FilterSetupShapeBase, as all the operations below are generic.... but, we only want
                // to be able to delete filter shapes. We want to enforce all elements and outputs to be kept.
                FilterShape filterShape = shape as FilterShape;
                if (filterShape != null)
                {
                    ControlPointId pointId;

                    // go through all outputs for the filter, and check for connections to other shapes.
                    // For any that we find, remove them (ie. set the other shape source to null).
                    for (int i = 0; i < filterShape.OutputCount; i++)
                    {
                        pointId = filterShape.GetControlPointIdForOutput(i);
                        _RemoveDataFlowLinksFromShapePoint(filterShape, pointId);
                    }

                    // now check the source of the filter; if it's connected to anything, remove the connecting shape.
                    // (don't really need to reset the source for the filter, since we're removing it, but may as well
                    // anyway, just in case there's something else that's paying attention...)
                    pointId = filterShape.GetControlPointIdForInput(0);
                    _RemoveDataFlowLinksFromShapePoint(filterShape, pointId);

                    VixenSystem.Filters.RemoveFilter(filterShape.FilterInstance);
                    _RemoveShape(filterShape);
                }
            }

            //looks like we may have delted shapes so assume we made changes
            _changesMade = true;
        }
Exemplo n.º 5
0
        private void _RemoveDataFlowLinksFromShapePoint(FilterSetupShapeBase shape, ControlPointId controlPoint)
        {
            foreach (ShapeConnectionInfo ci in shape.GetConnectionInfos(controlPoint, null))
            {
                if (ci.OtherShape == null)
                {
                    continue;
                }

                DataFlowConnectionLine line = ci.OtherShape as DataFlowConnectionLine;
                if (line == null)
                {
                    throw new Exception("a shape was connected to something other than a DataFlowLine!");
                }

                if (line.DestinationDataComponent == null || line.SourceDataFlowComponentReference == null)
                {
                    throw new Exception("Can't remove a link that isn't fully connected!");
                }

                // if the line is connected with the given shape as the SOURCE, remove the unknown DESTINATION's
                // source (on the other end of the line). Otherwise, it (should) be that the given shape is the
                // destination; so reset it's source. If neither of these are true, freak out.
                if (line.GetConnectionInfo(ControlPointId.FirstVertex, null).OtherShape == shape)
                {
                    VixenSystem.DataFlow.ResetComponentSource(line.DestinationDataComponent);
                }
                else if (line.GetConnectionInfo(ControlPointId.LastVertex, null).OtherShape == shape)
                {
                    VixenSystem.DataFlow.ResetComponentSource(shape.DataFlowComponent);
                }
                else
                {
                    throw new Exception("Can't reset a link that has neither the source or destination for the given shape!");
                }

                _RemoveShape(line);
            }
        }
 public override Shape Clone()
 {
     DataFlowConnectionLine result = new DataFlowConnectionLine(Type, (Template) null);
     result.CopyFrom(this);
     return result;
 }