-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added the possibility to test multiple websites (#348)
- Loading branch information
1 parent
5dc9920
commit 6dc7d9e
Showing
4 changed files
with
182 additions
and
9 deletions.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
InternetTest/InternetTest/Classes/DownDetectorTestResult.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
MIT License | ||
Copyright (c) Léo Corporation | ||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. | ||
*/ | ||
|
||
namespace InternetTest.Classes; | ||
public record DownDetectorTestResult(int Code, int Time, string Message); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
InternetTest/InternetTest/UserControls/DownDetectorItem.xaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<UserControl x:Class="InternetTest.UserControls.DownDetectorItem" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:local="clr-namespace:InternetTest.UserControls" | ||
mc:Ignorable="d" FontFamily="../Fonts/#Hauora" | ||
Height="Auto" Margin="0" Width="300"> | ||
<Grid d:Background="#fff"> | ||
<Grid.ColumnDefinitions> | ||
<ColumnDefinition/> | ||
<ColumnDefinition Width="Auto"/> | ||
</Grid.ColumnDefinitions> | ||
<TextBox Background="Transparent" x:Name="WebsiteTxt" Padding="2" Margin="5" BorderThickness="0" FontWeight="Bold" Foreground="{Binding Source={StaticResource DarkGray}}" d:Text="https://bing.com" VerticalAlignment="Center"/> | ||
<StackPanel Grid.Column="1" Orientation="Horizontal"> | ||
<Button x:Name="TestSiteBtn" Content="" 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="" Background="Transparent" BorderThickness="0" Padding="4" Margin="2" FontFamily="../Fonts/#FluentSystemIcons-Regular" Style="{DynamicResource ToolButton}" VerticalAlignment="Center" Click="InfoBtn_Click"/> | ||
<Button x:Name="DeleteBtn" Content="" Background="Transparent" BorderThickness="0" Padding="4" Margin="2" FontFamily="../Fonts/#FluentSystemIcons-Regular" Style="{DynamicResource ToolButton}" VerticalAlignment="Center" Click="DeleteBtn_Click"/> | ||
</StackPanel> | ||
</Grid> | ||
</UserControl> |
86 changes: 86 additions & 0 deletions
86
InternetTest/InternetTest/UserControls/DownDetectorItem.xaml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
/* | ||
MIT License | ||
Copyright (c) Léo Corporation | ||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. | ||
*/ | ||
using InternetTest.Classes; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using System.Windows; | ||
using System.Windows.Controls; | ||
using System.Windows.Data; | ||
using System.Windows.Documents; | ||
using System.Windows.Input; | ||
using System.Windows.Media; | ||
using System.Windows.Media.Imaging; | ||
using System.Windows.Navigation; | ||
using System.Windows.Shapes; | ||
|
||
namespace InternetTest.UserControls; | ||
/// <summary> | ||
/// Interaction logic for DownDetectorItem.xaml | ||
/// </summary> | ||
public partial class DownDetectorItem : UserControl | ||
{ | ||
StackPanel ParentStackPanel { get; init; } | ||
internal DownDetectorTestResult DownDetectorTestResult { get; set; } | ||
string URL { get; set; } | ||
public DownDetectorItem(StackPanel parentElement, string url, DownDetectorTestResult downDetectorTestResult) | ||
{ | ||
InitializeComponent(); | ||
ParentStackPanel = parentElement; // Save the parent element | ||
URL = url; // Save the URL | ||
DownDetectorTestResult = downDetectorTestResult; // Save the result | ||
|
||
InitUI(); // load the UI | ||
} | ||
|
||
private void InitUI() | ||
{ | ||
WebsiteTxt.Text = URL; // Set text | ||
} | ||
|
||
private async void TestSiteBtn_Click(object sender, RoutedEventArgs e) | ||
{ | ||
if (!WebsiteTxt.Text.StartsWith("http")) | ||
{ | ||
WebsiteTxt.Text = "https://" + WebsiteTxt.Text; | ||
} | ||
DownDetectorTestResult = await Global.DownDetectorPage.LaunchTest(WebsiteTxt.Text); // Launch the test | ||
} | ||
|
||
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 | ||
} | ||
|
||
private void DeleteBtn_Click(object sender, RoutedEventArgs e) | ||
{ | ||
ParentStackPanel.Children.Remove(this); // Delete this element from the parent element | ||
Global.DownDetectorPage.TotalWebsites--; // Update the total websites | ||
Global.DownDetectorPage.TestBtn.Content = $"{Properties.Resources.Test} ({Global.DownDetectorPage.TotalWebsites})"; // Update the text | ||
} | ||
} |