public FullChargeHandler(ChargeThresholdWrapper wrapper, ThinkPowerStatus powerStatus, ThinkTimer timer, EventHandler handler) { this.wrapper = wrapper; this.powerStatus = powerStatus; this.timer = timer; this.timer.Elapsed += CheckCharge; this.FullyChargedEventCallback += handler; originalLimit = wrapper.Limit; wrapper.Limit = 100; prevCharge = CurrentCharge; Wait(); }
public ChargeLimitApplicationContext(ChargeThresholdWrapper _wrapper) { wrapper = _wrapper; chargeLimit = wrapper.Limit; fullChargeMenuItem = new MenuItem("Fully Charge Once", new EventHandler(FullyChargeOnce)); MenuItem exitMenuItem = new MenuItem("Exit", new EventHandler(Exit)); MenuItem[] limitItems = new MenuItem[6]; int j = 0; for (int i = 50; i <= 100; i += 10) { limitItems[j] = new MenuItem(i.ToString() + '%', new EventHandler(SetLimit)) { RadioCheck = true }; if (i == chargeLimit) { limitItems[j].Checked = true; prevChecked = limitItems[j]; } j++; } limitsMenuItem = new MenuItem("Change Charge Limit", limitItems); notifyIcon = new NotifyIcon { ContextMenu = new ContextMenu(new MenuItem[] { limitsMenuItem, fullChargeMenuItem, exitMenuItem }), Visible = true }; notifyIcon.ContextMenu.Popup += new EventHandler(UpdateState); UpdateState(); }