Пример #1
0
 void OnShowElementMenu(object sender, AcceptElementLocationEventArgs e)
 {
     if (e.Element == null)
     {
         // Show a test menu for when you click on nothing
         testMenuItem.Text = "(clicked on nothing)";
         nodeMenu.Show(e.Position);
         e.Cancel = false;
     }
     else
     if (e.Element is Node)
     {
         // Show a test menu for a node
         testMenuItem.Text = ((Node)e.Element).Title;
         nodeMenu.Show(e.Position);
         e.Cancel = false;
     }
     else
     if (e.Element is NodeItem)
     {
         // Show a test menu for a nodeItem
         testMenuItem.Text = e.Element.GetType().Name;
         nodeMenu.Show(e.Position);
         e.Cancel = false;
     }
     else
     {
         // if you don't want to show a menu for this item (but perhaps show a menu for something more higher up)
         // then you can cancel the event
         e.Cancel = true;
     }
 }
Пример #2
0
        private void Desktop_ShowElementMenu(object sender, AcceptElementLocationEventArgs e)
        {
            NodeItem item = e.Element as NodeItem;

            if (item != null)
            {
                MyNodeView nodeView = item.Node as MyNodeView;

                if (nodeView != null)
                {
                    MyNode node = nodeView.Node;

                    openEditorToolStripMenuItem.Enabled = node is IScriptableNode;
                    openGroupToolStripMenuItem.Enabled  = node is MyNodeGroup;

                    nodeContextMenuStrip.Tag = node;
                    nodeContextMenuStrip.Show(e.Position);
                }
            }
        }
Пример #3
0
 void OnShowElementMenu(object sender, AcceptElementLocationEventArgs e)
 {
     if (e.Element is Node && ((Node)e.Element).Tag is ShaderProcedureNodeTag)
     {
         var tag = (ShaderProcedureNodeTag)((Node)e.Element).Tag;
         nodeMenu.Tag = tag.Id;
         nodeMenu.Show(e.Position);
         e.Cancel = false;
     }
     if (e.Element is Node && ((Node)e.Element).Tag is ShaderParameterNodeTag)
     {
         var tag = (ShaderParameterNodeTag)((Node)e.Element).Tag;
         parameterBoxMenu.Tag = tag.Id;
         parameterBoxMenu.Show(e.Position);
         e.Cancel = false;
     }
     else if (e.Element is ShaderFragmentNodeItem)
     {
         var tag = (ShaderFragmentNodeItem)e.Element;
         if (tag.ArchiveName != null)
         {
             ShaderParameterUtil.EditParameter(graphControl, tag.ArchiveName);
             e.Cancel = false;
         }
     }
     else if (e.Element is NodeConnector && ((NodeConnector)e.Element).Item is ShaderFragmentNodeItem)
     {
         var tag = (ShaderFragmentNodeItem)((NodeConnector)e.Element).Item;
         if (tag.ArchiveName != null)
         {
             ShaderParameterUtil.EditParameter(graphControl, tag.ArchiveName);
             e.Cancel = false;
         }
     }
     else
     {
         // if you don't want to show a menu for this item (but perhaps show a menu for something more higher up)
         // then you can cancel the event
         e.Cancel = true;
     }
 }
Пример #4
0
        void OnShowElementMenu(object sender, AcceptElementLocationEventArgs e)
        {
            if (e.Element == null)
            {
                _emptySpaceMenu.Tag = ClientToModel(new System.Drawing.PointF(e.Position.X, e.Position.Y));
                _emptySpaceMenu.Show(e.Position);
                e.Cancel = false;
            }
            else
            if (e.Element is Node && ((Node)e.Element).Tag is ShaderProcedureNodeTag)
            {
                var tag = (ShaderProcedureNodeTag)((Node)e.Element).Tag;
                _nodeMenu.Tag = tag.Id;
                _nodeMenu.Show(e.Position);
                e.Cancel = false;
            }
            // if (e.Element is Node && ((Node)e.Element).Tag is ShaderParameterNodeTag)
            // {
            //     var tag = (ShaderParameterNodeTag)((Node)e.Element).Tag;
            //     parameterBoxMenu.Tag = tag.Id;
            //     parameterBoxMenu.Show(e.Position);
            //     e.Cancel = false;
            // }
            // else
            // if (e.Element is ShaderFragmentNodeItem)
            // {
            //     var tag = (ShaderFragmentNodeItem)e.Element;
            //     if (tag.ArchiveName != null)
            //     {
            //         ShaderParameterUtil.EditParameter(GetGraphModel(), tag.ArchiveName);
            //         e.Cancel = false;
            //     }
            // }
            else if (e.Element is NodeConnector && ((NodeConnector)e.Element).Item is ShaderFragmentNodeItem)
            {
                NodeConnector conn = (NodeConnector)e.Element;
                var           tag  = (ShaderFragmentNodeItem)conn.Item;
                if (tag.ArchiveName != null)
                {
                    // pop up a context menu for this connector
                    var menu = new ContextMenuStrip();

                    var param = conn.Item as ShaderFragmentInterfaceParameterItem;
                    if (param != null)
                    {
                        var editItem = new ToolStripMenuItem()
                        {
                            Text = "Edit parameter"
                        };
                        editItem.Click += (object o, EventArgs a) => { EditInterfaceParameter(param); };
                        menu.Items.Add(editItem);
                    }

                    if (conn == conn.Item.Input)
                    {
                        var existing = GetSimpleConnection(conn);
                        if (!string.IsNullOrEmpty(existing))
                        {
                            var editItem = new ToolStripMenuItem()
                            {
                                Text = "Edit simple connection"
                            };
                            editItem.Click += (object o, EventArgs a) => { EditSimpleConnection(conn); };
                            menu.Items.Add(editItem);
                        }
                        else
                        {
                            var addItem = new ToolStripMenuItem()
                            {
                                Text = "Add simple connection"
                            };
                            addItem.Click += (object o, EventArgs a) => { EditSimpleConnection(conn); };
                            menu.Items.Add(addItem);
                        }
                    }

                    if (conn.Node.Connections.Where(x => x.To == conn || x.From == conn).Any())
                    {
                        var removeItem = new ToolStripMenuItem()
                        {
                            Text = "Disconnect"
                        };
                        removeItem.Click += (object o, EventArgs a) => { DisconnectAll(conn); };
                        menu.Items.Add(removeItem);
                    }

                    if (menu.Items.Count > 0)
                    {
                        menu.Show(e.Position);
                        e.Cancel = false;
                    }
                }
            }
            else
            {
                // if you don't want to show a menu for this item (but perhaps show a menu for something more higher up)
                // then you can cancel the event
                e.Cancel = true;
            }
        }