Exemplo n.º 1
0
        /// <summary>
        /// The standard constructor.  To construct a new instance use the static Create method to enable
        /// two pass creation
        /// </summary>
        protected GrowableNode()
        {
            // Set the Width. The height is set when SetVerticalChunkCount is called.
            Width = 40;

            // Add the fixed terminals
            AddComponent(new NodeTerminal(Direction.Output, PFTypes.Void, "element", TerminalHotspots.CreateOutputTerminalHotspot(TerminalSize.Small, Width, 0)));
            this.SetVerticalChunkCount(1, GrowNodeResizeDirection.Bottom);
            this.RecalculateNodeHeight();
        }
Exemplo n.º 2
0
        private void SetListViewGeometry()
        {
            var terminals = FixedTerminals.OfType <NodeTerminal>().ToArray();

            terminals[0].Hotspot = TerminalHotspots.CreateOutputTerminalHotspot(TerminalSize.Small, Width, 0u);
            uint index = 0u;

            foreach (Terminal terminal in terminals.Skip(1))
            {
                terminal.Hotspot = TerminalHotspots.CreateListViewInputTerminalHotspot(ListViewHeaderHeight, index);
                ++index;
            }
            Height = ListViewHeaderHeight + index * StockDiagramGeometries.LargeTerminalHeight + ListViewFooterHeight;
        }
