/* * The methods in this section are used exclusively externally. * When this editor is active, this will always be triggered whenever * a change occurs to the data model, including when this makes changes * through the core. * * DO NOT CALL CORE FUNCTIONS IN ANY OF THESE METHODS * DO NOT CALL DELETE OR ANYTHING THAT CAUSES A CORE FUNCTION TO BE CALLED */ /// <summary> /// Creates a new block for a specific IConnectable Item /// </summary> /// <param name="temp"></param> public void CreateBlock(IConnectable temp) { IDrawableIConnectable newDrawable; lock (ControlPanel.RenderLock) { BlockControl.MakeCurrent(); // Create a new Block depending on the type if (temp is DataFilter) { // Create the main Block var dfBlock = new DrawableFilter(_core, temp as DataFilter); if (dfBlock.Object.PositionX == 0 && dfBlock.Object.PositionY == 0) { dfBlock.Object.PositionX = BlockControl.Width / 2; dfBlock.Object.PositionY = BlockControl.Height / 2; } _renderables.Add(dfBlock.Z, dfBlock); _objectMapping.Add(temp, dfBlock); newDrawable = dfBlock; } else if (temp is DataConnection) { var dcBlock = new DrawableInputOutput(_core, temp as DataConnection); if (dcBlock.Object.PositionX == 0 && dcBlock.Object.PositionY == 0) { dcBlock.Object.PositionX = BlockControl.Width / 2; dcBlock.Object.PositionY = BlockControl.Height / 2; } _renderables.Add(dcBlock.Z, dcBlock); _objectMapping.Add(temp, dcBlock); newDrawable = dcBlock; } else { throw new NotSupportedException($"The type {temp.GetType()} does not have an associated block symbol"); } // Create an input and an output port as needed if (temp.OutputCount != 0) { var oPort = new DrawablePort(_core, temp, true); _renderables.Add(oPort.Z, oPort); newDrawable.MappedObjects.Add(oPort); } if (temp.InputCount != 0) { var iPort = new DrawablePort(_core, temp, false); _renderables.Add(iPort.Z, iPort); newDrawable.MappedObjects.Add(iPort); } BlockControl.Context.MakeCurrent(null); } // Select the block SelectObject(newDrawable as DrawableObject); Render(); }
public virtual bool CanConnect(IConnectable output, IConnectable input) { if (CanConnect(output.GetType(), input.GetType())) { if (output.GetType().Name == "ShellNodeConfig" && input.GetType().Name == "ShellNodeConfigInput") { InvertApplication.Log("!!!!Bingo!!!!"); InvertApplication.Log("CanOutputTo : " + output.CanOutputTo(input)); InvertApplication.Log("CanInputFrom : " + input.CanInputFrom(output)); } if (output.CanOutputTo(input) && input.CanInputFrom(output)) { return(true); } } return(false); }
public virtual bool CanConnect(IConnectable output, IConnectable input) { if (CanConnect(output.GetType(), input.GetType())) { if (output.CanOutputTo(input) && input.CanInputFrom(output)) { return(true); } } return(false); }
public virtual bool CanConnect(IConnectable output, IConnectable input) { if (CanConnect(output.GetType(), input.GetType())) { if (output.CanOutputTo(input) && input.CanInputFrom(output)) { return true; } } return false; }
public void Disconnect(IConnectable connector, IEmulationElement connectee) { try { ((dynamic)connector).DetachFrom((dynamic)connectee); connections.RemovePair(connector, connectee); } catch (RuntimeBinderException) { ThrowConnectionException(connectee.GetType(), connector.GetType(), true); } }
public void Connect(IEmulationElement connectee, IConnectable connector) { try { ((dynamic)connector).AttachTo((dynamic)connectee); connections.Add(connector, connectee); } catch (RuntimeBinderException) { ThrowConnectionException(connectee.GetType(), connector.GetType()); } }
public void Disconnect(IConnectable connector, IEmulationElement connectee) { try { ((dynamic)connector).DetachFrom((dynamic)connectee); connections.RemovePair(connector, connectee); } catch(RuntimeBinderException) { ThrowConnectionException(connectee.GetType(), connector.GetType(), true); } }
public void Connect(IEmulationElement connectee, IConnectable connector) { try { ((dynamic)connector).AttachTo((dynamic)connectee); connections.Add(connector, connectee); } catch (RuntimeBinderException) { ThrowConnectionException(connectee.GetType(), connector.GetType()); } }
public override bool CanOutputTo(IConnectable input) { if (input == this) { return(false); } if (this.GetType() != input.GetType()) { return(false); } if (BaseNodes.Any(p => p == input)) { return(false); } return(base.CanOutputTo(input)); }
public override bool CanOutputTo(IConnectable input) { if (input == this) return false; if (this.GetType() != input.GetType()) return false; if (BaseNodes.Any(p => p == input)) return false; return base.CanOutputTo(input); }