Exemplo n.º 1
0
        private ControlData getControlData(int tempIndex)
        {
            var tempBaseList = HardwareManager.getInstance().TempBaseList;

            if (tempIndex >= tempBaseList.Count)
            {
                return(null);
            }

            string id = tempBaseList[tempIndex].ID;

            ControlData controlData = null;
            int         modeIndex   = (int)mModeType;

            for (int i = 0; i < mControlDataList[modeIndex].Count; i++)
            {
                var tempControlData = mControlDataList[modeIndex][i];
                if (tempControlData.ID.Equals(id) == true)
                {
                    controlData = tempControlData;
                    break;
                }
            }
            return(controlData);
        }
Exemplo n.º 2
0
        private void onRGBnFCButtonClick(object sender, EventArgs e)
        {
            var form = new LightingForm(HardwareManager.getInstance().getRGBnFC());

            form.ShowDialog();
            form.Dispose();
        }
Exemplo n.º 3
0
        private void onControlTextBoxChanges(object sender, EventArgs e)
        {
            var textBox = (TextBox)sender;

            if (textBox.Focused == false)
            {
                return;
            }

            var hardwareManager = HardwareManager.getInstance();
            int value           = int.Parse(textBox.Text);

            for (int i = 0; i < mControlTextBoxList.Count; i++)
            {
                if (mControlTextBoxList[i].Equals(sender) == true)
                {
                    int minValue = hardwareManager.getControl(i).getMinSpeed();
                    int maxValue = hardwareManager.getControl(i).getMaxSpeed();

                    if (value >= minValue && value <= maxValue)
                    {
                        int changeValue = hardwareManager.addChangeValue(value, hardwareManager.getControl(i));
                        if (changeValue != value)
                        {
                            textBox.Text = changeValue.ToString();
                        }
                    }
                    break;
                }
            }
        }
Exemplo n.º 4
0
        public void onUpdateTimer()
        {
            if (mSensorComboBox.Items.Count == 0 ||
                mSelectedSensorIndex == -1 ||
                mFanComboBox.Items.Count == 0 ||
                mSelectedFanData == null ||
                mNowPoint == null ||
                mIsUpdateGraph == false)
            {
                return;
            }

            var hardwareManager = HardwareManager.getInstance();
            var sensor          = hardwareManager.getSensor(mSelectedSensorIndex);
            var control         = hardwareManager.getControl(mSelectedFanData.Index);

            if (sensor == null || control == null)
            {
                return;
            }

            mNowPoint[0].X = (double)sensor.Value;
            mNowPoint[0].Y = (double)control.LastValue;
            mGraph.Refresh();
        }
Exemplo n.º 5
0
        protected override void WndProc(ref Message msg)
        {
            switch (msg.Msg)
            {
            case WM_POWERBROADCAST:
                switch (msg.WParam.ToInt32())
                {
                case PBT_APMQUERYSUSPEND:
                case PBT_APMSUSPEND:
                    Console.WriteLine("MainForm.WndProc() : enter power saving mode");
                    break;

                case PBT_APMRESUMESUSPEND:
                    Console.WriteLine("MainForm.WndProc() : exit power saving mode");
                    this.BeginInvoke(new Action(delegate()
                    {
                        HardwareManager.getInstance().stop();
                        ControlManager.getInstance().reset();
                        OSDManager.getInstance().reset();

                        mIsFirstLoad = true;
                        this.reload();
                    }));
                    break;
                }
                break;
            }
            base.WndProc(ref msg);
        }
Exemplo n.º 6
0
        private void onRGBnFCButtonClick(object sender, EventArgs e)
        {
            var deviceList = HardwareManager.getInstance().getRGBnFCList();

            if (deviceList.Count == 1)
            {
                var form = new LightingForm(deviceList[0], 1);
                form.ShowDialog();
            }
            else
            {
                var menu = new ContextMenu();
                for (int i = 0; i < deviceList.Count; i++)
                {
                    int index = i;
                    var item  = new MenuItem(string.Format("{0}", i + 1), (sender2, e2) =>
                    {
                        var form = new LightingForm(deviceList[index], index + 1);
                        form.ShowDialog();
                    });
                    menu.MenuItems.Add(item);
                }

                var point = mRGBnFCButton.PointToClient(Control.MousePosition);
                menu.Show(mRGBnFCButton, point);
            }
        }
Exemplo n.º 7
0
        public OSDForm()
        {
            InitializeComponent();
            this.localizeComponent();

            mGroupListView.Columns.Add("Color", 50);
            mGroupListView.Columns.Add("Name", 130);
            mGroupListView.SelectedIndexChanged += onGroupListViewIndexChanged;

            mGroupListView.MouseDoubleClick += onGroupListViewMouseDoubleClick;
            mGroupEditTextBox.Leave         += onGroupEditTextBoxLeave;
            mGroupEditTextBox.Hide();

            mItemListView.Columns.Add("Color", 50);
            mItemListView.Columns.Add("Item", 280);

            mDigitNumericUpDown.ValueChanged += onDigitNumericUpDownValueChanged;

            this.enableItemConrol(false);

            var hardwareManager = HardwareManager.getInstance();
            var osdSensorList   = hardwareManager.OSDSensorList;

            for (int i = 0; i < osdSensorList.Count; i++)
            {
                var sensor = osdSensorList[i];
                var item   = new OSDItem();
                item.UnitType = sensor.UnitType;
                item.ID       = sensor.ID;
                mComboBoxItemList.Add(item);
                mItemComboBox.Items.Add(sensor.Prefix + sensor.Name);
            }

            mItemComboBox.SelectedIndex = 0;

            mEnableCheckBox.Checked     = OSDManager.getInstance().IsEnable;
            mSystemTimeCheckBox.Checked = OSDManager.getInstance().IsTime;

            mGroupList = OSDManager.getInstance().getCloneGroupList();
            for (int i = 0; i < mGroupList.Count; i++)
            {
                var group = mGroupList[i];

                var item = new ListViewItem();
                if (group.IsColor == false)
                {
                    item.Text = "Default";
                }
                else
                {
                    item.Text      = "";
                    item.BackColor = group.Color;
                }

                item.SubItems.Add(group.Name);
                item.UseItemStyleForSubItems = false;
                mGroupListView.Items.Add(item);
            }
        }
