Guest User

Untitled

a guest
Oct 21st, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.34 KB | None | 0 0
  1. //public partial class HotKeyWin : Window // WindowStyle="ToolWindow"
  2.  
  3. public partial class NotifyIconWrapper : Component
  4. {
  5. private HotKeyWin hkeyWin = new HotKeyWin();
  6.  
  7. public NotifyIconWrapper()
  8. {
  9. hkeyWin.Show();
  10. hkeyWin.Closing += new CancelEventHandler(hkeyWin_Closing);
  11. hkeyWin.Hide();
  12. }
  13.  
  14. void hkeyWin_Closing(object sender, CancelEventArgs e)
  15. {
  16. Console.WriteLine("hkeyWin_Closing enter");
  17. e.Cancel = true;
  18. }
  19.  
  20. private void contextMenuStrip2_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
  21. {
  22. if (e.Alt) hkeyWin.Activate();
  23. }
  24. }
  25.  
  26. private void Form1_Load(object sender, EventArgs e)
  27. {
  28. this.Activated += new EventHandler(Form1_Activated);
  29. }
  30.  
  31. void Form1_Activated(object sender, EventArgs e)
  32. {
  33. string iconPath = "some file system path";
  34. notifyIcon1.Icon = new Icon(iconPath);
  35. }
  36.  
  37. public mainForm_keypressed(object sender, //eventargs
  38. {
  39. if(_hidden && //Keystroke detection)
  40. {
  41. e.Handled = true;
  42. return;
  43. }
  44. }
  45.  
  46. private void myMenuTray_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
  47. {
  48. if (e.KeyCode == Keys.Menu && e.KeyValue == 18 && e.Alt)
  49. {
  50. MessageBox.Show("");
  51. MessageBox.Show("YOU CAN'T CLOSE HERE WITH ALT-F4");
  52. return;
  53. }
  54. }
Add Comment
Please, Sign In to add comment