public Form1() { InitializeComponent(); //create notification icon ico = new Icon("watchdog_ico.ico"); icon = new NotifyIcon(); icon.Icon = ico; icon.Visible = true; //create context menu for icon ContextMenu cm = new ContextMenu(); MenuItem infoMI = new MenuItem("BatteryWatchDog by Paulo Gliwa"); MenuItem quitMI = new MenuItem("Quit"); cm.MenuItems.Add(infoMI); cm.MenuItems.Add(quitMI); //add context menu to the icon icon.ContextMenu = cm; //menu item actions quitMI.Click += QuitMI_Click; st = new BeepThread(); bi = new BatteryInfo(this, st); Thread batteryThread = new Thread(new ThreadStart(bi.start)); Thread soundThread = new Thread(new ThreadStart(st.start)); batteryThread.IsBackground = true; //stops when the form is closed batteryThread.Start(); soundThread.IsBackground = true; soundThread.Start(); this.Visible = false; Form f = new Form(); f.FormBorderStyle = FormBorderStyle.SizableToolWindow; f.ShowInTaskbar = false; this.Owner = f; }
public BatteryInfo(Form1 f, BeepThread bt) { this.f = f; this.bt = bt; }