Skip to content

Commit

Permalink
Fixed issue Error Messages style and prevented multiple Instances
Browse files Browse the repository at this point in the history
  • Loading branch information
Rllyyy committed Apr 26, 2020
1 parent 5b5041a commit ed91355
Show file tree
Hide file tree
Showing 18 changed files with 1,666 additions and 56 deletions.
4 changes: 4 additions & 0 deletions Internet Check/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="Internet_Check.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup>

</configSections>
<System.Windows.Forms.ApplicationConfigurationSection>
<add key="DpiAwareness" value="PerMonitorV2" />
</System.Windows.Forms.ApplicationConfigurationSection>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
</startup>
Expand Down
70 changes: 56 additions & 14 deletions Internet Check/Form1.Designer.cs

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

55 changes: 49 additions & 6 deletions Internet Check/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ public Form1()
{
InitializeComponent();
this.textBoxInterval.Text = Properties.Settings.Default.SettingInterval.ToString();
//this.textBoxInterval.TabStop = false; to disable the highlight in textBoxInterval
notifyIcon1.Visible = true;
//this.textBoxInterval.TabStop = false; //to disable the highlight in textBoxInterval which sometimes occure
textBoxInterval.SelectionStart = 0;
textBoxInterval.SelectionLength = textBoxInterval.Text.Length;
}
public static int countclick = 0;
private System.Threading.Timer timer;
Expand All @@ -28,7 +31,17 @@ private void button1_Click(object sender, EventArgs e)

if (System.Text.RegularExpressions.Regex.IsMatch(textBoxInterval.Text, "[^0-9]") || Int32.Parse(textBoxInterval.Text) >= 32767 || Int32.Parse(textBoxInterval.Text) <= 4)
{
MessageBox.Show("Please enter only positve numbers that are smaller than 32767 but bigger than 4");
//MessageBox.Show("Please enter only positve numbers that are smaller than 32767 but bigger than 4");
this.panelError.BringToFront();
new Thread(() =>
{
this.labelErrormessage.BeginInvoke((MethodInvoker)delegate () { this.labelErrormessage.Text = "Please enter only positve numbers that are smaller than 32767 but bigger than 4."; ; });
this.panelError.BeginInvoke((MethodInvoker)delegate () { this.panelError.Visible = true; ; });
Thread.Sleep(5000);
Thread.CurrentThread.IsBackground = true;
this.panelError.BeginInvoke((MethodInvoker)delegate () { this.panelError.Visible = false; ; });

}).Start();
textBoxInterval.Text = textBoxInterval.Text.Remove(textBoxInterval.Text.Length - 1);
}
else
Expand All @@ -41,7 +54,7 @@ private void button1_Click(object sender, EventArgs e)
}
catch
{
//MessageBox.Show("Interval can't be accepted");

}
countclick++;
tTimer();
Expand All @@ -55,9 +68,26 @@ private void button1_Click(object sender, EventArgs e)
}
else
{
MessageBox.Show("Enter an intervall.", "Interval Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
//MessageBox.Show("Enter an intervall.", "Interval Error", MessageBoxButtons.OK, MessageBoxIcon.Error);


//this.labelErrormessage.Text = "Please enter an intervall.";
//this.panelError.Visible = true;

this.panelError.BringToFront();
new Thread(() =>
{
this.labelErrormessage.BeginInvoke((MethodInvoker)delegate () { this.labelErrormessage.Text = "Please enter an intervall." ; ; });
this.panelError.BeginInvoke((MethodInvoker)delegate () { this.panelError.Visible = true; ; });
Thread.Sleep(2700);
Thread.CurrentThread.IsBackground = true;
this.panelError.BeginInvoke((MethodInvoker)delegate () { this.panelError.Visible = false; ; });

}).Start();

}
}

}

private void tTimer()
{
Expand Down Expand Up @@ -164,10 +194,23 @@ private void Form1_FormClosing(object sender, FormClosingEventArgs e)
}
catch
{

}

}
}

private void notifyIcon1_MouseClick(object sender, MouseEventArgs e)
{
Show();
WindowState = FormWindowState.Normal;
}

private void Form1_Resize(object sender, EventArgs e)
{
if (WindowState == FormWindowState.Minimized)
{
Hide();
}
}
}
}
Loading

0 comments on commit ed91355

Please sign in to comment.