Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
jochenwezel committed Apr 19, 2020
2 parents 90e147d + e372113 commit ac77717
Show file tree
Hide file tree
Showing 43 changed files with 2,279 additions and 328 deletions.
2 changes: 1 addition & 1 deletion GUI/AboutBox.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions GUI/CrashForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.
Copyright (C) 2009-2010 Michael Möller <mmoeller@openhardwaremonitor.org>
Copyright (C) 2009-2020 Michael Möller <mmoeller@openhardwaremonitor.org>
*/


using OpenHardwareMonitor.Utilities;
using System;
using System.IO;
using System.Net;
Expand Down Expand Up @@ -59,10 +59,10 @@ private void sendButton_Click(object sender, EventArgs e) {

string report =
"type=crash&" +
"version=" + Uri.EscapeDataString(version.ToString()) + "&" +
"report=" + Uri.EscapeDataString(reportTextBox.Text) + "&" +
"comment=" + Uri.EscapeDataString(commentTextBox.Text) + "&" +
"email=" + Uri.EscapeDataString(emailTextBox.Text);
"version=" + HttpUtility.UrlEncode(version.ToString()) + "&" +
"report=" + HttpUtility.UrlEncode(reportTextBox.Text) + "&" +
"comment=" + HttpUtility.UrlEncode(commentTextBox.Text) + "&" +
"email=" + HttpUtility.UrlEncode(emailTextBox.Text);
byte[] byteArray = Encoding.UTF8.GetBytes(report);
request.ContentLength = byteArray.Length;

Expand Down
21 changes: 14 additions & 7 deletions GUI/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.
Copyright (C) 2009-2013 Michael Möller <mmoeller@openhardwaremonitor.org>
Copyright (C) 2009-2020 Michael Möller <mmoeller@openhardwaremonitor.org>
Copyright (C) 2010 Paul Werelds <paul@werelds.net>
Copyright (C) 2012 Prince Samuel <prince.samuel@gmail.com>
Expand Down Expand Up @@ -435,7 +435,7 @@ private void InitializePlotForm() {
private void InsertSorted(Collection<Node> nodes, HardwareNode node) {
int i = 0;
while (i < nodes.Count && nodes[i] is HardwareNode &&
((HardwareNode)nodes[i]).Hardware.HardwareType <
((HardwareNode)nodes[i]).Hardware.HardwareType <=
node.Hardware.HardwareType)
i++;
nodes.Insert(i, node);
Expand Down Expand Up @@ -575,12 +575,19 @@ private void timer_Tick(object sender, EventArgs e) {
}

private void SaveConfiguration() {
plotPanel.SetCurrentSettings();
foreach (TreeColumn column in treeView.Columns)
settings.SetValue("treeView.Columns." + column.Header + ".Width",
column.Width);
if (settings == null)
return;

if (plotPanel != null) {
plotPanel.SetCurrentSettings();
foreach (TreeColumn column in treeView.Columns)
settings.SetValue("treeView.Columns." + column.Header + ".Width",
column.Width);
}

this.settings.SetValue("listenerPort", server.ListenerPort);
if (server != null) {
this.settings.SetValue("listenerPort", server.ListenerPort);
}

string fileName = Path.ChangeExtension(
System.Windows.Forms.Application.ExecutablePath, ".config");
Expand Down
11 changes: 6 additions & 5 deletions GUI/ReportForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.
Copyright (C) 2009-2010 Michael Möller <mmoeller@openhardwaremonitor.org>
Copyright (C) 2009-2020 Michael Möller <mmoeller@openhardwaremonitor.org>
*/

using OpenHardwareMonitor.Utilities;
using System;
using System.Drawing;
using System.IO;
Expand Down Expand Up @@ -47,10 +48,10 @@ private void sendButton_Click(object sender, EventArgs e) {

string report =
"type=hardware&" +
"version=" + Uri.EscapeDataString(version.ToString()) + "&" +
"report=" + Uri.EscapeDataString(reportTextBox.Text) + "&" +
"comment=" + Uri.EscapeDataString(commentTextBox.Text) + "&" +
"email=" + Uri.EscapeDataString(emailTextBox.Text);
"version=" + HttpUtility.UrlEncode(version.ToString()) + "&" +
"report=" + HttpUtility.UrlEncode(reportTextBox.Text) + "&" +
"comment=" + HttpUtility.UrlEncode(commentTextBox.Text) + "&" +
"email=" + HttpUtility.UrlEncode(emailTextBox.Text);
byte[] byteArray = Encoding.UTF8.GetBytes(report);
request.ContentLength = byteArray.Length;

Expand Down
36 changes: 26 additions & 10 deletions GUI/SensorGadget.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.
Copyright (C) 2010-2012 Michael Möller <mmoeller@openhardwaremonitor.org>
Copyright (C) 2010-2020 Michael Möller <mmoeller@openhardwaremonitor.org>
*/

Expand Down Expand Up @@ -558,9 +558,6 @@ protected override void OnPaint(PaintEventArgs e) {
case SensorType.Clock:
format = "{0:F0} MHz";
break;
case SensorType.Temperature:
format = "{0:F1} °C";
break;
case SensorType.Fan:
format = "{0:F0} RPM";
break;
Expand All @@ -576,14 +573,33 @@ protected override void OnPaint(PaintEventArgs e) {
case SensorType.Factor:
format = "{0:F3}";
break;
case SensorType.SmallData:
format = "{0:F1} MB";
break;
}

if (sensor.SensorType == SensorType.Temperature &&
unitManager.TemperatureUnit == TemperatureUnit.Fahrenheit) {
formatted = string.Format("{0:F1} °F",
UnitManager.CelsiusToFahrenheit(sensor.Value));
} else {
formatted = string.Format(format, sensor.Value);
switch (sensor.SensorType) {
case SensorType.Temperature:
if (unitManager.TemperatureUnit == TemperatureUnit.Fahrenheit)
{
formatted = string.Format("{0:F1} °F",
UnitManager.CelsiusToFahrenheit(sensor.Value));
} else {
formatted = string.Format("{0:F1} °C", sensor.Value);
}
break;
case SensorType.Throughput:
if (sensor.Value < 1) {
formatted =
string.Format("{0:F1} KB/s", sensor.Value * 0x400);
} else {
formatted =
string.Format("{0:F1} MB/s", sensor.Value);
}
break;
default:
formatted = string.Format(format, sensor.Value);
break;
}
} else {
formatted = "-";
Expand Down
52 changes: 29 additions & 23 deletions GUI/SensorNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,40 @@ This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.
Copyright (C) 2009-2016 Michael Möller <mmoeller@openhardwaremonitor.org>
Copyright (C) 2009-2020 Michael Möller <mmoeller@openhardwaremonitor.org>
*/

using OpenHardwareMonitor.Hardware;
using System;
using System.Drawing;
using System.Collections.Generic;
using OpenHardwareMonitor.Hardware;
using OpenHardwareMonitor.Utilities;

namespace OpenHardwareMonitor.GUI {
public class SensorNode : Node {

private ISensor sensor;
private PersistentSettings settings;
private UnitManager unitManager;
private string format;
private string fixedFormat;
private bool plot = false;
private Color? penColor = null;

public string ValueToString(float? value) {
if (value.HasValue) {
if (sensor.SensorType == SensorType.Temperature &&
unitManager.TemperatureUnit == TemperatureUnit.Fahrenheit) {
return string.Format("{0:F1} °F", value * 1.8 + 32);
} else {
return string.Format(format, value);
}
switch (sensor.SensorType) {
case SensorType.Temperature:
if (unitManager.TemperatureUnit == TemperatureUnit.Fahrenheit)
return string.Format("{0:F1} °F", value * 1.8 + 32);
else
return string.Format("{0:F1} °C", value);
case SensorType.Throughput:
if (value < 1)
return string.Format("{0:F1} KB/s", value * 0x400);
else
return string.Format("{0:F1} MB/s", value);
default:
return string.Format(fixedFormat, value);
}
} else
return "-";
}
Expand All @@ -42,18 +48,18 @@ public SensorNode(ISensor sensor, PersistentSettings settings,
this.settings = settings;
this.unitManager = unitManager;
switch (sensor.SensorType) {
case SensorType.Voltage: format = "{0:F3} V"; break;
case SensorType.Clock: format = "{0:F0} MHz"; break;
case SensorType.Load: format = "{0:F1} %"; break;
case SensorType.Temperature: format = "{0:F1} °C"; break;
case SensorType.Fan: format = "{0:F0} RPM"; break;
case SensorType.Flow: format = "{0:F0} L/h"; break;
case SensorType.Control: format = "{0:F1} %"; break;
case SensorType.Level: format = "{0:F1} %"; break;
case SensorType.Power: format = "{0:F1} W"; break;
case SensorType.Data: format = "{0:F1} GB"; break;
case SensorType.SmallData: format = "{0:F1} MB"; break;
case SensorType.Factor: format = "{0:F3}"; break;
case SensorType.Voltage: fixedFormat = "{0:F3} V"; break;
case SensorType.Clock: fixedFormat = "{0:F1} MHz"; break;
case SensorType.Load: fixedFormat = "{0:F1} %"; break;
case SensorType.Fan: fixedFormat = "{0:F0} RPM"; break;
case SensorType.Flow: fixedFormat = "{0:F0} L/h"; break;
case SensorType.Control: fixedFormat = "{0:F1} %"; break;
case SensorType.Level: fixedFormat = "{0:F1} %"; break;
case SensorType.Power: fixedFormat = "{0:F1} W"; break;
case SensorType.Data: fixedFormat = "{0:F1} GB"; break;
case SensorType.SmallData: fixedFormat = "{0:F1} MB"; break;
case SensorType.Factor: fixedFormat = "{0:F3}"; break;
default: fixedFormat = ""; break;
}

bool hidden = settings.GetValue(new Identifier(sensor.Identifier,
Expand Down
10 changes: 7 additions & 3 deletions GUI/StartupManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.
Copyright (C) 2009-2010 Michael Möller <mmoeller@openhardwaremonitor.org>
Copyright (C) 2009-2020 Michael Möller <mmoeller@openhardwaremonitor.org>
*/

Expand Down Expand Up @@ -56,8 +56,10 @@ public StartupManager() {

if (scheduler != null) {
try {
// check if the taskscheduler is running
IRunningTaskCollection collection = scheduler.GetRunningTasks(0);
try {
// check if the taskscheduler is running
IRunningTaskCollection collection = scheduler.GetRunningTasks(0);
} catch (ArgumentException) { }

ITaskFolder folder = scheduler.GetFolder("\\Open Hardware Monitor");
IRegisteredTask task = folder.GetTask("Startup");
Expand All @@ -78,6 +80,8 @@ public StartupManager() {
scheduler = null;
} catch (COMException) {
scheduler = null;
} catch (NotImplementedException) {
scheduler = null;
}
}
} else {
Expand Down
4 changes: 4 additions & 0 deletions GUI/TypeNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ public TypeNode(SensorType sensorType) : base() {
this.Image = Utilities.EmbeddedResources.GetImage("factor.png");
this.Text = "Factors";
break;
case SensorType.Throughput:
this.Image = Utilities.EmbeddedResources.GetImage("throughput.png");
this.Text = "Throughput";
break;
}

NodeAdded += new NodeEventHandler(TypeNode_NodeAdded);
Expand Down
Loading

0 comments on commit ac77717

Please sign in to comment.