# HG changeset patch # User moel.mich # Date 1270224307 0 # Node ID b4f0f206173d1137ce24ccd8ade569ef40304add # Parent ec4ccaa1210d67fd778d8423e97d6cd2947d4448 Fixed Issue 26. Added a dialog to automatically send a crash report. diff -r ec4ccaa1210d -r b4f0f206173d GUI/CrashReportForm.Designer.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/GUI/CrashReportForm.Designer.cs Fri Apr 02 16:05:07 2010 +0000 @@ -0,0 +1,249 @@ +/* + + Version: MPL 1.1/GPL 2.0/LGPL 2.1 + + The contents of this file are subject to the Mozilla Public License Version + 1.1 (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.mozilla.org/MPL/ + + Software distributed under the License is distributed on an "AS IS" basis, + WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + for the specific language governing rights and limitations under the License. + + The Original Code is the Open Hardware Monitor code. + + The Initial Developer of the Original Code is + Michael Möller . + Portions created by the Initial Developer are Copyright (C) 2009-2010 + the Initial Developer. All Rights Reserved. + + Contributor(s): + + Alternatively, the contents of this file may be used under the terms of + either the GNU General Public License Version 2 or later (the "GPL"), or + the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + in which case the provisions of the GPL or the LGPL are applicable instead + of those above. If you wish to allow use of your version of this file only + under the terms of either the GPL or the LGPL, and not to allow others to + use your version of this file under the terms of the MPL, indicate your + decision by deleting the provisions above and replace them with the notice + and other provisions required by the GPL or the LGPL. If you do not delete + the provisions above, a recipient may use your version of this file under + the terms of any one of the MPL, the GPL or the LGPL. + +*/ + +namespace OpenHardwareMonitor.GUI { + partial class CrashReportForm { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) { + if (disposing && (components != null)) { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() { + this.sendButton = new System.Windows.Forms.Button(); + this.exitButton = new System.Windows.Forms.Button(); + this.commentTextBox = new System.Windows.Forms.TextBox(); + this.titleLabel = new System.Windows.Forms.Label(); + this.label3 = new System.Windows.Forms.Label(); + this.label1 = new System.Windows.Forms.Label(); + this.commentPanel = new System.Windows.Forms.Panel(); + this.reportPanel = new System.Windows.Forms.Panel(); + this.reportTextBox = new System.Windows.Forms.TextBox(); + this.textBox1 = new System.Windows.Forms.TextBox(); + this.commentPanel.SuspendLayout(); + this.reportPanel.SuspendLayout(); + this.SuspendLayout(); + // + // sendButton + // + this.sendButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.sendButton.Location = new System.Drawing.Point(467, 412); + this.sendButton.Name = "sendButton"; + this.sendButton.Size = new System.Drawing.Size(75, 23); + this.sendButton.TabIndex = 1; + this.sendButton.Text = "Send"; + this.sendButton.UseVisualStyleBackColor = true; + this.sendButton.Click += new System.EventHandler(this.sendButton_Click); + // + // exitButton + // + this.exitButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.exitButton.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.exitButton.Location = new System.Drawing.Point(548, 412); + this.exitButton.Name = "exitButton"; + this.exitButton.Size = new System.Drawing.Size(75, 23); + this.exitButton.TabIndex = 2; + this.exitButton.Text = "Exit"; + this.exitButton.UseVisualStyleBackColor = true; + // + // commentTextBox + // + this.commentTextBox.AcceptsReturn = true; + this.commentTextBox.BorderStyle = System.Windows.Forms.BorderStyle.None; + this.commentTextBox.Dock = System.Windows.Forms.DockStyle.Fill; + this.commentTextBox.Location = new System.Drawing.Point(4, 4); + this.commentTextBox.Multiline = true; + this.commentTextBox.Name = "commentTextBox"; + this.commentTextBox.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; + this.commentTextBox.Size = new System.Drawing.Size(604, 77); + this.commentTextBox.TabIndex = 0; + // + // titleLabel + // + this.titleLabel.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.titleLabel.BackColor = System.Drawing.SystemColors.Window; + this.titleLabel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.titleLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.titleLabel.Location = new System.Drawing.Point(-1, -1); + this.titleLabel.Name = "titleLabel"; + this.titleLabel.Padding = new System.Windows.Forms.Padding(10); + this.titleLabel.Size = new System.Drawing.Size(637, 52); + this.titleLabel.TabIndex = 4; + this.titleLabel.Text = "Open Hardware Monitor has encountered a problem and needs to close. We are sorry " + + "for the inconvenience."; + // + // label3 + // + this.label3.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.label3.AutoEllipsis = true; + this.label3.AutoSize = true; + this.label3.Location = new System.Drawing.Point(9, 63); + this.label3.Margin = new System.Windows.Forms.Padding(3, 12, 3, 8); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(571, 13); + this.label3.TabIndex = 5; + this.label3.Text = "To help diagnose and fix the problem, you can send a crash report. The following " + + "report has been created automatically."; + // + // label1 + // + this.label1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.label1.AutoEllipsis = true; + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(9, 290); + this.label1.Margin = new System.Windows.Forms.Padding(3, 12, 3, 8); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(233, 13); + this.label1.TabIndex = 6; + this.label1.Text = "You can add additional information to the report."; + // + // commentPanel + // + this.commentPanel.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.commentPanel.BackColor = System.Drawing.SystemColors.Window; + this.commentPanel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.commentPanel.Controls.Add(this.commentTextBox); + this.commentPanel.Location = new System.Drawing.Point(12, 314); + this.commentPanel.Margin = new System.Windows.Forms.Padding(3, 3, 3, 8); + this.commentPanel.Name = "commentPanel"; + this.commentPanel.Padding = new System.Windows.Forms.Padding(4, 4, 1, 4); + this.commentPanel.Size = new System.Drawing.Size(611, 87); + this.commentPanel.TabIndex = 7; + // + // reportPanel + // + this.reportPanel.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.reportPanel.BackColor = System.Drawing.SystemColors.Window; + this.reportPanel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.reportPanel.Controls.Add(this.reportTextBox); + this.reportPanel.Controls.Add(this.textBox1); + this.reportPanel.Location = new System.Drawing.Point(12, 87); + this.reportPanel.Name = "reportPanel"; + this.reportPanel.Padding = new System.Windows.Forms.Padding(4, 4, 1, 4); + this.reportPanel.Size = new System.Drawing.Size(611, 188); + this.reportPanel.TabIndex = 8; + // + // reportTextBox + // + this.reportTextBox.BackColor = System.Drawing.SystemColors.Window; + this.reportTextBox.BorderStyle = System.Windows.Forms.BorderStyle.None; + this.reportTextBox.Dock = System.Windows.Forms.DockStyle.Fill; + this.reportTextBox.Location = new System.Drawing.Point(4, 4); + this.reportTextBox.Multiline = true; + this.reportTextBox.Name = "reportTextBox"; + this.reportTextBox.ReadOnly = true; + this.reportTextBox.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; + this.reportTextBox.Size = new System.Drawing.Size(604, 178); + this.reportTextBox.TabIndex = 9; + this.reportTextBox.TabStop = false; + // + // textBox1 + // + this.textBox1.BorderStyle = System.Windows.Forms.BorderStyle.None; + this.textBox1.Dock = System.Windows.Forms.DockStyle.Fill; + this.textBox1.Location = new System.Drawing.Point(4, 4); + this.textBox1.Multiline = true; + this.textBox1.Name = "textBox1"; + this.textBox1.Size = new System.Drawing.Size(604, 178); + this.textBox1.TabIndex = 2; + // + // CrashReportForm + // + this.AcceptButton = this.sendButton; + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.CancelButton = this.exitButton; + this.ClientSize = new System.Drawing.Size(635, 447); + this.ControlBox = false; + this.Controls.Add(this.reportPanel); + this.Controls.Add(this.commentPanel); + this.Controls.Add(this.label1); + this.Controls.Add(this.label3); + this.Controls.Add(this.titleLabel); + this.Controls.Add(this.exitButton); + this.Controls.Add(this.sendButton); + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "CrashReportForm"; + this.ShowIcon = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + this.Text = "Open Hardware Monitor"; + this.commentPanel.ResumeLayout(false); + this.commentPanel.PerformLayout(); + this.reportPanel.ResumeLayout(false); + this.reportPanel.PerformLayout(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Button sendButton; + private System.Windows.Forms.Button exitButton; + private System.Windows.Forms.TextBox commentTextBox; + private System.Windows.Forms.Label titleLabel; + private System.Windows.Forms.Label label3; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.Panel commentPanel; + private System.Windows.Forms.Panel reportPanel; + private System.Windows.Forms.TextBox reportTextBox; + private System.Windows.Forms.TextBox textBox1; + } +} \ No newline at end of file diff -r ec4ccaa1210d -r b4f0f206173d GUI/CrashReportForm.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/GUI/CrashReportForm.cs Fri Apr 02 16:05:07 2010 +0000 @@ -0,0 +1,107 @@ +/* + + Version: MPL 1.1/GPL 2.0/LGPL 2.1 + + The contents of this file are subject to the Mozilla Public License Version + 1.1 (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.mozilla.org/MPL/ + + Software distributed under the License is distributed on an "AS IS" basis, + WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + for the specific language governing rights and limitations under the License. + + The Original Code is the Open Hardware Monitor code. + + The Initial Developer of the Original Code is + Michael Möller . + Portions created by the Initial Developer are Copyright (C) 2009-2010 + the Initial Developer. All Rights Reserved. + + Contributor(s): + + Alternatively, the contents of this file may be used under the terms of + either the GNU General Public License Version 2 or later (the "GPL"), or + the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + in which case the provisions of the GPL or the LGPL are applicable instead + of those above. If you wish to allow use of your version of this file only + under the terms of either the GPL or the LGPL, and not to allow others to + use your version of this file under the terms of the MPL, indicate your + decision by deleting the provisions above and replace them with the notice + and other provisions required by the GPL or the LGPL. If you do not delete + the provisions above, a recipient may use your version of this file under + the terms of any one of the MPL, the GPL or the LGPL. + +*/ + +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.IO; +using System.Net; +using System.Text; +using System.Web; +using System.Windows.Forms; + +namespace OpenHardwareMonitor.GUI { + public partial class CrashReportForm : Form { + + private Exception exception; + + public CrashReportForm() { + InitializeComponent(); + } + + public Exception Exception { + get { return exception; } + set { + exception = value; + StringBuilder s = new StringBuilder(); + Version version = typeof(CrashReportForm).Assembly.GetName().Version; + s.Append("Version: "); s.AppendLine(version.ToString()); + s.AppendLine(); + s.AppendLine(exception.ToString()); + s.AppendLine(); + if (exception.InnerException != null) { + s.AppendLine(exception.InnerException.ToString()); + s.AppendLine(); + } + reportTextBox.Text = s.ToString(); + } + } + + private void sendButton_Click(object sender, EventArgs e) { + Version version = typeof(CrashReportForm).Assembly.GetName().Version; + WebRequest request = WebRequest.Create( + "http://openhardwaremonitor.org/report.php"); + request.Method = "POST"; + request.Timeout = 3000; + request.ContentType = "application/x-www-form-urlencoded"; + + string report = + "version=" + HttpUtility.UrlEncode(version.ToString()) + "&" + + "report=" + HttpUtility.UrlEncode(reportTextBox.Text + + commentTextBox.Text); + byte[] byteArray = Encoding.UTF8.GetBytes(report); + request.ContentLength = byteArray.Length; + + Stream dataStream = request.GetRequestStream(); + dataStream.Write(byteArray, 0, byteArray.Length); + dataStream.Close(); + try { + WebResponse response = request.GetResponse(); + dataStream = response.GetResponseStream(); + StreamReader reader = new StreamReader(dataStream); + string responseFromServer = reader.ReadToEnd(); + reader.Close(); + dataStream.Close(); + response.Close(); + } catch (WebException) { + } + Close(); + } + } +} diff -r ec4ccaa1210d -r b4f0f206173d GUI/CrashReportForm.resx --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/GUI/CrashReportForm.resx Fri Apr 02 16:05:07 2010 +0000 @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff -r ec4ccaa1210d -r b4f0f206173d GUI/MainForm.Designer.cs --- a/GUI/MainForm.Designer.cs Sat Mar 27 19:55:09 2010 +0000 +++ b/GUI/MainForm.Designer.cs Fri Apr 02 16:05:07 2010 +0000 @@ -110,6 +110,7 @@ this.exitToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); this.sensorContextMenuStrip = new System.Windows.Forms.ContextMenuStrip(this.components); this.saveFileDialog = new System.Windows.Forms.SaveFileDialog(); + this.timer = new System.Windows.Forms.Timer(this.components); this.columnsContextMenuStrip.SuspendLayout(); this.menuStrip.SuspendLayout(); this.splitContainer.Panel1.SuspendLayout(); @@ -314,14 +315,14 @@ // saveReportToolStripMenuItem // this.saveReportToolStripMenuItem.Name = "saveReportToolStripMenuItem"; - this.saveReportToolStripMenuItem.Size = new System.Drawing.Size(152, 22); + this.saveReportToolStripMenuItem.Size = new System.Drawing.Size(145, 22); this.saveReportToolStripMenuItem.Text = "Save Report..."; this.saveReportToolStripMenuItem.Click += new System.EventHandler(this.saveReportToolStripMenuItem_Click); // // exitToolStripMenuItem // this.exitToolStripMenuItem.Name = "exitToolStripMenuItem"; - this.exitToolStripMenuItem.Size = new System.Drawing.Size(152, 22); + this.exitToolStripMenuItem.Size = new System.Drawing.Size(145, 22); this.exitToolStripMenuItem.Text = "Exit"; this.exitToolStripMenuItem.Click += new System.EventHandler(this.exitToolStripMenuItem_Click); // @@ -558,6 +559,11 @@ this.saveFileDialog.RestoreDirectory = true; this.saveFileDialog.Title = "Save Report As"; // + // timer + // + this.timer.Interval = 1000; + this.timer.Tick += new System.EventHandler(this.timer_Tick); + // // MainForm // this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); @@ -634,6 +640,7 @@ private System.Windows.Forms.ToolStripMenuItem flowsMenuItem; private System.Windows.Forms.ToolStripMenuItem startupMenuItem; private System.Windows.Forms.SaveFileDialog saveFileDialog; + private System.Windows.Forms.Timer timer; } } diff -r ec4ccaa1210d -r b4f0f206173d GUI/MainForm.cs --- a/GUI/MainForm.cs Sat Mar 27 19:55:09 2010 +0000 +++ b/GUI/MainForm.cs Fri Apr 02 16:05:07 2010 +0000 @@ -113,9 +113,10 @@ computer.HardwareAdded += new HardwareEventHandler(HardwareAdded); computer.HardwareRemoved += new HardwareEventHandler(HardwareRemoved); - computer.Updated += new UpdateEventHandler(Updated); computer.Open(); + timer.Enabled = true; + plotColorPalette = new Color[14]; plotColorPalette[0] = Color.Blue; plotColorPalette[1] = Color.OrangeRed; @@ -239,7 +240,8 @@ Close(); } - private void Updated() { + private void timer_Tick(object sender, EventArgs e) { + computer.Update(); treeView.Invalidate(); plotPanel.Invalidate(); sensorSystemTray.Redraw(); @@ -269,7 +271,9 @@ Config.Set("mainForm.Width", Width); Config.Set("mainForm.Height", Height); } - + + timer.Enabled = false; + sensorSystemTray.Dispose(); notifyIcon.Dispose(); computer.Close(); diff -r ec4ccaa1210d -r b4f0f206173d GUI/MainForm.resx --- a/GUI/MainForm.resx Sat Mar 27 19:55:09 2010 +0000 +++ b/GUI/MainForm.resx Fri Apr 02 16:05:07 2010 +0000 @@ -132,6 +132,9 @@ 690, 17 + + 819, 17 + 55 diff -r ec4ccaa1210d -r b4f0f206173d GUI/ParameterForm.Designer.cs --- a/GUI/ParameterForm.Designer.cs Sat Mar 27 19:55:09 2010 +0000 +++ b/GUI/ParameterForm.Designer.cs Fri Apr 02 16:05:07 2010 +0000 @@ -1,4 +1,41 @@ -namespace OpenHardwareMonitor.GUI { +/* + + Version: MPL 1.1/GPL 2.0/LGPL 2.1 + + The contents of this file are subject to the Mozilla Public License Version + 1.1 (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.mozilla.org/MPL/ + + Software distributed under the License is distributed on an "AS IS" basis, + WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + for the specific language governing rights and limitations under the License. + + The Original Code is the Open Hardware Monitor code. + + The Initial Developer of the Original Code is + Michael Möller . + Portions created by the Initial Developer are Copyright (C) 2009-2010 + the Initial Developer. All Rights Reserved. + + Contributor(s): + + Alternatively, the contents of this file may be used under the terms of + either the GNU General Public License Version 2 or later (the "GPL"), or + the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + in which case the provisions of the GPL or the LGPL are applicable instead + of those above. If you wish to allow use of your version of this file only + under the terms of either the GPL or the LGPL, and not to allow others to + use your version of this file under the terms of the MPL, indicate your + decision by deleting the provisions above and replace them with the notice + and other provisions required by the GPL or the LGPL. If you do not delete + the provisions above, a recipient may use your version of this file under + the terms of any one of the MPL, the GPL or the LGPL. + +*/ + +namespace OpenHardwareMonitor.GUI { partial class ParameterForm { /// /// Required designer variable. @@ -160,6 +197,8 @@ this.Controls.Add(this.captionLabel); this.Controls.Add(this.cancelButton); this.Controls.Add(this.okButton); + this.MaximizeBox = false; + this.MinimizeBox = false; this.Name = "ParameterForm"; this.ShowIcon = false; this.ShowInTaskbar = false; diff -r ec4ccaa1210d -r b4f0f206173d GUI/ParameterForm.cs --- a/GUI/ParameterForm.cs Sat Mar 27 19:55:09 2010 +0000 +++ b/GUI/ParameterForm.cs Fri Apr 02 16:05:07 2010 +0000 @@ -1,4 +1,41 @@ -using System; +/* + + Version: MPL 1.1/GPL 2.0/LGPL 2.1 + + The contents of this file are subject to the Mozilla Public License Version + 1.1 (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.mozilla.org/MPL/ + + Software distributed under the License is distributed on an "AS IS" basis, + WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + for the specific language governing rights and limitations under the License. + + The Original Code is the Open Hardware Monitor code. + + The Initial Developer of the Original Code is + Michael Möller . + Portions created by the Initial Developer are Copyright (C) 2009-2010 + the Initial Developer. All Rights Reserved. + + Contributor(s): + + Alternatively, the contents of this file may be used under the terms of + either the GNU General Public License Version 2 or later (the "GPL"), or + the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + in which case the provisions of the GPL or the LGPL are applicable instead + of those above. If you wish to allow use of your version of this file only + under the terms of either the GPL or the LGPL, and not to allow others to + use your version of this file under the terms of the MPL, indicate your + decision by deleting the provisions above and replace them with the notice + and other provisions required by the GPL or the LGPL. If you do not delete + the provisions above, a recipient may use your version of this file under + the terms of any one of the MPL, the GPL or the LGPL. + +*/ + +using System; using System.Collections.Generic; using System.ComponentModel; using System.Text; diff -r ec4ccaa1210d -r b4f0f206173d GUI/SensorNotifyIcon.cs --- a/GUI/SensorNotifyIcon.cs Sat Mar 27 19:55:09 2010 +0000 +++ b/GUI/SensorNotifyIcon.cs Fri Apr 02 16:05:07 2010 +0000 @@ -191,8 +191,12 @@ return IconFactory.Create(bytes, 16, 16, PixelFormat.Format32bppArgb); } - private Icon CreateLoadIcon() { - graphics.Clear(Color.Transparent); + private Icon CreateLoadIcon() { + try { + graphics.Clear(Color.Transparent); + } catch (ArgumentException) { + graphics.Clear(Color.Black); + } graphics.FillRectangle(darkBrush, 0.5f, -0.5f, 14, 16); float y = 0.16f * (100 - sensor.Value.Value); graphics.FillRectangle(brush, 0.5f, -0.5f + y, 14, 16 - y); diff -r ec4ccaa1210d -r b4f0f206173d Hardware/CPU/IntelCPU.cs --- a/Hardware/CPU/IntelCPU.cs Sat Mar 27 19:55:09 2010 +0000 +++ b/Hardware/CPU/IntelCPU.cs Fri Apr 02 16:05:07 2010 +0000 @@ -356,8 +356,7 @@ (timeEnd - timeBegin); } - public void Update() { - + public void Update() { for (int i = 0; i < coreTemperatures.Length; i++) { uint eax, edx; if (WinRing0.RdmsrTx( diff -r ec4ccaa1210d -r b4f0f206173d Hardware/Computer.cs --- a/Hardware/Computer.cs Sat Mar 27 19:55:09 2010 +0000 +++ b/Hardware/Computer.cs Fri Apr 02 16:05:07 2010 +0000 @@ -46,8 +46,6 @@ public class Computer : IComputer { - private Timer timer; - private List groups = new List(); private bool open = false; @@ -91,19 +89,6 @@ Add(new HDD.HDDGroup()); open = true; - - timer = new Timer( - delegate(Object stateInfo) { - #if !DEBUG - try { - #endif - Update(); - #if !DEBUG - } catch (Exception exception) { - Utilities.CrashReport.Save(exception); - } - #endif - }, null, 1000, 1000); } private void SubHardwareUpdate(IHardware hardware) { @@ -113,14 +98,12 @@ } } - private void Update() { + public void Update() { foreach (IGroup group in groups) foreach (IHardware hardware in group.Hardware) { hardware.Update(); SubHardwareUpdate(hardware); } - if (Updated != null) - Updated(); } public bool HDDEnabled { @@ -226,9 +209,6 @@ } public void Close() { - timer.Dispose(); - timer = null; - if (!open) return; @@ -239,9 +219,7 @@ open = false; } - public event UpdateEventHandler Updated; public event HardwareEventHandler HardwareAdded; public event HardwareEventHandler HardwareRemoved; - } } diff -r ec4ccaa1210d -r b4f0f206173d Hardware/IComputer.cs --- a/Hardware/IComputer.cs Sat Mar 27 19:55:09 2010 +0000 +++ b/Hardware/IComputer.cs Fri Apr 02 16:05:07 2010 +0000 @@ -40,7 +40,6 @@ namespace OpenHardwareMonitor.Hardware { - public delegate void UpdateEventHandler(); public delegate void HardwareEventHandler(IHardware hardware); public interface IComputer { @@ -51,7 +50,6 @@ string GetReport(); - event UpdateEventHandler Updated; event HardwareEventHandler HardwareAdded; event HardwareEventHandler HardwareRemoved; } diff -r ec4ccaa1210d -r b4f0f206173d Hardware/TBalancer/TBalancer.cs --- a/Hardware/TBalancer/TBalancer.cs Sat Mar 27 19:55:09 2010 +0000 +++ b/Hardware/TBalancer/TBalancer.cs Fri Apr 02 16:05:07 2010 +0000 @@ -221,7 +221,7 @@ } else { DeactivateSensor(sensorhubFlows[i]); } - + for (int i = 0; i < fans.Length; i++) { float maxRPM = 11.5f * ((data[149 + 2 * i] << 8) | data[148 + 2 * i]); @@ -325,7 +325,7 @@ } catch (Exception) { } } - public void Update() { + public void Update() { try { while (serialPort.IsOpen && serialPort.BytesToRead >= 285) ReadData(); @@ -337,7 +337,7 @@ } catch (InvalidOperationException) { foreach (Sensor sensor in active) sensor.Value = null; - } + } } public void Close() { diff -r ec4ccaa1210d -r b4f0f206173d OpenHardwareMonitor.csproj --- a/OpenHardwareMonitor.csproj Sat Mar 27 19:55:09 2010 +0000 +++ b/OpenHardwareMonitor.csproj Fri Apr 02 16:05:07 2010 +0000 @@ -54,10 +54,17 @@ + + + Form + + + CrashReportForm.cs + Form @@ -99,7 +106,6 @@ - @@ -179,6 +185,9 @@ + + CrashReportForm.cs + diff -r ec4ccaa1210d -r b4f0f206173d Program.cs --- a/Program.cs Sat Mar 27 19:55:09 2010 +0000 +++ b/Program.cs Fri Apr 02 16:05:07 2010 +0000 @@ -36,36 +36,39 @@ */ using System; +using System.IO; +using System.Text; +using System.Threading; using System.Windows.Forms; - +using OpenHardwareMonitor.GUI; namespace OpenHardwareMonitor { - static class Program { - /// - /// The main entry point for the application. - /// + public static class Program { + [STAThread] - static void Main() { + public static void Main() { #if !DEBUG - try { + AppDomain.CurrentDomain.UnhandledException += + new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); #endif - Application.EnableVisualStyles(); - Application.SetCompatibleTextRenderingDefault(false); - using (GUI.MainForm form = new GUI.MainForm()) { - form.FormClosed += delegate(Object sender, FormClosedEventArgs e) { - Application.Exit(); - }; - Application.Run(); - } - - #if !DEBUG - } catch (Exception e) { - Utilities.CrashReport.Save(e); + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + using (GUI.MainForm form = new GUI.MainForm()) { + form.FormClosed += delegate(Object sender, FormClosedEventArgs e) { + Application.Exit(); + }; + Application.Run(); } - #endif } - + public static void CurrentDomain_UnhandledException(object sender, + UnhandledExceptionEventArgs args) + { + CrashReportForm form = new CrashReportForm(); + form.Exception = (Exception)args.ExceptionObject; + form.ShowDialog(); + Environment.Exit(0); + } } } diff -r ec4ccaa1210d -r b4f0f206173d Utilities/CrashReport.cs --- a/Utilities/CrashReport.cs Sat Mar 27 19:55:09 2010 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,58 +0,0 @@ -/* - - Version: MPL 1.1/GPL 2.0/LGPL 2.1 - - The contents of this file are subject to the Mozilla Public License Version - 1.1 (the "License"); you may not use this file except in compliance with - the License. You may obtain a copy of the License at - - http://www.mozilla.org/MPL/ - - Software distributed under the License is distributed on an "AS IS" basis, - WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - for the specific language governing rights and limitations under the License. - - The Original Code is the Open Hardware Monitor code. - - The Initial Developer of the Original Code is - Michael Möller . - Portions created by the Initial Developer are Copyright (C) 2009-2010 - the Initial Developer. All Rights Reserved. - - Contributor(s): - - Alternatively, the contents of this file may be used under the terms of - either the GNU General Public License Version 2 or later (the "GPL"), or - the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - in which case the provisions of the GPL or the LGPL are applicable instead - of those above. If you wish to allow use of your version of this file only - under the terms of either the GPL or the LGPL, and not to allow others to - use your version of this file under the terms of the MPL, indicate your - decision by deleting the provisions above and replace them with the notice - and other provisions required by the GPL or the LGPL. If you do not delete - the provisions above, a recipient may use your version of this file under - the terms of any one of the MPL, the GPL or the LGPL. - -*/ - -using System; -using System.Collections.Generic; -using System.IO; -using System.Text; - -namespace OpenHardwareMonitor.Utilities { - public class CrashReport { - - public static void Save(Exception e) { - using (TextWriter w = - new StreamWriter("OpenHardwareMonitor.Crash.txt")) { - w.WriteLine(e.ToString()); - w.WriteLine(); - if (e.InnerException != null) { - w.WriteLine(e.InnerException.ToString()); - w.WriteLine(); - } - } - } - } -}