Exemplo n.º 8
0
        private void initControl()
        {
            ControlManager controlManager = ControlManager.getInstance();

            mEnableCheckBox.Checked = ControlManager.getInstance().IsEnable;

            mNormalRadioButton.Checked      = (mModeType == MODE_TYPE.NORMAL);
            mSilenceRadioButton.Checked     = (mModeType == MODE_TYPE.SILENCE);
            mPerformanceRadioButton.Checked = (mModeType == MODE_TYPE.PERFORMANCE);
            mGameRadioButton.Checked        = (mModeType == MODE_TYPE.GAME);

            mNormalRadioButton.Click      += onRadioButtonClick;
            mSilenceRadioButton.Click     += onRadioButtonClick;
            mPerformanceRadioButton.Click += onRadioButtonClick;
            mGameRadioButton.Click        += onRadioButtonClick;

            mTempComboBox.SelectedIndexChanged += onTempComboBoxIndexChanged;

            mFanListView.Columns.Add("MyColumn", -2, HorizontalAlignment.Center);
            mFanListView.AutoResizeColumn(0, ColumnHeaderAutoResizeStyle.ColumnContent);
            mFanListView.GridLines             = true;
            mFanListView.SelectedIndexChanged += onFanListViewIndexChanged;

            mUnitComboBox.Items.Add("1");
            mUnitComboBox.Items.Add("5");
            mUnitComboBox.Items.Add("10");
            mUnitComboBox.SelectedIndex         = 1;
            mUnitComboBox.SelectedIndexChanged += onUnitComboBoxIndexChanged;

            mHysNumericUpDown.ValueChanged += onHysNumericValueChanged;

            mAutoNumericUpDown.ValueChanged += onAutoNumericUpDownValueChanged;

            var tempBaseList    = HardwareManager.getInstance().TempBaseList;
            var controlBaseList = HardwareManager.getInstance().ControlBaseList;

            for (int i = 0; i < tempBaseList.Count; i++)
            {
                mTempComboBox.Items.Add(tempBaseList[i].Name);
            }

            for (int i = 0; i < controlBaseList.Count; i++)
            {
                mFanComboBox.Items.Add(controlBaseList[i].Name);
            }

            if (mTempComboBox.Items.Count > 0)
            {
                mTempComboBox.SelectedIndex = 0;
                mSelectedTempIndex          = 0;
            }

            if (mFanComboBox.Items.Count > 0)
            {
                mFanComboBox.SelectedIndex = 0;
            }
        }
Exemplo n.º 9
0
        private void onNameTextBoxLeaves(TextBox textBox, NAME_TYPE nameType, ref List <TextBox> nameTextBoxList)
        {
            try
            {
                string name  = textBox.Text;
                int    index = -1;
                for (int i = 0; i < nameTextBoxList.Count; i++)
                {
                    if (nameTextBoxList[i] == textBox)
                    {
                        index = i;
                        break;
                    }
                }

                if (index < 0)
                {
                    return;
                }

                BaseDevice device = null;
                if (nameType == NAME_TYPE.TEMPERATURE)
                {
                    device = HardwareManager.getInstance().TempBaseList[index];
                }
                else if (nameType == NAME_TYPE.FAN)
                {
                    device = HardwareManager.getInstance().FanBaseList[index];
                }
                else
                {
                    device = HardwareManager.getInstance().ControlBaseList[index];
                }

                string originName = device.Name;
                if (name.Length == 0)
                {
                    name = originName;
                }

                device.Name  = name;
                textBox.Text = name;

                var osdSensorMap = HardwareManager.getInstance().OSDSensorMap;
                if (osdSensorMap.ContainsKey(device.ID) == true)
                {
                    var sensor = osdSensorMap[device.ID];
                    sensor.Name = name;
                }

                HardwareManager.getInstance().write();
            }
            catch { }
        }
Exemplo n.º 10
0
        private void onGroupListViewIndexChanged(object sender, EventArgs e)
        {
            var items = mGroupListView.SelectedItems;

            if (items == null || items.Count == 0)
            {
                mItemListView.Items.Clear();
                this.enableItemConrol(false);
                return;
            }
            this.enableItemConrol(true);

            try
            {
                int index = mGroupListView.SelectedItems[0].Index;
                if (index < 0)
                {
                    return;
                }

                var hardwareManager = HardwareManager.getInstance();
                var osdSensorMap    = hardwareManager.OSDSensorMap;

                var group = mGroupList[index];
                mDigitNumericUpDown.Value = group.Digit;
                for (int i = 0; i < group.ItemList.Count; i++)
                {
                    var item     = group.ItemList[i];
                    var listItem = new ListViewItem();

                    if (item.IsColor == false)
                    {
                        listItem.Text = "Default";
                    }
                    else
                    {
                        listItem.Text      = "";
                        listItem.BackColor = item.Color;
                    }

                    string id = item.ID;
                    if (osdSensorMap.ContainsKey(id) == false)
                    {
                        continue;
                    }

                    var sensor = osdSensorMap[id];
                    listItem.SubItems.Add(sensor.Prefix + sensor.Name);
                    listItem.UseItemStyleForSubItems = false;
                    mItemListView.Items.Add(listItem);
                }
            }
            catch { }
        }
Exemplo n.º 11
0
        private void onUpdate()
        {
            if (this.Visible == false)
            {
                return;
            }

            this.BeginInvoke(new Action(delegate()
            {
                var hardwareManager = HardwareManager.getInstance();

                for (int i = 0; i < hardwareManager.getSensorCount(); i++)
                {
                    var sensor = hardwareManager.getSensor(i);
                    if (sensor == null)
                    {
                        break;
                    }

                    mSensorLabelList[i].Text = sensor.getString();
                }

                for (int i = 0; i < hardwareManager.getFanCount(); i++)
                {
                    var fan = hardwareManager.getFan(i);
                    if (fan == null)
                    {
                        break;
                    }

                    mFanLabelList[i].Text = fan.getString();
                }

                for (int i = 0; i < hardwareManager.getControlCount(); i++)
                {
                    var control = hardwareManager.getControl(i);
                    if (control == null)
                    {
                        break;
                    }

                    if (mControlTextBoxList[i].Focused == false)
                    {
                        mControlTextBoxList[i].Text = control.Value.ToString();
                    }
                }

                if (mControlForm != null)
                {
                    mControlForm.onUpdateTimer();
                }
            }));
        }
Exemplo n.º 12
0
        private void onReloadButtonClick(object sender, EventArgs e)
        {
            HardwareManager.getInstance().stop();
            ControlManager.getInstance().reset();
            OSDManager.getInstance().reset();

            if (OptionManager.getInstance().IsHWInfo == false)
            {
                HWInfoManager.getInstance().reset();
                HWInfoManager.getInstance().write();
            }

            this.reload();
        }
Exemplo n.º 13
0
        public MainForm()
        {
            InitializeComponent();
            this.localizeComponent();

            this.MinimumSize = new Size(this.Width, mOriginHeight);
            this.MaximumSize = new Size(this.Width, Int32.MaxValue);

            this.FormClosing += onClosing;

            mFanIconList.Add(Properties.Resources.fan_1);
            mFanIconList.Add(Properties.Resources.fan_2);
            mFanIconList.Add(Properties.Resources.fan_3);
            mFanIconList.Add(Properties.Resources.fan_4);
            mFanIconList.Add(Properties.Resources.fan_5);
            mFanIconList.Add(Properties.Resources.fan_6);
            mFanIconList.Add(Properties.Resources.fan_7);
            mFanIconList.Add(Properties.Resources.fan_8);

            mTrayIcon.Icon                = mFanIconList[0];
            mTrayIcon.Visible             = true;
            mTrayIcon.MouseDoubleClick   += onTrayIconDBClicked;
            mDonatePictureBox.MouseClick += onDonatePictureBoxClick;

            HardwareManager.getInstance().onUpdateCallback += onUpdate;

            if (OptionManager.getInstance().read() == false)
            {
                OptionManager.getInstance().write();
            }

            if (OptionManager.getInstance().Interval < 100)
            {
                OptionManager.getInstance().Interval = 100;
            }
            else if (OptionManager.getInstance().Interval > 5000)
            {
                OptionManager.getInstance().Interval = 5000;
            }

            if (OptionManager.getInstance().IsMinimized == true)
            {
                this.Visible       = false;
                this.WindowState   = FormWindowState.Minimized;
                this.ShowInTaskbar = false;
                mIsVisible         = false;
                mIsFirstShow       = false;
            }
        }
