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(); }
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(); })); } }
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(); }
private void onTrayMenuEnableClick(object sender, EventArgs e) { ControlManager.getInstance().IsEnable = !ControlManager.getInstance().IsEnable; mEnableToolStripMenuItem.Checked = ControlManager.getInstance().IsEnable; ControlManager.getInstance().write(); }
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(); })); } }
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; }
private void onOKButtonClick(object sender, EventArgs e) { int interval = int.Parse(mIntervalTextBox.Text); if (interval < 100) { interval = 100; } else if (interval > 5000) { interval = 5000; } int delayTime = int.Parse(mStartupDelayTextBox.Text); if (delayTime < 0) { delayTime = 0; } else if (delayTime > 59) { delayTime = 59; } 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.DelayTime = delayTime; optionManager.IsStartUp = false; 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(); }
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); }
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(); 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; }