diff --git a/LibreHardwareMonitor/UI/MainForm.Designer.cs b/LibreHardwareMonitor/UI/MainForm.Designer.cs index e49c20f..c634c55 100644 --- a/LibreHardwareMonitor/UI/MainForm.Designer.cs +++ b/LibreHardwareMonitor/UI/MainForm.Designer.cs @@ -770,7 +770,6 @@ namespace LibreHardwareMonitor.UI this.Name = "MainForm"; this.StartPosition = System.Windows.Forms.FormStartPosition.Manual; this.Text = "Libre Hardware Monitor"; - this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.MainForm_FormClosed); this.Load += new System.EventHandler(this.MainForm_Load); this.ResizeEnd += new System.EventHandler(this.MainForm_MoveOrResize); this.Move += new System.EventHandler(this.MainForm_MoveOrResize); diff --git a/LibreHardwareMonitor/UI/MainForm.cs b/LibreHardwareMonitor/UI/MainForm.cs index 79394c7..704f028 100644 --- a/LibreHardwareMonitor/UI/MainForm.cs +++ b/LibreHardwareMonitor/UI/MainForm.cs @@ -457,7 +457,7 @@ namespace LibreHardwareMonitor.UI _settings.SetValue("plotForm.Height", _plotForm.Bounds.Height); } } - + _plotForm.Move += MoveOrResizePlotForm; _plotForm.Resize += MoveOrResizePlotForm; @@ -614,7 +614,7 @@ namespace LibreHardwareMonitor.UI private void ExitClick(object sender, EventArgs e) { - Close(); + CloseApplication(); } private void Timer_Tick(object sender, EventArgs e) @@ -672,8 +672,7 @@ namespace LibreHardwareMonitor.UI Height = _settings.GetValue("mainForm.Height", 640) }; - Rectangle fullWorkingArea = new Rectangle(int.MaxValue, int.MaxValue, - int.MinValue, int.MinValue); + Rectangle fullWorkingArea = new Rectangle(int.MaxValue, int.MaxValue, int.MinValue, int.MinValue); foreach (Screen screen in Screen.AllScreens) fullWorkingArea = Rectangle.Union(fullWorkingArea, screen.Bounds); @@ -685,10 +684,13 @@ namespace LibreHardwareMonitor.UI newBounds.Y = (Screen.PrimaryScreen.WorkingArea.Height / 2) - (newBounds.Height / 2); } Bounds = newBounds; + FormClosed += MainForm_FormClosed; } - private void MainForm_FormClosed(object sender, FormClosedEventArgs e) + private void CloseApplication() { + FormClosed -= MainForm_FormClosed; + Visible = false; _systemTray.IsMainIconEnabled = false; timer.Enabled = false; @@ -697,6 +699,13 @@ namespace LibreHardwareMonitor.UI if (_runWebServer.Value) Server.Quit(); _systemTray.Dispose(); + + Application.Exit(); + } + + private void MainForm_FormClosed(object sender, FormClosedEventArgs e) + { + CloseApplication(); } private void AboutMenuItem_Click(object sender, EventArgs e) diff --git a/LibreHardwareMonitorLib/Hardware/Storage/AbstractStorage.cs b/LibreHardwareMonitorLib/Hardware/Storage/AbstractStorage.cs index 78dd509..4099831 100644 --- a/LibreHardwareMonitorLib/Hardware/Storage/AbstractStorage.cs +++ b/LibreHardwareMonitorLib/Hardware/Storage/AbstractStorage.cs @@ -68,6 +68,9 @@ namespace LibreHardwareMonitor.Hardware.Storage public static AbstractStorage CreateInstance(string deviceId, uint driveNumber, ulong diskSize, int scsiPort, ISettings settings) { StorageInfo info = WindowsStorage.GetStorageInfo(deviceId, driveNumber); + if (info == null) + return null; + info.DiskSize = diskSize; info.DeviceId = deviceId; info.Scsi = $@"\\.\SCSI{scsiPort}:"; diff --git a/LibreHardwareMonitorLib/Hardware/Storage/NVMeGeneric.cs b/LibreHardwareMonitorLib/Hardware/Storage/NVMeGeneric.cs index 6ec9212..14e8790 100644 --- a/LibreHardwareMonitorLib/Hardware/Storage/NVMeGeneric.cs +++ b/LibreHardwareMonitorLib/Hardware/Storage/NVMeGeneric.cs @@ -72,8 +72,8 @@ namespace LibreHardwareMonitor.Hardware.Storage private void AddSensor(string name, int index, bool defaultHidden, SensorType sensorType, GetSensorValue getValue) { var sensor = new NVMeSensor(name, index, defaultHidden, sensorType, this, _settings, getValue); - ActivateSensor(sensor); sensor.Value = 0; + ActivateSensor(sensor); _sensors.Add(sensor); } @@ -175,7 +175,13 @@ namespace LibreHardwareMonitor.Hardware.Storage public void Update(NVMeHealthInfo health) { - Value = _getValue(health); + float v = _getValue(health); + if (SensorType == SensorType.Temperature) + { + if (v < -1000 || v > 1000) + return; + } + Value = v; } } }