Exemplo n.º 14
0
        private void onTrayMenuExit(object sender, EventArgs e)
        {
            if (mControlForm != null)
            {
                mControlForm.Close();
                mControlForm = null;
            }

            HardwareManager.getInstance().stop();

            mFanIconTimer.Stop();
            mTrayIcon.Visible = false;

            mIsExit = true;
            Application.ExitThread();
            Application.Exit();
        }
Exemplo n.º 15
0
        private void onTempComboBoxIndexChanged(object sender, EventArgs e)
        {
            mPresetLabel.Visible       = false;
            mPresetLoadButton.Visible  = false;
            mPresetSaveButton.Visible  = false;
            mUnitLabel.Visible         = false;
            mUnitComboBox.Visible      = false;
            mGraph.Visible             = false;
            mAutoLabel.Visible         = false;
            mAutoNumericUpDown.Visible = false;
            mStepCheckBox.Visible      = false;
            mHysLabel.Visible          = false;
            mHysNumericUpDown.Visible  = false;
            mSelectedFanData           = null;

            mListViewBaseControlList.Clear();
            mFanListView.BeginUpdate();
            mFanListView.Clear();

            mSelectedTempIndex = mTempComboBox.SelectedIndex;
            var controlData = this.getControlData(mSelectedTempIndex);

            if (controlData == null)
            {
                mFanListView.EndUpdate();
                return;
            }

            var controlBaseMap = HardwareManager.getInstance().ControlBaseMap;

            for (int i = 0; i < controlData.FanDataList.Count; i++)
            {
                var fanData = controlData.FanDataList[i];

                string fanID = fanData.ID;
                if (controlBaseMap.ContainsKey(fanID) == false)
                {
                    continue;
                }

                var device = controlBaseMap[fanID];
                mListViewBaseControlList.Add(device);
                mFanListView.Items.Add(device.Name);
            }
            mFanListView.EndUpdate();
        }
Exemplo n.º 16
0
        private void onAddButtonClick(object sender, EventArgs e)
        {
            if (mTempComboBox.Items.Count == 0 || mFanComboBox.Items.Count == 0)
            {
                return;
            }

            int modeIndex = (int)mModeType;
            int tempIndex = mSelectedTempIndex;
            int fanIndex  = mFanComboBox.SelectedIndex;

            var tempBaseList    = HardwareManager.getInstance().TempBaseList;
            var controlBaseList = HardwareManager.getInstance().ControlBaseList;

            if (tempIndex >= tempBaseList.Count || fanIndex >= controlBaseList.Count)
            {
                return;
            }

            var tempDevice    = tempBaseList[tempIndex];
            var controlDevice = controlBaseList[fanIndex];

            var controlData = this.getControlData(tempIndex);

            if (controlData == null)
            {
                controlData = new ControlData(tempDevice.ID);
                mControlDataList[modeIndex].Add(controlData);
            }

            mFanListView.BeginUpdate();

            var fanData = this.getFanData(tempIndex, controlDevice.ID);

            if (fanData == null)
            {
                fanData = new FanData(controlDevice.ID, FanValueUnit.Size_5, true, 0);
                controlData.FanDataList.Add(fanData);

                mListViewBaseControlList.Add(controlDevice);
                mFanListView.Items.Add(controlDevice.Name);
            }

            mFanListView.EndUpdate();
        }
Exemplo n.º 17
0
        private void onRestartProgram(object sender, EventArgs e)
        {
            if (mControlForm != null)
            {
                mControlForm.Close();
                mControlForm = null;
            }

            HardwareManager.getInstance().stop();

            mFanIconTimer.Stop();
            mTrayIcon.Visible = false;

            Program.releaseMutex();
            Program.executeProgram();

            mIsExit = true;
            Environment.Exit(0);
        }
Exemplo n.º 18
0
        public void onUpdateTimer()
        {
            if (mTempComboBox.Items.Count == 0 ||
                mSelectedTempIndex == -1 ||
                mFanComboBox.Items.Count == 0 ||
                mSelectedFanData == null ||
                mNowPoint == null ||
                mIsUpdateGraph == false)
            {
                return;
            }

            var items = mFanListView.SelectedItems;

            if (items == null || items.Count == 0)
            {
                return;
            }

            int itemIndex       = items[0].Index;
            var hardwareManager = HardwareManager.getInstance();
            var tempBaseList    = hardwareManager.TempBaseList;
            var controlBaseList = hardwareManager.ControlBaseList;

            if (mSelectedTempIndex >= tempBaseList.Count || itemIndex >= mListViewBaseControlList.Count)
            {
                return;
            }

            var tempDevice    = tempBaseList[mSelectedTempIndex];
            var controlDevice = mListViewBaseControlList[itemIndex];

            if (tempDevice == null || controlDevice == null)
            {
                return;
            }

            mNowPoint.Location.X = (double)tempDevice.Value;
            mNowPoint.Location.Y = (double)controlDevice.Value;

            mGraph.Refresh();
        }
Exemplo n.º 19
0
        private void onOptionButtonClick(object sender, EventArgs e)
        {
            var form = new OptionForm();

            form.OnExitHandler += onRestartProgram;
            if (form.ShowDialog() == DialogResult.OK)
            {
                HardwareManager.getInstance().restartTimer(OptionManager.getInstance().Interval);

                // start icon update
                if (OptionManager.getInstance().IsAnimation == true)
                {
                    mFanIconTimer.Start();
                }
                else
                {
                    mFanIconTimer.Stop();
                }
            }
        }
Exemplo n.º 20
0
        public OptionForm()
        {
            InitializeComponent();
            this.localizeComponent();

            mToolTip.SetToolTip(mIntervalTextBox, "100 ≤ value ≤ 5000");
            mToolTip.SetToolTip(mStartupDelayTextBox, "0 ≤ value ≤ 59");

            mIntervalTextBox.Text      = OptionManager.getInstance().Interval.ToString();
            mIntervalTextBox.KeyPress += onTextBoxKeyPress;
            mIntervalTextBox.Leave    += onTextBoxLeaves;

            mGigabyteCheckBox.Checked = OptionManager.getInstance().IsGigabyte;

            mLibraryRadioButton1.Click  += onRadioClick;
            mLibraryRadioButton2.Click  += onRadioClick;
            mLibraryRadioButton1.Checked = (OptionManager.getInstance().LibraryType == LibraryType.LibreHardwareMonitor);
            mLibraryRadioButton2.Checked = (OptionManager.getInstance().LibraryType == LibraryType.OpenHardwareMonitor);

            mDimmCheckBox.Checked = OptionManager.getInstance().IsDimm;

            mNvApiCheckBox.Checked = OptionManager.getInstance().IsNvAPIWrapper;

            mKrakenCheckBox.Checked = OptionManager.getInstance().IsKraken;
            mKrakenButton.Enabled   = (HardwareManager.getInstance().getKrakenList().Count > 0);

            mCLCCheckBox.Checked = OptionManager.getInstance().IsCLC;
            mCLCButton.Enabled   = (HardwareManager.getInstance().getCLCList().Count > 0);

            mRGBnFCCheckBox.Checked = OptionManager.getInstance().IsRGBnFC;
            mRGBnFCButton.Enabled   = (HardwareManager.getInstance().getRGBnFCList().Count > 0);

            mFahrenheitCheckBox.Checked = OptionManager.getInstance().IsFahrenheit;
            mAnimationCheckBox.Checked  = OptionManager.getInstance().IsAnimation;
            mMinimizeCheckBox.Checked   = OptionManager.getInstance().IsMinimized;

            mStartupDelayTextBox.Text = OptionManager.getInstance().DelayTime.ToString();
            mStartupCheckBox.Checked  = OptionManager.getInstance().IsStartUp;
        }
