Beispiel #1
0
        private FilterShape _MakeFilterShape(IOutputFilterModuleInstance filter)
        {
            FilterShape filterShape = (FilterShape)project.ShapeTypes["FilterShape"].CreateInstance();

            filterShape.Title = filter.Descriptor.TypeName;
            filterShape.SecurityDomainName = SECURITY_DOMAIN_MOVABLE_SHAPE_WITH_CONNECTIONS;
            filterShape.FillStyle          = project.Design.FillStyles["Filter"];
            filterShape.SetFilterInstance(filter);

            diagramDisplay.InsertShape(filterShape);
            diagramDisplay.Diagram.Shapes.SetZOrder(filterShape, 10);
            // Z Order of 10; should be above other elements/outputs, but under lines
            diagramDisplay.Diagram.AddShapeToLayers(filterShape, _visibleLayer.Id);

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

            if (_filterToFilterShape.ContainsKey(filter))
            {
                throw new Exception("filter->shape map already has an entry when it shouldn't");
            }
            _filterToFilterShape[filter] = filterShape;

            return(filterShape);
        }
Beispiel #2
0
        private void displayDiagram_ShapeDoubleClick(object sender, DiagramPresenterShapeClickEventArgs e)
        {
            var shape = (FilterSetupShapeBase)e.Shape;

            // workaround: only modify the shape if it's currently selected. The diagram likes to
            // send click events to all shapes under the mouse, even if they're not active.
            if (!diagramDisplay.SelectedShapes.Contains(shape))
            {
                return;
            }

            if (shape is NestingSetupShape)
            {
                NestingSetupShape s = (shape as NestingSetupShape);
                s.Expanded = !s.Expanded;
            }
            else if (shape is FilterShape)
            {
                FilterShape filterShape = shape as FilterShape;
                filterShape.RunSetup();

                //changes were made to the filter so set _changesMade
                _changesMade = true;
            }

            if (shape is ElementNodeShape)
            {
                _ResizeAndPositionElementShapes(_elementsXPosition);
            }

            if (shape is ControllerShape)
            {
                _ResizeAndPositionControllerShapes(_controllersXPosition);
            }
        }
        public override Shape Clone()
        {
            FilterShape result = new FilterShape(Type, (Template)null);

            result.CopyFrom(this);
            return(result);
        }
Beispiel #4
0
        private void _UpdateFilterPositionDataForFilter(FilterShape filterShape)
        {
            FilterSetupFormShapePosition position = new FilterSetupFormShapePosition();

            position.xPositionProportion = (double)filterShape.X / _previousDiagramWidth;
            position.yPosition           = filterShape.Y;

            _applicationData.FilterSetupFormShapePositions[filterShape.FilterInstance.InstanceId] = position;
        }
Beispiel #5
0
        private FilterShape _CreateShapeFromFilter(IOutputFilterModuleInstance filter)
        {
            FilterShape filterShape = _MakeFilterShape(filter);

            if (filterShape != null)
            {
                _filterShapes.Add(filterShape);
            }
            return(filterShape);
        }
 public override void CopyFrom(Shape source)
 {
     base.CopyFrom(source);
     if (source is FilterShape)
     {
         FilterShape src = (FilterShape)source;
         _filterInstance = src.FilterInstance;
         _CopyControlPointsFrom(src);
     }
 }
Beispiel #7
0
        public IEnumerable <FilterShape> DuplicateFilterInstancesToShapes(
            IEnumerable <IOutputFilterModuleInstance> sourceInstances,
            int numberOfCopies,
            Point?startPosition = null,
            double horizontalPositionProportion = 0.5
            )
        {
            if (sourceInstances == null)
            {
                return(null);
            }

            Point pos;

            if (startPosition == null)
            {
                pos = new Point();
                int shapesWidth = diagramDisplay.Width - (2 * diagramDisplay.GetDiagramPosition().X);
                pos.X = (int)(shapesWidth * horizontalPositionProportion);
                pos.Y = diagramDisplay.GetDiagramOffset().Y + (diagramDisplay.Height / 4);
            }
            else
            {
                pos = (Point)startPosition;
            }

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

            for (int i = 0; i < numberOfCopies; i++)
            {
                foreach (IOutputFilterModuleInstance instance in sourceInstances)
                {
                    FilterShape newShape = _CreateNewFilterInstanceAndShape(instance.TypeId, false, instance.ModuleData);
                    newShape.ModuleDataUpdated();

                    newShape.X = pos.X;
                    newShape.Y = pos.Y;

                    pos.Y += newShape.Height + SHAPE_VERTICAL_SPACING;

                    // save the new shape position in the application data references
                    FilterSetupFormShapePosition position = new FilterSetupFormShapePosition();
                    position.xPositionProportion = (double)newShape.X / _previousDiagramWidth;
                    position.yPosition           = newShape.Y;
                    _applicationData.FilterSetupFormShapePositions[newShape.FilterInstance.InstanceId] = position;

                    result.Add(newShape);
                }
            }

            //assume we made changes since we added shapes
            _changesMade = true;
            return(result);
        }
Beispiel #8
0
 private void cachedRepository_ShapesUpdated(object sender, RepositoryShapesEventArgs e)
 {
     foreach (Shape shape in e.Shapes)
     {
         FilterShape filterShape = shape as FilterShape;
         if (filterShape != null)
         {
             _UpdateFilterPositionDataForFilter(filterShape);
         }
     }
 }
Beispiel #9
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;
        }
        private FilterShape _CreateNewFilterInstanceAndShape(Guid filterTypeId, bool defaultLayout, IModuleDataModel dataModelToCopy = null)
        {
            IOutputFilterModuleInstance moduleInstance = ApplicationServices.Get <IOutputFilterModuleInstance>(filterTypeId);

            if (dataModelToCopy != null)
            {
                moduleInstance.ModuleData = dataModelToCopy.Clone();
            }
            FilterShape shape = _CreateShapeFromFilter(moduleInstance);

            VixenSystem.Filters.AddFilter(moduleInstance);

            shape.Width  = SHAPE_FILTERS_WIDTH;
            shape.Height = SHAPE_FILTERS_HEIGHT;

            if (defaultLayout)
            {
                shape.X = (diagramDisplay.Width / 2) - diagramDisplay.GetDiagramPosition().X;
                shape.Y = diagramDisplay.GetDiagramOffset().Y + (diagramDisplay.Height / 2);
            }

            return(shape);
        }
 public override Shape Clone()
 {
     FilterShape result = new FilterShape(Type, (Template) null);
     result.CopyFrom(this);
     return result;
 }
        private void _UpdateFilterPositionDataForFilter(FilterShape filterShape)
        {
            FilterSetupFormShapePosition position = new FilterSetupFormShapePosition();
            position.xPositionProportion = (double)filterShape.X / _previousDiagramWidth;
            position.yPosition = filterShape.Y;

            _applicationData.FilterSetupFormShapePositions[filterShape.FilterInstance.InstanceId] = position;
        }