private void AddPin(IPin2 pin) { DX11Node vn = this.graph.FindNode(pin.ParentNode); IPluginIO io = pin.InternalCOMInterf as IPluginIO; if (pin.Direction == PinDirection.Input && io != null && pin.Type.StartsWith("DX11Resource")) { DX11InputPin vop = new DX11InputPin(vn, pin.InternalCOMInterf, io); //We only register event on input pin (more than enough to build graph) pin.Connected += pin_Connected; pin.Disconnected += pin_Disconnected; IPin src = this.GetSource(pin.InternalCOMInterf); if (src != null) { if (this.CanProcessPin(pin.InternalCOMInterf, src)) { if (!this.SetLink(pin.InternalCOMInterf, src, false)) { //Add projected pending link HdeLink link = new HdeLink(pin.InternalCOMInterf, src); this.pendinglinks.Add(pin.InternalCOMInterf, link); } } } } if (pin.Direction == PinDirection.Output && io != null && pin.Type.StartsWith("DX11Resource")) { DX11OutputPin vop = new DX11OutputPin(vn, pin.InternalCOMInterf, io); } }
protected override bool ProcessAddedPin(IPin2 pin) { viNode vn = this.graph.FindNode(pin.ParentNode); if (vn != null) { IPluginIO ip = this.pinlistener.GetInput(vn.Hoster, pin.Name); if (ip != null) { viInputPin vip = new viInputPin(vn); vip.ComInstance = ip; vip.Name = pin.Name; vip.HdePin = vn.HdeNode.FindHdePinByName(pin.Name); } else { IPluginIO op = this.pinlistener.GetOutput(vn.Hoster, pin.Name); if (op != null) { viOutputPin vop = new viOutputPin(vn); vop.ComInstance = op; vop.Name = pin.Name; vop.HdePin = vn.HdeNode.FindHdePinByName(pin.Name); } } } return false; }
public TodoHdeEnumVariable(INode2 node, TodoEngine engine, string varname) { this.node = node; //this.var = var; this.valuepin = this.node.FindPin("Input Enum"); enumname = this.valuepin.SubType.Split(",".ToCharArray())[1].Trim(); int ecnt = EnumManager.GetEnumEntryCount(enumname); for (int i = 0; i < ecnt; i++) { string eval = EnumManager.GetEnumEntryString(enumname, i); string vn = varname + "-" + eval; TodoVariable var = engine.GetVariableByName(vn); if (var == null) { var = new TodoVariable(vn); var.Category = "Global"; engine.RegisterVariable(var, false); } var.ValueChanged += var_ValueChanged; vars.Add(var); } //this.valuepin. //this.valuepin.Type //var.ValueChanged += var_ValueChanged; //var.VariableUpdated += var_VariableUpdated; }
public SRNodeView(NodeView parentNodeView, INode2 node, NodeFilter filter, int depth) : base(parentNodeView, node, filter, depth, false) { FChannelPin = FNode.FindPin(ChannelPinName); FChannelPin.Changed += HandleChannelPinChanged; FSRChannel = FChannelPin[0]; }
void maxpin_Changed(object sender, EventArgs e) { foreach (TodoVariable var in this.vars) { IPin2 pin = sender as IPin2; var.Mapper.MaxValue = Convert.ToDouble(pin.Spread); var.MarkForUpdate(false); } }
public IONodeView(NodeView parentNodeView, INode2 node, NodeFilter filter, int depth) : base(parentNodeView, node, filter, depth, false) { FNode.LabelPin.Changed += HandleLabelPinChanged; FLabel = FNode.LabelPin[0]; FComment = string.Empty; if (FNode.NodeInfo.Category == "String") { FCommentPin = FNode.FindPin("Input String"); FCommentPin.Changed += HandleCommentPinChanged; FComment = FCommentPin[0] ?? string.Empty; } }
protected override bool ProcessRemovedPin(IPin2 pin) { DX11Node vn = this.graph.FindNode(pin.ParentNode); if (vn != null) { vn.RemovePin(pin.InternalCOMInterf.Name, pin.InternalCOMInterf.Direction); if (reg.pinconnections.ContainsKey(pin.InternalCOMInterf)) { reg.pinconnections.Remove(pin.InternalCOMInterf); } } return(false); }
void LabelPin_Changed(object sender, EventArgs e) { IPin2 pin = (IPin2)sender; INode parent = pin.ParentNode.InternalCOMInterf; if (nodes.ContainsKey(parent)) { TodoHdeVariable var = nodes[parent]; var.Dispose(); nodes.Remove(parent); this.NodeAddedCB(pin.ParentNode); } }
public TodoHdeEnumVariable(INode2 node, TodoEngine engine, IHDEHost hde) { this.node = node; this.hde = hde; //this.var = var; this.valuepin = this.node.FindPin("Input Enum"); string enumname = this.valuepin.SubType.Split("|".ToCharArray())[1]; //this.valuepin. //this.valuepin.Type //var.ValueChanged += var_ValueChanged; //var.VariableUpdated += var_VariableUpdated; }
public TodoHdeVariable(INode2 node, TodoEngine engine, string varname) { this.node = node; this.valuepin = this.node.FindPin("Y Input Value"); if (this.valuepin.SliceCount == 1) { TodoVariable var = engine.GetVariableByName(varname); if (var == null) { var = new TodoVariable(varname); var.Category = "Global"; engine.RegisterVariable(var, false); } var.ValueChanged += var_ValueChanged; var.VariableUpdated += var_VariableUpdated; this.vars.Add(var); } else if (this.valuepin.SliceCount > 1) { for (int i = 0; i < this.valuepin.SliceCount; i++) { string vn = varname + "-" + i.ToString(); TodoVariable var = engine.GetVariableByName(vn); if (var == null) { var = new TodoVariable(vn); var.Category = "Global"; engine.RegisterVariable(var, false); } var.ValueChanged += var_ValueChanged; var.VariableUpdated += var_VariableUpdated; this.vars.Add(var); } } this.minpin = this.node.FindPin("Minimum"); this.maxpin = this.node.FindPin("Maximum"); this.minpin.Changed += minpin_Changed; this.maxpin.Changed += maxpin_Changed; }
protected override bool ProcessAddedPin(IPin2 pin, bool immediate) { DX11Node vn = this.graph.FindNode(pin.ParentNode); if (vn != null) { if (immediate) { this.AddPin(pin); } else { this.pendingpins.Add(pin); } } return(false); }
public RemoteValue(INode2 node, List <string> prefixes) { FNumberFormat.NumberDecimalSeparator = "."; Node = node; FPrefixes = prefixes; //note: this will break if patches are renamed! RuntimeNodePath = Node.GetNodePath(false); SourceNodePath = Node.Parent.NodeInfo.Filename + "/" + node.ID; FNamePin = node.LabelPin; FNamePin.Changed += ValueChangedCB; Name = FNamePin[0]; if (string.IsNullOrEmpty(Name)) { Name = RuntimeNodePath; } FValuePin = Node.FindPin("Y Input Value"); FValuePin.Changed += ValueChangedCB; FValuePin.SubtypeChanged += SubtypeChangedCB; Value = float.Parse(FValuePin[0], FNumberFormat); var subtype = FValuePin.SubType.Split(','); Type = subtype[0]; Default = float.Parse(subtype[2], FNumberFormat); Minimum = float.Parse(subtype[3], FNumberFormat); Maximum = float.Parse(subtype[4], FNumberFormat); if (Type == "Slider") { Stepsize = 1; } else { Stepsize = 0.01f; } State = RemoteValueState.Add; }
private string GetNameForInput(INode2 patch, IPin2 pin) { //concatenate the names of all pins connected to this output (which are in the selection) var names = new List <string>(); foreach (var cpin in pin.ConnectedPins) { var parent = cpin.ParentNodeByPatch(patch); if (FOldID2NewID.ContainsKey(parent.ID)) { var pinName = cpin.NameByParent(parent); if (!names.Contains(pinName)) { names.Add(pinName); } } } return(names.Aggregate((i, j) => i + " - " + j)); }
protected abstract bool ProcessAddedPin(IPin2 pin);
private void ProcessOSCMessage(OSCMessage message) { IPin2 pin = null; switch (FAcceptMode[0]) { case AcceptMode.OnlyCached: { if (FCachedPins.ContainsKey(message.Address)) { pin = FCachedPins[message.Address]; } break; } case AcceptMode.OnlyExposed: { if (FExposedPins.ContainsKey(message.Address)) { pin = FExposedPins[message.Address]; } break; } case AcceptMode.ExposedAndCached: { if (FExposedPins.ContainsKey(message.Address)) { pin = FExposedPins[message.Address]; } else if (FCachedPins.ContainsKey(message.Address)) { pin = FCachedPins[message.Address]; } break; } case AcceptMode.Any: { if (FCachedPins.ContainsKey(message.Address)) { pin = FCachedPins[message.Address]; } else { //check if address is in the format of a nodepath //ie. /4/545/46/pinname var path = message.Address.Split('/'); var pinName = path[path.Length - 1]; int id = 0; //last entry in path has to be a string (ie. pinname) not a number var validAddress = !string.IsNullOrEmpty(pinName) && !int.TryParse(pinName, out id); if (validAddress) { var pathIDs = new int[path.Length - 1]; for (int i = 1; i < pathIDs.Length; i++) { if (int.TryParse(path[i], out id)) { pathIDs[i] = id; } else { validAddress = false; break; } } } if (validAddress) { //check if a pin is available under this address var nodePath = message.Address.Substring(0, message.Address.LastIndexOf('/')); var node = FHDEHost.GetNodeFromPath(nodePath); if (node != null) { //FLogger.Log(LogType.Warning, node.Name); pin = node.FindPin(pinName.Trim()); if (pin != null) { FCachedPins.Add(message.Address, pin); pin.Changed += PinChanged; } else { FLogger.Log(LogType.Warning, "No pin available under: \"" + message.Address + "\"!"); } } else { FLogger.Log(LogType.Warning, "No node available under: \"" + nodePath + "\"!"); } } else { FLogger.Log(LogType.Warning, "\"" + message.Address + "\" is not a valid pin address!"); } } break; } } //send values to pin if (pin != null) { var values = ""; foreach (var v in message.Values) { if (v is float) { values += ((float)v).ToString(System.Globalization.CultureInfo.InvariantCulture) + ","; } else if (v is double) { values += ((double)v).ToString(System.Globalization.CultureInfo.InvariantCulture) + ","; } else { values += v.ToString() + ","; } } values = values.TrimEnd(','); pin.Spread = values; } }
private void ProcessOSCMessage(OSCMessage message) { IPin2 pin = null; switch (FAcceptMode[0]) { case AcceptMode.OnlyCached: { if (FCachedPins.ContainsKey(message.Address)) { pin = FCachedPins[message.Address]; } break; } case AcceptMode.OnlyExposed: { if (FExposedPins.ContainsKey(message.Address)) { pin = FExposedPins[message.Address]; } break; } case AcceptMode.ExposedAndCached: { if (FExposedPins.ContainsKey(message.Address)) { pin = FExposedPins[message.Address]; } else if (FCachedPins.ContainsKey(message.Address)) { pin = FCachedPins[message.Address]; } break; } case AcceptMode.Any: { if (FCachedPins.ContainsKey(message.Address)) { pin = FCachedPins[message.Address]; } else { //check if address is in the format of a nodepath //ie. /4/545/46/pinname var path = message.Address.Split('/'); var pinName = path[path.Length - 1]; int id = 0; //last entry in path has to be a string (ie. pinname) not a number var validAddress = !string.IsNullOrEmpty(pinName) && !int.TryParse(pinName, out id); if (validAddress) { var pathIDs = new int[path.Length - 1]; for (int i = 1; i < pathIDs.Length; i++) { if (int.TryParse(path[i], out id)) { pathIDs[i] = id; } else { validAddress = false; break; } } } if (validAddress) { //check if a pin is available under this address var nodePath = message.Address.Substring(0, message.Address.LastIndexOf('/')); var node = FHDEHost.GetNodeFromPath(nodePath); if (node != null) { //FLogger.Log(LogType.Warning, node.Name); pin = node.FindPin(pinName.Trim()); if (pin != null) { FCachedPins.Add(message.Address, pin); pin.Changed += PinChanged; } else { FLogger.Log(LogType.Warning, "No pin available under: \"" + message.Address + "\"!"); } } else { FLogger.Log(LogType.Warning, "No node available under: \"" + nodePath + "\"!"); } } else { FLogger.Log(LogType.Warning, "\"" + message.Address + "\" is not a valid pin address!"); } } break; } } //send values to pin if (pin != null) { var values = ""; foreach (var v in message.Values) { if (v is float) { values += ((float)v).ToString(System.Globalization.CultureInfo.InvariantCulture) + ","; } else if (v is double) { values += ((double)v).ToString(System.Globalization.CultureInfo.InvariantCulture) + ","; } else { //pipes are used in pin values only to surround slices that have a "space", "comma" or "pipe" in them //therefore they only make sense in string and color values in the first place //but also it does no harm if a slice is surrounded by pipes anyway //so lets check if first and last character is a pipe, then assume user knows those rules and don't do anything //otherwise: //- always escape a single pipe with an extra pipe //- always surround the string with pipes string s = v.ToString(); if (s.StartsWith("|") && s.EndsWith("|")) { values += s + ","; } else { s = s.Replace("|", "||"); //escape a single pipe with a double pipe values += "|" + s + "|,"; //quote the string with pipes in order for it to be treated as a single slice } } } values = values.TrimEnd(','); pin.Spread = values; } }
private void Pins_Added(IViewableCollection<IPin2> collection, IPin2 item) { this.ProcessAddedPin(item,false); }
private void Pins_Added(IViewableCollection <IPin2> collection, IPin2 item) { this.ProcessAddedPin(item, false); }
public static bool IsConnected(this IPin2 pin) { return(pin.ConnectedPins.Count > 0); }
private void pin_Connected(object sender, PinConnectionEventArgs args) { IPin2 sink = sender as IPin2; this.SetLink(sink.InternalCOMInterf, args.OtherPin, false); }
public static bool IsConnected(this IPin2 pin) { return((pin.Status & StatusCode.IsConnected) == StatusCode.IsConnected); }
protected abstract bool ProcessAddedPin(IPin2 pin,bool imediate);
protected abstract bool ProcessRemovedPin(IPin2 pin);
protected abstract bool ProcessAddedPin(IPin2 pin, bool imediate);
protected override bool ProcessRemovedPin(IPin2 pin) { viNode vn = this.graph.FindNode(pin.ParentNode); if (vn != null) { //Remove from cache this.pinlistener.RemovePin(vn.Hoster, pin.Name); vn.RemovePin(pin.Name); } return false; }
private void Pins_Removed(IViewableCollection<IPin2> collection, IPin2 item) { this.ProcessRemovedPin(item); }
private void Pins_Removed(IViewableCollection <IPin2> collection, IPin2 item) { this.ProcessRemovedPin(item); }