Exemplo n.º 21
0
        private void onControlTextBoxLeaves(object sender, EventArgs e)
        {
            var textBox         = (TextBox)sender;
            var hardwareManager = HardwareManager.getInstance();
            var controlBaseList = hardwareManager.ControlBaseList;

            try
            {
                int value = int.Parse(textBox.Text);
                for (int i = 0; i < mControlTextBoxList.Count; i++)
                {
                    if (mControlTextBoxList[i].Equals(sender) == true)
                    {
                        var controlDevice = controlBaseList[i];
                        int originValue   = controlDevice.Value;

                        int minValue = controlBaseList[i].getMinSpeed();
                        int maxValue = controlBaseList[i].getMaxSpeed();

                        if (value >= minValue && value <= maxValue)
                        {
                            int changeValue = hardwareManager.addChangeValue(value, controlDevice);
                            if (changeValue != originValue)
                            {
                                textBox.Text = changeValue.ToString();
                            }
                        }
                        else
                        {
                            textBox.Text = originValue.ToString();
                            var tooltipString = minValue + " ≤  value ≤ " + maxValue;
                            mToolTip.Show(tooltipString, textBox, 2000);
                        }
                        break;
                    }
                }
            }
            catch { }
        }
Exemplo n.º 22
0
        private void onUpdate()
        {
            if (this.Visible == false)
            {
                return;
            }

            this.BeginInvoke(new Action(delegate()
            {
                var hardwareManager = HardwareManager.getInstance();

                for (int i = 0; i < hardwareManager.TempBaseList.Count; i++)
                {
                    var device             = hardwareManager.TempBaseList[i];
                    mTempLabelList[i].Text = device.getString();
                }

                for (int i = 0; i < hardwareManager.FanBaseList.Count; i++)
                {
                    var device            = hardwareManager.FanBaseList[i];
                    mFanLabelList[i].Text = device.getString();
                }

                for (int i = 0; i < hardwareManager.ControlBaseList.Count; i++)
                {
                    var device = hardwareManager.ControlBaseList[i];
                    if (mControlTextBoxList[i].Focused == false)
                    {
                        mControlTextBoxList[i].Text = device.Value.ToString();
                    }
                }

                if (mControlForm != null)
                {
                    mControlForm.onUpdateTimer();
                }
            }));
        }
Exemplo n.º 23
0
        private void onMainLoad()
        {
            this.createComponent();
            this.ActiveControl = mFanControlButton;

            mEnableToolStripMenuItem.Checked      = ControlManager.getInstance().IsEnable;
            mEnableOSDToolStripMenuItem.Checked   = OSDManager.getInstance().IsEnable;
            mNormalToolStripMenuItem.Checked      = (ControlManager.getInstance().ModeType == MODE_TYPE.NORMAL);
            mSilenceToolStripMenuItem.Checked     = (ControlManager.getInstance().ModeType == MODE_TYPE.SILENCE);
            mPerformanceToolStripMenuItem.Checked = (ControlManager.getInstance().ModeType == MODE_TYPE.PERFORMANCE);
            mGameToolStripMenuItem.Checked        = (ControlManager.getInstance().ModeType == MODE_TYPE.GAME);

            // startUpdate
            HardwareManager.getInstance().startUpdate();

            // start icon update
            mTrayIcon.ContextMenuStrip = mTrayMenuStrip;
            mFanIconTimer          = new System.Windows.Forms.Timer();
            mFanIconTimer.Interval = 100;
            mFanIconTimer.Tick    += onFanIconTimer;
            if (OptionManager.getInstance().IsAnimation == true)
            {
                mFanIconTimer.Start();
            }

            mLoadingPanel.Visible = false;

            if (mIsVisible == true)
            {
                mIsFirstShow  = true;
                this.Location = new Point((Screen.PrimaryScreen.WorkingArea.Width - this.Width) / 2,
                                          (Screen.PrimaryScreen.WorkingArea.Height - this.Height) / 2);
            }

            this.Enabled = true;
        }
Exemplo n.º 24
0
        private void reload()
        {
            this.Enabled = false;

            mLoadingPanel.Visible      = true;
            mTrayIcon.ContextMenuStrip = null;

            mTempPanel.Controls.Clear();
            mFanPanel.Controls.Clear();
            mControlPanel.Controls.Clear();

            mTempLabelList.Clear();
            mTempNameTextBoxList.Clear();
            mFanLabelList.Clear();
            mFanNameTextBoxList.Clear();
            mControlTextBoxList.Clear();
            mControlLabelList.Clear();
            mControlNameTextBoxList.Clear();

            if (mFanIconTimer != null)
            {
                mFanIconTimer.Stop();
                mFanIconTimer.Dispose();
                mFanIconTimer = null;
            }

            mTrayIcon.Icon = mFanIconList[0];
            mFanIconIndex  = 0;

            mNowHeight = mOriginHeight;
            this.resizeForm();

            mStartThread = new Thread(new ThreadStart(() =>
            {
                int checkCount = (mIsFirstLoad == true) ? 3 : 0;
                mIsFirstLoad   = false;
                while (true)
                {
                    // start hardware manager
                    HardwareManager.getInstance().start();

                    // set hardware name
                    bool isDifferent = false;
                    if (HardwareManager.getInstance().read(ref isDifferent) == false)
                    {
                        break;
                    }

                    if (isDifferent == true && checkCount > 0)
                    {
                        // restart
                        HardwareManager.getInstance().stop();
                        Thread.Sleep(100);
                        checkCount--;
                        continue;
                    }
                    break;
                }

                // set hardware name to file
                HardwareManager.getInstance().write();

                // read auto fan curve
                ControlManager.getInstance().read();

                // read osd data
                OSDManager.getInstance().read();

                this.BeginInvoke(new Action(delegate()
                {
                    this.onMainLoad();
                }));
            }));
            mStartThread.Start();
        }
