Пример #1
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);
        }
Пример #2
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);
            }
        }
Пример #3
0
 private void onApplyButtonClick(object sender, EventArgs e)
 {
     OSDManager.getInstance().IsEnable = mEnableCheckBox.Checked;
     OSDManager.getInstance().IsTime   = mSystemTimeCheckBox.Checked;
     OSDManager.getInstance().setGroupList(mGroupList);
     OSDManager.getInstance().write();
     onApplyCallback(sender, e);
 }
Пример #4
0
        private void onOSDButtonClick(object sender, EventArgs e)
        {
            var form = new OSDForm();

            form.onApplyCallback += (sender2, e2) =>
            {
                mEnableOSDToolStripMenuItem.Checked = OSDManager.getInstance().IsEnable;
            };
            form.ShowDialog();
        }
Пример #5
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();
        }
Пример #6
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;
        }
Пример #7
0
        private void onOKButtonClick(object sender, EventArgs e)
        {
            int interval = int.Parse(mIntervalTextBox.Text);

            if (interval < 100)
            {
                interval = 100;
            }
            else if (interval > 5000)
            {
                interval = 5000;
            }

            var  optionManager = OptionManager.getInstance();
            bool isRestart     = false;

            // 변경
            if ((optionManager.IsGigabyte != mGigabyteCheckBox.Checked) ||
                (optionManager.LibraryType == LibraryType.LibreHardwareMonitor && mLibraryRadioButton2.Checked == true) ||
                (optionManager.LibraryType == LibraryType.OpenHardwareMonitor && mLibraryRadioButton1.Checked == true) ||
                (optionManager.IsDimm != mDimmCheckBox.Checked) ||
                (optionManager.IsNvAPIWrapper != mNvApiCheckBox.Checked) ||
                (optionManager.IsKraken != mKrakenCheckBox.Checked) ||
                (optionManager.IsCLC != mCLCCheckBox.Checked) ||
                (optionManager.IsRGBnFC != mRGBnFCCheckBox.Checked))
            {
                var result = MessageBox.Show(StringLib.OptionRestart, StringLib.Option, MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
                if (result == DialogResult.Cancel)
                {
                    return;
                }
                isRestart = true;
            }

            optionManager.Interval       = interval;
            optionManager.IsGigabyte     = mGigabyteCheckBox.Checked;
            optionManager.LibraryType    = (mLibraryRadioButton1.Checked == true) ? LibraryType.LibreHardwareMonitor : LibraryType.OpenHardwareMonitor;
            optionManager.IsDimm         = mDimmCheckBox.Checked;
            optionManager.IsNvAPIWrapper = mNvApiCheckBox.Checked;
            optionManager.IsKraken       = mKrakenCheckBox.Checked;
            optionManager.IsCLC          = mCLCCheckBox.Checked;
            optionManager.IsRGBnFC       = mRGBnFCCheckBox.Checked;
            optionManager.IsFahrenheit   = mFahrenheitCheckBox.Checked;
            optionManager.IsAnimation    = mAnimationCheckBox.Checked;
            optionManager.IsMinimized    = mMinimizeCheckBox.Checked;
            optionManager.IsStartUp      = mStartupCheckBox.Checked;
            optionManager.write();

            if (isRestart == true)
            {
                ControlManager.getInstance().reset();
                ControlManager.getInstance().write();

                OSDManager.getInstance().reset();
                OSDManager.getInstance().write();

                OnExitHandler(null, EventArgs.Empty);
                return;
            }

            this.DialogResult = DialogResult.OK;
            this.Close();
        }
Пример #8
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);
            }
        }
