Skip to content

Commit

Permalink
0.3.0-RC.1 - Expand options & info
Browse files Browse the repository at this point in the history
  • Loading branch information
AlphaDelta committed May 31, 2023
1 parent 04f282d commit 0ca8976
Show file tree
Hide file tree
Showing 5 changed files with 532 additions and 162 deletions.
230 changes: 140 additions & 90 deletions WizTreeCompare/FormMain.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

53 changes: 49 additions & 4 deletions WizTreeCompare/FormMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,19 @@ public FormMain()

txtPast.DragDrop += Txt_DragDrop;
txtFuture.DragDrop += Txt_DragDrop;

ToolTip tipNegatives = new ToolTip();
tipNegatives.InitialDelay = 1000;
tipNegatives.SetToolTip(chkIncludeNegatives, "Not currently compatiable with WizTree");

#if DEBUG
chkDry.Checked = true;
#endif
}

private void Txt_DragEnter(object sender, DragEventArgs e)
{
if(e.Data.GetDataPresent(DataFormats.FileDrop))
if (e.Data.GetDataPresent(DataFormats.FileDrop))
{
if (((string[])e.Data.GetData(DataFormats.FileDrop)).Length == 1)
{
Expand Down Expand Up @@ -60,11 +68,40 @@ private void SelectFile(TextBox tb)
}
}

CancellationTokenSource token = new CancellationTokenSource();
Task tcompare = Task.CompletedTask;
private void btnCompare_Click(object sender, EventArgs e)
{
if (!tcompare.IsCompleted)
{
token.Cancel();
return;
}

string output = null;
tcompare = new Task(() =>
{
WTComparer comparer = new WTComparer(txtPast.Text, txtFuture.Text)
{
IncludeNegatives = chkIncludeNegatives.Checked,
IncludeUnchanged = chkIncludeUnchanged.Checked,
Dry = chkDry.Checked,
CancellationToken = token.Token
};
comparer.CompareAndSave(output);

this.Invoke(() =>
{
btnCompare.Text = "Compare...";
btnCompare.Enabled = true;

using(SaveFileDialog sfd = new SaveFileDialog())
token.Dispose();
token = new CancellationTokenSource();
});
});

/* Save file dialog */
using (SaveFileDialog sfd = new SaveFileDialog())
{
sfd.FileName = $"WizTreeCompare_{DateTime.Now:yyyyMMddHHmmss}.csv";
sfd.Filter = "CSV File (*.csv)|*.csv";
Expand All @@ -75,8 +112,16 @@ private void btnCompare_Click(object sender, EventArgs e)
output = sfd.FileName;
}

WTComparer comparer = new WTComparer(txtPast.Text, txtFuture.Text);
comparer.CompareAndSave(output);
btnCompare.Enabled = false;
btnCompare.Text = "Cancel";
Task.Run(async () =>
{
await Task.Delay(1000);
this.Invoke(() => { btnCompare.Enabled = true; });
});

/* Compare */
tcompare.Start();
}
}
}
Loading

0 comments on commit 0ca8976

Please sign in to comment.