void Graph_NodeAdded(object sender, EventArgs e) { DaggerNode node = sender as DaggerNode; comboBox1.Items.Add(new DropDownItem(node.ToString() + " -" + node.GetType().ToString(), node)); comboBox1.SelectedIndex = comboBox1.Items.Count - 1; // hook the pin add/remove events node.InputPins.PinAdded += new DaggerPinAdded(node_PinAdded); node.OutputPins.PinAdded += new DaggerPinAdded(node_PinAdded); node.InputPins.PinRemoved += new DaggerPinRemoved(node_PinRemoved); node.OutputPins.PinRemoved += new DaggerPinRemoved(node_PinRemoved); (node.UINode as DaggerUINode).Activated += new EventHandler(DaggerGraphPropertyGrid_Activated); }
void DaggerUISubNode_DaggerNodeAttached(DaggerNode node) { // store the sub node so we can make the UIGraph for it later _node = (DaggerSubNode)node; _node.SubNodeGraph.ImportedPins.PinAdded += new DaggerPinAdded(ImportedPins_PinAdded); _node.SubNodeGraph.ExportedPins.PinAdded += new DaggerPinAdded(ExportedPins_PinAdded); _editSubNodeButton = new SimpleImageButton(); _editSubNodeButton.ButtonImage = _subnodeEditButtonImageList.Images[0]; _editSubNodeButton.ButtonImage2 = _subnodeEditButtonImageList.Images[1]; _editSubNodeButton.MultiState = true; _editSubNodeButton.ToolTipText = "Edit SubNode"; _editSubNodeButton.ToolTipEnabled = true; _editSubNodeButton.StateChanged += new SimpleImageButton.StateChangedEventHandler(_editSubNodeButton_StateChanged); CaptionButtons.Add(_editSubNodeButton); }
void Graph_AfterNodeRemoved(DaggerNode node) { // if this node is currently selected, select the Graph Data item if (((DropDownItem)comboBox1.SelectedItem).Tag == node) { comboBox1.SelectedIndex = 1; } foreach (DropDownItem item in comboBox1.Items) { if (item.Tag == node) { comboBox1.Items.Remove(item); break; } } }
/// <summary> /// Called before a node is removed from a DaggerLib Graph /// </summary> /// <param name="node"></param> /// <returns>false if node cannot be removed</returns> bool Graph_BeforeNodeRemoved(DaggerNode node) { // make sure the graph is stopped Stop(); // make sure there if in fact a IBaseFilter in this node if ((node as DSFilterNode)._filter != null) { int hr = _graph.RemoveFilter((node as DSFilterNode)._filter); if (hr != 0) { // the filtergraph won't let go of the filter MessageBox.Show(DsError.GetErrorText(hr)); return(false); } } return(true); }
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { DropDownItem item = (DropDownItem)comboBox1.SelectedItem; if (item.Tag is DaggerUIGraph) { propertyGridEx1.SelectedObject = item.Tag; propertyGridEx1.ShowCustomProperties = false; } else if (item.Tag is DaggerGraph) { propertyGridEx1.ShowCustomProperties = true; ClearProperties(); foreach (DaggerOutputPin pin in _uiGraph.Graph.ImportedPins) { AddPin("Imported Pins", "", pin); } foreach (DaggerInputPin pin in _uiGraph.Graph.ExportedPins) { AddPin("Exported Pins", "", pin); } propertyGridEx1.Refresh(); } else if (item.Tag is DaggerNode) { propertyGridEx1.ShowCustomProperties = true; ClearProperties(); DaggerNode node = item.Tag as DaggerNode; foreach (DaggerInputPin pin in node.InputPins) { AddPin("Input Pins", "", pin); } foreach (DaggerOutputPin pin in node.OutputPins) { AddPin("Output Pins", "", pin); } propertyGridEx1.Refresh(); } else { ClearProperties(); } }
public DaggerNodeTreeViewSubnodeItem(string category, string name, Type nodeType) { Category = category; SubnodeName = name; ReadOnly = true; DaggerNodeType = nodeType; // Fabricate a temp node to extract it's pin's data types. // This will be used in computing noodle bisecting and auto drop connections DaggerNode node = null; try { node = (DaggerNode)Activator.CreateInstance(nodeType); } catch (MissingMemberException ex) { // The node type has no parameterless constructor. // The most likely cause is that there is a deserialization constructor, but // no public parameterless constructor defined. MessageBox.Show("Node type " + name + " has no parameterless constructor defined", "Error adding node to DaggerNodeTreeView"); } if (node != null) { OutputPinTypes = new List <Type>(); InputpinTypes = new List <Type>(); foreach (DaggerInputPin pin in node.InputPins) { InputpinTypes.Add(pin.DataType); } foreach (DaggerOutputPin pin in node.OutputPins) { OutputPinTypes.Add(pin.DataType); } // set the ToolTip to the help string ToolTipText = node.HelpString; } }
protected override void OnOpening(System.ComponentModel.CancelEventArgs e) { base.OnOpening(e); //clear out the existing items and rebuild the menu to specs Items.Clear(); bool itemsAdded = false; DaggerBasePin pin = Tag as DaggerBasePin; if (pin.IsConnected) { Items.Add(_disconnectMenuItem); itemsAdded = true; } else if (pin.ParentNode != null) { DaggerUIGraph parentui = pin.ParentNode.ParentGraph.ParentUIGraph as DaggerUIGraph; // can we set the value? if (parentui.AllowPinSetValue) { Items.Add(_setpropertyMenuItem); itemsAdded = true; } // can we export? if (parentui.AllowPinExport) { Items.Add(_exportMenuItem); itemsAdded = true; } } // build the "Connect to" list if ((pin is DaggerOutputPin && (pin as DaggerOutputPin).AllowMultiConnect) || (pin is DaggerOutputPin && !(pin as DaggerOutputPin).AllowMultiConnect && !pin.IsConnected) || (pin is DaggerInputPin && !pin.IsConnected)) { _attachToPinMenuItem.DropDownItems.Clear(); DaggerNode myNode = pin.ParentNode; foreach (DaggerNode node in pin.ParentNode.ParentGraph.AllNodes) { if (node != myNode) { if (pin is DaggerInputPin) { if (node.Ordinal <= myNode.Ordinal || node.SubgraphAffiliation != myNode.SubgraphAffiliation) { foreach (DaggerOutputPin outpin in node.OutputPins.MutexAvailablePins) { if ((!outpin.IsConnected || outpin.AllowMultiConnect) && outpin.IsCompatibleDataTypes((DaggerInputPin)pin, (DaggerOutputPin)outpin)) { ToolStripMenuItem tmi = new ToolStripMenuItem(); tmi.Text = node.UINode.CaptionText + ": " + outpin.Name; tmi.Tag = new PinConnection(outpin, (DaggerInputPin)pin); tmi.DisplayStyle = ToolStripItemDisplayStyle.ImageAndText; tmi.Image = (outpin.PinUIElements as PinUI).PinImageDisconnected; tmi.ImageTransparentColor = (outpin.PinUIElements as PinUI).PinImageDisconnectedTransparent; tmi.MouseEnter += new EventHandler(tmi_MouseEnter); tmi.MouseLeave += new EventHandler(tmi_MouseLeave); tmi.Click += new EventHandler(tmi_Click); _attachToPinMenuItem.DropDownItems.Add(tmi); } } } } else { if (node.Ordinal >= myNode.Ordinal || node.SubgraphAffiliation != myNode.SubgraphAffiliation) { foreach (DaggerInputPin inpin in node.InputPins.MutexAvailablePins) { if (!inpin.IsConnected && inpin.IsCompatibleDataTypes((DaggerInputPin)inpin, (DaggerOutputPin)pin)) { ToolStripMenuItem tmi = new ToolStripMenuItem(); tmi.Text = node.UINode.CaptionText + ": " + inpin.Name; tmi.Tag = new PinConnection((DaggerOutputPin)pin, inpin); tmi.DisplayStyle = ToolStripItemDisplayStyle.ImageAndText; tmi.Image = (inpin.PinUIElements as PinUI).PinImageDisconnected; tmi.ImageTransparentColor = (inpin.PinUIElements as PinUI).PinImageDisconnectedTransparent; tmi.MouseEnter += new EventHandler(tmi_MouseEnter); tmi.MouseLeave += new EventHandler(tmi_MouseLeave); tmi.Click += new EventHandler(tmi_Click); _attachToPinMenuItem.DropDownItems.Add(tmi); } } } } } } if (_attachToPinMenuItem.DropDownItems.Count > 0) { Items.Add(_attachToPinMenuItem); itemsAdded = true; } } //merge the pin's user defined context menu if ((pin.PinUIElements as PinUI).ContextMenuStrip != null) { if (itemsAdded) { Items.Add(_seperator); } // simulate a sync root on the MenuItemCollection ToolStripMenuItem[] tia = new ToolStripMenuItem[(pin.PinUIElements as PinUI).ContextMenuStrip.Items.Count]; (pin.PinUIElements as PinUI).ContextMenuStrip.Items.CopyTo(tia, 0); for (int i = 0; i < tia.Length; i++) { Items.Add(tia[i]); } itemsAdded = true; } //if we didn't add anything, don't show it e.Cancel = !itemsAdded; }