Skip to content

Commit

Permalink
Update version and cleanup comments
Browse files Browse the repository at this point in the history
  • Loading branch information
swvincent committed Feb 5, 2023
1 parent 7b563d9 commit cdc01c6
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 208 deletions.
21 changes: 2 additions & 19 deletions PcMeterSln/PcMeter/AboutForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics; //for Process
using System.Diagnostics;

namespace PcMeter
{
Expand All @@ -17,17 +17,12 @@ public AboutForm()
InitializeComponent();
}

/// <summary>
/// Load link and license text.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
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
Expand All @@ -54,23 +49,11 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
licenseTextBox.Text = LICENSE_TEXT;
}


/// <summary>
/// Close about form.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void okButton_Click(object sender, EventArgs e)
{
this.Close();
}


/// <summary>
/// Load website.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void pcMeterLinkLabel_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
Process.Start(e.Link.LinkData as string);
Expand Down
99 changes: 1 addition & 98 deletions PcMeterSln/PcMeter/CustomApplicationContext.cs
Original file line number Diff line number Diff line change
@@ -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: [email protected]
//
// 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;
Expand Down Expand Up @@ -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

Expand All @@ -93,12 +47,6 @@ public class CustomApplicationContext : ApplicationContext

#region Constructor and Init

/// <summary>
/// Default constructor
/// </summary>
/// <remarks>
/// This class should be created and passed into Application.Run( ... )
/// </remarks>
public CustomApplicationContext()
{
InitializeContext();
Expand All @@ -116,10 +64,6 @@ public CustomApplicationContext()
}
}


/// <summary>
/// Initialize Context
/// </summary>
private void InitializeContext()
{
components = new System.ComponentModel.Container();
Expand Down Expand Up @@ -166,17 +110,11 @@ private void InitializeContext()

#region Timer and Update Stats

/// <summary>
/// Calculate stats and send to COM port on tick
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void meterTimer_Tick(object sender, EventArgs e)
{
UpdateAndSentStats();
}


private void UpdateAndSentStats()
{
try
Expand Down Expand Up @@ -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;
Expand All @@ -307,10 +240,6 @@ private void settingsForm_Closed(object sender, EventArgs e)

#region Exit

/// <summary>
/// Dispose objects, etc.
/// </summary>
/// <param name="disposing"></param>
protected override void Dispose(bool disposing)
{
//Dispose things specific to this app
Expand All @@ -322,21 +251,11 @@ protected override void Dispose(bool disposing)
components.Dispose();
}


/// <summary>
/// When the exit menu item is clicked, make a call to terminate the ApplicationContext.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void exitItem_Click(object sender, EventArgs e)
{
ExitThread();
}


/// <summary>
/// If we are presently showing a form, clean it up.
/// </summary>
protected override void ExitThreadCore()
{
// before we exit, let forms clean themselves up.
Expand All @@ -350,11 +269,6 @@ protected override void ExitThreadCore()

#region Serial

/// <summary>
/// Connect/Disconnect COM port.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void connectMenuItem_Click(object sender, EventArgs e)
{
if (connectMenuItem.Checked)
Expand All @@ -363,18 +277,13 @@ private void connectMenuItem_Click(object sender, EventArgs e)
InitSerial();
}


/// <summary>
/// Refresh available options based on serial port status.
/// </summary>
private void RefreshMenuOptions()
{
bool portActive = meterPort != null && meterPort.IsOpen;
connectMenuItem.Checked = portActive;
settingsMenuItem.Enabled = !portActive;
}


/// <summary>
/// Initialize serial port and connect. Display error if any occur.
/// If program is minimized, then display brief message using balloon tip instead.
Expand Down Expand Up @@ -420,7 +329,6 @@ private bool InitSerial()
}
}


private bool DisposeSerial()
{
try
Expand Down Expand Up @@ -456,10 +364,6 @@ private bool DisposeSerial()

#region Counters Init/Dispose

/// <summary>
/// Initialize performance counters
/// </summary>
/// <returns></returns>
private bool InitCounters()
{
try
Expand All @@ -475,7 +379,6 @@ private bool InitCounters()
}
}


/// <summary>
/// Dispose counter objects
/// </summary>
Expand Down
4 changes: 2 additions & 2 deletions PcMeterSln/PcMeter/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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("")]
Expand All @@ -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")]
56 changes: 3 additions & 53 deletions PcMeterSln/PcMeter/SettingsForm.cs
Original file line number Diff line number Diff line change
@@ -1,60 +1,23 @@
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// 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: [email protected]
//
// 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;
using System.Drawing;
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
{
/// <summary>
/// Default Constructor
/// </summary>
public SettingsForm()
{
InitializeComponent();
}


private void SettingsForm_Load(object sender, EventArgs e)
{
//Load COM ports into combo box
Expand All @@ -78,23 +41,11 @@ private void SettingsForm_Load(object sender, EventArgs e)
}
}


/// <summary>
/// Close form without saving changes.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void cancelButton_Click(object sender, EventArgs e)
{
this.Close();
}


/// <summary>
/// Attempt to save changes and close form.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void okButton_Click(object sender, EventArgs e)
{
if (ValidateFormData())
Expand All @@ -105,7 +56,6 @@ private void okButton_Click(object sender, EventArgs e)
}
}


private bool ValidateFormData()
{
if (comPortComboBox.SelectedIndex != -1)
Expand Down
Loading

0 comments on commit cdc01c6

Please sign in to comment.