Exemplo n.º 25
0
        public OptionForm()
        {
            InitializeComponent();
            this.localizeComponent();

            if (Screen.PrimaryScreen.WorkingArea.Height < this.Height)
            {
                this.AutoScroll      = true;
                this.AutoSizeMode    = AutoSizeMode.GrowOnly;
                this.FormBorderStyle = FormBorderStyle.Sizable;
                this.Width           = this.Width + 10;
                this.Height          = this.Height - 100;

                this.MinimumSize = new Size(this.Width, 300);
                this.MaximumSize = new Size(this.Width, Int32.MaxValue);
            }

            mToolTip.SetToolTip(mIntervalTextBox, "100 ≤ value ≤ 5000");
            mToolTip.SetToolTip(mStartupDelayTextBox, "0 ≤ value ≤ 59");

            mIntervalTextBox.Text      = OptionManager.getInstance().Interval.ToString();
            mIntervalTextBox.KeyPress += onTextBoxKeyPress;
            mIntervalTextBox.Leave    += onTextBoxLeaves;

            mGigabyteCheckBox.CheckedChanged += (object sender, EventArgs e) =>
            {
                mGigabyteCPUCheckBox.Enabled = mGigabyteCheckBox.Checked;
                mGigabyteGPUCheckBox.Enabled = mGigabyteCheckBox.Checked;
            };
            mGigabyteCheckBox.Checked    = OptionManager.getInstance().IsGigabyte;
            mGigabyteCPUCheckBox.Checked = OptionManager.getInstance().IsGigabyteMotherboard;
            mGigabyteGPUCheckBox.Checked = OptionManager.getInstance().IsGigabyteGpu;
            if (mGigabyteCheckBox.Checked == false)
            {
                mGigabyteCPUCheckBox.Enabled = false;
                mGigabyteGPUCheckBox.Enabled = false;
            }

            mLHMCheckBox.CheckedChanged += (object sender, EventArgs e) =>
            {
                mLHMCPUCheckBox.Enabled        = mLHMCheckBox.Checked;
                mLHMMBCheckBox.Enabled         = mLHMCheckBox.Checked;
                mLHMGPUCheckBox.Enabled        = mLHMCheckBox.Checked;
                mLHMControllerCheckBox.Enabled = mLHMCheckBox.Checked;
                mLHMStorageCheckBox.Enabled    = mLHMCheckBox.Checked;
            };
            mLHMCheckBox.Checked           = OptionManager.getInstance().IsLHM;
            mLHMCPUCheckBox.Checked        = OptionManager.getInstance().IsLHMCpu;
            mLHMMBCheckBox.Checked         = OptionManager.getInstance().IsLHMMotherboard;
            mLHMGPUCheckBox.Checked        = OptionManager.getInstance().IsLHMGpu;
            mLHMControllerCheckBox.Checked = OptionManager.getInstance().IsLHMContolled;
            mLHMStorageCheckBox.Checked    = OptionManager.getInstance().IsLHMStorage;
            if (mLHMCheckBox.Checked == false)
            {
                mLHMCPUCheckBox.Enabled        = false;
                mLHMMBCheckBox.Enabled         = false;
                mLHMGPUCheckBox.Enabled        = false;
                mLHMControllerCheckBox.Enabled = false;
                mLHMStorageCheckBox.Enabled    = false;
            }

            mOHMCheckBox.CheckedChanged += (object sender, EventArgs e) =>
            {
                mOHMCPUCheckBox.Enabled        = mOHMCheckBox.Checked;
                mOHMMBCheckBox.Enabled         = mOHMCheckBox.Checked;
                mOHMGPUCheckBox.Enabled        = mOHMCheckBox.Checked;
                mOHMControllerCheckBox.Enabled = mOHMCheckBox.Checked;
                mOHMStorageCheckBox.Enabled    = mOHMCheckBox.Checked;
            };
            mOHMCheckBox.Checked           = OptionManager.getInstance().IsOHM;
            mOHMCPUCheckBox.Checked        = OptionManager.getInstance().IsOHMCpu;
            mOHMMBCheckBox.Checked         = OptionManager.getInstance().IsOHMMotherboard;
            mOHMGPUCheckBox.Checked        = OptionManager.getInstance().IsOHMGpu;
            mOHMControllerCheckBox.Checked = OptionManager.getInstance().IsOHMContolled;
            mOHMStorageCheckBox.Checked    = OptionManager.getInstance().IsOHMStorage;
            if (mOHMCheckBox.Checked == false)
            {
                mOHMCPUCheckBox.Enabled        = false;
                mOHMMBCheckBox.Enabled         = false;
                mOHMGPUCheckBox.Enabled        = false;
                mOHMControllerCheckBox.Enabled = false;
                mOHMStorageCheckBox.Enabled    = false;
            }

            mNvApiCheckBox.Checked = OptionManager.getInstance().IsNvAPIWrapper;

            mDimmCheckBox.Checked = OptionManager.getInstance().IsDimm;

            mKrakenCheckBox.Checked = OptionManager.getInstance().IsKraken;
            mKrakenButton.Enabled   = (HardwareManager.getInstance().KrakenList.Count > 0);

            mCLCCheckBox.Checked = OptionManager.getInstance().IsCLC;
            mCLCButton.Enabled   = (HardwareManager.getInstance().CLCList.Count > 0);

            mRGBnFCCheckBox.Checked = OptionManager.getInstance().IsRGBnFC;
            mRGBnFCButton.Enabled   = (HardwareManager.getInstance().RGBnFCList.Count > 0);

            mFahrenheitCheckBox.Checked = OptionManager.getInstance().IsFahrenheit;
            mAnimationCheckBox.Checked  = OptionManager.getInstance().IsAnimation;
            mMinimizeCheckBox.Checked   = OptionManager.getInstance().IsMinimized;

            mStartupDelayTextBox.Text = OptionManager.getInstance().DelayTime.ToString();
            mStartupCheckBox.Checked  = OptionManager.getInstance().IsStartUp;
        }
Exemplo n.º 26
0
        public OSDForm()
        {
            InitializeComponent();
            this.localizeComponent();

            mGroupListView.Columns.Add("Color", 50);
            mGroupListView.Columns.Add("Name", 130);
            mGroupListView.SelectedIndexChanged += onGroupListViewIndexChanged;

            mGroupListView.MouseDoubleClick += onGroupListViewMouseDoubleClick;
            mGroupEditTextBox.Leave         += onGroupEditTextBoxLeave;
            mGroupEditTextBox.Hide();

            mItemListView.Columns.Add("Color", 50);
            mItemListView.Columns.Add("Item", 280);

            mDigitNumericUpDown.ValueChanged += onDigitNumericUpDownValueChanged;

            this.enableItemConrol(false);

            var hardwareManager = HardwareManager.getInstance();
            var controlManager  = ControlManager.getInstance();

            // Sensor
            for (int i = 0; i < hardwareManager.getSensorCount(); i++)
            {
                var sensor = hardwareManager.getSensor(i);
                var item   = new OSDItem();
                item.ItemType = OSDItemType.Sensor;
                item.UnitType = OSDUnitType.Temperature;
                item.Index    = i;
                mComboBoxItemList.Add(item);
                mItemComboBox.Items.Add("[" + StringLib.Temperature + "] " + controlManager.getName(0, i, false));
            }

            // Fan
            for (int i = 0; i < hardwareManager.getFanCount(); i++)
            {
                var fan  = hardwareManager.getFan(i);
                var item = new OSDItem();
                item.ItemType = OSDItemType.Fan;
                item.UnitType = OSDUnitType.RPM;
                item.Index    = i;
                mComboBoxItemList.Add(item);
                mItemComboBox.Items.Add("[" + StringLib.Fan_speed + "] " + controlManager.getName(1, i, false));
            }

            // Control
            for (int i = 0; i < hardwareManager.getControlCount(); i++)
            {
                var control = hardwareManager.getControl(i);
                var item    = new OSDItem();
                item.ItemType = OSDItemType.Control;
                item.UnitType = OSDUnitType.Percent;
                item.Index    = i;
                mComboBoxItemList.Add(item);
                mItemComboBox.Items.Add("[" + StringLib.Fan_control + "] " + controlManager.getName(2, i, false));
            }

            // Predefined
            // Framerate
            var osdItem = new OSDItem();

            osdItem.ItemType = OSDItemType.Predefined;
            osdItem.UnitType = OSDUnitType.FPS;
            mComboBoxItemList.Add(osdItem);
            mItemComboBox.Items.Add("[" + StringLib.ETC + "] Framerate");

            // Blank
            osdItem          = new OSDItem();
            osdItem.ItemType = OSDItemType.Predefined;
            osdItem.UnitType = OSDUnitType.Blank;
            mComboBoxItemList.Add(osdItem);
            mItemComboBox.Items.Add("[" + StringLib.ETC + "] Blank");

            // osd sensor
            for (int i = 0; i < hardwareManager.getOSDSensorCount(); i++)
            {
                var osdSensor = hardwareManager.getOSDSensor(i);
                var item      = new OSDItem();
                item.ItemType = OSDItemType.Predefined;
                item.UnitType = osdSensor.UnitType;
                item.Index    = i;
                mComboBoxItemList.Add(item);
                mItemComboBox.Items.Add(osdSensor.Name);
            }

            mItemComboBox.SelectedIndex = 0;

            mEnableCheckBox.Checked     = OSDManager.getInstance().IsEnable;
            mSystemTimeCheckBox.Checked = OSDManager.getInstance().IsTime;

            mGroupList = OSDManager.getInstance().getCloneGroupList();
            for (int i = 0; i < mGroupList.Count; i++)
            {
                var group = mGroupList[i];

                var item = new ListViewItem();
                if (group.IsColor == false)
                {
                    item.Text = "Default";
                }
                else
                {
                    item.Text      = "";
                    item.BackColor = group.Color;
                }

                item.SubItems.Add(group.Name);
                item.UseItemStyleForSubItems = false;
                mGroupListView.Items.Add(item);
            }
        }
