Repository: FlaxEngine/FlaxEngine
File: Source/Editor/Surface/VisjectSurfaceWindow.cs (C#)

Code before:
                    Index = index,
                    Before = window.VisjectSurface.Parameters[index].Meta.GetAttributes(),
                    After = newValue,
                };
                window.VisjectSurface.Undo.AddAction(action);
                action.Do();
            };
            editor.Show(label, label.Size * 0.5f);
        }

        private void DeleteParameter(int index)
        {
            bool displayWarning = Editor.Instance.Options.Options.Interface.WarnOnDeletingUsedVisjectParameter;

            var window = (IVisjectSurfaceWindow)Values[0];
            SurfaceParameter param = window.VisjectSurface.Parameters[index];

            int connectedParameterNodeCount = 0;

            List<SurfaceNode> nodes = window.VisjectSurface.Nodes;

            for (int i = 0; i < window.VisjectSurface.Nodes.Count; i++)
            {
                if (nodes[i] is IParametersDependantNode node)
                {
                    if (displayWarning && (Guid)nodes[i].Values[0] == param.ID && nodes[i].GetBoxes().Any(b => b.Connections.Count > 0))
                        connectedParameterNodeCount++;
                }
            }

            if (displayWarning)
            {
                string singularPlural = connectedParameterNodeCount > 1 ? "s" : "";
                string msg = $"Delete parameter {param.Name}?\nParameter is being used in a graph {connectedParameterNodeCount} time{singularPlural}.\n\nYou can disable this warning in the editor settings.";

                if (connectedParameterNodeCount > 0)
                    if (MessageBox.Show(msg, "Delete parameter", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) != DialogResult.OK)
                        return;
            }

            var action = new AddRemoveParamAction
            {
                Window = window,
                IsAdd = false,
                Index = index,
            };
            window.VisjectSurface.Undo.AddAction(action);
            action.Do();
        }

        /// <summary>

Review comment (suggestion):
I think it would be better to add method like `bool IsParamReferenced(SurfaceParameter param)` to `IParametersDependantNode ` so we could have more generic way of checking this parameter reference.

Code after:
                    Index = index,
                    Before = window.VisjectSurface.Parameters[index].Meta.GetAttributes(),
                    After = newValue,
                };
                window.VisjectSurface.Undo.AddAction(action);
                action.Do();
            };
            editor.Show(label, label.Size * 0.5f);
        }

        private void DeleteParameter(int index)
        {
            bool displayWarning = Editor.Instance.Options.Options.Interface.WarnOnDeletingUsedVisjectParameter;

            var window = (IVisjectSurfaceWindow)Values[0];
            SurfaceParameter param = window.VisjectSurface.Parameters[index];

            int connectedParameterNodeCount = 0;

            List<SurfaceNode> nodes = window.VisjectSurface.Nodes;

            for (int i = 0; i < window.VisjectSurface.Nodes.Count; i++)
            {
                if (nodes[i] is IParametersDependantNode node)
                {
                    if (displayWarning && node.IsParamreferenced(param))
                        connectedParameterNodeCount++;
                }
            }

            if (displayWarning)
            {
                string singularPlural = connectedParameterNodeCount > 1 ? "s" : "";
                string msg = $"Delete parameter {param.Name}?\nParameter is being used in a graph {connectedParameterNodeCount} time{singularPlural}.\n\nYou can disable this warning in the editor settings.";

                if (connectedParameterNodeCount > 0)
                    if (MessageBox.Show(msg, "Delete parameter", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) != DialogResult.OK)
                        return;
            }

            var action = new AddRemoveParamAction
            {
                Window = window,
                IsAdd = false,
                Index = index,
            };
            window.VisjectSurface.Undo.AddAction(action);
            action.Do();
        }

        /// <summary>