Skip to content

Commit

Permalink
In "Locate IP", when changing to "Website" from "IP", the previous te…
Browse files Browse the repository at this point in the history
…xt should be removed (#320)
  • Loading branch information
Leo-Peyronnet committed May 15, 2022
1 parent 6d1d741 commit 08d5b65
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 2 additions & 2 deletions InternetTest/InternetTest/Pages/LocalizeIPPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
</Button>
</StackPanel>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
<RadioButton x:Name="IPRadioBtn" Style="{DynamicResource RadioButtonStyle1}" GroupName="LocalizeRadioGroup" Content="{x:Static lang:Resources.IP}" Foreground="{Binding Source={StaticResource Foreground1}}" Background="{Binding Source={StaticResource Background1}}" BorderBrush="#2153E0" FontWeight="Bold" FontSize="13" VerticalAlignment="Center" IsChecked="True"/>
<RadioButton x:Name="WebsiteRadioBtn" Style="{DynamicResource RadioButtonStyle1}" GroupName="LocalizeRadioGroup" Content="{x:Static lang:Resources.Website}" Foreground="{Binding Source={StaticResource Foreground1}}" Background="{Binding Source={StaticResource Background1}}" BorderBrush="#2153E0" FontWeight="Bold" FontSize="13" VerticalAlignment="Center" Margin="10,0,10,0"/>
<RadioButton x:Name="IPRadioBtn" Style="{DynamicResource RadioButtonStyle1}" GroupName="LocalizeRadioGroup" Content="{x:Static lang:Resources.IP}" Foreground="{Binding Source={StaticResource Foreground1}}" Background="{Binding Source={StaticResource Background1}}" BorderBrush="#2153E0" FontWeight="Bold" FontSize="13" VerticalAlignment="Center" IsChecked="True" Checked="IPRadioBtn_Checked"/>
<RadioButton x:Name="WebsiteRadioBtn" Style="{DynamicResource RadioButtonStyle1}" GroupName="LocalizeRadioGroup" Content="{x:Static lang:Resources.Website}" Foreground="{Binding Source={StaticResource Foreground1}}" Background="{Binding Source={StaticResource Background1}}" BorderBrush="#2153E0" FontWeight="Bold" FontSize="13" VerticalAlignment="Center" Margin="10,0,10,0" Checked="IPRadioBtn_Checked"/>
</StackPanel>
<StackPanel Orientation="Horizontal" VerticalAlignment="Center" HorizontalAlignment="Center">
<Button x:Name="LocalizeBtn" Click="LocalizeBtn_Click" Content="{x:Static lang:Resources.LocalizeIP}" HorizontalAlignment="Center" Padding="10,5,10,5" Style="{StaticResource TabButtonStyle}" Foreground="{Binding Source={StaticResource WindowButtonsHoverForeground1}}" Background="{Binding Source={StaticResource AccentColor}}" FontWeight="Bold" Margin="0,10,10,0"/>
Expand Down
9 changes: 9 additions & 0 deletions InternetTest/InternetTest/Pages/LocalizeIPPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ namespace InternetTest.Pages;
public partial class LocalizeIPPage : Page
{
IPInfo IPInfo { get; set; }
string lastIP, lastWebsite = "";
public LocalizeIPPage()
{
InitializeComponent();
Expand All @@ -55,6 +56,7 @@ private async void LocalizeBtn_Click(object sender, RoutedEventArgs e)
lat = ip.Lat; // Define
lon = ip.Lon; // Define
IPInfoTxt.Text = ip.ToString(); // Show IP info
lastIP = IPTxt.Text; // Define

if (string.IsNullOrEmpty(IPTxt.Text))
{
Expand All @@ -75,6 +77,7 @@ private async void LocalizeBtn_Click(object sender, RoutedEventArgs e)
lat = ip.Lat; // Define
lon = ip.Lon; // Define
IPInfoTxt.Text = ip.ToString(); // Show IP info
lastWebsite = IPTxt.Text; // Define

if (string.IsNullOrEmpty(IPTxt.Text))
{
Expand Down Expand Up @@ -153,6 +156,11 @@ private void IPTxt_TextChanged(object sender, TextChangedEventArgs e)
IPPwrBox.Password = IPTxt.Text; // Set text
}

private void IPRadioBtn_Checked(object sender, RoutedEventArgs e)
{
IPTxt.Text = IPRadioBtn.IsChecked.Value ? lastIP : lastWebsite; // Clear text
}

private async void MyIPBtn_Click(object sender, RoutedEventArgs e)
{
if (await NetworkConnection.IsAvailableAsync())
Expand All @@ -162,6 +170,7 @@ private async void MyIPBtn_Click(object sender, RoutedEventArgs e)
lon = ip.Lon; // Define
IPInfoTxt.Text = ip.ToString(); // Show IP info
IPTxt.Text = ip.Query;
lastIP = ip.Query; // Define
IPRadioBtn.IsChecked = true;
IPInfo = ip; // Set
}
Expand Down

0 comments on commit 08d5b65

Please sign in to comment.