Exemplo n.º 27
0
        private void onGroupListViewIndexChanged(object sender, EventArgs e)
        {
            var items = mGroupListView.SelectedItems;

            if (items == null || items.Count == 0)
            {
                mItemListView.Items.Clear();
                this.enableItemConrol(false);
                return;
            }
            this.enableItemConrol(true);

            try
            {
                int index = mGroupListView.SelectedItems[0].Index;
                if (index < 0)
                {
                    return;
                }

                var hardwareManager = HardwareManager.getInstance();
                var controlManager  = ControlManager.getInstance();

                var group = mGroupList[index];
                mDigitNumericUpDown.Value = group.Digit;
                for (int i = 0; i < group.ItemList.Count; i++)
                {
                    var item     = group.ItemList[i];
                    var listItem = new ListViewItem();

                    if (item.IsColor == false)
                    {
                        listItem.Text = "Default";
                    }
                    else
                    {
                        listItem.Text      = "";
                        listItem.BackColor = item.Color;
                    }

                    if (item.ItemType == OSDItemType.Sensor)
                    {
                        listItem.SubItems.Add("[" + StringLib.Temperature + "] " + controlManager.getName(0, item.Index, false));
                    }
                    else if (item.ItemType == OSDItemType.Fan)
                    {
                        listItem.SubItems.Add("[" + StringLib.Fan_speed + "] " + controlManager.getName(1, item.Index, false));
                    }
                    else if (item.ItemType == OSDItemType.Control)
                    {
                        listItem.SubItems.Add("[" + StringLib.Fan_control + "] " + controlManager.getName(2, item.Index, false));
                    }
                    else if (item.ItemType == OSDItemType.Predefined)
                    {
                        if (item.UnitType == OSDUnitType.FPS)
                        {
                            listItem.SubItems.Add("[" + StringLib.ETC + "] Framerate");
                        }
                        else if (item.UnitType == OSDUnitType.Blank)
                        {
                            listItem.SubItems.Add("[" + StringLib.ETC + "] Blank");
                        }
                        else
                        {
                            listItem.SubItems.Add(hardwareManager.getOSDSensor(item.Index).Name);
                        }
                    }

                    listItem.UseItemStyleForSubItems = false;
                    mItemListView.Items.Add(listItem);
                }
            }
            catch { }
        }
Exemplo n.º 28
0
        private void readData(JObject rootObject, string keyString, List <ControlData> controlDataList)
        {
            if (rootObject.ContainsKey(keyString) == false)
            {
                return;
            }

            var tempBaseMap    = HardwareManager.getInstance().TempBaseMap;
            var controlBaseMap = HardwareManager.getInstance().ControlBaseMap;

            var controlList = rootObject.Value <JArray>(keyString);

            for (int i = 0; i < controlList.Count; i++)
            {
                var controlObject = (JObject)controlList[i];
                if (controlObject.ContainsKey("id") == false)
                {
                    continue;
                }

                string id = controlObject.Value <string>("id");

                // check temperature sensor
                if (tempBaseMap.ContainsKey(id) == false)
                {
                    continue;
                }

                var controlData = new ControlData(id);

                // FanData
                var fanList = controlObject.Value <JArray>("fan");
                for (int j = 0; j < fanList.Count; j++)
                {
                    var fanObject = (JObject)fanList[j];
                    if (fanObject.ContainsKey("id") == false)
                    {
                        continue;
                    }

                    string fanID = fanObject.Value <string>("id");

                    // check control sensor
                    if (controlBaseMap.ContainsKey(fanID) == false)
                    {
                        continue;
                    }

                    bool isStep     = (fanObject.ContainsKey("step") == true) ? fanObject.Value <bool>("step") : true;
                    int  hysteresis = (fanObject.ContainsKey("hysteresis") == true) ? fanObject.Value <int>("hysteresis") : 0;
                    int  unit       = (fanObject.ContainsKey("unit") == true) ? fanObject.Value <int>("unit") : 1;

                    var fanData = new FanData(fanID, (FanValueUnit)unit, isStep, hysteresis);

                    // Percent value
                    var valueList = fanObject.Value <JArray>("value");

                    // fan value list
                    if (valueList.Count == fanData.getMaxFanValue())
                    {
                        for (int k = 0; k < valueList.Count; k++)
                        {
                            int value = valueList[k].Value <int>();
                            fanData.ValueList[k] = value;
                        }

                        // add fan data
                        controlData.FanDataList.Add(fanData);
                    }
                }

                // add control data
                controlDataList.Add(controlData);
            }
        }
