示例#1
0
        private void EditSimpleConnection(NodeConnector connector)
        {
            using (var dialog = new HyperGraph.TextEditForm())
            {
                var existing = GetSimpleConnection(connector);
                dialog.InputText = (!string.IsNullOrEmpty(existing)) ? existing : "1.0f";

                var result = dialog.ShowDialog();
                if (result == DialogResult.OK)
                {
                    bool foundExisting = false;
                    foreach (var i in connector.Node.Connections)
                        if (i.To == connector && i.From == null)
                        {
                            // empty dialog text means we want to disconnect any existing connections
                            if (dialog.InputText.Length > 0)
                            {
                                i.Name = dialog.InputText;
                            }
                            else
                            {
                                GetGraphModel().Disconnect(i);
                                break;
                            }
                            foundExisting = true;
                        }

                    if (!foundExisting && dialog.InputText.Length > 0)
                        GetGraphModel().Connect(null, connector, dialog.InputText);

                    GetGraphModel().InvokeMiscChange(true);
                }
            }
        }
示例#2
0
        private void SetArchiveName_Click(object sender, EventArgs e)
        {
            var n = GetNode(AttachedId(sender));

            if (n == null)
            {
                return;
            }

            var tag = n.Tag as ShaderFragmentNodeTag;

            if (tag == null)
            {
                return;
            }

            using (var dialog = new HyperGraph.TextEditForm {
                InputText = tag.ArchiveName
            })
            {
                // careful -- should we validate that the archive name is at least reasonable?
                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    tag.ArchiveName = dialog.InputText;
                }
            }
        }
示例#3
0
文件: ExampleForm.cs 项目: taknim/XLE
        void OnConnectorDoubleClick(object sender, HyperGraph.GraphControl.NodeConnectorEventArgs e)
        {
            var dialog = new HyperGraph.TextEditForm();

            dialog.InputText = "1.0f";

            //  look for an existing simple connection attached to this connector
            foreach (var i in e.Node.Connections)
            {
                if (i.To == e.Connector && i.From == null)
                {
                    dialog.InputText = i.Name;
                }
            }

            var result = dialog.ShowDialog();

            if (result == DialogResult.OK)
            {
                bool foundExisting = false;
                foreach (var i in e.Node.Connections)
                {
                    if (i.To == e.Connector && i.From == null)
                    {
                        i.Name        = dialog.InputText;
                        foundExisting = true;
                    }
                }

                if (!foundExisting)
                {
                    var connection = new NodeConnection();
                    connection.To   = e.Connector;
                    connection.Name = dialog.InputText;
                    e.Node.AddConnection(connection);
                }

                ShaderFragmentNodeUtil.InvalidateAttachedConstants(graphControl);
            }
        }
示例#4
0
        private void EditSimpleConnection(NodeConnector connector)
        {
            using (var dialog = new HyperGraph.TextEditForm())
            {
                var existing = GetSimpleConnection(connector);
                dialog.InputText = (!string.IsNullOrEmpty(existing)) ? existing : "1.0f";

                var result = dialog.ShowDialog();
                if (result == DialogResult.OK)
                {
                    bool foundExisting = false;
                    foreach (var i in connector.Node.Connections)
                    {
                        if (i.To == connector && i.From == null)
                        {
                            // empty dialog text means we want to disconnect any existing connections
                            if (dialog.InputText.Length > 0)
                            {
                                i.Name = dialog.InputText;
                            }
                            else
                            {
                                GetGraphModel().Disconnect(i);
                                break;
                            }
                            foundExisting = true;
                        }
                    }

                    if (!foundExisting && dialog.InputText.Length > 0)
                    {
                        GetGraphModel().Connect(null, connector, dialog.InputText);
                    }

                    GetGraphModel().InvokeMiscChange(true);
                }
            }
        }
示例#5
0
        private void SetArchiveName_Click(object sender, EventArgs e)
        {
            var n = GetNode(AttachedId(sender));
            if (n == null) return;

            var tag = n.Tag as ShaderFragmentNodeTag;
            if (tag == null) return;

            using (var dialog = new HyperGraph.TextEditForm { InputText = tag.ArchiveName })
            {
                    // careful -- should we validate that the archive name is at least reasonable?
                if (dialog.ShowDialog() == DialogResult.OK)
                    tag.ArchiveName = dialog.InputText;
            }
        }
示例#6
0
        void OnConnectorDoubleClick(object sender, HyperGraph.GraphControl.NodeConnectorEventArgs e)
        {
            var dialog = new HyperGraph.TextEditForm();
            dialog.InputText = "1.0f";

                //  look for an existing simple connection attached to this connector
            foreach(var i in e.Node.Connections)
            {
                if (i.To == e.Connector && i.From == null)
                    dialog.InputText = i.Name;
            }

            var result = dialog.ShowDialog();
            if (result == DialogResult.OK)
            {
                bool foundExisting = false;
                foreach (var i in e.Node.Connections)
                    if (i.To == e.Connector && i.From == null)
                    {
                        i.Name = dialog.InputText;
                        foundExisting = true;
                    }

                if (!foundExisting)
                {
                    var connection = new NodeConnection();
                    connection.To = e.Connector;
                    connection.Name = dialog.InputText;
                    e.Node.AddConnection(connection);
                }

                ShaderFragmentNodeUtil.InvalidateAttachedConstants(graphControl);
            }
        }