Ejemplo n.º 1
0
 void importexport_PinRemoved(object sender, DaggerBasePin pin)
 {
     if (comboBox1.SelectedIndex == 1)
     {
         RemovePin(pin);
     }
 }
Ejemplo n.º 2
0
        void _disconnectMenuItem_Click(object sender, EventArgs e)
        {
            DaggerBasePin pin = Tag as DaggerBasePin;

            pin.Disconnect(false);
            pin.ParentUIGraph.RefreshGraph();
        }
Ejemplo n.º 3
0
 void ImportedPins_PinAdded(object sender, DaggerBasePin pin)
 {
     if (pin.PinUIElements == null)
     {
         pin.PinUIElements = new PinUI(pin);
     }
 }
Ejemplo n.º 4
0
        /// <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();
                        }
                    }
                }
            }
        }
Ejemplo n.º 5
0
 public ValueEditorDialog(DaggerBasePin pin)
 {
     InitializeComponent();
     Text = pin.Name;
     genericValueEditor1.EditedType    = pin.DataType;
     genericValueEditor1.Value         = pin.Data;
     genericValueEditor1.ValueChanged += new EventHandler(genericValueEditor1_ValueChanged);
 }
Ejemplo n.º 6
0
        void node_PinRemoved(object sender, DaggerBasePin pin)
        {
            DropDownItem item = comboBox1.SelectedItem as DropDownItem;

            if (item.Tag == pin.ParentNode)
            {
                RemovePin(pin);
            }
        }
Ejemplo n.º 7
0
 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);
 }
Ejemplo n.º 8
0
 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();
     }
 }
Ejemplo n.º 9
0
        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();
            }
        }
Ejemplo n.º 10
0
 /// <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;
     }
 }
Ejemplo n.º 11
0
 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;
         }
     }
 }
Ejemplo n.º 12
0
 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;
         }
     }
 }
Ejemplo n.º 13
0
        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();
        }
Ejemplo n.º 14
0
 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;
             }
         }
     }
 }
Ejemplo n.º 15
0
 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;
             }
         }
     }
 }
Ejemplo n.º 16
0
 /// <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();
 }
Ejemplo n.º 17
0
 public PinUI(DaggerBasePin pin)
 {
     _pin = pin;
 }
Ejemplo n.º 18
0
        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;
        }