Skip to content

Commit da828c4

Browse files
committed
.
1 parent bfd07bf commit da828c4

File tree

4 files changed

+108
-14
lines changed

4 files changed

+108
-14
lines changed

fast cf ip scanner/Model/IpOptionModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public class IpOptionModel
1010
{
1111
public List<string> Ports { get; set; } = Constants.HttpPorts.Concat(Constants.HttpsPorts).ToList();
1212

13-
public string MaxPingOfIP { get; set; } = "1000";
13+
public int MaxPingOfIP { get; set; } = 1000;
1414

1515
public int MinimumCountOfValidIp { get; set; } = 5;
1616
public int CountOfRepeatTestForEachIp { get; set; } = 3;
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,90 @@
11

22
using System.ComponentModel;
3+
using System.Diagnostics.Tracing;
34

45
namespace fast_cf_ip_scanner.ViewModels;
56

7+
public record PortForShow(string Port,bool IsChecked);
8+
69

710
[QueryProperty("IpOptions", "IpOptions")]
811

912
public partial class IpOptionViewModel : BaseViewModel
1013
{
1114
[ObservableProperty]
1215
IpOptionModel _ipOptions;
16+
17+
[ObservableProperty]
18+
ObservableCollection<PortForShow> ports;
19+
20+
[ObservableProperty]
21+
int maxPingOfIP;
22+
23+
[ObservableProperty]
24+
int minimumCountOfValidIp;
1325

26+
[ObservableProperty]
27+
int countOfRepeatTestForEachIp;
1428

1529

30+
bool Saved = false;
1631

1732

33+
public IpOptionViewModel()
34+
{
35+
ports = new ObservableCollection<PortForShow>();
36+
}
37+
38+
protected override void OnPropertyChanged(PropertyChangedEventArgs e)
39+
{
40+
base.OnPropertyChanged(e);
41+
if (e.PropertyName == "IpOptions" && !Saved)
42+
{
43+
foreach (var port in IpOptions.Ports)
44+
{
45+
Ports.Add(new PortForShow(port, false));
46+
}
47+
MaxPingOfIP = IpOptions.MaxPingOfIP;
48+
MinimumCountOfValidIp = IpOptions.MinimumCountOfValidIp;
49+
CountOfRepeatTestForEachIp = IpOptions.CountOfRepeatTestForEachIp;
50+
}
51+
}
52+
53+
[RelayCommand]
54+
async void Save()
55+
{
56+
Saved = true;
57+
58+
//IpOptions.Ports = Ports;
59+
if (MinimumCountOfValidIp > 0)
60+
{
61+
IpOptions.MinimumCountOfValidIp = MinimumCountOfValidIp;
62+
}
63+
else
64+
{
65+
await App.Current.MainPage.DisplayAlert("error", "Minimum Count is 1", "ok");
66+
}
67+
if (MinimumCountOfValidIp > 0)
68+
{
69+
IpOptions.CountOfRepeatTestForEachIp = CountOfRepeatTestForEachIp;
70+
}
71+
else
72+
{
73+
await App.Current.MainPage.DisplayAlert("error", "Minimum Count is 1", "ok");
74+
75+
}
76+
if (MaxPingOfIP > 100)
77+
{
78+
IpOptions.MaxPingOfIP = MaxPingOfIP;
79+
}
80+
else
81+
{
82+
await App.Current.MainPage.DisplayAlert("error", "Minimum ping is 100", "ok");
83+
}
84+
85+
await Shell.Current.GoToAsync("../");
86+
}
87+
88+
89+
1890
}

fast cf ip scanner/ViewModels/ScanPageViewModel.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-

2-
using fast_cf_ip_scanner.Views;
1+
using fast_cf_ip_scanner.Views;
32

43
namespace fast_cf_ip_scanner.ViewModels
54
{
@@ -43,7 +42,7 @@ async void GetValidIPs()
4342

4443
ValidIPs.Clear();
4544

46-
var maxping = ConvertMaxPingOfIPToInt(_ipOption.MaxPingOfIP);
45+
var maxping = 0;
4746
var ips = await _iPServices.GetIps();
4847
if (ips.Length < 1)
4948
{

fast cf ip scanner/Views/IpOptionsPage.xaml

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,40 @@
55
Title="IpOptions"
66
xmlns:viewmodel="clr-namespace:fast_cf_ip_scanner.ViewModels"
77
x:DataType="viewmodel:IpOptionViewModel">
8-
<StackLayout Padding="20">
9-
<Label Text="Ports:"/>
10-
<Picker x:Name="PortsPicker" ItemsSource="{Binding IpOptions.Ports}"/>
8+
<ScrollView>
119

12-
<Label Text="Max Ping of IP:"/>
13-
<Entry x:Name="MaxPingEntry" Text="{Binding IpOptions.MaxPingOfIP}"/>
10+
<StackLayout Padding="20">
1411

15-
<Label Text="Minimum Count of Valid IP:"/>
16-
<Entry x:Name="MinCountEntry" Text="{Binding IpOptions.MinimumCountOfValidIp}"/>
12+
<Label Text="Ports:"/>
13+
<CollectionView ItemsSource="{Binding Ports}">
14+
<CollectionView.ItemsLayout>
15+
<LinearItemsLayout Orientation="Horizontal" />
16+
</CollectionView.ItemsLayout>
17+
<CollectionView.ItemTemplate>
18+
<DataTemplate x:DataType="viewmodel:PortForShow">
19+
<StackLayout Orientation="Horizontal" Spacing="10">
20+
<Label Text="{Binding Port}"
21+
VerticalOptions="Center"/>
22+
<CheckBox IsChecked="{Binding IsChecked}"
23+
VerticalOptions="Center"
24+
/>
25+
</StackLayout>
26+
</DataTemplate>
27+
</CollectionView.ItemTemplate>
28+
</CollectionView>
1729

18-
<Label Text="Count of Repeat Test for Each IP:"/>
19-
<Entry x:Name="RepeatCountEntry" Text="{Binding IpOptions.CountOfRepeatTestForEachIp}"/>
20-
</StackLayout>
30+
<Label Text="Max Ping of IP:"/>
31+
<Entry x:Name="MaxPingEntry" Text="{Binding MaxPingOfIP}"/>
32+
33+
<Label Text="Minimum Count of Valid IP:"/>
34+
<Entry x:Name="MinCountEntry" Text="{Binding MinimumCountOfValidIp}"/>
35+
36+
<Label Text="Count of Repeat Test for Each IP:"/>
37+
<Entry x:Name="RepeatCountEntry" Text="{Binding CountOfRepeatTestForEachIp}"/>
38+
39+
40+
<Button Text="Save" Command="{Binding SaveCommand}"/>
41+
42+
</StackLayout>
43+
</ScrollView>
2144
</ContentPage>

0 commit comments

Comments
 (0)