Beispiel #1
0
        void ValidConnectionMade()
        {
            CurrentStartNode.SetHasConnection(true);
            CurrentEndNode.SetHasConnection(true);

            var connectingSourceNode = GetSourceNode();
            var connectingTargetNode = GetTargetNode();

            var layer = CreateLayer(connectingSourceNode.ColorComponent.GetColor().ToNSColor());

            DrawPathOnLayer(layer);

            var existingConnections = NodeConnectionData.Where(n =>
                                                               n.SourceNodeView.ColorComponent == connectingSourceNode.ColorComponent ||
                                                               n.TargetNodeView.TargetModifier == connectingTargetNode.TargetModifier)
                                      .ToList();

            if (existingConnections.Count >= 0)
            {
                foreach (var existingConnection in existingConnections)
                {
                    var sourceNode = existingConnection.SourceNodeView;
                    var targetNode = existingConnection.TargetNodeView;

                    if (sourceNode.ColorComponent != connectingSourceNode.ColorComponent)
                    {
                        sourceNode.SetHasConnection(false);
                    }
                    if (targetNode.TargetModifier != connectingTargetNode.TargetModifier)
                    {
                        targetNode.SetNodePortColor(NSColor.Black);
                        targetNode.SetHasConnection(false);
                    }

                    existingConnection.ConnectionLayer.RemoveFromSuperLayer();
                    NodeConnectionData.Remove(existingConnection);
                }
            }

            NodeConnectionData.Add(new NodeConnectionData
            {
                SourceNodeView  = connectingSourceNode,
                TargetNodeView  = connectingTargetNode,
                ConnectionLayer = layer
            });

            Layer.AddSublayer(layer);

            SynthSettings.Instance.SetSourceForTarget
                (connectingSourceNode.ColorComponent, connectingTargetNode.TargetModifier);

            SetNodeColors();
        }
Beispiel #2
0
        public override void MouseDown(NSEvent theEvent)
        {
            base.MouseDown(theEvent);

            CurrentStartNode = GetInteractingNodePort();

            if (CurrentStartNode != null)
            {
                SetNodeColors();
                SetDrawingLayerColor();

                CurrentStartPosition = CurrentStartNode.GetNodePortMidPoint();
                CurrentStartNode.SetHasConnection(true);
            }
        }
Beispiel #3
0
 void NoConnectionMade()
 {
     CurrentStartNode?.SetHasConnection(false);
     CurrentEndNode?.SetHasConnection(false);
 }