Esempio n. 1
0
        public Operator(Guid id, MetaOperator metaOp, List <OperatorPart> inputs, List <OperatorPart> outputs,
                        List <Operator> internalOps, List <OperatorPart> internalParts)
        {
            ID            = id;
            Definition    = metaOp;
            Inputs        = inputs;
            Outputs       = outputs;
            InternalOps   = internalOps;
            InternalParts = internalParts;
            Name          = "";
            Position      = new Point(100, 100);
            Width         = 75; // This should be Grid.Size * 3

            UpdateOutputIndices();

            // Forward Modified-events of parameters as Manipulated-Event
            foreach (var opPart in Inputs.Union(Outputs).Union(InternalParts))
            {
                opPart.Parent            = this;
                opPart.ManipulatedEvent += (o, a) => EventExt.Raise(ModifiedEvent, this, EventArgs.Empty);
            }

            foreach (var op in InternalOps)
            {
                op.Parent = this;
            }
            ConnectTypeChangedHanderWith(Inputs);
        }
Esempio n. 2
0
        internal void RemoveOperatorInternal(Operator op, bool disposeOpResources)
        {
            InternalOps.Remove(op);

            EventExt.Raise(OperatorRemovedEvent, this, new OperatorChangedEventArgs(op));

            if (disposeOpResources)
            {
                op.Dispose(); // clean up all resources locked by op
            }
        }
Esempio n. 3
0
        internal void InsertInput(int index, OperatorPart input)
        {
            if ((index < 0) || (index > Inputs.Count))
            {
                throw new IndexOutOfRangeException();
            }

            Inputs.Insert(index, input);
            input.Parent = this;

            EventExt.Raise(InputAddedEvent, this, new OperatorPartChangedEventArgs(input));
        }
Esempio n. 4
0
        internal void InsertOutput(int index, OperatorPart output)
        {
            if ((index < 0) || (index > Outputs.Count))
            {
                throw new IndexOutOfRangeException();
            }

            Outputs.Insert(index, output);
            output.Parent = this;
            UpdateOutputIndices();

            EventExt.Raise(OutputAddedEvent, this, new OperatorPartChangedEventArgs(output));
        }
Esempio n. 5
0
        internal void RemoveInputInternal(OperatorPart input)
        {
            var inputOp  = input.Parent;
            var parentOp = inputOp.Parent;

            // remove possible connection to this input in parent op
            if (parentOp != null)
            {
                while (input.Connections.Count > 0)
                {
                    var sourceOpPart = input.Connections[0];
                    var sourceOp     = sourceOpPart.Parent;
                    var connection   = new Connection(sourceOp, sourceOpPart, this, input, 0);
                    parentOp.RemoveConnection(connection);
                }
            }

            Inputs.Remove(input);
            EventExt.Raise(InputRemovedEvent, this, new OperatorPartChangedEventArgs(input));
        }
Esempio n. 6
0
        internal void RemoveOutputInternal(OperatorPart output)
        {
            var outputOp = this;
            var parentOp = outputOp.Parent;

            // remove possible connection from this output in parent op
            if (parentOp != null)
            {
                var connectionsToRemove = (from con in parentOp.Connections
                                           where con.SourceOp == outputOp
                                           where con.SourceOpPart == output
                                           select con).ToList();
                foreach (var connection in connectionsToRemove)
                {
                    parentOp.RemoveConnection(connection);
                }
            }

            Outputs.Remove(output);
            UpdateOutputIndices();
            EventExt.Raise(OutputRemovedEvent, this, new OperatorPartChangedEventArgs(output));
        }
Esempio n. 7
0
 internal void TriggerOperatorPartStateChanged(OperatorPartStateChangedEventArgs args)
 {
     EventExt.Raise(OperatorPartStateChangedEvent, this, args);
 }
Esempio n. 8
0
 protected void TriggerDisabledEvent()
 {
     EventExt.Raise(DisabledEvent, this, EventArgs.Empty);
 }
Esempio n. 9
0
 internal void TriggerVisibleChanged(VisibleChangedEventArgs args)
 {
     EventExt.Raise(VisibleChangedEvent, this, args);
 }
Esempio n. 10
0
 internal void TriggerWidthChanged(WidthChangedEventArgs args)
 {
     EventExt.Raise(WidthChangedEvent, this, args);
 }
Esempio n. 11
0
 internal void TriggerPositionChanged(PositionChangedEventArgs args)
 {
     EventExt.Raise(PositionChangedEvent, this, args);
 }
Esempio n. 12
0
 private void TriggerConnectionRemoved(ConnectionChangedEventArgs args)
 {
     EventExt.Raise(ConnectionRemovedEvent, this, args);
 }
Esempio n. 13
0
 internal void AddOperator(Operator op)
 {
     InternalOps.Add(op);
     op.Parent = this;
     EventExt.Raise(OperatorAddedEvent, this, new OperatorChangedEventArgs(op));
 }