Skip to content

Commit

Permalink
Added the possibility to clear Locate IP page (#597)
Browse files Browse the repository at this point in the history
  • Loading branch information
lpeyr committed Aug 4, 2024
1 parent 0e2d5bf commit f89b235
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
17 changes: 17 additions & 0 deletions InternetTest/InternetTest/Pages/LocateIpPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,23 @@
<ToolTip Content="{x:Static lang:Resources.Save}" />
</Button.ToolTip>
</Button>
<Button
x:Name="ResetBtn"
Margin="5 0 0 0"
Padding="5 2"
Background="{DynamicResource LightAccent}"
BorderThickness="0"
Click="ResetBtn_Click"
Content="&#xF34D;"
Cursor="Hand"
FontFamily="../Fonts/#FluentSystemIcons-Regular"
FontWeight="ExtraBold"
Foreground="{DynamicResource Accent}"
Style="{DynamicResource PrimaryButton}">
<Button.ToolTip>
<ToolTip Content="{x:Static lang:Resources.Reset}" />
</Button.ToolTip>
</Button>
</StackPanel>

<WrapPanel
Expand Down
25 changes: 24 additions & 1 deletion InternetTest/InternetTest/Pages/LocateIpPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Runtime;
using System.Windows;
using System.Windows.Controls;

Expand Down Expand Up @@ -58,7 +59,7 @@ private async void InitUI()
LocateIP(""); // Get the current IP of the user
}
}
catch (Exception) { } // Cancel if there is no internet connection
catch { } // Cancel if there is no internet connection
}

internal void ToggleConfidentialMode(bool toggle)
Expand Down Expand Up @@ -171,4 +172,26 @@ private void MyIpBtn_Click(object sender, RoutedEventArgs e)
{
LocateIP(""); // Empty query will return the user's public IP
}

private void ResetUI()
{
StatusIconTxt.Text = "\uF4AB";
StatusIconTxt.Foreground = Global.GetBrushFromResource("Gray");
MyIPTxt.Text = Properties.Resources.IPShowHere2;
CountryTxt.Text = "N/A";
RegionTxt.Text = "N/A";
CityTxt.Text = "N/A";
ZipCodeTxt.Text = "N/A";
LatTxt.Text = "N/A";
LongitudeTxt.Text = "N/A";
TimezoneTxt.Text = "N/A";
IspTxt.Text = "N/A";
IpTxt.Text = "";
}

private void ResetBtn_Click(object sender, RoutedEventArgs e)
{
ResetUI();
CurrentIP = null;
}
}

0 comments on commit f89b235

Please sign in to comment.