// This is a horrible abomination of a function and purpose. When a shape is duplicated, the control
		// point positions aren't properly copied by the base classes. When we copy the type specific data
		// which gives the DataFlowComponent (in subclasses), the control points are regenerated. However,
		// the problem is that they are generated at a 0-offset, rather than the position-relative offset.
		// So, the easiest way to fix it is just to copy the correct positions from the source shape to update
		// them correctly. Nasty.
		//
		// (Ideally, we would have the NShape system properly transform the points when it's used; but I can't
		// figure out at what point the generated points get transformed from shape-relative points into the
		// absolute position points).
		//
		// (Because these points are (incorrectly) generated when copying the DataFlowComponent in subclasses,
		// this needs to be called AFTER all the other copying is done, so will need to be called in each CopyFrom.
		protected void _CopyControlPointsFrom(FilterSetupShapeBase source)
		{
			controlPoints = new Point[ControlPointCount];
			for (int i = 0; i < source.ControlPoints.Length; i++) {
				controlPoints[i] = source.ControlPoints[i];
			}
		}
Beispiel #2
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));
        }
 // This is a horrible abomination of a function and purpose. When a shape is duplicated, the control
 // point positions aren't properly copied by the base classes. When we copy the type specific data
 // which gives the DataFlowComponent (in subclasses), the control points are regenerated. However,
 // the problem is that they are generated at a 0-offset, rather than the position-relative offset.
 // So, the easiest way to fix it is just to copy the correct positions from the source shape to update
 // them correctly. Nasty.
 //
 // (Ideally, we would have the NShape system properly transform the points when it's used; but I can't
 // figure out at what point the generated points get transformed from shape-relative points into the
 // absolute position points).
 //
 // (Because these points are (incorrectly) generated when copying the DataFlowComponent in subclasses,
 // this needs to be called AFTER all the other copying is done, so will need to be called in each CopyFrom.
 protected void _CopyControlPointsFrom(FilterSetupShapeBase source)
 {
     controlPoints = new Point[ControlPointCount];
     for (int i = 0; i < source.ControlPoints.Length; i++)
     {
         controlPoints[i] = source.ControlPoints[i];
     }
 }
 public override void CopyFrom(Shape source)
 {
     base.CopyFrom(source);
     if (source is FilterSetupShapeBase)
     {
         FilterSetupShapeBase src = (FilterSetupShapeBase)source;
     }
 }
 private void _LookupAndConnectShapeToSource(FilterSetupShapeBase shape)
 {
     if (shape.DataFlowComponent != null && shape.DataFlowComponent.Source != null)
     {
         IDataFlowComponentReference source = shape.DataFlowComponent.Source;
         if (!_dataFlowComponentToShapes.ContainsKey(source.Component))
         {
             VixenSystem.Logging.Error("CreateConnectionsFromExistingLinks: can't find shape for source " + source.Component + source.OutputIndex);
             return;
         }
         List <FilterSetupShapeBase> sourceShapes = _dataFlowComponentToShapes[source.Component];
         // TODO: deal with multiple instances of the source data flow component: eg. a element existing as
         // multiple shapes (currently, we'll assume it's the first shape in the list)
         ConnectShapes(sourceShapes.First(), source.OutputIndex, shape);
     }
 }
