예제 #1
0
        private void onApplyButtonClick(object sender, EventArgs e)
        {
            for (int i = 0; i < mControlDataList.Length; i++)
            {
                for (int j = 0; j < mControlDataList[i].Count; j++)
                {
                    for (int k = 0; k < mControlDataList[i][j].FanDataList.Count; k++)
                    {
                        mControlDataList[i][j].FanDataList[k].LastChangedTemp  = 0;
                        mControlDataList[i][j].FanDataList[k].LastChangedValue = 0;
                    }
                }
                ControlManager.getInstance().setControlDataList((MODE_TYPE)i, mControlDataList[i]);
            }

            ControlManager.getInstance().Width      = mNormalLastSize.Width;
            ControlManager.getInstance().Height     = mNormalLastSize.Height;
            ControlManager.getInstance().IsMaximize = (this.WindowState == FormWindowState.Maximized);

            ControlManager.getInstance().ModeType = mModeType;
            ControlManager.getInstance().IsEnable = mEnableCheckBox.Checked;
            ControlManager.getInstance().write();

            onApplyCallback(sender, e);
        }
예제 #2
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);
        }
예제 #3
0
 private void onTrayMenuGameClick(object sender, EventArgs e)
 {
     ControlManager.getInstance().ModeType = MODE_TYPE.GAME;
     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);
     ControlManager.getInstance().write();
 }
예제 #4
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;
            }
        }
예제 #5
0
 private void onTrayMenuGameClick(object sender, EventArgs e)
 {
     ControlManager.getInstance().ModeIndex = 3;
     mNormalToolStripMenuItem.Checked      = (ControlManager.getInstance().ModeIndex == 0);
     mSilenceToolStripMenuItem.Checked     = (ControlManager.getInstance().ModeIndex == 1);
     mPerformanceToolStripMenuItem.Checked = (ControlManager.getInstance().ModeIndex == 2);
     mGameToolStripMenuItem.Checked        = (ControlManager.getInstance().ModeIndex == 3);
     ControlManager.getInstance().write();
 }
예제 #6
0
        private void initControl()
        {
            ControlManager controlManager = ControlManager.getInstance();

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

            mNormalRadioButton.Checked      = (mModeIndex == 0);
            mSilenceRadioButton.Checked     = (mModeIndex == 1);
            mPerformanceRadioButton.Checked = (mModeIndex == 2);
            mGameRadioButton.Checked        = (mModeIndex == 3);

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

            mSensorComboBox.SelectedIndexChanged += onSensorComboBoxIndexChanged;

            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;

            for (int i = 0; i < controlManager.getNameCount(0); i++)
            {
                mSensorComboBox.Items.Add(controlManager.getName(0, i, false));
            }

            for (int i = 0; i < controlManager.getNameCount(2); i++)
            {
                mFanComboBox.Items.Add(controlManager.getName(2, i, false));
            }

            if (mSensorComboBox.Items.Count > 0)
            {
                mSensorComboBox.SelectedIndex = 0;
                mSelectedSensorIndex          = 0;
            }

            if (mFanComboBox.Items.Count > 0)
            {
                mFanComboBox.SelectedIndex = 0;
            }
        }
예제 #7
0
        private void onFanIconTimer(object sender, EventArgs e)
        {
            if (ControlManager.getInstance().IsEnable == false || OptionManager.getInstance().IsAnimation == false)
            {
                return;
            }

            if (mFanIconIndex >= mFanIconList.Count)
            {
                mFanIconIndex = 0;
            }
            mTrayIcon.Icon = mFanIconList[mFanIconIndex++];
        }
예제 #8
0
 private void onFanControlButtonClick(object sender, EventArgs e)
 {
     mControlForm = new ControlForm();
     mControlForm.onApplyCallback += (sender2, e2) =>
     {
         mEnableToolStripMenuItem.Checked      = ControlManager.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);
     };
     mControlForm.ShowDialog();
     mControlForm = null;
 }
예제 #9
0
 private void onFanControlButtonClick(object sender, EventArgs e)
 {
     mControlForm = new ControlForm();
     mControlForm.onApplyCallback += (sender2, e2) =>
     {
         mEnableToolStripMenuItem.Checked      = ControlManager.getInstance().IsEnable;
         mNormalToolStripMenuItem.Checked      = (ControlManager.getInstance().ModeIndex == 0);
         mSilenceToolStripMenuItem.Checked     = (ControlManager.getInstance().ModeIndex == 1);
         mPerformanceToolStripMenuItem.Checked = (ControlManager.getInstance().ModeIndex == 2);
         mGameToolStripMenuItem.Checked        = (ControlManager.getInstance().ModeIndex == 3);
     };
     mControlForm.ShowDialog();
     mControlForm = null;
 }
