private void projectNameChangeBTN_Click(object sender, EventArgs e) { StringQueryDialog sqd = new StringQueryDialog("Rename Project To: ", projectNameLabel.Text); sqd.ShowDialog(); if (sqd.Value != "") { projectNameLabel.Text = sqd.Value; } }
private void entryNameLabel_Click(object sender, EventArgs e) { StringQueryDialog sqd = new StringQueryDialog("Rename mod to [min length:1]: ", ModName); sqd.ShowDialog(); if (sqd.Value != "") { ModName = sqd.Value.PadRight(3, '-'); entryNameLabel.Text = ModName; } }
/// <summary> /// Event handler for when a DragDrop operation completed on top of the changesview /// </summary> void changesView_DragDrop(object sender, DragEventArgs e) { //Check if we have a file/list of filfes if (e.Data is DataObject && ((DataObject)e.Data).ContainsFileDropList()) { DataObject dataObject = (DataObject)e.Data; StringCollection dropList = dataObject.GetFileDropList(); List <string> filePaths = new List <string>(); foreach (string path in dropList) { if (File.GetAttributes(path).HasFlag(FileAttributes.Directory)) { filePaths.AddRange(Util.GetAllChildFiles(path));//Directory.GetFiles(rootPath, "**", SearchOption.AllDirectories); } else { filePaths.Add(path); } } if (filePaths.Count == 1) //test if its a project { if (filePaths[0].ToLower().EndsWith(".rmproj")) { if (HasProjectChanged) { PromptSaveToClose(); } //Load the project LoadProject(filePaths[0]); return; } } //Iterate through all files StringQueryDialog nameQueryDialog = new StringQueryDialog("Type File Group Name:"); nameQueryDialog.ShowDialog(); if (nameQueryDialog.Value.Trim() == "") { Log("Invalid name '{0}' given. ".F(nameQueryDialog.Value.Trim())); return; } TristateTreeNode topNode = new TristateTreeNode(nameQueryDialog.Value); topNode.HasCheckBox = true; for (int z = 0; z < filePaths.Count; z++) { SetTaskbarProgress(z * 100 / filePaths.Count); string filePath = filePaths[z].Replace("\\", "/"); //Console.WriteLine(filePath); //ADD TO VIEW HERE TristateTreeNode node; topNode.Nodes.Add( node = new TristateTreeNode(filePath) ); node.HasCheckBox = true; //changesView.Rows[rowIndex].Cells[CN_LOCALPATH].Style.Alignment = DataGridViewContentAlignment.MiddleRight; //Split the path into pieces split by FSOs... Search the RAF archives and see if we can link it to the raf path string[] pathParts = filePath.Split("/"); RAFFileListEntry matchedEntry = null; List <RAFFileListEntry> lastMatches = null; bool done = false; //Smart search insertion for (int i = 1; i < pathParts.Length + 1 && !done; i++) { string[] searchPathParts = pathParts.SubArray(pathParts.Length - i, i); string searchPath = String.Join("/", searchPathParts); //Console.WriteLine(searchPath); List <RAFFileListEntry> matches = new List <RAFFileListEntry>(); RAFArchive[] archives = rafArchives.Values.ToArray(); for (int j = 0; j < archives.Length; j++) { List <RAFFileListEntry> newmatches = archives[j].GetDirectoryFile().GetFileList().SearchFileEntries(searchPath); matches.AddRange(newmatches); } if (matches.Count == 1) { matchedEntry = matches[0]; done = true; } else if (matches.Count == 0) { done = true; } else { lastMatches = matches; } } if (matchedEntry == null) { if (lastMatches != null && lastMatches.Count > 0) { //Resolve ambiguity FileEntryAmbiguityResolver ambiguityResolver = new FileEntryAmbiguityResolver(lastMatches.ToArray(), "!"); ambiguityResolver.ShowDialog(); RAFFileListEntry resolvedItem = (RAFFileListEntry)ambiguityResolver.SelectedItem; if (resolvedItem != null) { matchedEntry = resolvedItem; } } else if (advancedUser) { //We'll use the file browser to select where we want to save... string rafPath = PickRafPath(false) + "/"; RAFArchive archive = rafArchives[rafPath.Replace("\\", "/").Split("/").First()]; rafPath = rafPath.Substring(rafPath.IndexOf("/") + 1); //remove the archive name now... if (rafPath.Length != 0) { Console.WriteLine("FRP: " + "len!= 0"); if (rafPath[rafPath.Length - 1] == '/') { Console.WriteLine("FRP: " + rafPath); rafPath = rafPath.Substring(0, rafPath.Length - 1);//remove the trailing /, since we add it later } } Console.WriteLine("FRP: " + rafPath); if (rafPath == "") { matchedEntry = new RAFFileListEntry(archive, pathParts.Last(), UInt32.MaxValue, (UInt32) new FileInfo(filePath).Length, UInt32.MaxValue); } else { matchedEntry = new RAFFileListEntry(archive, rafPath + "/" + pathParts.Last(), UInt32.MaxValue, (UInt32) new FileInfo(filePath).Length, UInt32.MaxValue); } //Add the tree node to the raf viewer } } if (matchedEntry != null) //If it's still not resolved { node.Tag = new ChangesViewEntry(filePath, matchedEntry, node); node.Nodes.Add(new TristateTreeNode("Local Path: " + filePath)); node.Nodes.Add(new TristateTreeNode("RAF Path: " + matchedEntry.RAFArchive.GetID() + "/" + matchedEntry.FileName)); node.Nodes[0].HasCheckBox = false; node.Nodes[1].HasCheckBox = false; //changesView.Rows[rowIndex].Cells[CN_RAFPATH].Value = matchedEntry.RAFArchive.GetID() + "/" + matchedEntry.FileName; //changesView.Rows[rowIndex].Cells[CN_RAFPATH].Tag = matchedEntry; } else { node.Tag = new ChangesViewEntry(filePath, null, node); node.Nodes.Add(new TristateTreeNode("Local Path: " + filePath)); node.Nodes.Add(new TristateTreeNode("RAF Path: " + "undefined")); node.Nodes[0].HasCheckBox = false; node.Nodes[1].HasCheckBox = false; Log("Unable to link file '" + filePath + "' to RAF Archive. Please manually select RAF path"); } } changesView.Nodes.Add(topNode); changesView.Invalidate(); SetTaskbarProgress(0); } }
void changesView_NodeRightClicked(TristateTreeNode node, MouseEventArgs e) { ContextMenu cm = new ContextMenu(); MenuItem pack = new MenuItem("Pack (Install checked, uninstall unchecked)"); #region pack button pack.Click += delegate(object sender, EventArgs e2) { if (VerifyPackPrecondition( new List <TristateTreeNode>( new TristateTreeNode[] { node } ) )) { Title("Begin Packing..."); PackNode(node); Title(GetWindowTitle()); Log("Pack done"); } }; #endregion cm.MenuItems.Add(pack); MenuItem rename = new MenuItem("Rename"); #region rename button rename.Click += delegate(object s2, EventArgs e2) { StringQueryDialog sqd = new StringQueryDialog("Rename '" + node.Text + "' to:", node.Text); sqd.ShowDialog(); node.Text = sqd.Value; node.TreeView.Invalidate(); HasProjectChanged = true; }; #endregion cm.MenuItems.Add(rename); MenuItem groupButton = new MenuItem("Group"); #region group button groupButton.Click += delegate(object s2, EventArgs e2) { List <TristateTreeNode> nodes = new List <TristateTreeNode>(changesView.SelectedNodes); changesView.SelectedNodes.Clear(); StringQueryDialog sqd = new StringQueryDialog("What would you like to name this group?"); sqd.ShowDialog(); if (sqd.Value == "") { return; } TristateTreeNode newNode = new TristateTreeNode(sqd.Value.Trim()); //Remove the nodes from their parent, keep the first one for replacement w/ our new node for (int i = 1; i < nodes.Count; i++) { if (nodes[i].Parent is TristateTreeNode) { ((TristateTreeNode)nodes[i].Parent).Nodes.Remove(nodes[i]); } else { ((TristateTreeView)nodes[i].Parent).Nodes.Remove(nodes[i]); } } Object oldParent = nodes[0].Parent; //Add the nodes to our new node for (int i = 0; i < nodes.Count; i++) { newNode.Nodes.Add(nodes[i]); } //Replace the previous node with our new node if (oldParent is TristateTreeNode) { TristateTreeNode parent = (TristateTreeNode)oldParent; parent.Nodes[parent.Nodes.IndexOf(nodes[0])] = newNode; newNode.Parent = parent; } else { TristateTreeView parent = (TristateTreeView)oldParent; parent.Nodes[parent.Nodes.IndexOf(nodes[0])] = newNode; newNode.Parent = parent; } newNode.HasCheckBox = true; newNode.UpdateCheckState(true, true); changesView.Invalidate(); }; #endregion cm.MenuItems.Add(groupButton); #region ungroup button if (changesView.SelectedNodes.Count == 1) { if (changesView.SelectedNode.Tag == null) //If it's a RAF Object, we can't ungroup it. { //This isn't a raf object MenuItem ungroupButton = new MenuItem("Ungroup"); ungroupButton.Click += delegate(object s2, EventArgs e2) { if (changesView.SelectedNode.Parent is TristateTreeView) { TristateTreeNode groupNode = changesView.SelectedNode; TristateTreeView parent = (TristateTreeView)changesView.SelectedNode.Parent; int oldIndex = parent.Nodes.IndexOf(groupNode); parent.Nodes.Remove(groupNode); for (int i = 0; i < groupNode.Nodes.Count; i++) { parent.Nodes.Insert(oldIndex + i, groupNode.Nodes[i]); } //parent.Nodes.Remove(groupNode); changesView.Invalidate(); } }; cm.MenuItems.Add(ungroupButton); } } #endregion #region delete button if (changesView.SelectedNodes.Count >= 2) { MenuItem multiDelete = new MenuItem("Remove From Project (Won't uninstall)"); #region delete button multiDelete.Click += delegate(object sender, EventArgs e2) { while (changesView.SelectedNodes.Count > 0) { node = changesView.SelectedNodes[0]; if (node.Parent is TristateTreeView) { TristateTreeView p = (TristateTreeView)node.Parent; p.Nodes.Remove(node); if (p.SelectedNode == node) { p.SelectedNode = null; } p.Invalidate(); } else { TristateTreeNode n = (TristateTreeNode)node.Parent; n.Nodes.Remove(node); if (n.TreeView.SelectedNode == node) { n.TreeView.SelectedNode = null; } n.TreeView.Invalidate(); } changesView.SelectedNodes.RemoveAt(0); } HasProjectChanged = true; }; #endregion cm.MenuItems.Add(multiDelete); } else { MenuItem delete = new MenuItem("Remove From Project (Won't uninstall)"); #region delete button delete.Click += delegate(object sender, EventArgs e2) { if (node.Parent is TristateTreeView) { TristateTreeView p = (TristateTreeView)node.Parent; p.Nodes.Remove(node); if (p.SelectedNode == node) { p.SelectedNode = null; } p.Invalidate(); } else { TristateTreeNode n = (TristateTreeNode)node.Parent; n.Nodes.Remove(node); if (n.TreeView.SelectedNode == node) { n.TreeView.SelectedNode = null; } n.TreeView.Invalidate(); } HasProjectChanged = true; }; #endregion cm.MenuItems.Add(delete); } #endregion //Checkbox or radio? if (changesView.SelectedNode.NodeType == TristateTreeNodeType.Radio || changesView.SelectedNode.NodeType == TristateTreeNodeType.Checkboxes) {//It's swappable MenuItem changeType = new MenuItem("Change to " + (changesView.SelectedNode.NodeType == TristateTreeNodeType.Checkboxes ? "Radio Selector" : "Checkboxes") + " - Coming Soon!" ); changeType.Click += delegate(object s2, EventArgs e2) { if (changesView.SelectedNode.NodeType == TristateTreeNodeType.Radio) { changesView.SelectedNode.NodeType = TristateTreeNodeType.Checkboxes; } else if (changesView.SelectedNode.NodeType == TristateTreeNodeType.Checkboxes) { changesView.SelectedNode.NodeType = TristateTreeNodeType.Radio; } changesView.Invalidate(); }; changeType.Enabled = false; cm.MenuItems.Add(changeType); } cm.Show(changesView, new Point(e.X, e.Y)); }
/// <summary> /// Dragdrop - process file drops /// Add them if appropriate /// </summary> void modEntriesPanel_DragDrop(object sender, DragEventArgs e) { if (e.Data is DataObject && ((DataObject)e.Data).ContainsFileDropList()) { StringCollection filePaths = ((DataObject)e.Data).GetFileDropList(); //Get all files that were dropped in, by searching subdirectories too List<String> resultFiles = new List<string>(); foreach (string path in filePaths) if ((new FileInfo(path).Attributes & FileAttributes.Directory) != 0) { resultFiles.AddRange(Util.GetAllChildFiles(path)); } else resultFiles.Add(path); List<TreeNode> resultantNodes = new List<TreeNode>(); string iconPath = null; //If there is a script it overrides default action RMPropInterpreter script = null; foreach (string path in resultFiles) { string rafPath = GuessRafPathFromPath(path); if (rafPath != "undefined") { TreeNode node = new TreeNode(path.Replace("\\", "/").Split("/").Last()); node.Nodes.Add("Local Path: " + path); node.Nodes.Add("RAF Path: " + rafPath); node.Tag = new ModEntryNodeTag() { localPath = path, rafPath = rafPath }; resultantNodes.Add(node); } else { //We usually skip it if it is undefined. We have some special cases if (path.EndsWith("rafmanagericon.jpg")) { iconPath = path; } else if (path.EndsWith("rafmanagerscript")) { try { script = new RMPropInterpreter( path, this ); }catch(Exception ex) { Console.WriteLine(ex); } }else Log("Unable to resolve local path to RAF path: " + path); } } ModEntry modEntry = null; if (script == null) { //resultFiles has all our files. StringQueryDialog sqd = new StringQueryDialog("What is the name of the mod that you are dropping into RAF Manager?"); sqd.ShowDialog(); if (sqd.Value == "") return; modEntry = CreateAndAppendModEntry(sqd.Value, "-", "-", resultantNodes.ToArray()); } else { modEntry = CreateAndAppendModEntry(script.Name, script.Creator, script.WebsiteURL, resultantNodes.ToArray()); modEntry.Script = script; } try { if (iconPath != null) { modEntry.IconImage = Bitmap.FromFile(iconPath); modEntry.IconImage.Tag = iconPath; } } catch { } } }
/// <summary> /// Dragdrop - process file drops /// Add them if appropriate /// </summary> void modEntriesPanel_DragDrop(object sender, DragEventArgs e) { if (e.Data is DataObject && ((DataObject)e.Data).ContainsFileDropList()) { StringCollection filePaths = ((DataObject)e.Data).GetFileDropList(); //Get all files that were dropped in, by searching subdirectories too List <String> resultFiles = new List <string>(); foreach (string path in filePaths) { if ((new FileInfo(path).Attributes & FileAttributes.Directory) != 0) { resultFiles.AddRange(Util.GetAllChildFiles(path)); } else { resultFiles.Add(path); } } List <TreeNode> resultantNodes = new List <TreeNode>(); string iconPath = null; //If there is a script it overrides default action RMPropInterpreter script = null; foreach (string path in resultFiles) { string rafPath = GuessRafPathFromPath(path); if (rafPath != "undefined") { TreeNode node = new TreeNode(path.Replace("\\", "/").Split("/").Last()); node.Nodes.Add("Local Path: " + path); node.Nodes.Add("RAF Path: " + rafPath); node.Tag = new ModEntryNodeTag() { localPath = path, rafPath = rafPath }; resultantNodes.Add(node); } else { //We usually skip it if it is undefined. We have some special cases if (path.EndsWith("rafmanagericon.jpg")) { iconPath = path; } else if (path.EndsWith("rafmanagerscript")) { try { script = new RMPropInterpreter( path, this ); }catch (Exception ex) { Console.WriteLine(ex); } } else { Log("Unable to resolve local path to RAF path: " + path); } } } ModEntry modEntry = null; if (script == null) { //resultFiles has all our files. StringQueryDialog sqd = new StringQueryDialog("What is the name of the mod that you are dropping into RAF Manager?"); sqd.ShowDialog(); if (sqd.Value == "") { return; } modEntry = CreateAndAppendModEntry(sqd.Value, "-", "-", resultantNodes.ToArray()); } else { modEntry = CreateAndAppendModEntry(script.Name, script.Creator, script.WebsiteURL, resultantNodes.ToArray()); modEntry.Script = script; } try { if (iconPath != null) { modEntry.IconImage = Bitmap.FromFile(iconPath); modEntry.IconImage.Tag = iconPath; } } catch { } } }
private void projectNameChangeBTN_Click(object sender, EventArgs e) { StringQueryDialog sqd = new StringQueryDialog("Rename Project To: ", projectNameLabel.Text); sqd.ShowDialog(); if (sqd.Value != "") projectNameLabel.Text = sqd.Value; }
private void entryNameLabel_Click(object sender, EventArgs e) { StringQueryDialog sqd = new StringQueryDialog("Rename mod to [min length:1]: ", ModName); sqd.ShowDialog(); if (sqd.Value != "") { ModName = sqd.Value.PadRight(3, '-'); entryNameLabel.Text = ModName; } }
/// <summary> /// Event handler for when a DragDrop operation completed on top of the changesview /// </summary> void changesView_DragDrop(object sender, DragEventArgs e) { //Check if we have a file/list of filfes if (e.Data is DataObject && ((DataObject)e.Data).ContainsFileDropList()) { DataObject dataObject = (DataObject)e.Data; StringCollection dropList = dataObject.GetFileDropList(); List<string> filePaths = new List<string>(); foreach (string path in dropList) { if (File.GetAttributes(path).HasFlag(FileAttributes.Directory)) filePaths.AddRange(Util.GetAllChildFiles(path));//Directory.GetFiles(rootPath, "**", SearchOption.AllDirectories); else filePaths.Add(path); } if (filePaths.Count == 1) //test if its a project { if (filePaths[0].ToLower().EndsWith(".rmproj")) { if (HasProjectChanged) PromptSaveToClose(); //Load the project LoadProject(filePaths[0]); return; } } //Iterate through all files StringQueryDialog nameQueryDialog = new StringQueryDialog("Type File Group Name:"); nameQueryDialog.ShowDialog(); if (nameQueryDialog.Value.Trim() == "") { Log("Invalid name '{0}' given. ".F(nameQueryDialog.Value.Trim())); return; } TristateTreeNode topNode = new TristateTreeNode(nameQueryDialog.Value); topNode.HasCheckBox = true; for (int z = 0; z < filePaths.Count; z++) { SetTaskbarProgress(z * 100 / filePaths.Count); string filePath = filePaths[z].Replace("\\", "/"); //Console.WriteLine(filePath); //ADD TO VIEW HERE TristateTreeNode node; topNode.Nodes.Add( node = new TristateTreeNode(filePath) ); node.HasCheckBox = true; //changesView.Rows[rowIndex].Cells[CN_LOCALPATH].Style.Alignment = DataGridViewContentAlignment.MiddleRight; //Split the path into pieces split by FSOs... Search the RAF archives and see if we can link it to the raf path string[] pathParts = filePath.Split("/"); RAFFileListEntry matchedEntry = null; List<RAFFileListEntry> lastMatches = null; bool done = false; //Smart search insertion for (int i = 1; i < pathParts.Length + 1 && !done; i++) { string[] searchPathParts = pathParts.SubArray(pathParts.Length - i, i); string searchPath = String.Join("/", searchPathParts); //Console.WriteLine(searchPath); List<RAFFileListEntry> matches = new List<RAFFileListEntry>(); RAFArchive[] archives = rafArchives.Values.ToArray(); for (int j = 0; j < archives.Length; j++) { List<RAFFileListEntry> newmatches = archives[j].GetDirectoryFile().GetFileList().SearchFileEntries(searchPath); matches.AddRange(newmatches); } if (matches.Count == 1) { matchedEntry = matches[0]; done = true; } else if (matches.Count == 0) { done = true; } else { lastMatches = matches; } } if (matchedEntry == null) { if (lastMatches != null && lastMatches.Count > 0) { //Resolve ambiguity FileEntryAmbiguityResolver ambiguityResolver = new FileEntryAmbiguityResolver(lastMatches.ToArray(), "!"); ambiguityResolver.ShowDialog(); RAFFileListEntry resolvedItem = (RAFFileListEntry)ambiguityResolver.SelectedItem; if (resolvedItem != null) { matchedEntry = resolvedItem; } } else if (advancedUser) { //We'll use the file browser to select where we want to save... string rafPath = PickRafPath(false) + "/"; RAFArchive archive = rafArchives[rafPath.Replace("\\", "/").Split("/").First()]; rafPath = rafPath.Substring(rafPath.IndexOf("/") + 1); //remove the archive name now... if (rafPath.Length != 0) { Console.WriteLine("FRP: " + "len!= 0"); if (rafPath[rafPath.Length - 1] == '/') { Console.WriteLine("FRP: " + rafPath); rafPath = rafPath.Substring(0, rafPath.Length - 1);//remove the trailing /, since we add it later } } Console.WriteLine("FRP: " + rafPath); if (rafPath == "") matchedEntry = new RAFFileListEntry(archive, pathParts.Last(), UInt32.MaxValue, (UInt32)new FileInfo(filePath).Length, UInt32.MaxValue); else matchedEntry = new RAFFileListEntry(archive, rafPath + "/" + pathParts.Last(), UInt32.MaxValue, (UInt32)new FileInfo(filePath).Length, UInt32.MaxValue); //Add the tree node to the raf viewer } } if (matchedEntry != null) //If it's still not resolved { node.Tag = new ChangesViewEntry(filePath, matchedEntry, node); node.Nodes.Add(new TristateTreeNode("Local Path: " + filePath)); node.Nodes.Add(new TristateTreeNode("RAF Path: " + matchedEntry.RAFArchive.GetID() + "/" + matchedEntry.FileName)); node.Nodes[0].HasCheckBox = false; node.Nodes[1].HasCheckBox = false; //changesView.Rows[rowIndex].Cells[CN_RAFPATH].Value = matchedEntry.RAFArchive.GetID() + "/" + matchedEntry.FileName; //changesView.Rows[rowIndex].Cells[CN_RAFPATH].Tag = matchedEntry; } else { node.Tag = new ChangesViewEntry(filePath, null, node); node.Nodes.Add(new TristateTreeNode("Local Path: " + filePath)); node.Nodes.Add(new TristateTreeNode("RAF Path: " + "undefined")); node.Nodes[0].HasCheckBox = false; node.Nodes[1].HasCheckBox = false; Log("Unable to link file '" + filePath + "' to RAF Archive. Please manually select RAF path"); } } changesView.Nodes.Add(topNode); changesView.Invalidate(); SetTaskbarProgress(0); } }
void changesView_NodeRightClicked(TristateTreeNode node, MouseEventArgs e) { ContextMenu cm = new ContextMenu(); MenuItem pack = new MenuItem("Pack (Install checked, uninstall unchecked)"); #region pack button pack.Click += delegate(object sender, EventArgs e2) { if (VerifyPackPrecondition( new List<TristateTreeNode>( new TristateTreeNode[] { node } ) )) { Title("Begin Packing..."); PackNode(node); Title(GetWindowTitle()); Log("Pack done"); } }; #endregion cm.MenuItems.Add(pack); MenuItem rename = new MenuItem("Rename"); #region rename button rename.Click += delegate(object s2, EventArgs e2) { StringQueryDialog sqd = new StringQueryDialog("Rename '" + node.Text + "' to:", node.Text); sqd.ShowDialog(); node.Text = sqd.Value; node.TreeView.Invalidate(); HasProjectChanged = true; }; #endregion cm.MenuItems.Add(rename); MenuItem groupButton = new MenuItem("Group"); #region group button groupButton.Click += delegate(object s2, EventArgs e2) { List<TristateTreeNode> nodes = new List<TristateTreeNode>(changesView.SelectedNodes); changesView.SelectedNodes.Clear(); StringQueryDialog sqd = new StringQueryDialog("What would you like to name this group?"); sqd.ShowDialog(); if (sqd.Value == "") return; TristateTreeNode newNode = new TristateTreeNode(sqd.Value.Trim()); //Remove the nodes from their parent, keep the first one for replacement w/ our new node for (int i = 1; i < nodes.Count; i++) { if (nodes[i].Parent is TristateTreeNode) ((TristateTreeNode)nodes[i].Parent).Nodes.Remove(nodes[i]); else ((TristateTreeView)nodes[i].Parent).Nodes.Remove(nodes[i]); } Object oldParent = nodes[0].Parent; //Add the nodes to our new node for (int i = 0; i < nodes.Count; i++) newNode.Nodes.Add(nodes[i]); //Replace the previous node with our new node if (oldParent is TristateTreeNode) { TristateTreeNode parent = (TristateTreeNode)oldParent; parent.Nodes[parent.Nodes.IndexOf(nodes[0])] = newNode; newNode.Parent = parent; } else { TristateTreeView parent = (TristateTreeView)oldParent; parent.Nodes[parent.Nodes.IndexOf(nodes[0])] = newNode; newNode.Parent = parent; } newNode.HasCheckBox = true; newNode.UpdateCheckState(true, true); changesView.Invalidate(); }; #endregion cm.MenuItems.Add(groupButton); #region ungroup button if (changesView.SelectedNodes.Count == 1) { if (changesView.SelectedNode.Tag == null) //If it's a RAF Object, we can't ungroup it. { //This isn't a raf object MenuItem ungroupButton = new MenuItem("Ungroup"); ungroupButton.Click += delegate(object s2, EventArgs e2) { if(changesView.SelectedNode.Parent is TristateTreeView) { TristateTreeNode groupNode = changesView.SelectedNode; TristateTreeView parent = (TristateTreeView)changesView.SelectedNode.Parent; int oldIndex = parent.Nodes.IndexOf(groupNode); parent.Nodes.Remove(groupNode); for(int i = 0; i < groupNode.Nodes.Count; i++) parent.Nodes.Insert(oldIndex + i, groupNode.Nodes[i]); //parent.Nodes.Remove(groupNode); changesView.Invalidate(); } }; cm.MenuItems.Add(ungroupButton); } } #endregion #region delete button if (changesView.SelectedNodes.Count >= 2) { MenuItem multiDelete = new MenuItem("Remove From Project (Won't uninstall)"); #region delete button multiDelete.Click += delegate(object sender, EventArgs e2) { while (changesView.SelectedNodes.Count > 0) { node = changesView.SelectedNodes[0]; if (node.Parent is TristateTreeView) { TristateTreeView p = (TristateTreeView)node.Parent; p.Nodes.Remove(node); if (p.SelectedNode == node) p.SelectedNode = null; p.Invalidate(); } else { TristateTreeNode n = (TristateTreeNode)node.Parent; n.Nodes.Remove(node); if (n.TreeView.SelectedNode == node) n.TreeView.SelectedNode = null; n.TreeView.Invalidate(); } changesView.SelectedNodes.RemoveAt(0); } HasProjectChanged = true; }; #endregion cm.MenuItems.Add(multiDelete); } else { MenuItem delete = new MenuItem("Remove From Project (Won't uninstall)"); #region delete button delete.Click += delegate(object sender, EventArgs e2) { if (node.Parent is TristateTreeView) { TristateTreeView p = (TristateTreeView)node.Parent; p.Nodes.Remove(node); if (p.SelectedNode == node) p.SelectedNode = null; p.Invalidate(); } else { TristateTreeNode n = (TristateTreeNode)node.Parent; n.Nodes.Remove(node); if (n.TreeView.SelectedNode == node) n.TreeView.SelectedNode = null; n.TreeView.Invalidate(); } HasProjectChanged = true; }; #endregion cm.MenuItems.Add(delete); } #endregion //Checkbox or radio? if (changesView.SelectedNode.NodeType == TristateTreeNodeType.Radio || changesView.SelectedNode.NodeType == TristateTreeNodeType.Checkboxes) {//It's swappable MenuItem changeType = new MenuItem("Change to " + (changesView.SelectedNode.NodeType == TristateTreeNodeType.Checkboxes ? "Radio Selector" : "Checkboxes") +" - Coming Soon!" ); changeType.Click += delegate(object s2, EventArgs e2) { if (changesView.SelectedNode.NodeType == TristateTreeNodeType.Radio) changesView.SelectedNode.NodeType = TristateTreeNodeType.Checkboxes; else if (changesView.SelectedNode.NodeType == TristateTreeNodeType.Checkboxes) changesView.SelectedNode.NodeType = TristateTreeNodeType.Radio; changesView.Invalidate(); }; changeType.Enabled = false; cm.MenuItems.Add(changeType); } cm.Show(changesView, new Point(e.X, e.Y)); }