Skip to content

Commit

Permalink
New Release Notification in GUI
Browse files Browse the repository at this point in the history
The GUI now shows some info when there's a new release on github, including a button that links directly to the release
  • Loading branch information
modery committed Aug 16, 2022
1 parent fcf53cf commit f5d6386
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 11 deletions.
16 changes: 16 additions & 0 deletions PowerDocu.GUI/PowerDocuForm.Designer.cs

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

79 changes: 68 additions & 11 deletions PowerDocu.GUI/PowerDocuForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,25 @@ public partial class PowerDocuForm : Form
public PowerDocuForm()
{
InitializeComponent();
NotificationHelper.AddNotificationReceiver(new PowerDocuFormNotificationReceiver(appStatusTextBox));
NotificationHelper.AddNotificationReceiver(
new PowerDocuFormNotificationReceiver(appStatusTextBox)
);
using (var stream = File.OpenRead("Icons\\PowerDocu.ico"))
{
this.Icon = new Icon(stream);
}
CheckForNewerRelease();
}

private async void CheckForNewerRelease()
{
if (await PowerDocuReleaseHelper.HasNewerPowerDocuRelease())
{
newReleaseButton.Visible = true;
NotificationHelper.SendNotification("A new PowerDocu release has been found: " + PowerDocuReleaseHelper.latestVersionTag);
NotificationHelper.SendNotification("Please visit " + PowerDocuReleaseHelper.latestVersionUrl + " to download it");
NotificationHelper.SendNotification("");
}
}

private void selectZIPFileButton_Click(object sender, EventArgs e)
Expand All @@ -26,24 +40,47 @@ private void selectZIPFileButton_Click(object sender, EventArgs e)
{
try
{
NotificationHelper.SendNotification("Preparing to parse file " + openFileToParseDialog.FileName + ", please wait.");
NotificationHelper.SendNotification(
"Preparing to parse file "
+ openFileToParseDialog.FileName
+ ", please wait."
);
Cursor = Cursors.WaitCursor; // change cursor to hourglass type
if (openFileToParseDialog.FileName.EndsWith(".zip"))
{
NotificationHelper.SendNotification("Trying to process Power Automate Flows");
FlowDocumentationGenerator.GenerateWordDocumentation(openFileToParseDialog.FileName, (openWordTemplateDialog.FileName != "") ? openWordTemplateDialog.FileName : null);
NotificationHelper.SendNotification(
"Trying to process Power Automate Flows"
);
FlowDocumentationGenerator.GenerateWordDocumentation(
openFileToParseDialog.FileName,
(openWordTemplateDialog.FileName != "")
? openWordTemplateDialog.FileName
: null
);
NotificationHelper.SendNotification("Trying to process Power Apps");
AppDocumentationGenerator.GenerateWordDocumentation(openFileToParseDialog.FileName, (openWordTemplateDialog.FileName != "") ? openWordTemplateDialog.FileName : null);
AppDocumentationGenerator.GenerateWordDocumentation(
openFileToParseDialog.FileName,
(openWordTemplateDialog.FileName != "")
? openWordTemplateDialog.FileName
: null
);
}
else if (openFileToParseDialog.FileName.EndsWith(".msapp"))
{
AppDocumentationGenerator.GenerateWordDocumentation(openFileToParseDialog.FileName, (openWordTemplateDialog.FileName != "") ? openWordTemplateDialog.FileName : null);
AppDocumentationGenerator.GenerateWordDocumentation(
openFileToParseDialog.FileName,
(openWordTemplateDialog.FileName != "")
? openWordTemplateDialog.FileName
: null
);
}
}
catch (Exception ex)
{
MessageBox.Show($"Security error.\n\nError message: {ex.Message}\n\n" +
$"Details:\n\n{ex.StackTrace}");
MessageBox.Show(
$"Security error.\n\nError message: {ex.Message}\n\n"
+ $"Details:\n\n{ex.StackTrace}"
);
}
finally
{
Expand All @@ -58,8 +95,11 @@ private void selectWordTemplateButton_Click(object sender, EventArgs e)
{
try
{
wordTemplateInfoLabel.Text = "Template: " + Path.GetFileName(openWordTemplateDialog.FileName);
NotificationHelper.SendNotification("Selected Word template " + openWordTemplateDialog.FileName);
wordTemplateInfoLabel.Text =
"Template: " + Path.GetFileName(openWordTemplateDialog.FileName);
NotificationHelper.SendNotification(
"Selected Word template " + openWordTemplateDialog.FileName
);
}
catch (Exception ex)
{
Expand All @@ -73,15 +113,32 @@ private void selectWordTemplateButton_Click(object sender, EventArgs e)
}
}

private void newReleaseButton_Click(object sender, EventArgs e)
{
var sInfo = new System.Diagnostics.ProcessStartInfo(PowerDocuReleaseHelper.latestVersionUrl)
{
UseShellExecute = true,
};
System.Diagnostics.Process.Start(sInfo);
}

private void sizeChanged(object sender, EventArgs e)
{
appStatusTextBox.Size = new Size(ClientSize.Width - 30, ClientSize.Height - selectFileToParseButton.Height - selectWordTemplateButton.Height - 40);
appStatusTextBox.Size = new Size(
ClientSize.Width - 30,
ClientSize.Height
- selectFileToParseButton.Height
- selectWordTemplateButton.Height
- 40
);
newReleaseButton.Location = new Point(ClientSize.Width - 80, 15);
}
}

public class PowerDocuFormNotificationReceiver : NotificationReceiverBase
{
private readonly TextBox notificationTextBox;

public PowerDocuFormNotificationReceiver(TextBox textBox)
{
notificationTextBox = textBox;
Expand Down

0 comments on commit f5d6386

Please sign in to comment.