Skip to content

Commit

Permalink
Added "Add website" section (#517)
Browse files Browse the repository at this point in the history
  • Loading branch information
Leo-Peyronnet committed Dec 28, 2023
1 parent 8574268 commit 79296ad
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
2 changes: 1 addition & 1 deletion InternetTest/InternetTest/Pages/DownDetectorPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@
BlurRadius="15"
Opacity="0.15"
ShadowDepth="0"
Color="Black" />
Color="{Binding Source={StaticResource AccentColor}}" />
</Border.Effect>
<Grid>
<Grid.RowDefinitions>
Expand Down
26 changes: 16 additions & 10 deletions InternetTest/InternetTest/Pages/DownDetectorPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,12 @@ MIT License
*/
using InternetTest.Classes;
using InternetTest.UserControls;
using PeyrSharp.Core;
using PeyrSharp.Core.Converters;
using PeyrSharp.Enums;
using Synethia;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Threading;

namespace InternetTest.Pages
{
Expand All @@ -64,14 +55,29 @@ private void ClearBtn_Click(object sender, RoutedEventArgs e)
WebsiteTxt.Text = string.Empty;
}

internal List<string> Websites = new();
private void AddBtn_Click(object sender, RoutedEventArgs e)
{
if (!Global.IsUrlValid(WebsiteTxt.Text) || Websites.Contains(WebsiteTxt.Text)) return;
if (!WebsiteTxt.Text.StartsWith("http"))
{
WebsiteTxt.Text = (Global.Settings.UseHttps ? "https://" : "http://") + WebsiteTxt.Text;
}

WebsiteDisplayer.Children.Add(new WebsiteItem(WebsiteTxt.Text));
Websites.Add(WebsiteTxt.Text);
WebsiteTxt.Text = string.Empty;
}

private void TestBtn_Click(object sender, RoutedEventArgs e)
{

for (int i = 0; i < WebsiteDisplayer.Children.Count; i++)
{
if (WebsiteDisplayer.Children[i] is WebsiteItem websiteItem)
{
websiteItem.LaunchTestAsync();
}
}
}

private void IntervalTxt_PreviewTextInput(object sender, TextCompositionEventArgs e)
Expand Down

0 comments on commit 79296ad

Please sign in to comment.