Ejemplo n.º 1
0
        private void OnAutostart(object sender, EventArgs e)
        {
            MenuItem menuItem = (MenuItem)sender;

            Autostart.SetAutoStart(!menuItem.Checked);
            menuItem.Checked = Autostart.GetAutostart();
        }
Ejemplo n.º 2
0
        public Main()
        {
            // set language to English/US
            Thread.CurrentThread.CurrentCulture   = new CultureInfo("en-US");
            Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-US");

            InitializeComponent();

            // read settings file
            settings = new Settings();
            settings.ReadConfig();

            // create info window
            windowInfo = new WindowInfo(settings);

            // create hotkey detection window
            _windowHotkeyDetection = new WindowHotkeyDetection();

            // create tray icon
            _trayIcon          = new NotifyIcon();
            _trayIcon.Icon     = (Icon)Properties.Resources.ResourceManager.GetObject("icon");
            _trayIcon.Text     = System.Windows.Forms.Application.ProductName;
            _trayIcon.MouseUp += OnTrayMenu_MouseUp;

            // create tray menu
            ContextMenu trayMenu = new ContextMenu();

            MenuItem version = new MenuItem(System.Windows.Forms.Application.ProductName + " " + Helper.GetVersion());

            version.Enabled = false;
            trayMenu.MenuItems.Add(version);

            trayMenu.MenuItems.Add("Configuration...", OnConfiguration);

            MenuItem autostartMenuItem = new MenuItem("Autostart");

            autostartMenuItem.Checked = Autostart.GetAutostart();
            autostartMenuItem.Click  += OnAutostart;
            trayMenu.MenuItems.Add(autostartMenuItem);

            trayMenu.MenuItems.Add("-");

            _batteryLevelHeaderMenuItem         = new MenuItem("Controller Battery Level:");
            _batteryLevelHeaderMenuItem.Enabled = false;
            _batteryLevelHeaderMenuItem.Visible = false;
            trayMenu.MenuItems.Add(_batteryLevelHeaderMenuItem);
            _batteryLevelMenuItems = new MenuItem[Constants.MAX_CONTROLLERS];
            for (uint i = 0; i < Constants.MAX_CONTROLLERS; i++)
            {
                _batteryLevelMenuItems[i]         = new MenuItem();
                _batteryLevelMenuItems[i].Enabled = false;
                _batteryLevelMenuItems[i].Visible = false;
                trayMenu.MenuItems.Add(_batteryLevelMenuItems[i]);
            }
            _batteryLevelSeparatorMenuItem         = new MenuItem("-");
            _batteryLevelSeparatorMenuItem.Visible = false;
            trayMenu.MenuItems.Add(_batteryLevelSeparatorMenuItem);

#if DEBUG
            trayMenu.MenuItems.Add("Test: Controller 1 Low", OnShowTest1);
            trayMenu.MenuItems.Add("Test: Controller 1 Full", OnShowTest2);
            trayMenu.MenuItems.Add("Test: Controller 2 Medium", OnShowTest3);
            trayMenu.MenuItems.Add("Test: Hotkey Detection", OnHotkeyTest1);

            trayMenu.MenuItems.Add("-");
#endif

            trayMenu.MenuItems.Add("Exit", OnTrayMenuExitClicked);

            // add tray menu to icon
            _trayIcon.ContextMenu = trayMenu;

            // enable tray icon
            _trayIcon.Visible = true;

            // create watcher
            watcher = new Watcher(this, settings);
        }