public void RebuildMenuItems()
        {
            contextMenu.MenuItems.Clear();

            FanProfile selected = null;

            for (int i = 0, len = Config.AllProfiles.Length; i < len; i++)
            {
                FanProfile      profile  = Config.AllProfiles[i];
                ProfileMenuItem menuItem = new ProfileMenuItem(profile);
                menuItem.Click += HandleProfileMenuItemClick;
                contextMenu.MenuItems.Add(menuItem);
                if (profile.IsDefault && selected == null)
                {
                    menuItem.Checked = true;
                    selected         = profile;
                }
            }

            for (int i = 0, len = StandardMenuItems.Length; i < len; i++)
            {
                contextMenu.MenuItems.Add(StandardMenuItems[i]);
            }

            Program.Regulator.RunProfile(selected ?? MenuItem_BIOS.Profile);
        }
        private void LoadFanConfigXML(string sxml)
        {
            XmlDocument doc = new XmlDocument();

            doc.LoadXml(sxml);

            GeneralOptions  general = new GeneralOptions(doc.SelectSingleNode("//configuration/general"));
            TVicPortOptions ports   = new TVicPortOptions(doc.SelectSingleNode("//configuration/tvicports"));

            //List<FanProfile> profiles = new List<FanProfile>();
            XmlNodeList xmlProfileDefs = doc.SelectNodes("//configuration/fanprofiles/profile");

            FanProfile[] profiles = new FanProfile[xmlProfileDefs.Count];
            for (int i = 0; i < profiles.Length; i++)
            {
                profiles[i] = (new FanProfile(xmlProfileDefs[i], general));
            }

            //If we got this far, there was no exception.  So it's safe to actually use the values.
            this._general     = general;
            this._ports       = ports;
            this._allProfiles = profiles;
        }
 public void Update(FanProfile profile, byte temp, byte speed)
 {
     if (activeProfile != profile)
     {
         for (int i = 0, len = contextMenu.MenuItems.Count; i < len; i++)
         {
             if (contextMenu.MenuItems[i] is ProfileMenuItem item)
             {
                 item.Checked = (profile.MenuItem == item);
             }
         }
     }
     if (prevTemp != temp || prevSpeed != speed || activeProfile != profile)
     {
         activeProfile = profile;
         prevTemp      = temp;
         prevSpeed     = speed;
         RenderIcon(temp, speed);
         _sbIcon.Append(profile == null ? "BIOS" : profile.Name).AppendLine();
         _sbIcon.Append("CPU:").Append(temp).Append(", Fan:").Append(speed).Append('%');
         notifyIcon.Text = _sbIcon.ToString();
         _sbIcon.Clear();
     }
 }
 public ProfileMenuItem(FanProfile profile) : base(profile.Name)
 {
     base.Name        = profile.Name;
     Profile          = profile;
     profile.MenuItem = this;
 }