private void OnRenameAnimation(object sender, EventArgs e) { if (ActiveRawAnimation == null) { return; } Animation animation = ActiveRawAnimation; SafeRenamer renamer = new SafeRenamer(_scene); // Animations names need not be unique even amongst themselves, but it's good if they are. // Put all names in the entire scene into the greylist. RenameDialog dialog = new RenameDialog(animation.Name, new HashSet <string>(), renamer.GetAllAnimationNames()); if (dialog.ShowDialog() == DialogResult.OK) { string newName = dialog.NewName; string oldName = animation.Name; _scene.UndoStack.PushAndDo("Rename Animation", // Do () => renamer.RenameAnimation(animation, newName), // Undo () => renamer.RenameAnimation(animation, oldName), // Update () => listBoxAnimations.Items[FindAnimationIndex(animation) + 1] = FormatAnimationName(animation)); } }
private void OnRenameNode(object sender, EventArgs e) { var node = GetTreeNodeForContextMenuEvent(sender); if (node == null || (node.Tag as Node) == null) { return; } var sceneNode = (Node)node.Tag; SafeRenamer renamer = new SafeRenamer(_scene); HashSet <string> greylist = renamer.GetAllMeshNames(); greylist.UnionWith(renamer.GetAllMaterialNames()); greylist.UnionWith(renamer.GetAllAnimationNames()); RenameDialog dialog = new RenameDialog(sceneNode.Name, renamer.GetAllNodeNames(), greylist); if (dialog.ShowDialog() == DialogResult.OK) { string newName = dialog.NewName; string oldName = sceneNode.Name; _scene.UndoStack.PushAndDo("Rename Node", () => { renamer.RenameNode(sceneNode, newName); node.Text = newName; }, () => { renamer.RenameNode(sceneNode, oldName); node.Text = oldName; }); } }
private void OnRenameMesh(object sender, EventArgs e) { var node = GetTreeNodeForContextMenuEvent(sender); if (node == null || !(node.Tag as KeyValuePair <Node, Mesh>?).HasValue) { return; } var nodeMeshPair = (KeyValuePair <Node, Mesh>)node.Tag; var mesh = nodeMeshPair.Value; SafeRenamer renamer = new SafeRenamer(_scene); HashSet <string> greylist = renamer.GetAllNodeNames(); greylist.UnionWith(renamer.GetAllMaterialNames()); greylist.UnionWith(renamer.GetAllAnimationNames()); // Mesh names need not be unique, but it's good if they are. // Don't put in blacklist though. greylist.UnionWith(renamer.GetAllMeshNames()); RenameDialog dialog = new RenameDialog(mesh.Name, new HashSet <string>(), greylist); if (dialog.ShowDialog() == DialogResult.OK) { string newName = dialog.NewName; string oldName = mesh.Name; _scene.UndoStack.PushAndDo("Rename Mesh", () => { renamer.RenameMesh(mesh, newName); }, () => { renamer.RenameMesh(mesh, oldName); }, () => { node.Text = GetMeshDisplayName(mesh, GetIndexForMesh(mesh)); }); } }
private void OnRenameMesh(object sender, EventArgs e) { var node = GetTreeNodeForContextMenuEvent(sender); if (node == null || !(node.Tag as KeyValuePair<Node, Mesh>?).HasValue) { return; } var nodeMeshPair = (KeyValuePair<Node, Mesh>)node.Tag; var mesh = nodeMeshPair.Value; SafeRenamer renamer = new SafeRenamer(_scene); HashSet<string> greylist = renamer.GetAllNodeNames(); greylist.UnionWith(renamer.GetAllMaterialNames()); greylist.UnionWith(renamer.GetAllAnimationNames()); // Mesh names need not be unique, but it's good if they are. // Don't put in blacklist though. greylist.UnionWith(renamer.GetAllMeshNames()); RenameDialog dialog = new RenameDialog(mesh.Name, new HashSet<string>(), greylist); if (dialog.ShowDialog() == DialogResult.OK) { string newName = dialog.NewName; string oldName = mesh.Name; _scene.UndoStack.PushAndDo("Rename Mesh", () => { renamer.RenameMesh(mesh, newName); }, () => { renamer.RenameMesh(mesh, oldName); }, () => { node.Text = GetMeshDisplayName(mesh, GetIndexForMesh(mesh)); }); } }
private void OnRenameNode(object sender, EventArgs e) { var node = GetTreeNodeForContextMenuEvent(sender); if (node == null || (node.Tag as Node) == null) { return; } var sceneNode = (Node)node.Tag; SafeRenamer renamer = new SafeRenamer(_scene); HashSet<string> greylist = renamer.GetAllMeshNames(); greylist.UnionWith(renamer.GetAllMaterialNames()); greylist.UnionWith(renamer.GetAllAnimationNames()); RenameDialog dialog = new RenameDialog(sceneNode.Name, renamer.GetAllNodeNames(), greylist); if (dialog.ShowDialog() == DialogResult.OK) { string newName = dialog.NewName; string oldName = sceneNode.Name; _scene.UndoStack.PushAndDo("Rename Node", () => { renamer.RenameNode(sceneNode, newName); node.Text = newName; }, () => { renamer.RenameNode(sceneNode, oldName); node.Text = oldName; }); } }
private void OnRenameAnimation(object sender, EventArgs e) { if (ActiveRawAnimation == null) { return; } Animation animation = ActiveRawAnimation; SafeRenamer renamer = new SafeRenamer(_scene); // Animations names need not be unique even amongst themselves, but it's good if they are. // Put all names in the entire scene into the greylist. RenameDialog dialog = new RenameDialog(animation.Name, new HashSet<string>(), renamer.GetAllAnimationNames()); if (dialog.ShowDialog() == DialogResult.OK) { string newName = dialog.NewName; string oldName = animation.Name; _scene.UndoStack.PushAndDo("Rename Animation", // Do () => renamer.RenameAnimation(animation, newName), // Undo () => renamer.RenameAnimation(animation, oldName), // Update () => listBoxAnimations.Items[FindAnimationIndex(animation) + 1] = FormatAnimationName(animation)); } }