Skip to content

Commit

Permalink
Improved experience when testing websites (#348)
Browse files Browse the repository at this point in the history
  • Loading branch information
Leo-Peyronnet committed Aug 13, 2022
1 parent 6dc7d9e commit aef1c69
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 7 deletions.
2 changes: 1 addition & 1 deletion InternetTest/InternetTest/Pages/DownDetectorPage.xaml
Expand Up @@ -40,7 +40,7 @@
</Grid.ColumnDefinitions>
<TextBox x:Name="WebsiteTxt" Padding="5" Margin="5" BorderThickness="0" FontWeight="Bold" Foreground="{Binding Source={StaticResource DarkGray}}" d:Text="https://bing.com"/>
<StackPanel Grid.Column="1" Orientation="Horizontal">
<Button x:Name="TestSiteBtn" Content="&#xF606;" Background="Transparent" BorderThickness="0" Padding="4" Margin="2" FontFamily="../Fonts/#FluentSystemIcons-Regular" Style="{DynamicResource ToolButton}" VerticalAlignment="Center" Click="TestBtn_Click"/>
<Button x:Name="TestSiteBtn" Content="&#xF606;" Background="Transparent" BorderThickness="0" Padding="4" Margin="2" FontFamily="../Fonts/#FluentSystemIcons-Regular" Style="{DynamicResource ToolButton}" VerticalAlignment="Center" Click="TestSiteBtn_Click"/>
<Button x:Name="InfoBtn" Content="&#xF4A4;" Background="Transparent" BorderThickness="0" Padding="4" Margin="2" FontFamily="../Fonts/#FluentSystemIcons-Regular" Style="{DynamicResource ToolButton}" VerticalAlignment="Center" Click="InfoBtn_Click"/>
<Button x:Name="AddBtn" Content="&#xF10A;" Background="Transparent" BorderThickness="0" Padding="4" Margin="2" FontFamily="../Fonts/#FluentSystemIcons-Regular" Style="{DynamicResource ToolButton}" VerticalAlignment="Center" Click="AddBtn_Click"/>
</StackPanel>
Expand Down
26 changes: 23 additions & 3 deletions InternetTest/InternetTest/Pages/DownDetectorPage.xaml.cs
Expand Up @@ -81,7 +81,9 @@ private async void TestBtn_Click(object sender, RoutedEventArgs e)
{
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"));
}
}
}
Expand Down Expand Up @@ -159,9 +161,12 @@ private void BrowserBtn_Click(object sender, RoutedEventArgs e)

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
if (CurrentResult is not null)
{
DetailsStatusTxt.Text = CurrentResult.Code.ToString(); // Set the text
DetailsTimeTxt.Text = $"{CurrentResult.Time}ms"; // Set the text
DetailsMessageTxt.Text = CurrentResult.Message; // Set the text
}
}

private void AddBtn_Click(object sender, RoutedEventArgs e)
Expand All @@ -175,5 +180,20 @@ private void AddBtn_Click(object sender, RoutedEventArgs e)
TotalWebsites = DownDetectorItemDisplayer.Children.Count + ((!string.IsNullOrEmpty(WebsiteTxt.Text)) ? 1 : 0);
TestBtn.Content = $"{Properties.Resources.Test} ({TotalWebsites})";
}

private async void TestSiteBtn_Click(object sender, RoutedEventArgs e)
{
// Check if the URL is valid
if (!WebsiteTxt.Text.StartsWith("http"))
{
WebsiteTxt.Text = "https://" + WebsiteTxt.Text;
}

TotalWebsites = DownDetectorItemDisplayer.Children.Count + ((!string.IsNullOrEmpty(WebsiteTxt.Text)) ? 1 : 0);
TestBtn.Content = $"{Properties.Resources.Test} ({TotalWebsites})";

// Test the current website
CurrentResult = await LaunchTest(WebsiteTxt.Text);
}
}
}
Expand Up @@ -72,9 +72,12 @@ private async void TestSiteBtn_Click(object sender, RoutedEventArgs e)

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
if (DownDetectorTestResult is not null)
{
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
}
}

private void DeleteBtn_Click(object sender, RoutedEventArgs e)
Expand Down

0 comments on commit aef1c69

Please sign in to comment.