Added the remote web enhancement developed by Prince Samuel.
3 This Source Code Form is subject to the terms of the Mozilla Public
4 License, v. 2.0. If a copy of the MPL was not distributed with this
5 file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 Copyright (C) 2009-2010 Michael Möller <mmoeller@openhardwaremonitor.org>
13 using System.Collections.Generic;
14 using System.ComponentModel;
16 using System.Windows.Forms;
17 using OpenHardwareMonitor.Hardware;
18 using OpenHardwareMonitor.Collections;
20 namespace OpenHardwareMonitor.GUI {
21 public partial class ParameterForm : Form {
23 private IReadOnlyArray<IParameter> parameters;
24 private BindingList<ParameterRow> parameterRows;
26 public ParameterForm() {
27 InitializeComponent();
30 public IReadOnlyArray<IParameter> Parameters {
36 parameterRows = new BindingList<ParameterRow>();
37 foreach (IParameter parameter in parameters)
38 parameterRows.Add(new ParameterRow(parameter));
39 bindingSource.DataSource = parameterRows;
43 private class ParameterRow : INotifyPropertyChanged {
44 public IParameter parameter;
46 public bool isDefault;
48 public event PropertyChangedEventHandler PropertyChanged;
50 private void NotifyPropertyChanged(String propertyName) {
51 if (PropertyChanged != null) {
52 PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
56 public ParameterRow(IParameter parameter){
57 this.parameter = parameter;
58 this.value = parameter.Value;
59 this.isDefault = parameter.IsDefault;
63 get { return parameter.Name; }
69 this.isDefault = false;
71 NotifyPropertyChanged("Default");
72 NotifyPropertyChanged("Value");
77 get { return isDefault; }
81 this.value = parameter.DefaultValue;
82 NotifyPropertyChanged("Default");
83 NotifyPropertyChanged("Value");
88 private void dataGridView_RowEnter(object sender,
89 DataGridViewCellEventArgs e)
91 if (e.RowIndex >= 0 && e.RowIndex < parameters.Length)
92 descriptionLabel.Text = parameters[e.RowIndex].Description;
94 descriptionLabel.Text = "";
97 private void dataGridView_CellValidating(object sender,
98 DataGridViewCellValidatingEventArgs e)
101 if (e.ColumnIndex == 2 &&
102 !float.TryParse(e.FormattedValue.ToString(), out value)) {
103 dataGridView.Rows[e.RowIndex].Cells[0].ErrorText =
109 private void dataGridView_CellEndEdit(object sender,
110 DataGridViewCellEventArgs e) {
111 dataGridView.Rows[e.RowIndex].Cells[0].ErrorText = "";
114 private void okButton_Click(object sender, EventArgs e) {
115 foreach (ParameterRow row in parameterRows) {
117 row.parameter.IsDefault = true;
119 row.parameter.Value = row.Value;
124 private void dataGridView_CurrentCellDirtyStateChanged(object sender,
126 if (dataGridView.CurrentCell is DataGridViewCheckBoxCell ||
127 dataGridView.CurrentCell is DataGridViewComboBoxCell)
129 dataGridView.CommitEdit(DataGridViewDataErrorContexts.Commit);