/// <summary> /// Creates a line that connects two blocks /// </summary> /// <param name="A">The first block to connect (from output)</param> /// <param name="B">The second block to connect (from input)</param> public void ConnectBlocks(IConnectable A, IConnectable B) { var newConnection = new DrawableConnector(_core, A, B); _renderables.Add(newConnection.Z, newConnection); (_objectMapping[A] as IDrawableIConnectable)?.MappedObjects.Add(newConnection); // Trigger a re-draw Render(); }
/// <summary> /// Deletes a line that connects two blocks /// </summary> /// <param name="A"></param> /// <param name="B"></param> /// <param name="callback"></param> public void DisconnectBlocks(IConnectable A, IConnectable B, bool callback = false) { // Get the connectable object through A's mapped objects DrawableConnector selected = null; var oMap = (_objectMapping[A] as IDrawableIConnectable).MappedObjects; foreach (var obj in oMap) { selected = obj as DrawableConnector; if (selected != null && selected.Child == B) { break; } } // Remove the object from all mappings _renderables.RemoveAt(_renderables.IndexOfValue(selected)); oMap.Remove(selected); // Trigger a re-draw Render(); }