Exemplo n.º 29
0
        private void onOptionButtonClick(object sender, EventArgs e)
        {
            var form   = new OptionForm();
            var result = form.ShowDialog();

            if (result == DialogResult.OK)
            {
                HardwareManager.getInstance().restartTimer();

                // start icon update
                if (OptionManager.getInstance().IsAnimation == true)
                {
                    if (mFanIconTimer == null)
                    {
                        mFanIconTimer          = new System.Windows.Forms.Timer();
                        mFanIconTimer.Interval = 100;
                        mFanIconTimer.Tick    += onFanIconTimer;
                        mFanIconTimer.Start();
                    }
                }
                else
                {
                    if (mFanIconTimer != null)
                    {
                        mFanIconTimer.Stop();
                        mFanIconTimer.Dispose();
                        mFanIconTimer = null;
                    }

                    mTrayIcon.Icon = mFanIconList[0];
                    mFanIconIndex  = 0;
                }
            }

            // Changed option data
            else if (result == DialogResult.Yes)
            {
                this.BeginInvoke(new Action(delegate()
                {
                    HardwareManager.getInstance().stop();
                    ControlManager.getInstance().reset();
                    OSDManager.getInstance().reset();
                    this.reload();
                }));
            }

            // Reset option data
            else if (result == DialogResult.No)
            {
                this.BeginInvoke(new Action(delegate()
                {
                    HardwareManager.getInstance().stop();
                    HardwareManager.getInstance().write();
                    ControlManager.getInstance().reset();
                    ControlManager.getInstance().write();
                    OSDManager.getInstance().reset();
                    OSDManager.getInstance().write();

                    this.reload();
                }));
            }
        }
