/// <summary> /// Adds an object port to the node /// </summary> /// <param name="node"></param> /// <param name="text">Title of the port</param> /// <param name="porttype">Type of the port (Input,Output)</param> /// <param name="type">Type of the data of the port</param> /// <para name="multicon">Multiple connections in one port</para> /// <param name="multiconnections"></param> /// <param name="control">The control that will host the data <c>optional</c></param> public void AddObjectPort(Node node, string text, PortTypes porttype, RTypes type, bool multiconnections, Control control) { var port = new ObjectPort(Host, porttype, text, type) { Control = control, MultipleConnectionsAllowed = multiconnections, ParentNode = this }; if (port.PortTypes == PortTypes.Input) { port.Style = (Style)FindResource("InObjectPortStyle"); port.index = InputPorts.Count; InputPorts.Add(port); } else { port.Style = (Style)FindResource("OutObjectPortStyle"); port.index = OutputPorts.Count; OutputPorts.Add(port); } }
public void AddObjectPort(Node node, string text, PortTypes porttype, RTypes type, bool multiconnections) { var port = new ObjectPort(Host, porttype, text, type) { MultipleConnectionsAllowed = multiconnections }; port.ParentNode = node; if (port.PortTypes == PortTypes.Input) { InputPorts?.Add(port); InputPortsPanel?.Children.Add(port); } else { OutputPorts?.Add(port); OutputPortsPanel?.Children.Add(port); } OnPropertyChanged(); }
public ObjectPort(VirtualControl host, PortTypes portType, string text, RTypes type) { Text = text; Data = new RVariable(type); Host = host; // Focusable = false; Data.ParentPort = this; if (portType == PortTypes.Input) { if (type == RTypes.ArrayOrFactorOrListOrMatrix) { Style = (Style)FindResource("InArrayPortStyle"); } else { Style = (Style)FindResource("InObjectPortStyle"); } PortTypes = PortTypes.Input; } else { if (type == RTypes.ArrayOrFactorOrListOrMatrix) { Style = (Style)FindResource("OutArrayPortStyle"); } else { Style = (Style)FindResource("OutObjectPortStyle"); } PortTypes = PortTypes.Output; } Loaded += (sender, args) => { Host = host; _panel = (StackPanel)Template.FindName("ControlsPanel", this); _pin = (UIElement)Template.FindName("Pin", this); if (_pin != null) { _pin.PreviewMouseDown += OnMouseDown; } if (_panel == null) { return; } if (Control != null) { try { _panel.Children.Remove(Control); _panel.Children.Add(Control); } catch (Exception) { MagicLaboratory.unLinkChild(Control); _panel.Children.Add(Control); } } }; PreviewMouseUp += OnMouseUp; PreviewMouseMove += ObjectPort_PreviewMouseMove; MouseLeave += (sender, args) => { Host.HideLinkingPossiblity(); ParentNode.Refresh(); args.Handled = true; }; Control.Loaded += Control_Loaded; Control.SizeChanged += Control_SizeChanged; }
/// <summary> /// Virtual type that works as a data container for R-data-like types. /// </summary> /// <param name="type"></param> public RVariable(RTypes type) { Type = type; }