File tree Expand file tree Collapse file tree 2 files changed +32
-7
lines changed Expand file tree Collapse file tree 2 files changed +32
-7
lines changed Original file line number Diff line number Diff line change @@ -54,8 +54,18 @@ protected override void OnPropertyChanged(PropertyChangedEventArgs e)
54
54
async void Save ( )
55
55
{
56
56
Saved = true ;
57
-
58
- //IpOptions.Ports = Ports;
57
+ IpOptions . Ports . Clear ( ) ;
58
+ foreach ( var portForShow in Ports )
59
+ {
60
+ if ( portForShow . IsChecked )
61
+ {
62
+ IpOptions . Ports . Add ( portForShow . Port ) ;
63
+ }
64
+ }
65
+ if ( IpOptions . Ports . Count == 0 )
66
+ {
67
+ IpOptions . Ports . AddRange ( GetRandomPort ( ) ) ;
68
+ }
59
69
if ( MinimumCountOfValidIp > 0 )
60
70
{
61
71
IpOptions . MinimumCountOfValidIp = MinimumCountOfValidIp ;
@@ -84,7 +94,19 @@ async void Save()
84
94
85
95
await Shell . Current . GoToAsync ( "../" ) ;
86
96
}
97
+ public string [ ] GetRandomPort ( int count = 3 )
98
+ {
99
+ Random random = new Random ( ) ;
100
+ string [ ] randomPorts = new string [ count ] ;
101
+ var allPorts = Constants . HttpPorts . Concat ( Constants . HttpsPorts ) . ToList ( ) ;
102
+
103
+ for ( int i = 0 ; i < count ; i ++ )
104
+ {
105
+ int randomIndex = random . Next ( allPorts . Count ) ;
106
+ randomPorts [ i ] = allPorts [ randomIndex ] ;
107
+ }
108
+ return randomPorts ;
109
+ }
87
110
88
111
89
-
90
112
}
Original file line number Diff line number Diff line change 16
16
</CollectionView .ItemsLayout>
17
17
<CollectionView .ItemTemplate>
18
18
<DataTemplate x : DataType =" viewmodel:PortForShow" >
19
- <StackLayout Orientation =" Horizontal" Spacing =" 10" >
19
+ <StackLayout Orientation =" Horizontal" Spacing =" 10" Padding = " 5 " >
20
20
<Label Text =" {Binding Port}"
21
- VerticalOptions =" Center" />
21
+ VerticalOptions =" CenterAndExpand"
22
+ FontSize =" Small"
23
+ TextColor =" White" />
22
24
<CheckBox IsChecked =" {Binding IsChecked}"
23
- VerticalOptions =" Center "
24
- />
25
+ VerticalOptions =" CenterAndExpand "
26
+ Color = " DodgerBlue " />
25
27
</StackLayout >
26
28
</DataTemplate >
27
29
</CollectionView .ItemTemplate>
28
30
</CollectionView >
29
31
32
+
30
33
<Label Text =" Max Ping of IP:" />
31
34
<Entry x : Name =" MaxPingEntry" Text =" {Binding MaxPingOfIP}" />
32
35
You can’t perform that action at this time.
0 commit comments