Exemplo n.º 30
0
        private void createComponent()
        {
            var hardwareManager = HardwareManager.getInstance();
            var controlManager  = ControlManager.getInstance();

            int tempHeight    = mTempPanel.Height;
            int fanHeight     = mFanPanel.Height;
            int controlHeight = mControlPanel.Height;

            // temperature
            int pointY = 15;

            for (int i = 0; i < hardwareManager.TempList.Count(); i++)
            {
                var tempList = hardwareManager.TempList[i];
                if (tempList.Count == 0)
                {
                    continue;
                }

                var libLabel = new Label();
                libLabel.Location  = new System.Drawing.Point(15, pointY);
                libLabel.Text      = Define.cLibraryTypeString[i];
                libLabel.AutoSize  = true;
                libLabel.ForeColor = Color.Red;
                libLabel.Font      = new Font(libLabel.Font, FontStyle.Bold);
                mTempPanel.Controls.Add(libLabel);

                var libLabel2 = new Label();
                libLabel2.Location    = new System.Drawing.Point(5, pointY + 5);
                libLabel2.Size        = new System.Drawing.Size(mTempPanel.Width - 30, 2);
                libLabel2.AutoSize    = false;
                libLabel2.BorderStyle = BorderStyle.Fixed3D;
                mTempPanel.Controls.Add(libLabel2);

                pointY     = pointY + 21;
                tempHeight = tempHeight + 21;

                for (int j = 0; j < tempList.Count; j++)
                {
                    var hardwareDevice = tempList[j];

                    var hardwareLabel = new Label();
                    hardwareLabel.Location  = new System.Drawing.Point(25, pointY);
                    hardwareLabel.AutoSize  = true;
                    hardwareLabel.Height    = 20;
                    hardwareLabel.Text      = hardwareDevice.Name;
                    hardwareLabel.ForeColor = Color.Blue;
                    mTempPanel.Controls.Add(hardwareLabel);

                    var hardwareLabel2 = new Label();
                    hardwareLabel2.Location    = new System.Drawing.Point(20, pointY + 5);
                    hardwareLabel2.Size        = new System.Drawing.Size(190, 2);
                    hardwareLabel2.AutoSize    = false;
                    hardwareLabel2.BorderStyle = BorderStyle.Fixed3D;
                    mTempPanel.Controls.Add(hardwareLabel2);

                    pointY     = pointY + 25;
                    tempHeight = tempHeight + 25;

                    for (int k = 0; k < hardwareDevice.DeviceList.Count; k++)
                    {
                        var device = hardwareDevice.DeviceList[k];

                        var label = new Label();
                        label.Location  = new System.Drawing.Point(3, pointY);
                        label.Size      = new System.Drawing.Size(40, 23);
                        label.Text      = "";
                        label.AutoSize  = false;
                        label.TextAlign = ContentAlignment.TopRight;
                        mTempPanel.Controls.Add(label);
                        mTempLabelList.Add(label);

                        var textBox = new TextBox();
                        textBox.Location  = new System.Drawing.Point(label.Right + 5, label.Top - 5);
                        textBox.Size      = new System.Drawing.Size(mTempPanel.Width - 70, 23);
                        textBox.Multiline = false;
                        textBox.MaxLength = 40;
                        textBox.Text      = device.Name;
                        textBox.Leave    += (object sender, EventArgs e) =>
                        {
                            this.onNameTextBoxLeaves((TextBox)sender, NAME_TYPE.TEMPERATURE, ref mTempNameTextBoxList);
                        };
                        textBox.KeyDown += (object sender, KeyEventArgs e) =>
                        {
                            if (e.KeyCode == Keys.Enter)
                            {
                                this.onNameTextBoxLeaves((TextBox)sender, NAME_TYPE.TEMPERATURE, ref mTempNameTextBoxList);
                            }
                        };
                        mTempPanel.Controls.Add(textBox);
                        mTempNameTextBoxList.Add(textBox);

                        pointY     = pointY + 25;
                        tempHeight = tempHeight + 25;
                    }

                    pointY     = pointY + 10;
                    tempHeight = tempHeight + 10;
                }
            }

            tempHeight = tempHeight - 30;

            int maxHeight = Screen.PrimaryScreen.WorkingArea.Height - 200;

            if (tempHeight > maxHeight)
            {
                int gap = tempHeight - maxHeight;
                tempHeight = tempHeight - gap;
            }

            pointY = 15;
            for (int i = 0; i < hardwareManager.FanList.Count(); i++)
            {
                var fanList = hardwareManager.FanList[i];
                if (fanList.Count == 0)
                {
                    continue;
                }

                var libLabel = new Label();
                libLabel.Location  = new System.Drawing.Point(15, pointY);
                libLabel.Text      = Define.cLibraryTypeString[i];
                libLabel.AutoSize  = true;
                libLabel.ForeColor = Color.Red;
                libLabel.Font      = new Font(libLabel.Font, FontStyle.Bold);
                mFanPanel.Controls.Add(libLabel);

                var libLabel2 = new Label();
                libLabel2.Location    = new System.Drawing.Point(5, pointY + 5);
                libLabel2.Size        = new System.Drawing.Size(mFanPanel.Width - 30, 2);
                libLabel2.AutoSize    = false;
                libLabel2.BorderStyle = BorderStyle.Fixed3D;
                mFanPanel.Controls.Add(libLabel2);

                pointY    = pointY + 21;
                fanHeight = fanHeight + 21;

                for (int j = 0; j < fanList.Count; j++)
                {
                    var hardwareDevice = fanList[j];

                    var hardwareLabel = new Label();
                    hardwareLabel.Location  = new System.Drawing.Point(25, pointY);
                    hardwareLabel.AutoSize  = true;
                    hardwareLabel.Height    = 20;
                    hardwareLabel.Text      = hardwareDevice.Name;
                    hardwareLabel.ForeColor = Color.Blue;
                    mFanPanel.Controls.Add(hardwareLabel);

                    var hardwareLabel2 = new Label();
                    hardwareLabel2.Location    = new System.Drawing.Point(20, pointY + 5);
                    hardwareLabel2.Size        = new System.Drawing.Size(190, 2);
                    hardwareLabel2.AutoSize    = false;
                    hardwareLabel2.BorderStyle = BorderStyle.Fixed3D;
                    mFanPanel.Controls.Add(hardwareLabel2);

                    pointY    = pointY + 25;
                    fanHeight = fanHeight + 25;

                    for (int k = 0; k < hardwareDevice.DeviceList.Count; k++)
                    {
                        var device = hardwareDevice.DeviceList[k];

                        var label = new Label();
                        label.Location  = new System.Drawing.Point(3, pointY);
                        label.Size      = new System.Drawing.Size(60, 23);
                        label.Text      = "";
                        label.AutoSize  = false;
                        label.TextAlign = ContentAlignment.TopRight;
                        mFanPanel.Controls.Add(label);
                        mFanLabelList.Add(label);

                        var textBox = new TextBox();
                        textBox.Location  = new System.Drawing.Point(label.Right + 5, label.Top - 5);
                        textBox.Size      = new System.Drawing.Size(mFanPanel.Width - 90, 23);
                        textBox.Multiline = false;
                        textBox.MaxLength = 40;
                        textBox.Text      = device.Name;
                        textBox.Leave    += (object sender, EventArgs e) =>
                        {
                            this.onNameTextBoxLeaves((TextBox)sender, NAME_TYPE.FAN, ref mFanNameTextBoxList);
                        };
                        textBox.KeyDown += (object sender, KeyEventArgs e) =>
                        {
                            if (e.KeyCode == Keys.Enter)
                            {
                                this.onNameTextBoxLeaves((TextBox)sender, NAME_TYPE.FAN, ref mFanNameTextBoxList);
                            }
                        };
                        mFanPanel.Controls.Add(textBox);
                        mFanNameTextBoxList.Add(textBox);

                        pointY    = pointY + 25;
                        fanHeight = fanHeight + 25;
                    }

                    pointY    = pointY + 10;
                    fanHeight = fanHeight + 10;
                }
            }

            fanHeight = fanHeight - 30;

            if (fanHeight > maxHeight)
            {
                int gap = fanHeight - maxHeight;
                fanHeight = fanHeight - gap;
            }

            // set height
            if (fanHeight > tempHeight)
            {
                tempHeight = fanHeight;
            }
            else
            {
                fanHeight = tempHeight;
            }

            pointY = 15;
            for (int i = 0; i < hardwareManager.ControlList.Count(); i++)
            {
                var controlList = hardwareManager.ControlList[i];
                if (controlList.Count == 0)
                {
                    continue;
                }

                var libLabel = new Label();
                libLabel.Location  = new System.Drawing.Point(15, pointY);
                libLabel.Text      = Define.cLibraryTypeString[i];
                libLabel.AutoSize  = true;
                libLabel.ForeColor = Color.Red;
                libLabel.Font      = new Font(libLabel.Font, FontStyle.Bold);
                mControlPanel.Controls.Add(libLabel);

                var libLabel2 = new Label();
                libLabel2.Location    = new System.Drawing.Point(5, pointY + 5);
                libLabel2.Size        = new System.Drawing.Size(mControlPanel.Width - 30, 2);
                libLabel2.AutoSize    = false;
                libLabel2.BorderStyle = BorderStyle.Fixed3D;
                mControlPanel.Controls.Add(libLabel2);

                pointY        = pointY + 21;
                controlHeight = controlHeight + 21;

                for (int j = 0; j < controlList.Count; j++)
                {
                    var hardwareDevice = controlList[j];

                    var hardwareLabel = new Label();
                    hardwareLabel.Location  = new System.Drawing.Point(25, pointY);
                    hardwareLabel.AutoSize  = true;
                    hardwareLabel.Height    = 20;
                    hardwareLabel.Text      = hardwareDevice.Name;
                    hardwareLabel.ForeColor = Color.Blue;
                    mControlPanel.Controls.Add(hardwareLabel);

                    var hardwareLabel2 = new Label();
                    hardwareLabel2.Location    = new System.Drawing.Point(20, pointY + 5);
                    hardwareLabel2.Size        = new System.Drawing.Size(190, 2);
                    hardwareLabel2.AutoSize    = false;
                    hardwareLabel2.BorderStyle = BorderStyle.Fixed3D;
                    mControlPanel.Controls.Add(hardwareLabel2);

                    pointY        = pointY + 25;
                    controlHeight = controlHeight + 25;

                    for (int k = 0; k < hardwareDevice.DeviceList.Count; k++)
                    {
                        var device = (BaseControl)hardwareDevice.DeviceList[k];

                        var textBox = new TextBox();
                        textBox.Location  = new System.Drawing.Point(10, pointY - 5);
                        textBox.Size      = new System.Drawing.Size(40, 23);
                        textBox.Multiline = false;
                        textBox.MaxLength = 3;
                        textBox.Text      = "" + device.Value;
                        textBox.KeyPress += (object sender, KeyPressEventArgs e) =>
                        {
                            if (e.KeyChar == (char)Keys.Enter)
                            {
                                this.onControlTextBoxLeaves(sender, EventArgs.Empty);
                            }
                            else if (char.IsDigit(e.KeyChar) == false)
                            {
                                e.Handled = true;
                            }
                        };
                        textBox.Leave += onControlTextBoxLeaves;

                        mControlPanel.Controls.Add(textBox);
                        mControlTextBoxList.Add(textBox);

                        int minValue      = device.getMinSpeed();
                        int maxValue      = device.getMaxSpeed();
                        var tooltipString = minValue + " ≤  value ≤ " + maxValue;
                        mToolTip.SetToolTip(textBox, tooltipString);

                        var label = new Label();
                        label.Location = new System.Drawing.Point(textBox.Right + 2, pointY);
                        label.Size     = new System.Drawing.Size(15, 23);
                        label.Text     = "%";
                        mControlPanel.Controls.Add(label);
                        mControlLabelList.Add(label);

                        var textBox2 = new TextBox();
                        textBox2.Location  = new System.Drawing.Point(label.Right + 5, label.Top - 5);
                        textBox2.Size      = new System.Drawing.Size(mControlPanel.Width - 95, 23);
                        textBox2.Multiline = false;
                        textBox2.MaxLength = 40;
                        textBox2.Text      = device.Name;
                        textBox2.Leave    += (object sender, EventArgs e) =>
                        {
                            this.onNameTextBoxLeaves((TextBox)sender, NAME_TYPE.CONTOL, ref mControlNameTextBoxList);
                        };
                        textBox2.KeyDown += (object sender, KeyEventArgs e) =>
                        {
                            if (e.KeyCode == Keys.Enter)
                            {
                                this.onNameTextBoxLeaves((TextBox)sender, NAME_TYPE.CONTOL, ref mControlNameTextBoxList);
                            }
                        };
                        mControlPanel.Controls.Add(textBox2);
                        mControlNameTextBoxList.Add(textBox2);

                        pointY        = pointY + 25;
                        controlHeight = controlHeight + 25;
                    }

                    pointY        = pointY + 10;
                    controlHeight = controlHeight + 10;
                }
            }

            controlHeight = controlHeight - 30;

            if (controlHeight > maxHeight)
            {
                int gap = controlHeight - maxHeight;
                controlHeight = controlHeight - gap;
            }

            // set height
            if (fanHeight > controlHeight)
            {
                controlHeight = fanHeight;
            }
            else
            {
                tempHeight = controlHeight;
                fanHeight  = controlHeight;
            }

            int originPanelHeight = 35;
            int heightGap         = tempHeight - originPanelHeight;

            mNowHeight = mNowHeight + heightGap;

            this.resizeForm();
        }