예제 #10
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();
        }
예제 #11
0
 private void onFanControlButtonClick(object sender, EventArgs e)
 {
     mControlForm = new ControlForm();
     mControlForm.onApplyCallback += (sender2, e2) =>
     {
         mEnableToolStripMenuItem.Checked      = ControlManager.getInstance().IsEnable;
         mNormalToolStripMenuItem.Checked      = (ControlManager.getInstance().ModeIndex == 0);
         mSilenceToolStripMenuItem.Checked     = (ControlManager.getInstance().ModeIndex == 1);
         mPerformanceToolStripMenuItem.Checked = (ControlManager.getInstance().ModeIndex == 2);
         mGameToolStripMenuItem.Checked        = (ControlManager.getInstance().ModeIndex == 3);
     };
     mControlForm.StartPosition = FormStartPosition.Manual;
     mControlForm.Location      = new Point(this.Location.X + 100, this.Location.Y + 100);
     mControlForm.ShowDialog();
     mControlForm.Dispose();
     mControlForm = null;
 }
예제 #12
0
        private void onNameTextBoxLeaves(TextBox textBox, int type, ref List <TextBox> nameTextBoxList)
        {
            var    controlManager = ControlManager.getInstance();
            int    index          = -1;
            int    num            = 2;
            string name           = textBox.Text;

            while (true)
            {
                bool isExist = false;
                for (int i = 0; i < nameTextBoxList.Count; i++)
                {
                    if (nameTextBoxList[i] == textBox)
                    {
                        if (name.Length == 0)
                        {
                            textBox.Text = controlManager.getName(type, i, false);
                            return;
                        }

                        index = i;
                        continue;
                    }

                    else if (nameTextBoxList[i].Text.Equals(name) == true)
                    {
                        isExist = true;
                        break;
                    }
                }

                if (isExist == true)
                {
                    name = textBox.Text + " #" + num++;
                    continue;
                }

                textBox.Text = name;
                controlManager.setName(type, index, false, name);
                break;
            }
            controlManager.write();
        }
예제 #13
0
        private void onAddButtonClick(object sender, EventArgs e)
        {
            if (mSensorComboBox.Items.Count == 0 || mFanComboBox.Items.Count == 0)
            {
                return;
            }

            int sensorIndex = mSelectedSensorIndex;
            int fanIndex    = mFanComboBox.SelectedIndex;

            var controlManager = ControlManager.getInstance();
            var sensorName     = controlManager.getName(0, sensorIndex, false);
            var fanControlName = controlManager.getName(2, fanIndex, false);

            var controlData = this.getControlData(sensorIndex);

            if (controlData == null)
            {
                controlData = new ControlData(sensorIndex, sensorName);
                mControlDataList[mModeIndex].Add(controlData);
            }

            mFanListView.BeginUpdate();

            var fanData = this.getFanData(sensorIndex, fanIndex);

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

                mFanListView.Items.Add(fanData.Name);
            }

            mFanListView.EndUpdate();
        }
예제 #14
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;
        }
예제 #15
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();
        }
예제 #16
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 { }
        }
예제 #17
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);
            }
        }
