///
///
///
///
#region tree node drag private void trv_ParkTree_DragDrop (object sender, System.Windows.Forms.DragEventArgs e) {// get information obtaining source node for "Drag" drag operation string TreeNode sourceNode = this.trv_ParkTree.SelectedNode; string dummy = "temp"; string source_Text = (string) e.Data.GetData (dummy.GetType ()); string target_Text = ""; int source_id = 0; source_Text = source_Text.Substring (source_Text.IndexOf ( ":" ) 1) .Trim (); string soruceNodeType = this.checkNode (sourceNode); TreeNode DragNode = new TreeNode (source_Text); // Create a node DragNode.Tag = sourceNode.Tag; switch (soruceNodeType) // The source node type calculates correlation ID {case "ParkNode": source_id = ((OMTPark) this.trv_ParkTree.SelectedNode.Tag) .PRK_ID; DragNode.ImageIndex = 0; break; case "RootParkNode": source_id = ((OMTPark) this.trv_ParkTree. SELECTEDNODE.TAG) .prk_id; SorucenodeType = "parknode"; Dragnode.ImageIndex = 1; Break; Case "computenode": Source_ID = ((OMTComputer) this.trv_park Tree.SelectedNode.Tag) .COM_ID; DragNode.ImageIndex = 2; break; case "MachineNode": source_id = ((OMTMachine) this.trv_ParkTree.SelectedNode.Tag) .MAC_NO; DragNode.ImageIndex = 3; break; default: break ;} //MessageBox.Show (source_Text "" soruceNodeType); // get the target node information m_Position.X = eX; m_Position.Y = eY; m_Position = trv_ParkTree.PointToClient (m_Position); TreeNode DropNode = this.trv_ParkTree.GetNodeAt (m_position); string targetnodetype = this.checknode (dropnode); target_text =
DropNode.Text.trim (); //messagebox.show (dropnode.text); // Add to item IF titled with this string in the target component (DropNode! = Null && Source_id.toString ()! = "" ) {if ((soruceNodeType == "ComputerNode" && targetNodeType == "RootParkNode") || (soruceNodeType == "ParkNode" && targetNodeType == "ParkNode") || (soruceNodeType == "ComputerNode" && targetNodeType == " Parknode ") || (SorucenodeType ==" Machinenode "&& targetNodeType ==" computerNode ")) {if (source_text == target_text) {MessageBox.show (this," Drag and drop position is not "," Tips ", MessageBoxButtons.ok , MessageBoxIcon.Exclamation); return;} if (targetNodeType == "RootParkNode" && soruceNodeType == "ParkNode") {((OMTPark) sourceNode.Tag) .PPARK_ID = ((OMTPark) DropNode.Tag) .PRK_ID; (( OMTPark) sourceNode.Tag) .store ();} else if (targetNodeType == "ParkNode" && soruceNodeType == "ComputerNode" || targetNodeType == "RootParkNode" && soruceNodeType == "ComputerNode") {((OMTComputer) sourceNode .Tag) .prk_id = ((OMTPARK) DROPNODE.TAG) .prk_id; ((OMTComputer) sourceNode.Tag) .store ();} else if (targetNodeType == "ComputerNode" && soruceNodeType == "MachineNode") {((OMTMachine) sourceNode.Tag) .COM_ID = ((OMTComputer) DropNode.Tag ) .Com_id; (OMTMACHINE) SourceNode.tag) .Store ();} InitloadTree (); //dropnode.nodes.insert(Dropnode.index 1, Dragnode;
// Insert to the target node //this.trv_parktree.selectedNode.Remove ();} else {messagebox.show ("Incorrect drag and drop position", "prompt", MessageBoxButtons.ok, MessageBoxicon.exclamation;}}} priva Void TRV_PARKTREE_DRAGENTER (Object sender, system.windows.Forms.drageventargs e) {// determines whether the data currently drag is a string, if yes, drag the string to copy if the destination component (E.DATA.GETDATAPRESENT DataFormats.Text) {E.Effect = DragDropeffects.move;} else {E.Effect = DragDropeffects.none;}}
private void trv_ParkTree_ItemDrag (object sender, System.Windows.Forms.ItemDragEventArgs e) {// determines whether the right mouse button pressed if (this.trv_ParkTree.SelectedNode == null) {return;} else if (this.trv_ParkTree.SelectedNode. PARENT == NULL) {Return;} else if (e.button == mousebuttons.right) {Return;}
String strient = E.Item.tostring (); // Start "DRAG" Operation // DodragDrop (Stritem, Dragdropeffects.copy | Dragdropeffects.move); DodragDrop (Stritem, Dragdropeffects.Move);}
Private void TRV_PARKTREE_DRAGOVER (Object Sender, System.Windows E) {} #ENDREGON