void importexport_PinRemoved(object sender, DaggerBasePin pin) { if (comboBox1.SelectedIndex == 1) { RemovePin(pin); } }
void _disconnectMenuItem_Click(object sender, EventArgs e) { DaggerBasePin pin = Tag as DaggerBasePin; pin.Disconnect(false); pin.ParentUIGraph.RefreshGraph(); }
void ImportedPins_PinAdded(object sender, DaggerBasePin pin) { if (pin.PinUIElements == null) { pin.PinUIElements = new PinUI(pin); } }
/// <summary> /// Called when a user sets a value /// </summary> /// <param name="s"></param> /// <param name="e"></param> void propertyGridEx1_PropertyValueChanged(object s, PropertyValueChangedEventArgs e) { if (comboBox1.SelectedIndex != 0) { PropertyGridEx.CustomProperty cp = (PropertyGridEx.CustomProperty)((PropertyGridEx.CustomProperty.CustomPropertyDescriptor)(e.ChangedItem.PropertyDescriptor)).CustomProperty; if (cp.Tag != null) { // set the pin's Data via it's property so the Data can be transmited through the // proper channels DaggerBasePin pin = cp.Tag as DaggerBasePin; pin.Data = cp.Value; // process the graph if (pin.ParentNode != null) { pin.ParentNode.ParentGraph.GraphScheduler.ProcessGraph(pin.ParentNode); } else { // process the entire graph if it is an imported pin if (pin is DaggerOutputPin) { pin.ParentGraph.GraphScheduler.ProcessGraph(); } } } } }
public ValueEditorDialog(DaggerBasePin pin) { InitializeComponent(); Text = pin.Name; genericValueEditor1.EditedType = pin.DataType; genericValueEditor1.Value = pin.Data; genericValueEditor1.ValueChanged += new EventHandler(genericValueEditor1_ValueChanged); }
void node_PinRemoved(object sender, DaggerBasePin pin) { DropDownItem item = comboBox1.SelectedItem as DropDownItem; if (item.Tag == pin.ParentNode) { RemovePin(pin); } }
private void AddPin(string category, string helpString, DaggerBasePin pin) { propertyGridEx1.Item.Add(pin.Name, pin.Data, false, category, helpString, true); propertyGridEx1.Item[propertyGridEx1.Item.Count - 1].DefaultType = pin.DataType; propertyGridEx1.Item[propertyGridEx1.Item.Count - 1].Tag = pin; pin.PinDataSet += new DaggerPinDataSetHandler(pin_PinDataSet); pin.PinDataTypeChanged += new DaggerPinDataTypeChanged(pin_PinDataTypeChanged); pin.PinNameChanged += new DaggerPinNameChanged(pin_PinNameChanged); }
void importexport_PinAdded(object sender, DaggerBasePin pin) { if (comboBox1.SelectedIndex == 1) { string cat = (pin is DaggerOutputPin) ? "Imported Pins" : "Exported Pins"; AddPin(cat, "", pin); propertyGridEx1.Refresh(); } }
void node_PinAdded(object sender, DaggerBasePin pin) { DropDownItem item = comboBox1.SelectedItem as DropDownItem; if (item.Tag == pin.ParentNode) { string cat = (pin is DaggerOutputPin) ? "Output Pins" : "Input Pins"; AddPin(cat, "", pin); propertyGridEx1.Refresh(); } }
/// <summary> /// Called when a user sets a value. Does not process the Graph /// </summary> /// <param name="s"></param> /// <param name="e"></param> void propertyGridEx1_PropertyValueChangedNoProcess(object s, PropertyValueChangedEventArgs e) { PropertyGridEx.CustomProperty cp = (PropertyGridEx.CustomProperty)((PropertyGridEx.CustomProperty.CustomPropertyDescriptor)(e.ChangedItem.PropertyDescriptor)).CustomProperty; if (cp.Tag != null) { // set the pin's Data via it's property so the Data can be transmited through the // proper channels DaggerBasePin pin = cp.Tag as DaggerBasePin; pin.Data = cp.Value; } }
void pin_PinNameChanged(DaggerBasePin pin) { for (int i = 0; i < propertyGridEx1.Item.Count; i++) { if (propertyGridEx1.Item[i].Tag == pin) { propertyGridEx1.Item[i].Name = pin.Name; propertyGridEx1.Refresh(); break; } } }
void pin_PinDataTypeChanged(DaggerBasePin pin, Type type) { for (int i = 0; i < propertyGridEx1.Item.Count; i++) { if (propertyGridEx1.Item[i].Tag == pin) { propertyGridEx1.Item[i].DefaultType = pin.DataType; propertyGridEx1.Item[i].Value = null; propertyGridEx1.Refresh(); break; } } }
void _setpropertyMenuItem_Click(object sender, EventArgs e) { DaggerBasePin pin = Tag as DaggerBasePin; ValueEditorDialog ved = new ValueEditorDialog(pin); if (ved.ShowDialog() == DialogResult.OK) { pin.Data = ved.Data; pin.ParentNode.Process(); } ved.Dispose(); }
void pin_PinDataSet(DaggerBasePin sender, object data) { if (Enabled) { for (int i = 0; i < propertyGridEx1.Item.Count; i++) { if (propertyGridEx1.Item[i].Tag == sender) { propertyGridEx1.Item[i].Value = sender.Data; propertyGridEx1.Refresh(); break; } } } }
private void RemovePin(DaggerBasePin pin) { if (comboBox1.SelectedIndex >= 1) { for (int i = 0; i < propertyGridEx1.Item.Count; i++) { if (propertyGridEx1.Item[i].Tag == pin) { propertyGridEx1.Item.RemoveAt(i); propertyGridEx1.Refresh(); break; } } } }
/// <summary> /// Clear properties and unhook the pin data events /// </summary> private void ClearProperties() { // clear the existing pins for (int i = 0; i < propertyGridEx1.Item.Count; i++) { DaggerBasePin pin = propertyGridEx1.Item[i].Tag as DaggerBasePin; if (pin != null) { // unhook existing events pin.PinDataSet -= new DaggerPinDataSetHandler(pin_PinDataSet); pin.PinDataTypeChanged -= new DaggerPinDataTypeChanged(pin_PinDataTypeChanged); pin.PinNameChanged -= new DaggerPinNameChanged(pin_PinNameChanged); } } propertyGridEx1.Item.Clear(); }
public PinUI(DaggerBasePin pin) { _pin = pin; }
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; }