예제 #18
0
        public ControlForm()
        {
            InitializeComponent();
            this.localizeComponent();

            mControlDataList[0] = ControlManager.getInstance().getCloneControlDataList(MODE_TYPE.NORMAL);
            mControlDataList[1] = ControlManager.getInstance().getCloneControlDataList(MODE_TYPE.SILENCE);
            mControlDataList[2] = ControlManager.getInstance().getCloneControlDataList(MODE_TYPE.PERFORMANCE);
            mControlDataList[3] = ControlManager.getInstance().getCloneControlDataList(MODE_TYPE.GAME);

            mModeType = ControlManager.getInstance().ModeType;

            this.initControl();
            this.initGraph();

            this.SetStyle(ControlStyles.UserPaint |
                          ControlStyles.OptimizedDoubleBuffer |
                          ControlStyles.AllPaintingInWmPaint |
                          ControlStyles.SupportsTransparentBackColor, true);
            this.Resize += (sender, e) =>
            {
                if (mIsResize == true)
                {
                    return;
                }
                mIsResize = true;

                //Console.WriteLine("Size : {0}, {1}", this.Width, this.Height);

                int widthGap  = this.Width - mLastSize.Width;
                int heightGap = this.Height - mLastSize.Height;

                //Console.WriteLine("Gap : {0}, {1}", widthGap, heightGap);

                mFanGroupBox.Height = mFanGroupBox.Height + heightGap;
                mFanListView.Height = mFanListView.Height + heightGap;
                mRemoveButton.Top   = mRemoveButton.Top + heightGap;

                mModeGroupBox.Width = mModeGroupBox.Width + widthGap;

                mGraphGroupBox.Width  = mGraphGroupBox.Width + widthGap;
                mGraphGroupBox.Height = mGraphGroupBox.Height + heightGap;

                mGraph.Width  = mGraph.Width + widthGap;
                mGraph.Height = mGraph.Height + heightGap;

                mPresetLabel.Left      = mPresetLabel.Left + widthGap;
                mPresetLoadButton.Left = mPresetLoadButton.Left + widthGap;
                mPresetSaveButton.Left = mPresetSaveButton.Left + widthGap;
                mUnitLabel.Left        = mUnitLabel.Left + widthGap;
                mUnitComboBox.Left     = mUnitComboBox.Left + widthGap;
                mHysLabel.Left         = mHysLabel.Left + widthGap;
                mHysNumericUpDown.Left = mHysNumericUpDown.Left + widthGap;
                mStepCheckBox.Left     = mStepCheckBox.Left + widthGap;

                mApplyButton.Left = mApplyButton.Left + widthGap;
                mApplyButton.Top  = mApplyButton.Top + heightGap;

                mOKButton.Left = mOKButton.Left + widthGap;
                mOKButton.Top  = mOKButton.Top + heightGap;

                mLastSize.Width  = this.Width;
                mLastSize.Height = this.Height;

                if (this.WindowState != FormWindowState.Maximized)
                {
                    mNormalLastSize.Width  = this.Width;
                    mNormalLastSize.Height = this.Height;
                }

                mIsResize = false;
            };

            this.ResizeBegin += (s, e) =>
            {
                mIsUpdateGraph = false;
                this.SuspendLayout();
            };
            this.ResizeEnd += (s, e) =>
            {
                this.ResumeLayout();
                mIsUpdateGraph = true;
            };

            if (ControlManager.getInstance().IsMaximize == true)
            {
                this.WindowState = FormWindowState.Maximized;
            }

            this.Width             = ControlManager.getInstance().Width;
            this.Height            = ControlManager.getInstance().Height;
            mLastSize.Width        = this.Width;
            mLastSize.Height       = this.Height;
            mNormalLastSize.Width  = this.Width;
            mNormalLastSize.Height = this.Height;
        }
