Add reset option
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:local="clr-namespace:KurtzPelRegionPicker"
|
||||
mc:Ignorable="d"
|
||||
Title="KPRP" Height="190" Width="220"
|
||||
Title="KPRP" Height="225" Width="220"
|
||||
ResizeMode="CanMinimize">
|
||||
<StackPanel Orientation="Vertical"
|
||||
Margin="10">
|
||||
@@ -19,5 +19,9 @@
|
||||
Height="25"
|
||||
Content="Apply"
|
||||
Click="Button_Apply_Click" />
|
||||
<Button Height="25"
|
||||
Background="#FFD2D2"
|
||||
Content="Reset"
|
||||
Click="Button_Reset_Click" />
|
||||
</StackPanel>
|
||||
</Window>
|
||||
|
||||
@@ -55,6 +55,13 @@ namespace KurtzPelRegionPicker
|
||||
}
|
||||
}
|
||||
|
||||
private void Button_Reset_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
ResetRegion();
|
||||
|
||||
MessageBox.Show("Region reset", "Success", MessageBoxButton.OK, MessageBoxImage.Information);
|
||||
}
|
||||
|
||||
private void ApplyRegion(Region source, Region destination)
|
||||
{
|
||||
string[] content = File.ReadAllLines(HOSTS_PATH);
|
||||
@@ -85,6 +92,25 @@ namespace KurtzPelRegionPicker
|
||||
File.WriteAllLines(HOSTS_PATH, newContent);
|
||||
}
|
||||
|
||||
private void ResetRegion()
|
||||
{
|
||||
string[] content = File.ReadAllLines(HOSTS_PATH);
|
||||
|
||||
if (content.Contains(COMMENT))
|
||||
{
|
||||
// Purge
|
||||
int index = content.IndexOf(COMMENT);
|
||||
|
||||
var list = content.ToList();
|
||||
|
||||
list.RemoveAt(index);
|
||||
list.RemoveAt(index);
|
||||
|
||||
content = list.ToArray();
|
||||
File.WriteAllLines(HOSTS_PATH, content);
|
||||
}
|
||||
}
|
||||
|
||||
private string GetRealIP(string dns)
|
||||
{
|
||||
var process = new Process()
|
||||
|
||||
Reference in New Issue
Block a user