Skip to content

Commit

Permalink
Fixed issues with DownDetector page (#348)
Browse files Browse the repository at this point in the history
  • Loading branch information
Leo-Peyronnet committed Aug 13, 2022
1 parent 80c9545 commit 35ac618
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
2 changes: 1 addition & 1 deletion InternetTest/InternetTest/MainWindow.xaml.cs
Expand Up @@ -73,7 +73,7 @@ private void InitUI()
LocationChanged += (o, e) => HandleWindowStateChanged();
SizeChanged += (o, e) =>
{
PageScroller.Height = (ActualHeight - (GridRow1.ActualHeight + 32) > 0) ? ActualHeight - (GridRow1.ActualHeight + 74) : 0; // Set the scroller height
PageScroller.Height = (ActualHeight - (GridRow1.ActualHeight + 68) > 0) ? ActualHeight - (GridRow1.ActualHeight + 68) : 0; // Set the scroller height
};

HelloTxt.Text = Global.GetHiSentence; // Show greeting message to the user
Expand Down
15 changes: 13 additions & 2 deletions InternetTest/InternetTest/Pages/DownDetectorPage.xaml.cs
Expand Up @@ -63,6 +63,7 @@ private void InitUI()
{
TitleTxt.Text = $"{Properties.Resources.WebUtilities} > {Properties.Resources.DownDetector}"; // Set the title of the page
TimeIntervalTxt.Text = string.Format(Properties.Resources.ScheduledTestInterval, 10); // Set the time interval text
WebsiteTxt.Text = "https://leocorporation.dev";
}

private async void TestBtn_Click(object sender, RoutedEventArgs e)
Expand Down Expand Up @@ -172,6 +173,7 @@ private void InfoBtn_Click(object sender, RoutedEventArgs e)
DetailsStatusTxt.Text = CurrentResult.Code.ToString(); // Set the text
DetailsTimeTxt.Text = $"{CurrentResult.Time}ms"; // Set the text
DetailsMessageTxt.Text = CurrentResult.Message; // Set the text
DetailsSiteNameTxt.Text = string.Format(Properties.Resources.OfWebsite, WebsiteTxt.Text); // Set the text
}
}

Expand Down Expand Up @@ -225,12 +227,21 @@ private void ScheduledTestLaunchBtn_Click(object sender, RoutedEventArgs e)
ScheduledTestLaunchBtn.Content = Properties.Resources.StopScheduledTests;
TimeIntervalTxt.Visibility = Visibility.Visible;

timer.Tick += (o, e) =>
timer.Tick += async (o, e) =>
{
timeCounter++;
if (timeCounter == secondsRemainingFixed)
{
_ = LaunchTest(WebsiteTxt.Text);
_ = LaunchTest(WebsiteTxt.Text);
for (int i = 0; i < DownDetectorItemDisplayer.Children.Count; i++)
{
if (DownDetectorItemDisplayer.Children[i] is DownDetectorItem item)
{
item.WebsiteTxt.Foreground = new SolidColorBrush(Global.GetColorFromResource("Foreground1"));
item.DownDetectorTestResult = await LaunchTest(item.WebsiteTxt.Text);
item.WebsiteTxt.Foreground = new SolidColorBrush(Global.GetColorFromResource("DarkGray"));
}
}
}
if (secondsRemaining > 0)
{
Expand Down
Expand Up @@ -68,6 +68,7 @@ private async void TestSiteBtn_Click(object sender, RoutedEventArgs e)
WebsiteTxt.Text = "https://" + WebsiteTxt.Text;
}
DownDetectorTestResult = await Global.DownDetectorPage.LaunchTest(WebsiteTxt.Text); // Launch the test
URL = WebsiteTxt.Text;
}

private void InfoBtn_Click(object sender, RoutedEventArgs e)
Expand All @@ -77,6 +78,7 @@ private void InfoBtn_Click(object sender, RoutedEventArgs e)
Global.DownDetectorPage.DetailsStatusTxt.Text = DownDetectorTestResult.Code.ToString(); // Set the text
Global.DownDetectorPage.DetailsTimeTxt.Text = $"{DownDetectorTestResult.Time}ms"; // Set the text
Global.DownDetectorPage.DetailsMessageTxt.Text = DownDetectorTestResult.Message; // Set the text
Global.DownDetectorPage.DetailsSiteNameTxt.Text = string.Format(Properties.Resources.OfWebsite, URL); // Set the text
}
}

Expand Down

0 comments on commit 35ac618

Please sign in to comment.