Beispiel #6
0
        private ElementNodeShape _MakeElementNodeShape(ElementNode node, int zOrder)
        {
            ElementNodeShape shape = (ElementNodeShape)project.ShapeTypes["ElementNodeShape"].CreateInstance();

            shape.SetElementNode(node);
            shape.Title = node.Name;
            diagramDisplay.InsertShape(shape);
            diagramDisplay.Diagram.Shapes.SetZOrder(shape, zOrder);
            diagramDisplay.Diagram.AddShapeToLayers(shape, _visibleLayer.Id);

            if (!_elementNodeToElementShapes.ContainsKey(node))
            {
                _elementNodeToElementShapes[node] = new List <ElementNodeShape>();
            }
            _elementNodeToElementShapes[node].Add(shape);

            if (shape.DataFlowComponent != null)
            {
                if (!_dataFlowComponentToShapes.ContainsKey(shape.DataFlowComponent))
                {
                    _dataFlowComponentToShapes[shape.DataFlowComponent] = new List <FilterSetupShapeBase>();
                }
                _dataFlowComponentToShapes[shape.DataFlowComponent].Add(shape);
            }

            if (node.Children.Any())
            {
                foreach (var child in node.Children)
                {
                    FilterSetupShapeBase childSetupShapeBase = _MakeElementNodeShape(child, zOrder + 1);
                    shape.ChildFilterShapes.Add(childSetupShapeBase);
                }
                shape.SecurityDomainName = SECURITY_DOMAIN_FIXED_SHAPE_NO_CONNECTIONS;
                shape.FillStyle          = project.Design.FillStyles["ElementGroup"];
            }
            else
            {
                shape.SecurityDomainName = SECURITY_DOMAIN_FIXED_SHAPE_WITH_CONNECTIONS;
                shape.FillStyle          = project.Design.FillStyles["ElementLeaf"];
            }
            return(shape);
        }
Beispiel #7
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);
            }
        }
Beispiel #8
0
        private void _ResizeAndPositionNestingShape(FilterSetupShapeBase shape, int width, int x, int y, bool visible)
        {
            if (visible)
            {
                _ShowShape(shape);
            }
            else
            {
                _HideShape(shape);
            }

            if (visible && (shape is NestingSetupShape) && (shape as NestingSetupShape).Expanded &&
                (shape as NestingSetupShape).ChildFilterShapes.Count > 0)
            {
                int curY = y + SHAPE_GROUP_HEADER_HEIGHT;
                foreach (FilterSetupShapeBase childShape in (shape as NestingSetupShape).ChildFilterShapes)
                {
                    _ResizeAndPositionNestingShape(childShape, width - SHAPE_CHILD_WIDTH_REDUCTION, x, curY, true);
                    curY += childShape.Height + SHAPE_VERTICAL_SPACING;
                }
                shape.Width  = width;
                shape.Height = (curY - SHAPE_VERTICAL_SPACING + SHAPE_GROUP_FOOTER_HEIGHT) - y;
            }
            else
            {
                shape.Width  = width;
                shape.Height = SHAPE_ELEMENTS_HEIGHT;
                if (shape is NestingSetupShape)
                {
                    foreach (FilterSetupShapeBase childShape in (shape as NestingSetupShape).ChildFilterShapes)
                    {
                        _ResizeAndPositionNestingShape(childShape, width, x, y, false);
                    }
                }
            }
            shape.X = x;
            shape.Y = y + shape.Height / 2;
        }
