Skip to content

Commit

Permalink
Version 1.1, working Appveyor builds, Tray baloon notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
Plenyx committed Apr 3, 2019
1 parent 120162f commit 2962226
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 34 deletions.
4 changes: 2 additions & 2 deletions FormMain.Designer.cs

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

56 changes: 25 additions & 31 deletions FormMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public partial class FormMain : Form
private List<string> Logs { get; set; } = new List<string>();
private string LogsLocation { get; set; } = "";
private string LastLog { get; set; } = "";
private string Version { get; } = "0.70";
private string Version { get; } = "1.1";
private const int maxFileSize = 122880;

public FormMain()
Expand Down Expand Up @@ -87,6 +87,7 @@ private void FormMain_Load(object sender, EventArgs e)
if ((int)RegistryAccess.GetValue("uploadToTwitch", 0) == 1)
{
checkBoxPostToTwitch.Checked = true;
checkBoxPostToTwitch.Enabled = true;
}
if ((int)RegistryAccess.GetValue("wepSkill1", 0) == 1)
{
Expand All @@ -95,6 +96,7 @@ private void FormMain_Load(object sender, EventArgs e)
if ((int)RegistryAccess.GetValue("trayEnabled", 0) == 1)
{
checkBoxTrayEnable.Checked = true;
notifyIconTray.Visible = true;
}
if ((int)RegistryAccess.GetValue("trayMinimise", 0) == 1)
{
Expand All @@ -103,14 +105,7 @@ private void FormMain_Load(object sender, EventArgs e)
if ((int)RegistryAccess.GetValue("trayInfo", 0) == 1)
{
checkBoxTrayNotification.Checked = true;
}
if (checkBoxUploadLogs.Checked)
{
checkBoxPostToTwitch.Enabled = true;
}
if (checkBoxTrayEnable.Checked)
{
notifyIconTray.Visible = true;
ShowBalloon("Tray information", "Tray information enabled.", 4500);
}
string channel = (string)RegistryAccess.GetValue("channel", "");
if (channel != "")
Expand All @@ -130,11 +125,13 @@ private void FormMain_Load(object sender, EventArgs e)
catch
{
Registry.CurrentUser.DeleteSubKey(@"SOFTWARE\Plenyx\PlenBotUploader");
MessageBox.Show("An error in the Windows' registry has occurred.\nAll settings are reset.\nThe application will now restart.", "An error has occurred");
RestartApp();
MessageBox.Show("An error in the Windows' registry has occurred.\nAll settings are reset.\nTry running the application again.", "An error has occurred");
Application.Exit();
}
}

private void ShowBalloon(string title, string description, int ms) => notifyIconTray.ShowBalloonTip(ms, title, description, ToolTipIcon.Info);

#pragma warning disable 1998
protected async void NewVersionCheck()
{
Expand Down Expand Up @@ -188,20 +185,6 @@ protected void DoCommandArgs()

private string GetLocalDir() => $"{Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().CodeBase.Remove(0, 8))}\\";

private void RestartApp()
{
ProcessStartInfo Info = new ProcessStartInfo
{
Arguments = "/C ping 127.0.0.1 -n 2 && \"" + Application.ExecutablePath + "\"",
WindowStyle = ProcessWindowStyle.Hidden,
CreateNoWindow = true,
FileName = "cmd.exe"
};
Process.Start(Info);
notifyIconTray.Visible = false;
Application.Exit();
}

private void AddToText(string s)
{
textBoxUploadInfo.AppendText(s + Environment.NewLine);
Expand Down Expand Up @@ -263,6 +246,10 @@ public async void HttpUploadFile(string url, string file, string paramName, stri
string link = split.Split(new string[] { "\"" }, StringSplitOptions.None)[0];
link = link.Replace("\\", "");
File.AppendAllText(GetLocalDir() + "logs.txt", link + "\n");
if (checkBoxTrayNotification.Checked)
{
ShowBalloon("New log uploaded", link, 4500);
}
if (checkBoxPostToTwitch.Checked && !bypassMessage)
{
AddToText("File uploaded, link received and posted to chat: " + link);
Expand Down Expand Up @@ -468,7 +455,14 @@ private void checkBoxTrayEnable_CheckedChanged(object sender, EventArgs e)

private void checkBoxTrayMinimiseToIcon_CheckedChanged(object sender, EventArgs e) => RegistryAccess.SetValue("trayMinimise", checkBoxTrayMinimiseToIcon.Checked ? 1 : 0);

private void checkBoxTrayNotification_CheckedChanged(object sender, EventArgs e) => RegistryAccess.SetValue("trayInfo", checkBoxTrayNotification.Checked ? 1 : 0);
private void checkBoxTrayNotification_CheckedChanged(object sender, EventArgs e)
{
RegistryAccess.SetValue("trayInfo", checkBoxTrayNotification.Checked ? 1 : 0);
if (checkBoxTrayNotification.Checked)
{
ShowBalloon("Tray information", "Tray information enabled.", 4500);
}
}

private void checkBoxPostToTwitch_CheckedChanged(object sender, EventArgs e) => RegistryAccess.SetValue("uploadToTwitch", checkBoxPostToTwitch.Checked ? 1 : 0);

Expand All @@ -482,7 +476,7 @@ private void FormMain_Resize(object sender, EventArgs e)

private void notifyIconTray_MouseDoubleClick(object sender, MouseEventArgs e)
{
if(ShowInTaskbar)
if (ShowInTaskbar)
{
WindowState = FormWindowState.Minimized;
ShowInTaskbar = false;
Expand All @@ -498,17 +492,17 @@ private void notifyIconTray_MouseDoubleClick(object sender, MouseEventArgs e)

protected async void ReadMessages(object sender, IrcMessageEventArgs e)
{
if(e == null)
if (e == null)
{
return;
}
string[] messageSplit = e.Message.Split(new string[] { $"#{textBoxChannel.Text.ToLower()} :" }, StringSplitOptions.None);
if(messageSplit.Length > 1)
if (messageSplit.Length > 1)
{
string command = messageSplit[1].Split(' ')[0];
if(command.Contains("!lastlog") || command.Contains("!log"))
if (command.Contains("!lastlog") || command.Contains("!log"))
{
if(LastLog != "")
if (LastLog != "")
{
AddToText("> LAST LOG COMMAND USED");
await chatConnect.SendChatMessage(textBoxChannel.Text.ToLower(), $"Link to the last log: {LastLog}");
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.70
1.1

0 comments on commit 2962226

Please sign in to comment.