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); } }
// 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(); } }
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); }