From cdc01c67b452c1043b62a998f7b0234a2a65bbcf Mon Sep 17 00:00:00 2001 From: "Scott W. Vincent" Date: Sun, 5 Feb 2023 18:08:24 -0500 Subject: [PATCH] Update version and cleanup comments --- PcMeterSln/PcMeter/AboutForm.cs | 21 +--- .../PcMeter/CustomApplicationContext.cs | 99 +------------------ PcMeterSln/PcMeter/Properties/AssemblyInfo.cs | 4 +- PcMeterSln/PcMeter/SettingsForm.cs | 56 +---------- PcMeterSln/PcMeter/WinFormHelper.cs | 39 +------- 5 files changed, 11 insertions(+), 208 deletions(-) diff --git a/PcMeterSln/PcMeter/AboutForm.cs b/PcMeterSln/PcMeter/AboutForm.cs index 878c31e..6e9f6c5 100644 --- a/PcMeterSln/PcMeter/AboutForm.cs +++ b/PcMeterSln/PcMeter/AboutForm.cs @@ -6,7 +6,7 @@ using System.Linq; using System.Text; using System.Windows.Forms; -using System.Diagnostics; //for Process +using System.Diagnostics; namespace PcMeter { @@ -17,17 +17,12 @@ public AboutForm() InitializeComponent(); } - /// - /// Load link and license text. - /// - /// - /// private void AboutForm_Load(object sender, EventArgs e) { const string WEB_LINK = "http://www.swvincent.com/pcmeter"; const string LICENSE_TEXT = @"MIT License -Copyright (c) 2018 Scott W. Vincent +Copyright (c) 2018-2023 Scott W. Vincent Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ""Software""), to deal @@ -54,23 +49,11 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE licenseTextBox.Text = LICENSE_TEXT; } - - /// - /// Close about form. - /// - /// - /// private void okButton_Click(object sender, EventArgs e) { this.Close(); } - - /// - /// Load website. - /// - /// - /// private void pcMeterLinkLabel_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { Process.Start(e.Link.LinkData as string); diff --git a/PcMeterSln/PcMeter/CustomApplicationContext.cs b/PcMeterSln/PcMeter/CustomApplicationContext.cs index d0be854..aad9f57 100644 --- a/PcMeterSln/PcMeter/CustomApplicationContext.cs +++ b/PcMeterSln/PcMeter/CustomApplicationContext.cs @@ -1,48 +1,4 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// PcMeter CustomApplicationContext.cs -// -// Display CPU load% and Committed Memory% and send to PC meter device via serial port. -// -// PC Meter application written by Scott W. Vincent. -// -// http://www.swvincent.com/pcmeter -// Visit the webpage for more information including info on the arduino-based meter I built that is driven by this program. -// -// Email: scott@swvincent.com -// -// Revised 5/20/2015 - Switched from using PerformanceCounter("Memory", "% Committed Bytes In Use", ""); for memory (which is actually page file usage) -// to using Antonio Bakula's GetPerformanceInfo code. Thanks to mnedix for bringing the issue to my attention. You can see what he -// did using my code at http://www.instructables.com/id/Nixie-PC-MeterMonitor/. -// -// Revised 2/28/2018 - v2.0! Big rewrite so the program runs properly as a tray application. When I originally wrote this app I had no experience with -// writing this type of application and made several beginner's mistakes that caused errors on shutdown/resume/etc. Many thanks to -// Michael Sorens for his excellent article and code that shows the correct way of doing it. You can find it here: -// https://www.red-gate.com/simple-talk/dotnet/.net-framework/creating-tray-applications-in-.net-a-practical-guide/ -// -// MIT License -// -// Copyright (c) 2018 Scott W. Vincent -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. -// -////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -80,8 +36,6 @@ public class CustomApplicationContext : ApplicationContext //Menu private ToolStripLabel cpuLabel; //For displaying CPU% private ToolStripLabel memLabel; //For displaying Memory% - //private ToolStripTextBox cpuTextBox; //CPU Text box, show CPU% - //private ToolStripTextBox memTextBox; //Memory text box, show Memory% private ToolStripMenuItem connectMenuItem; //Menu item to connect/disconnect com port private ToolStripMenuItem settingsMenuItem; //Menu item to open settings form @@ -93,12 +47,6 @@ public class CustomApplicationContext : ApplicationContext #region Constructor and Init - /// - /// Default constructor - /// - /// - /// This class should be created and passed into Application.Run( ... ) - /// public CustomApplicationContext() { InitializeContext(); @@ -116,10 +64,6 @@ public CustomApplicationContext() } } - - /// - /// Initialize Context - /// private void InitializeContext() { components = new System.ComponentModel.Container(); @@ -166,17 +110,11 @@ private void InitializeContext() #region Timer and Update Stats - /// - /// Calculate stats and send to COM port on tick - /// - /// - /// private void meterTimer_Tick(object sender, EventArgs e) { UpdateAndSentStats(); } - private void UpdateAndSentStats() { try @@ -277,27 +215,22 @@ private void notifyIcon_MouseUp(object sender, MouseEventArgs e) } } - - // attach to context menu items private void showAboutItem_Click(object sender, EventArgs e) { ShowAboutForm(); } - private void settingsMenuItem_Click(object sender, EventArgs e) { ShowSettingsForm(); } - // null out the forms so we know to create a new one. private void aboutForm_Closed(object sender, EventArgs e) { aboutForm = null; } - private void settingsForm_Closed(object sender, EventArgs e) { settingsForm = null; @@ -307,10 +240,6 @@ private void settingsForm_Closed(object sender, EventArgs e) #region Exit - /// - /// Dispose objects, etc. - /// - /// protected override void Dispose(bool disposing) { //Dispose things specific to this app @@ -322,21 +251,11 @@ protected override void Dispose(bool disposing) components.Dispose(); } - - /// - /// When the exit menu item is clicked, make a call to terminate the ApplicationContext. - /// - /// - /// private void exitItem_Click(object sender, EventArgs e) { ExitThread(); } - - /// - /// If we are presently showing a form, clean it up. - /// protected override void ExitThreadCore() { // before we exit, let forms clean themselves up. @@ -350,11 +269,6 @@ protected override void ExitThreadCore() #region Serial - /// - /// Connect/Disconnect COM port. - /// - /// - /// private void connectMenuItem_Click(object sender, EventArgs e) { if (connectMenuItem.Checked) @@ -363,10 +277,6 @@ private void connectMenuItem_Click(object sender, EventArgs e) InitSerial(); } - - /// - /// Refresh available options based on serial port status. - /// private void RefreshMenuOptions() { bool portActive = meterPort != null && meterPort.IsOpen; @@ -374,7 +284,6 @@ private void RefreshMenuOptions() settingsMenuItem.Enabled = !portActive; } - /// /// Initialize serial port and connect. Display error if any occur. /// If program is minimized, then display brief message using balloon tip instead. @@ -420,7 +329,6 @@ private bool InitSerial() } } - private bool DisposeSerial() { try @@ -456,10 +364,6 @@ private bool DisposeSerial() #region Counters Init/Dispose - /// - /// Initialize performance counters - /// - /// private bool InitCounters() { try @@ -475,7 +379,6 @@ private bool InitCounters() } } - /// /// Dispose counter objects /// diff --git a/PcMeterSln/PcMeter/Properties/AssemblyInfo.cs b/PcMeterSln/PcMeter/Properties/AssemblyInfo.cs index 722b6ec..bd08607 100644 --- a/PcMeterSln/PcMeter/Properties/AssemblyInfo.cs +++ b/PcMeterSln/PcMeter/Properties/AssemblyInfo.cs @@ -8,7 +8,7 @@ [assembly: AssemblyTitle("PC Meter")] [assembly: AssemblyDescription("Small program that drives the PC Meter device")] [assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("Scott W. Vincent (www.lungStruck.com)")] +[assembly: AssemblyCompany("Scott W. Vincent")] [assembly: AssemblyProduct("PcMeter")] [assembly: AssemblyCopyright("CC0 1.0 Universal (CC0 1.0)")] [assembly: AssemblyTrademark("")] @@ -32,5 +32,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyVersion("2.1.0.0")] [assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/PcMeterSln/PcMeter/SettingsForm.cs b/PcMeterSln/PcMeter/SettingsForm.cs index 69e4bd9..292721d 100644 --- a/PcMeterSln/PcMeter/SettingsForm.cs +++ b/PcMeterSln/PcMeter/SettingsForm.cs @@ -1,37 +1,4 @@ -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// PcMeter SettingsForm.cs -// -// PC Meter application written by Scott W. Vincent. -// -// http://www.swvincent.com/pcmeter -// Visit the webpage for more information including info on the arduino-based meter I built that is driven by this program. -// -// Email: scott@swvincent.com -// -// MIT License -// -// Copyright (c) 2018 Scott W. Vincent -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. -// -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -using System; +using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; @@ -39,22 +6,18 @@ using System.Linq; using System.Text; using System.Windows.Forms; -using PcMeter.Properties; //Settings load/save -using System.IO.Ports; //For serial port list +using PcMeter.Properties; +using System.IO.Ports; namespace PcMeter { public partial class SettingsForm : Form { - /// - /// Default Constructor - /// public SettingsForm() { InitializeComponent(); } - private void SettingsForm_Load(object sender, EventArgs e) { //Load COM ports into combo box @@ -78,23 +41,11 @@ private void SettingsForm_Load(object sender, EventArgs e) } } - - /// - /// Close form without saving changes. - /// - /// - /// private void cancelButton_Click(object sender, EventArgs e) { this.Close(); } - - /// - /// Attempt to save changes and close form. - /// - /// - /// private void okButton_Click(object sender, EventArgs e) { if (ValidateFormData()) @@ -105,7 +56,6 @@ private void okButton_Click(object sender, EventArgs e) } } - private bool ValidateFormData() { if (comPortComboBox.SelectedIndex != -1) diff --git a/PcMeterSln/PcMeter/WinFormHelper.cs b/PcMeterSln/PcMeter/WinFormHelper.cs index 17d4a9d..46c4ac9 100644 --- a/PcMeterSln/PcMeter/WinFormHelper.cs +++ b/PcMeterSln/PcMeter/WinFormHelper.cs @@ -1,41 +1,8 @@ -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// PcMeter WinFormHelper.cs -// -// Contains helper code needed by PcMeter. -// -// PC Meter application -// -// http://www.swvincent.com/pcmeter -// Visit the webpage for more information including info on the arduino-based meter I built that is driven by this program. -// -// MIT License -// -// Copyright (c) 2018 Scott W. Vincent -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. -///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Text; -using System.Windows.Forms; //For messagebox +using System.Windows.Forms; namespace PcMeter { @@ -72,4 +39,4 @@ public static void DisplayErrorMessage(string processDescription, Exception caug #endregion Error Handling } -} +} \ No newline at end of file