diff --git a/SuperGrate/Main.cs b/SuperGrate/Main.cs
index 8635983..2ed7e1c 100644
--- a/SuperGrate/Main.cs
+++ b/SuperGrate/Main.cs
@@ -31,6 +31,10 @@ public partial class Main : Form
{ ListSources.MigrationStore, ULColumnType.NTAccount },
{ ListSources.SourceComputer, ULColumnType.NTAccount }
};
+ ///
+ /// The main form entry point.
+ ///
+ /// A list of parameters to override XML settings.
public Main(string[] parameters)
{
MainParameters = parameters;
@@ -61,6 +65,9 @@ public Main(string[] parameters)
miConProperties.SetMenuItemIcon(Properties.Resources.user);
miConStart.SetMenuItemIcon(Properties.Resources.go);
}
+ ///
+ /// This event will fire when the main form has loaded.
+ ///
private void Main_Load(object sender, EventArgs e)
{
Config.LoadConfig(MainParameters);
@@ -69,18 +76,25 @@ private void Main_Load(object sender, EventArgs e)
UpdateFormRestrictions();
BindHelp(this);
}
+ ///
+ /// This method will loop through all child controls of a control and apply the Control_Hover event to the MouseEnter event.
+ ///
+ /// Parent control.
private void BindHelp(Control control)
{
foreach (Control childControl in control.Controls)
{
- childControl.MouseEnter += Control_Click;
+ childControl.MouseEnter += Control_Hover;
if(childControl.HasChildren)
{
BindHelp(childControl);
}
}
}
- private void Control_Click(object sender, EventArgs e)
+ ///
+ /// This event will fire whenever any control on the main form is hovered. And will show a help box if requested.
+ ///
+ private void Control_Hover(object sender, EventArgs e)
{
if (Cursor == Cursors.Help)
{
@@ -89,6 +103,9 @@ private void Control_Click(object sender, EventArgs e)
Help.ShowPopup(this, helpProvider.GetHelpString((Control)sender), mouse);
}
}
+ ///
+ /// This getter/setter will attempt to cancel a running task if set true.
+ ///
public static bool Canceled
{
get
@@ -106,6 +123,9 @@ public static bool Canceled
}
}
}
+ ///
+ /// This getter/setter will update various controls and variables whenever changed in regards to a running task.
+ ///
private RunningTask Running {
get {
return storeRunningTask;
@@ -161,6 +181,9 @@ private RunningTask Running {
}
}
}
+ ///
+ /// This event will fire whenever the btStartStop button is clicked, starting or stopping whatever task is queued to happen.
+ ///
private async void BtStartStop_Click(object sender, EventArgs e)
{
if (Running != RunningTask.None)
@@ -197,6 +220,9 @@ private async void BtStartStop_Click(object sender, EventArgs e)
Logger.Information("Done.");
}
}
+ ///
+ /// This event will fire whenever the btnListSource is clicked. This will refresh or re-list the listUsers control with users from the source computer.
+ ///
private async void BtnListSource_Click(object sender, EventArgs e)
{
Running = RunningTask.Unknown;
@@ -209,6 +235,9 @@ private async void BtnListSource_Click(object sender, EventArgs e)
CurrentListSource = ListSources.SourceComputer;
Running = RunningTask.None;
}
+ ///
+ /// This event will fire whenever the btnListStore is clicked. This will refresh or re-list the listUsers control with users from the store.
+ ///
private async void BtnListStore_Click(object sender, EventArgs e)
{
Running = RunningTask.Unknown;
@@ -221,6 +250,9 @@ private async void BtnListStore_Click(object sender, EventArgs e)
CurrentListSource = ListSources.MigrationStore;
Running = RunningTask.None;
}
+ ///
+ /// This event will fire if the logBox text box is double clicked, and will toggle VerboseMode (Which allows the logger class to output more).
+ ///
private void LogBox_DoubleClick(object sender, EventArgs e)
{
if(Logger.VerboseEnabled)
@@ -234,6 +266,9 @@ private void LogBox_DoubleClick(object sender, EventArgs e)
Logger.Information("Verbose mode enabled.");
}
}
+ ///
+ /// This method will enable or disable different controls on the main form depending on conditions in the form to prevent invalid inputs.
+ ///
private void UpdateFormRestrictions(object sender = null, EventArgs e = null)
{
if (listUsers.SelectedIndices.Count == 0 || (tbDestinationComputer.Text == "" && CurrentListSource == ListSources.MigrationStore))
@@ -263,6 +298,9 @@ private void UpdateFormRestrictions(object sender = null, EventArgs e = null)
btnListSource.Enabled = true;
}
}
+ ///
+ /// This event will fire whenever the tbSourceComputer text box receives new text, and will clear the users from the list, and call UpdateFormRestrictions().
+ ///
private void TbSourceComputer_TextChanged(object sender, EventArgs e)
{
SourceComputer = tbSourceComputer.Text;
@@ -272,11 +310,17 @@ private void TbSourceComputer_TextChanged(object sender, EventArgs e)
}
UpdateFormRestrictions();
}
+ ///
+ /// This event will fire when the tbDestinationComputer text box recieves new text, and will call the UpdateFormRestrictions() method.
+ ///
private void TbDestinationComputer_TextChanged(object sender, EventArgs e)
{
DestinationComputer = tbDestinationComputer.Text;
UpdateFormRestrictions();
}
+ ///
+ /// This event will fire when the btnDelete button is clicked, and will start the deletion process for the selected users.
+ ///
private async void BtnDelete_Click(object sender, EventArgs e)
{
int selectedCount = listUsers.SelectedItems.Count;
@@ -314,6 +358,9 @@ private async void BtnDelete_Click(object sender, EventArgs e)
Running = RunningTask.None;
}
}
+ ///
+ /// This event will fire when the tbSourceComputer text box recieves an enter key, then will simulate a click on the btnListSource button.
+ ///
private void TbSourceComputer_KeyDown(object sender, KeyEventArgs e)
{
if(e.KeyCode == Keys.Enter)
@@ -321,18 +368,30 @@ private void TbSourceComputer_KeyDown(object sender, KeyEventArgs e)
btnListSource.PerformClick();
}
}
+ ///
+ /// This event will fire when the btnBFillDest button is clicked, this will fill the ajacent text box with the current PC name.
+ ///
private void BtnAFillSrc_Click(object sender, EventArgs e)
{
tbSourceComputer.Text = Environment.MachineName;
}
+ ///
+ /// This event will fire when the btnAFillDest button is clicked, this will fill the ajacent text box with the current PC name.
+ ///
private void BtnAFillDest_Click(object sender, EventArgs e)
{
tbDestinationComputer.Text = Environment.MachineName;
}
+ ///
+ /// This event will fire if the miExitButton is clicked, and will attempt to close the main form.
+ ///
private void MiExitButton_Click(object sender, EventArgs e)
{
Close();
}
+ ///
+ /// This event will fire when the menu item miSaveLog is clicked, and will open the save log dialog window.
+ ///
private async void MiSaveLog_Click(object sender, EventArgs e)
{
dialogSaveLog.FileName =
@@ -344,6 +403,9 @@ private async void MiSaveLog_Click(object sender, EventArgs e)
await Logger.WriteLogToFile(dialogSaveLog.OpenFile());
}
}
+ ///
+ /// This event will fire when the main window is about to close, and will block the closure if a task is running, otherwise it will allow the window to close after writing a log if instrucuted.
+ ///
private async void Main_FormClosing(object sender, FormClosingEventArgs e)
{
if(++CloseAttempts >= 3) return;
@@ -377,18 +439,30 @@ private async void Main_FormClosing(object sender, FormClosingEventArgs e)
}
Logger.Warning("Super Grate is exiting. Attempt: " + CloseAttempts + "/3.");
}
+ ///
+ /// This event will fire when the miAbout menu item is clicked, and will open the about dialog box.
+ ///
private void MiAboutSG_Click(object sender, EventArgs e)
{
new About().ShowDialog();
}
+ ///
+ /// This event will fire when the miDocumentation menu item is clicked, and will open the docs page on github.
+ ///
private void MiDocumentation_Click(object sender, EventArgs e)
{
Process.Start("https://github.com/belowaverage-org/SuperGrate/wiki");
}
+ ///
+ /// This event will fire when the miIssues menu item is clicked, and will open the issues page on github.
+ ///
private void MiIssues_Click(object sender, EventArgs e)
{
Process.Start("https://github.com/belowaverage-org/SuperGrate/issues");
}
+ ///
+ /// This event fires when the tbSourceDestComputer text box recieves an enter key, this will simulate a click on the button btnListSource.
+ ///
private void tbSourceDestComputer_KeyDown(object sender, KeyEventArgs e)
{
if(e.KeyCode == Keys.Enter)
@@ -400,6 +474,9 @@ private void tbSourceDestComputer_KeyDown(object sender, KeyEventArgs e)
}
}
}
+ ///
+ /// This event will fire when the lbxUsers registers an enter key, this simulates a click on the button btnStartStop.
+ ///
private void lbxUsers_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)