예제 #19
0
        private void createComponent()
        {
            var hardwareManager = HardwareManager.getInstance();
            var controlManager  = ControlManager.getInstance();

            // temperature
            for (int i = 0; i < hardwareManager.getSensorCount(); i++)
            {
                var label = new Label();
                label.Location  = new System.Drawing.Point(3, 25 + i * 25);
                label.Name      = "sensorLabel" + i.ToString();
                label.Size      = new System.Drawing.Size(40, 23);
                label.Text      = "";
                label.AutoSize  = false;
                label.TextAlign = ContentAlignment.TopRight;
                mTempGroupBox.Controls.Add(label);
                mSensorLabelList.Add(label);

                var textBox = new TextBox();
                textBox.Location  = new System.Drawing.Point(label.Left + label.Width + 5, label.Top - 5);
                textBox.Name      = "sensorName" + i.ToString();
                textBox.Size      = new System.Drawing.Size(mTempGroupBox.Width - 60, 23);
                textBox.Multiline = false;
                textBox.MaxLength = 40;
                textBox.Text      = controlManager.getName(0, i, false);
                textBox.Leave    += onSensorNameTextBoxLeaves;
                mTempGroupBox.Controls.Add(textBox);
                mSensorNameTextBoxList.Add(textBox);

                if (i < hardwareManager.getSensorCount() - 1)
                {
                    mTempGroupBox.Height = mTempGroupBox.Height + 25;
                }
            }

            // fan
            for (int i = 0; i < hardwareManager.getFanCount(); i++)
            {
                var label = new Label();
                label.Location  = new System.Drawing.Point(10, 25 + i * 25);
                label.Name      = "fanLabel" + i.ToString();
                label.Size      = new System.Drawing.Size(60, 23);
                label.Text      = "";
                label.AutoSize  = false;
                label.TextAlign = ContentAlignment.TopRight;
                mFanGroupBox.Controls.Add(label);
                mFanLabelList.Add(label);

                var textBox = new TextBox();
                textBox.Location  = new System.Drawing.Point(label.Left + label.Width + 5, label.Top - 5);
                textBox.Name      = "fanName" + i.ToString();
                textBox.Size      = new System.Drawing.Size(mFanGroupBox.Width - 85, 23);
                textBox.Multiline = false;
                textBox.MaxLength = 40;
                textBox.Text      = controlManager.getName(1, i, false);
                textBox.Leave    += onFanNameTextBoxLeaves;
                mFanGroupBox.Controls.Add(textBox);
                mFanNameTextBoxList.Add(textBox);

                if (i < hardwareManager.getFanCount() - 1)
                {
                    mFanGroupBox.Height = mFanGroupBox.Height + 25;
                }
            }

            // set groupbox height
            if (mFanGroupBox.Height > mTempGroupBox.Height)
            {
                mTempGroupBox.Height = mFanGroupBox.Height;
            }
            else
            {
                mFanGroupBox.Height = mTempGroupBox.Height;
            }

            // control
            for (int i = 0; i < hardwareManager.getControlCount(); i++)
            {
                var textBox = new TextBox();
                textBox.Location     = new System.Drawing.Point(10, 20 + i * 25);
                textBox.Name         = "controlTextBox" + i.ToString();
                textBox.Size         = new System.Drawing.Size(40, 23);
                textBox.Multiline    = false;
                textBox.MaxLength    = 3;
                textBox.Text         = "" + hardwareManager.getControl(i).Value;
                textBox.KeyPress    += onControlTextBoxKeyPress;
                textBox.TextChanged += onControlTextBoxChanges;
                mControlGroupBox.Controls.Add(textBox);
                mControlTextBoxList.Add(textBox);

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

                var label = new Label();
                label.Location = new System.Drawing.Point(textBox.Left + textBox.Width + 2, 25 + i * 25);
                label.Name     = "controlLabel" + i.ToString();
                label.Size     = new System.Drawing.Size(15, 23);
                label.Text     = "%";
                mControlGroupBox.Controls.Add(label);
                mControlLabelList.Add(label);

                var textBox2 = new TextBox();
                textBox2.Location  = new System.Drawing.Point(label.Left + label.Width + 5, label.Top - 5);
                textBox2.Name      = "controlName" + i.ToString();
                textBox2.Size      = new System.Drawing.Size(mControlGroupBox.Width - 85, 23);
                textBox2.Multiline = false;
                textBox2.MaxLength = 40;
                textBox2.Text      = controlManager.getName(2, i, false);
                textBox2.Leave    += onFanControlNameTextBoxLeaves;
                mControlGroupBox.Controls.Add(textBox2);
                mControlNameTextBoxList.Add(textBox2);

                if (i < hardwareManager.getControlCount() - 1)
                {
                    mControlGroupBox.Height = mControlGroupBox.Height + 25;
                }
            }

            // set groupbox height
            if (mFanGroupBox.Height > mControlGroupBox.Height)
            {
                mControlGroupBox.Height = mFanGroupBox.Height;
            }
            else
            {
                mTempGroupBox.Height = mControlGroupBox.Height;
                mFanGroupBox.Height  = mControlGroupBox.Height;
            }

            // position
            mOSDButton.Top        = mFanGroupBox.Top + mFanGroupBox.Height + 10;
            mOptionButton.Top     = mFanGroupBox.Top + mFanGroupBox.Height + 10;
            mFanControlButton.Top = mFanGroupBox.Top + mFanGroupBox.Height + 10;
            mMadeLabel1.Top       = mFanGroupBox.Top + mFanGroupBox.Height + 15;
            mMadeLabel2.Top       = mFanGroupBox.Top + mFanGroupBox.Height + 32;
            mDonatePictureBox.Top = mFanGroupBox.Top + mFanGroupBox.Height + 17;
            this.Height           = mFanGroupBox.Height + mOptionButton.Height + 70;
        }
예제 #20
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();
                }));
            }
        }
예제 #21
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);
        }
예제 #22
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();
                }));
            }
        }
예제 #23
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();
        }
예제 #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();
        }
