예제 #1
0
        static void Main(string[] args)
        {
            if (args.Length == 2 && args[0] == "-delay")
            {
                System.Threading.Thread.Sleep(Int32.Parse(args[1]) * 1000); // sleep for X sec before starting the app
            }
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Regulator regulator = null;

            try
            {
                regulator = new Regulator();
                TrayIcon context = new TrayIcon(regulator);
                Application.Run(context);
                regulator.Stop();
            }
            catch (Exception e)
            {
                if (regulator != null)
                {
                    regulator.Stop();
                }
                MessageBox.Show(e.ToString(), "Dell SCT IT8518E Fan Control", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
예제 #2
0
        public TrayIcon(Regulator regulator)
        {
            components = new System.ComponentModel.Container();
            notifyIcon = new NotifyIcon(this.components);

            this.regulator    = regulator;
            config            = new Config("config.xml");
            regulator.profile = config.defaultProfile;

            //context menu
            contextMenu = new ContextMenu();
            foreach (IProfile profile in config.profiles)
            {
                MenuItem menuItem = new MenuItem(profile.name);
                menuItem.Checked = config.defaultProfile == profile;
                menuItem.Click  += delegate(Object sender, EventArgs e)
                {
                    regulator.profile = profile;
                    foreach (MenuItem other in contextMenu.MenuItems)
                    {
                        other.Checked = false;
                    }
                    menuItem.Checked = true;
                };
                contextMenu.MenuItems.Add(menuItem);
            }
            contextMenu.MenuItems.Add("-");
            MenuItem bios = new MenuItem("Automatic");

            bios.Checked = config.defaultProfile == null;
            bios.Click  += delegate(Object sender, EventArgs e)
            {
                regulator.profile = null;
                foreach (MenuItem other in contextMenu.MenuItems)
                {
                    other.Checked = false;
                }
                bios.Checked = true;
            };
            contextMenu.MenuItems.Add(bios);
            contextMenu.MenuItems.Add("-");
            contextMenu.MenuItems.Add("Exit", OnExitClicked);
            notifyIcon.ContextMenu = contextMenu;

            RenderIcon(-1, 0, 0);
            notifyIcon.Visible     = true;
            regulator.UpdateEvent += UpdateView;
        }
예제 #3
0
 public void UpdateView(Regulator regulator, int fanSpeed, int temperature, int mode, String status)
 {
     RenderIcon((int)fanSpeed, (int)temperature, (int)mode);
     notifyIcon.Text = status; //this is limited to 64 characters only
 }