Exemplo n.º 3
0
        /// <summary>
        /// Performs node initialization
        /// </summary>
        /// <param name="info">Information about why the node is being created</param>
        protected override void Init(IElementCreateInfo info)
        {
            base.Init(info);
            Width  = 80;
            Height = 50;

            _input1Terminal = new NodeTerminal(Direction.Unknown, NITypes.Void, "Input 1", TerminalHotspots.CreateInputTerminalHotspot(TerminalSize.Small, 0));
            _input2Terminal = new NodeTerminal(Direction.Unknown, NITypes.Void, "Input 1", TerminalHotspots.CreateInputTerminalHotspot(TerminalSize.Small, 3));

            // We are using a custom terminal for our outputs so that the wires of these terminals will be spline wires.
            _output1Terminal = new SplineWireTerminal(Direction.Unknown, NITypes.Void, "Output 1", TerminalHotspots.CreateOutputTerminalHotspot(TerminalSize.Small, Width, 0));
            _output2Terminal = new SplineWireTerminal(Direction.Unknown, NITypes.Void, "Output 1", TerminalHotspots.CreateOutputTerminalHotspot(TerminalSize.Small, Width, 3));

            OnComponentInserted(_input1Terminal);
            OnComponentInserted(_input2Terminal);
            OnComponentInserted(_output1Terminal);
            OnComponentInserted(_output2Terminal);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Performs node initialization
        /// </summary>
        /// <param name="info">Information about why the node is being created</param>
        protected override void Init(IElementCreateInfo info)
        {
            base.Init(info);
            Width  = StockDiagramGeometries.StandardNodeWidth;
            Height = StockDiagramGeometries.StandardNodeHeight;

            _inputTerminal  = new NodeTerminal(Direction.Input, PFTypes.Double, "Input", TerminalHotspots.CreateInputTerminalHotspot(TerminalSize.Small, 0));
            _outputTerminal = new NodeTerminal(Direction.Output, PFTypes.Double, "Result", TerminalHotspots.CreateOutputTerminalHotspot(TerminalSize.Small, Width, 0));
            OnComponentInserted(_inputTerminal);
            OnComponentInserted(_outputTerminal);
        }
Exemplo n.º 5
0
 /// <summary>
 /// Performs node initialization
 /// </summary>
 /// <param name="info">Information about why the node is being created</param>
 protected override void Init(IElementCreateInfo info)
 {
     base.Init(info);
     Width            = StockDiagramGeometries.StandardNodeWidth;
     Height           = StockDiagramGeometries.StandardNodeHeight;
     _input1Terminal  = new NodeTerminal(Direction.Unknown, NITypes.Void, "Input 1", TerminalHotspots.CreateInputTerminalHotspot(TerminalSize.Small, 0));
     _input2Terminal  = new NodeTerminal(Direction.Unknown, NITypes.Void, "Input 1", TerminalHotspots.CreateInputTerminalHotspot(TerminalSize.Small, 3));
     _output1Terminal = new NodeTerminal(Direction.Unknown, NITypes.Void, "Output 1", TerminalHotspots.CreateOutputTerminalHotspot(TerminalSize.Small, Width, 0));
     _output2Terminal = new NodeTerminal(Direction.Unknown, NITypes.Void, "Output 1", TerminalHotspots.CreateOutputTerminalHotspot(TerminalSize.Small, Width, 3));
     OnComponentInserted(_input1Terminal);
     OnComponentInserted(_input2Terminal);
     OnComponentInserted(_output1Terminal);
     OnComponentInserted(_output2Terminal);
 }
Exemplo n.º 6
0
        /// <summary>
        /// This method is a post-parser fixup method for configuring <see cref="MatchStructureBase"/>s on this structure
        /// after the rest of the structure and its subcomponents is parsed.
        /// </summary>
        /// <remarks>This was copied from CaseStructure.cs in VI. This exists because the serializer for
        /// StackedStructureTunnel terminals does not record things like the Role of each terminal, since they
        /// can be recovered from which diagram the terminal is associated with. This is the method that
        /// does that reassociation; it has to run after the tunnel and all associated Diagrams have been parsed.</remarks>
        private static void FixupMatchStructureBase(Element element, IElementServices services)
        {
            var matchStructure = (MatchStructureBase)element;

            // EnsureView will make sure all nested diagrams are sized consistently.  This shouldn't technically be necessary if everything was
            // persisted correctly.  However, there were some previous bugs where case diagram bounds weren't persisted correctly.  Also, we may
            // eventually decide not to persist bounds for nested diagrams and just calculate them from the owning structure.  For that to work,
            // we'll always need to call EnsureView.
            matchStructure.EnsureView(EnsureViewHints.Bounds);

            MatchStructureSelectorBase selector = matchStructure.Components.OfType <MatchStructureSelectorBase>().FirstOrDefault();

            if (selector != null)
            {
                var selectorOuterTerminal = selector.BorderNodeTerminals.First();
                selectorOuterTerminal.Primary   = true;
                selectorOuterTerminal.Direction = Direction.Input;
                selectorOuterTerminal.Role      = BorderNodeTerminalRole.Outer;
                selectorOuterTerminal.Hotspot   = TerminalHotspots.Input1;
                matchStructure.AddTerminalAlias(selectorOuterTerminal);

                foreach (var pair in matchStructure.NestedDiagrams.Zip(selector.BorderNodeTerminals.Skip(1)))
                {
                    var selectorInnerTerminal = pair.Value;
                    selectorInnerTerminal.Primary   = true;
                    selectorInnerTerminal.Direction = Direction.Output;
                    selectorInnerTerminal.Role      = BorderNodeTerminalRole.Inner;
                    selectorInnerTerminal.Hotspot   = TerminalHotspots.CreateOutputTerminalHotspot(TerminalSize.Small, selector.Width, 0u);
                    NestedDiagram nestedDiagram = pair.Key;
                    nestedDiagram.AddTerminalAlias(selectorInnerTerminal);
                }
            }

            List <MatchStructureTunnelBase> tunnels = matchStructure.BorderNodes.OfType <MatchStructureTunnelBase>().ToList();

            foreach (var tunnel in tunnels)
            {
                if (tunnel.Terminals.Count() == matchStructure.NestedDiagrams.Count() + 1)
                {
                    var outerTerm = tunnel.BorderNodeTerminals.First();
                    outerTerm.Primary = true;
                    outerTerm.Role    = BorderNodeTerminalRole.Outer;
                    if (tunnel.TerminalIdentifiersMatchAliasParent)
                    {
                        matchStructure.AddTerminalAlias(outerTerm);
                    }

                    foreach (var terminalDiagramPair in tunnel.BorderNodeTerminals.Skip(1).Zip(matchStructure.NestedDiagrams))
                    {
                        BorderNodeTerminal innerTerminal = terminalDiagramPair.Key;
                        innerTerminal.Primary = true;
                        innerTerminal.Role    = BorderNodeTerminalRole.Inner;
                        NestedDiagram diagram = terminalDiagramPair.Value;
                        diagram.AddTerminalAlias(innerTerminal);
                    }
                }
                else
                {
                    throw new InvalidParseException("Attempting to setup tunnels on MatchStructureTunnelBase ID=" + matchStructure.Identifier.ToParsableString() +
                                                    " at post-parse fixup, MatchStructureTunnelBase has malformed tunnel without enough terminals.");
                }

                // This correctly places the hotspots of the tunnels so that wires that are about to be connected to them
                // during parsing will have the accurate positions and not get diagonal wires
                tunnel.EnsureView(EnsureViewHints.Bounds);
            }
        }
        /// <summary>
        /// Performs node initialization
        /// </summary>
        /// <param name="info">Information about why the node is being created</param>
        protected override void Init(IElementCreateInfo info)
        {
            base.Init(info);
            Width  = StockDiagramGeometries.StandardNodeWidth;
            Height = StockDiagramGeometries.StandardNodeHeight;

            _inputNamesTerminal     = new NodeTerminal(Direction.Input, PFTypes.StringArray1D, "names", TerminalHotspots.Input1);
            _inputExtraNameTerminal = new NodeTerminal(Direction.Input, PFTypes.String, "extra name", TerminalHotspots.Input2);
            _outputTerminal         = new NodeTerminal(Direction.Output, PFTypes.Int32, "length", TerminalHotspots.CreateOutputTerminalHotspot(TerminalSize.Small, Width, 0));
            OnComponentInserted(_inputNamesTerminal);
            OnComponentInserted(_inputExtraNameTerminal);
            OnComponentInserted(_outputTerminal);
        }
Exemplo n.º 8
0
        /// <summary>
        /// Performs node initialization
        /// </summary>
        /// <param name="info">Information about why the node is being created</param>
        protected override void Init(IElementCreateInfo info)
        {
            base.Init(info);
            Width  = 80;
            Height = 50;

            _input1Terminal  = new NodeTerminal(Direction.Unknown, PFTypes.Void, "Input 1", TerminalHotspots.CreateInputTerminalHotspot(TerminalSize.Small, 0));
            _input2Terminal  = new NodeTerminal(Direction.Unknown, PFTypes.Void, "Input 1", TerminalHotspots.CreateInputTerminalHotspot(TerminalSize.Small, 3));
            _output1Terminal = new NodeTerminal(Direction.Unknown, PFTypes.Void, "Output 1", TerminalHotspots.CreateOutputTerminalHotspot(TerminalSize.Small, Width, 0));
            _output2Terminal = new NodeTerminal(Direction.Unknown, PFTypes.Void, "Output 1", TerminalHotspots.CreateOutputTerminalHotspot(TerminalSize.Small, Width, 3));
            OnComponentInserted(_input1Terminal);
            OnComponentInserted(_input2Terminal);
            OnComponentInserted(_output1Terminal);
            OnComponentInserted(_output2Terminal);
        }