Пример #9
0
        private void onUpdateTimer(object sender, EventArgs e)
        {
            if (Monitor.TryEnter(mLock) == false)
            {
                return;
            }

            if (mIsGigabyte == true && mGigabyte != null)
            {
                mGigabyte.update();
            }

            if (mLHM != null)
            {
                mLHM.update();
            }

            if (mOHM != null)
            {
                mOHM.update();
            }

            for (int i = 0; i < mSensorList.Count; i++)
            {
                mSensorList[i].update();
            }

            for (int i = 0; i < mFanList.Count; i++)
            {
                mFanList[i].update();
            }

            for (int i = 0; i < mControlList.Count; i++)
            {
                mControlList[i].update();
            }

            // change value
            bool isExistChange = false;

            if (mChangeValueList.Count > 0)
            {
                for (int i = 0; i < mChangeControlList.Count; i++)
                {
                    isExistChange = true;
                    mChangeControlList[i].setSpeed(mChangeValueList[i]);
                }
                mChangeControlList.Clear();
                mChangeValueList.Clear();
            }

            // Control
            var controlManager = ControlManager.getInstance();

            if (controlManager.IsEnable == true && isExistChange == false)
            {
                var controlDictionary = new Dictionary <int, BaseControl>();
                int modeIndex         = controlManager.ModeIndex;

                for (int i = 0; i < controlManager.getControlDataCount(modeIndex); i++)
                {
                    var controlData = controlManager.getControlData(modeIndex, i);
                    if (controlData == null)
                    {
                        break;
                    }

                    int sensorIndex = controlData.Index;
                    int temperature = mSensorList[sensorIndex].Value;

                    for (int j = 0; j < controlData.FanDataList.Count; j++)
                    {
                        var fanData      = controlData.FanDataList[j];
                        int controlIndex = fanData.Index;
                        int percent      = fanData.getValue(temperature);

                        var control = mControlList[controlIndex];

                        if (controlDictionary.ContainsKey(controlIndex) == false)
                        {
                            controlDictionary[controlIndex] = control;
                            control.NextValue = percent;
                        }
                        else
                        {
                            control.NextValue = (control.NextValue >= percent) ? control.NextValue : percent;
                        }
                    }
                }

                foreach (var keyPair in controlDictionary)
                {
                    var control = keyPair.Value;
                    if (control.Value == control.NextValue)
                    {
                        continue;
                    }
                    control.setSpeed(control.NextValue);
                }
            }

            // onUpdateCallback
            onUpdateCallback();

            var osdManager = OSDManager.getInstance();

            if (osdManager.IsEnable == true)
            {
                var osdHeaderString = "<A0=-5><A1=5><S0=50>\r";

                var osdString = new StringBuilder();
                if (osdManager.IsTime == true)
                {
                    osdString.Append(DateTime.Now.ToString("HH:mm:ss") + "\n");
                }

                int maxNameLength = 0;
                for (int i = 0; i < osdManager.getGroupCount(); i++)
                {
                    var group = osdManager.getGroup(i);
                    if (group == null)
                    {
                        break;
                    }
                    if (group.Name.Length > maxNameLength)
                    {
                        maxNameLength = group.Name.Length;
                    }
                }

                for (int i = 0; i < osdManager.getGroupCount(); i++)
                {
                    var group = osdManager.getGroup(i);
                    if (group == null)
                    {
                        break;
                    }
                    osdString.Append(group.getOSDString(maxNameLength));
                }

                if (osdString.ToString().Length > 0)
                {
                    var sendString = osdHeaderString + osdString.ToString();
                    OSDController.updateOSD(sendString);
                    osdManager.IsUpdate = true;
                }
            }
            else
            {
                if (osdManager.IsUpdate == true)
                {
                    OSDController.releaseOSD();
                    osdManager.IsUpdate = false;
                }
            }

            Monitor.Exit(mLock);
        }
Пример #10
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();
                }));
            }
        }
Пример #11
0
 private void onTrayManuEnableOSDClick(object sender, EventArgs e)
 {
     OSDManager.getInstance().IsEnable = !OSDManager.getInstance().IsEnable;
     mEnableOSDToolStripMenuItem.Checked = OSDManager.getInstance().IsEnable;
     OSDManager.getInstance().write();
 }
Пример #12
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();
        }
Пример #13
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

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

            hardwareManager.onUpdateCallback += onUpdate;
            hardwareManager.start();

            // name
            controlManager.setNameCount(0, hardwareManager.getSensorCount());
            controlManager.setNameCount(1, hardwareManager.getFanCount());
            controlManager.setNameCount(2, hardwareManager.getControlCount());

            for (int i = 0; i < hardwareManager.getSensorCount(); i++)
            {
                var temp = hardwareManager.getSensor(i);
                controlManager.setName(0, i, true, temp.Name);
                controlManager.setName(0, i, false, temp.Name);
            }

            for (int i = 0; i < hardwareManager.getFanCount(); i++)
            {
                var temp = hardwareManager.getFan(i);
                controlManager.setName(1, i, true, temp.Name);
                controlManager.setName(1, i, false, temp.Name);
            }

            for (int i = 0; i < hardwareManager.getControlCount(); i++)
            {
                var temp = hardwareManager.getControl(i);
                controlManager.setName(2, i, true, temp.Name);
                controlManager.setName(2, i, false, temp.Name);
            }

            if (controlManager.read() == false)
            {
                MessageBox.Show(StringLib.Not_Match);
            }
            else
            {
                if (controlManager.checkData() == false)
                {
                    MessageBox.Show(StringLib.Not_Match);
                }
            }

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

            this.createComponent();
            this.ActiveControl = mFanControlButton;

            mEnableToolStripMenuItem.Checked      = controlManager.IsEnable;
            mEnableOSDToolStripMenuItem.Checked   = OSDManager.getInstance().IsEnable;
            mNormalToolStripMenuItem.Checked      = (controlManager.ModeIndex == 0);
            mSilenceToolStripMenuItem.Checked     = (controlManager.ModeIndex == 1);
            mPerformanceToolStripMenuItem.Checked = (controlManager.ModeIndex == 2);
            mGameToolStripMenuItem.Checked        = (controlManager.ModeIndex == 3);

            // startUpdate
            hardwareManager.startUpdate();

            // start icon update
            mFanIconTimer.Interval = 100;
            mFanIconTimer.Tick    += onFanIconTimer;
            if (OptionManager.getInstance().IsAnimation == true)
            {
                mFanIconTimer.Start();
            }

            if (OptionManager.getInstance().IsMinimized == true)
            {
                this.BeginInvoke(new Action(delegate()
                {
                    this.Close();
                }));
            }
        }