예제 #25
0
 private void onTrayMenuEnableClick(object sender, EventArgs e)
 {
     ControlManager.getInstance().IsEnable = !ControlManager.getInstance().IsEnable;
     mEnableToolStripMenuItem.Checked = ControlManager.getInstance().IsEnable;
     ControlManager.getInstance().write();
 }
예제 #26
0
        public ControlForm()
        {
            InitializeComponent();
            this.localizeComponent();

            mControlDataList.Add(ControlManager.getInstance().getCloneControlDataList(0));
            mControlDataList.Add(ControlManager.getInstance().getCloneControlDataList(1));
            mControlDataList.Add(ControlManager.getInstance().getCloneControlDataList(2));
            mControlDataList.Add(ControlManager.getInstance().getCloneControlDataList(3));
            mModeIndex = ControlManager.getInstance().ModeIndex;

            this.initControl();
            this.initGraph();

            // Can only resize windows with Windows 10
            if (System.Environment.OSVersion.Version.Major >= 10)
            {
                this.SetStyle(ControlStyles.UserPaint |
                              ControlStyles.OptimizedDoubleBuffer |
                              ControlStyles.AllPaintingInWmPaint |
                              ControlStyles.SupportsTransparentBackColor, true);
                this.Resize += (sender, e) =>
                {
                    if (mIsResize == true)
                    {
                        return;
                    }
                    mIsResize = true;

                    //Console.WriteLine("Size : {0}, {1}", this.Width, this.Height);

                    int widthGap  = this.Width - mLastSize.Width;
                    int heightGap = this.Height - mLastSize.Height;

                    //Console.WriteLine("Gap : {0}, {1}", widthGap, heightGap);

                    mFanGroupBox.Height = mFanGroupBox.Height + heightGap;
                    mFanListView.Height = mFanListView.Height + heightGap;
                    mRemoveButton.Top   = mRemoveButton.Top + heightGap;

                    mModeGroupBox.Width = mModeGroupBox.Width + widthGap;

                    mGraphGroupBox.Width  = mGraphGroupBox.Width + widthGap;
                    mGraphGroupBox.Height = mGraphGroupBox.Height + heightGap;

                    mGraph.Width  = mGraph.Width + widthGap;
                    mGraph.Height = mGraph.Height + heightGap;

                    mUnitLabel.Left        = mUnitLabel.Left + widthGap;
                    mUnitComboBox.Left     = mUnitComboBox.Left + widthGap;
                    mHysLabel.Left         = mHysLabel.Left + widthGap;
                    mHysNumericUpDown.Left = mHysNumericUpDown.Left + widthGap;
                    mStepCheckBox.Left     = mStepCheckBox.Left + widthGap;

                    mApplyButton.Left = mApplyButton.Left + widthGap;
                    mApplyButton.Top  = mApplyButton.Top + heightGap;

                    mOKButton.Left = mOKButton.Left + widthGap;
                    mOKButton.Top  = mOKButton.Top + heightGap;

                    mLastSize.Width  = this.Width;
                    mLastSize.Height = this.Height;

                    if (this.WindowState != FormWindowState.Maximized)
                    {
                        mNormalLastSize.Width  = this.Width;
                        mNormalLastSize.Height = this.Height;
                    }

                    mIsResize = false;
                };

                this.ResizeBegin += (s, e) =>
                {
                    mIsUpdateGraph = false;
                    this.SuspendLayout();
                };
                this.ResizeEnd += (s, e) =>
                {
                    this.ResumeLayout();
                    mIsUpdateGraph = true;
                };

                this.FormClosing += (s, e) =>
                {
                    ControlManager.getInstance().Width      = mNormalLastSize.Width;
                    ControlManager.getInstance().Height     = mNormalLastSize.Height;
                    ControlManager.getInstance().IsMaximize = (this.WindowState == FormWindowState.Maximized);
                    ControlManager.getInstance().write();
                };

                if (ControlManager.getInstance().IsMaximize == true)
                {
                    this.WindowState = FormWindowState.Maximized;
                }

                this.Width             = ControlManager.getInstance().Width;
                this.Height            = ControlManager.getInstance().Height;
                mLastSize.Width        = this.Width;
                mLastSize.Height       = this.Height;
                mNormalLastSize.Width  = this.Width;
                mNormalLastSize.Height = this.Height;
            }
            else
            {
                this.MaximizeBox     = false;
                this.FormBorderStyle = FormBorderStyle.FixedSingle;
            }
        }