private void UpdateShortcut(TreeView targetTreeView, int treeViewNo) { if (targetTreeView.SelectedNode != null) { DataTreeNode node = (DataTreeNode)targetTreeView.SelectedNode; string nodeID = (node.Data as Shortcut).ID; frmUpdateShortcut x = new frmUpdateShortcut(); x.ShortcutAlias = (node.Data as Shortcut).Alias; x.ShortcutPath = (node.Data as Shortcut).Path; if (x.ShowDialog() == DialogResult.OK) { switch (treeViewNo) { case 1: _shortcutOperations1.UpdateNodeAliasByID(nodeID, x.ShortcutAlias); _shortcutOperations1.UpdateNodePathByID(nodeID, x.ShortcutPath); _shortcutOperations1.ReadXMLShortcuts(targetTreeView); break; case 2: _shortcutOperations2.UpdateNodeAliasByID(nodeID, x.ShortcutAlias); _shortcutOperations2.UpdateNodePathByID(nodeID, x.ShortcutPath); _shortcutOperations2.ReadXMLShortcuts(targetTreeView); break; } } } }
void trvShortcuts3_DragDrop(object sender, DragEventArgs e) { if (e.Data.GetDataPresent(DataFormats.FileDrop)) { AddNewShortcutOnDragDrop(trvShortcuts3, e, _shortcutOperations3); } else { Point pos = trvShortcuts3.PointToClient(new Point(e.X, e.Y)); TreeNode targetNode = trvShortcuts3.GetNodeAt(pos); if (targetNode != null) { DataTreeNode node = (DataTreeNode)targetNode; string targetOrderNo = (node.Data as Shortcut).OrderNo; DataTreeNode node2 = (DataTreeNode)sourceNode; string sourceOrderNo = (node2.Data as Shortcut).OrderNo; _shortcutOperations3.UpdateNodeOrderNoByID((node.Data as Shortcut).ID, sourceOrderNo); _shortcutOperations3.UpdateNodeOrderNoByID((node2.Data as Shortcut).ID, targetOrderNo); _shortcutOperations3.ReadXMLShortcuts(trvShortcuts3); } } }
private void RemoveShortcutFromTree(TreeView targetTreeView, ShortcutOperations shortcutOperations) { if (targetTreeView.SelectedNode != null) { DataTreeNode node = (DataTreeNode)targetTreeView.SelectedNode; string nodeID = (node.Data as Shortcut).ID; shortcutOperations.DeleteNodeByID(nodeID); shortcutOperations.ReadXMLShortcuts(targetTreeView); } }
private void AddNewShortcutOnDragDrop(TreeView senderTreeView, DragEventArgs e, ShortcutOperations shortcutOperations) { // Extract the data from the DataObject-Container into a string list string[] FileList = (string[])e.Data.GetData(DataFormats.FileDrop, false); // Do something with the data... // For example add all files into a simple label control: foreach (string File in FileList) { frmNewShortcut x = new frmNewShortcut(); x.Path = File; if (x.ShowDialog() == DialogResult.OK) { shortcutOperations.AddNewShortcut(x.Path, x.Alias); } } shortcutOperations.ReadXMLShortcuts(senderTreeView); }
// Form load event or a similar place private void frmMain_Load(object sender, EventArgs e) { // this.Visible = false; this.Hide(); this.ShowInTaskbar = false; this.FormBorderStyle = FormBorderStyle.None; int x = Screen.GetWorkingArea(this).Width; int y = Screen.GetWorkingArea(this).Height; this.Location = new Point(x - this.Width - xOffset, y - this.Height - yOffset); Color c = System.Drawing.ColorTranslator.FromHtml("#FFFFFF");// #F4FEFF this.BackColor = c; this.trvShortcuts.BackColor = c; this.trvShortcuts2.BackColor = c; this.trvShortcuts3.BackColor = c; this.Show(); // Enable drag and drop for this form // (this can also be applied to any controls) this.AllowDrop = true; // Add event handlers for the drag & drop functionality this.DragEnter += new DragEventHandler(frmMain_DragEnter); this.DragDrop += new DragEventHandler(frmMain_DragDrop); trvShortcuts.AllowDrop = true; trvShortcuts.DragEnter += new DragEventHandler(trvShortcuts_DragEnter); trvShortcuts.DragDrop += new DragEventHandler(trvShortcuts_DragDrop); trvShortcuts2.AllowDrop = true; trvShortcuts2.DragEnter += new DragEventHandler(trvShortcuts2_DragEnter); trvShortcuts2.DragDrop += new DragEventHandler(trvShortcuts2_DragDrop); trvShortcuts3.AllowDrop = true; trvShortcuts3.DragEnter += new DragEventHandler(trvShortcuts3_DragEnter); trvShortcuts3.DragDrop += new DragEventHandler(trvShortcuts3_DragDrop); //ReadXMLShortcuts(); _shortcutOperations1 = new ShortcutOperations(Application.StartupPath + "\\Shortcuts.xml"); _shortcutOperations1.ReadXMLShortcuts(trvShortcuts); _shortcutOperations2 = new ShortcutOperations(Application.StartupPath + "\\Shortcuts2.xml"); _shortcutOperations2.ReadXMLShortcuts(trvShortcuts2); _shortcutOperations3 = new ShortcutOperations(Application.StartupPath + "\\Shortcuts3.xml"); _shortcutOperations3.ReadXMLShortcuts(trvShortcuts3); /*string bgFile = Application.StartupPath + "\\background.png"; * if (File.Exists(bgFile)) * this.BackgroundImage = Bitmap.FromFile(bgFile);*/ //SET KEYBOARD HOOK //actHook = new UserActivityHook(true, false); // create an instance //actHook.OnMouseActivity += new MouseEventHandler(MouseMoved); //actHook.KeyDown += new KeyEventHandler(MyKeyDown); //actHook.KeyPress += new KeyPressEventHandler(MyKeyPress); //actHook.KeyUp += new KeyEventHandler(MyKeyUp); // MakeEffect(50); object o = Microsoft.Win32.Registry.GetValue("HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Run", "Shortcuts", null); if (o == null) { frmIntro z = new frmIntro(); z.ShowDialog(); } }