Ejemplo n.º 1
0
 /// <inheritdoc />
 public override int GetHashCode()
 {
     return(HashCodeHelpers.Combine(
                Source.GetHashCode(),
                Target.GetHashCode(),
                SourceTerminal.GetHashCode(),
                TargetTerminal.GetHashCode()));
 }
Ejemplo n.º 2
0
 public void PretendWireMoved()
 {
     SourceTerminal.Wiggle();
     SinkTerminal.Wiggle();
     OnModelPropertyChanged(nameof(X1));
     OnModelPropertyChanged(nameof(Y1));
     OnModelPropertyChanged(nameof(X2));
     OnModelPropertyChanged(nameof(Y2));
 }
Ejemplo n.º 3
0
 public virtual void DisconnectWire()
 {
     SourceTerminal.PropertyChanged -= SourceTerminalOnPropertyChanged;
     SinkTerminal.PropertyChanged   -= SinkTerminalOnPropertyChanged;
     SourceTerminal.DisconnectWire(this);
     SinkTerminal.Data = null;
     SinkTerminal.DisconnectWire(this);
     SourceTerminal = null;
     SinkTerminal   = null;
 }
Ejemplo n.º 4
0
 /// <inheritdoc />
 public virtual bool Equals(EquatableTermEdge <TVertex> other)
 {
     if (other is null)
     {
         return(false);
     }
     return(EqualityComparer <TVertex> .Default.Equals(Source, other.Source) &&
            EqualityComparer <TVertex> .Default.Equals(Target, other.Target) &&
            SourceTerminal.Equals(other.SourceTerminal) &&
            TargetTerminal.Equals(other.TargetTerminal));
 }
Ejemplo n.º 5
0
 /// <inheritdoc />
 public virtual bool Equals(EquatableTermEdge <TVertex> other)
 {
     if (other is null)
     {
         return(false);
     }
     return(Source.Equals(other.Source) &&
            Target.Equals(other.Target) &&
            SourceTerminal.Equals(other.SourceTerminal) &&
            TargetTerminal.Equals(other.TargetTerminal));
 }
Ejemplo n.º 6
0
        public WireModel(TerminalModel startTerminal, TerminalModel endTerminal)
        {
            if (startTerminal.Kind == endTerminal.Kind)
            {
                throw new ArgumentException("Wires require one input terminal and one output terminal");
            }

            SinkTerminal   = startTerminal.Kind == TerminalKind.Input ? startTerminal : endTerminal;
            SourceTerminal = startTerminal.Kind == TerminalKind.Output ? startTerminal : endTerminal;
            SourceTerminal.ConnectWire(this);
            SinkTerminal.ConnectWire(this);

            SetupTerminalPropertyChangeNotifications();
            UserWiredFromInput = startTerminal == SourceTerminal;
            SinkTerminal.Data  = SourceTerminal.Data;
        }
Ejemplo n.º 7
0
        public Wire(TerminalModel terminal1, TerminalModel terminal2)
        {
            IsActive       = true;
            SinkTerminal   = terminal1.Kind == TerminalKind.Input ? terminal1 : terminal2;
            SourceTerminal = terminal1.Kind == TerminalKind.Output ? terminal1 : terminal2;;

            if (!SourceTerminal.Type.IsSubclassOf(SinkTerminal.Type) && SourceTerminal.Type != SinkTerminal.Type)
            {
                return;
            }

            SourceTerminal.DisconnectWire();
            SinkTerminal.DisconnectWire();

            SourceTerminal.ConnectedWire = this;
            SinkTerminal.ConnectedWire   = this;
        }