private void treCharacterList_DragOver(object sender, DragEventArgs e) { TreeView treSenderView = sender as TreeView; if (treSenderView == null) { return; } Point pt = treSenderView.PointToClient(new Point(e.X, e.Y)); TreeNode objNode = treSenderView.GetNodeAt(pt).Parent; if (objNode.Tag.ToString() != "Watch") { objNode.BackColor = SystemColors.ControlDark; } // Clear the background colour for all other Nodes. treCharacterList.ClearNodeBackground(objNode); }
private void treCharacterList_DragDrop(object sender, DragEventArgs e) { // Do not allow the root element to be moved. if (treCharacterList.SelectedNode == null || treCharacterList.SelectedNode.Level == 0 || treCharacterList.SelectedNode.Parent.Tag.ToString() == "Watch") { return; } if (e.Data.GetDataPresent("System.Windows.Forms.TreeNode", false)) { TreeView treSenderView = sender as TreeView; if (treSenderView == null) { return; } Point pt = treSenderView.PointToClient(new Point(e.X, e.Y)); TreeNode nodDestinationNode = treSenderView.GetNodeAt(pt); if (nodDestinationNode.Level > 0) { nodDestinationNode = nodDestinationNode.Parent; } if (nodDestinationNode.Tag.ToString() != "Watch") { TreeNode nodNewNode = e.Data.GetData("System.Windows.Forms.TreeNode") as TreeNode; int intCharacterIndex; CharacterCache objCache = null; if (nodNewNode == null) { return; } if (int.TryParse(nodNewNode.Tag.ToString(), out intCharacterIndex) && intCharacterIndex >= 0 && intCharacterIndex < lstCharacterCache.Count) { objCache = lstCharacterCache[intCharacterIndex]; } if (objCache == null) { return; } switch (nodDestinationNode.Tag.ToString()) { case "Recent": GlobalOptions.Instance.RemoveFromMRUList(objCache.FilePath, "stickymru"); GlobalOptions.Instance.AddToMRUList(objCache.FilePath); break; case "Favourite": GlobalOptions.Instance.RemoveFromMRUList(objCache.FilePath); GlobalOptions.Instance.AddToMRUList(objCache.FilePath, "stickymru"); break; default: return; } TreeNode nodClonedNewNode = nodNewNode.Clone() as TreeNode; if (nodClonedNewNode != null) { nodDestinationNode.Nodes.Add(nodClonedNewNode); nodDestinationNode.Expand(); } nodNewNode.Remove(); } } }