Beispiel #9
0
 private void _ShowShape(FilterSetupShapeBase setupShapeBase)
 {
     diagramDisplay.Diagram.AddShapeToLayers(setupShapeBase, _visibleLayer.Id);
     diagramDisplay.Diagram.RemoveShapeFromLayers(setupShapeBase, _hiddenLayer.Id);
 }
		private void UpdateConnection(MouseState mouseState, FilterSetupShapeBase filterShape)
		{
			if (currentConnectionLine == null)
				throw new Exception("expecting to have a connection line when in CONNECT mode on drag!");

			bool connectionLineTargetConnected = false;

			if (filterShape != null) {
				ControlPointId point = filterShape.HitTest(mouseState.X, mouseState.Y, ControlPointCapabilities.Connect, 10);

				if (point != ControlPointId.Any && point != ControlPointId.None) {
					bool skipConnection = false;

					if (filterShape.GetTypeForControlPoint(point) != FilterSetupShapeBase.FilterShapeControlPointType.Input) {
						// Later on, if/when we support multiple inputs, we'll need to get an appropriate input. For now, there's only 1 option.
						if (filterShape.InputCount > 0) {
							point = filterShape.GetControlPointIdForInput(0);
						}
						else {
							skipConnection = true;
						}
					}

					FilterSetupShapeBase sourceShape =
						currentConnectionLine.GetConnectionInfo(ControlPointId.FirstVertex, null).OtherShape as FilterSetupShapeBase;

					// check to see if it's pointing at itself
					if (sourceShape == filterShape) {
						skipConnection = true;
					}

					// check to see if targeting this shape would create a circular dependency
					if (sourceShape != null &&
					    VixenSystem.DataFlow.CheckComponentSourceForCircularDependency(filterShape.DataFlowComponent,
					                                                                   sourceShape.DataFlowComponent)) {
						skipConnection = true;
					}

					if (!skipConnection) {
						if (currentConnectionLine.GetConnectionInfo(ControlPointId.LastVertex, null).OtherPointId != point ||
						    currentConnectionLine.GetConnectionInfo(ControlPointId.LastVertex, null).OtherShape != filterShape) {
							currentConnectionLine.Disconnect(ControlPointId.LastVertex);
							currentConnectionLine.Connect(ControlPointId.LastVertex, filterShape, point);
							currentConnectionLine.DestinationDataComponent = filterShape.DataFlowComponent;
						}

						connectionLineTargetConnected = true;
					}
				}
			}

			if (!connectionLineTargetConnected) {
				currentConnectionLine.Disconnect(ControlPointId.LastVertex);
				currentConnectionLine.MoveControlPointTo(ControlPointId.LastVertex, mouseState.X, mouseState.Y, ResizeModifiers.None);
				currentConnectionLine.DestinationDataComponent = null;
			}
		}
 private void _ShowShape(FilterSetupShapeBase setupShapeBase)
 {
     diagramDisplay.Diagram.AddShapeToLayers(setupShapeBase, _visibleLayer.Id);
     diagramDisplay.Diagram.RemoveShapeFromLayers(setupShapeBase, _hiddenLayer.Id);
 }
        private void _ResizeAndPositionNestingShape(FilterSetupShapeBase shape, int width, int x, int y, bool visible)
        {
            if (visible) {
                _ShowShape(shape);
            } else {
                _HideShape(shape);
            }

            if (visible && (shape is NestingSetupShape) && (shape as NestingSetupShape).Expanded &&
                (shape as NestingSetupShape).ChildFilterShapes.Count > 0)
            {
                int curY = y + SHAPE_GROUP_HEADER_HEIGHT;
                foreach (FilterSetupShapeBase childShape in (shape as NestingSetupShape).ChildFilterShapes) {
                    _ResizeAndPositionNestingShape(childShape, width - SHAPE_CHILD_WIDTH_REDUCTION, x, curY, true);
                    curY += childShape.Height + SHAPE_VERTICAL_SPACING;
                }
                shape.Width = width;
                shape.Height = (curY - SHAPE_VERTICAL_SPACING + SHAPE_GROUP_FOOTER_HEIGHT) - y;
            } else {
                shape.Width = width;
                shape.Height = SHAPE_ELEMENTS_HEIGHT;
                if (shape is NestingSetupShape) {
                    foreach (FilterSetupShapeBase childShape in (shape as NestingSetupShape).ChildFilterShapes) {
                        _ResizeAndPositionNestingShape(childShape, width, x, y, false);
                    }
                }
            }
            shape.X = x;
            shape.Y = y + shape.Height / 2;
        }
        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);
            }
        }
 private void _LookupAndConnectShapeToSource(FilterSetupShapeBase shape)
 {
     if (shape.DataFlowComponent != null && shape.DataFlowComponent.Source != null) {
         IDataFlowComponentReference source = shape.DataFlowComponent.Source;
         if (!_dataFlowComponentToShapes.ContainsKey(source.Component)) {
             VixenSystem.Logging.Error("CreateConnectionsFromExistingLinks: can't find shape for source " + source.Component + source.OutputIndex);
             return;
         }
         List<FilterSetupShapeBase> sourceShapes = _dataFlowComponentToShapes[source.Component];
         // TODO: deal with multiple instances of the source data flow component: eg. a element existing as
         // multiple shapes (currently, we'll assume it's the first shape in the list)
         ConnectShapes(sourceShapes.First(), source.OutputIndex, shape);
     }
 }
        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));
        }