File tree Expand file tree Collapse file tree 5 files changed +25
-29
lines changed Expand file tree Collapse file tree 5 files changed +25
-29
lines changed Original file line number Diff line number Diff line change 1212 <VerticalStackLayout >
1313
1414 <Grid
15+ RowDefinitions =" 1*,1*,100*"
1516 ColumnDefinitions =" .20*,.80*"
1617 Margin =" 10" >
1718
1819 <Button Text =" start"
1920 Grid.Column=" 0"
21+ Grid.Row=" 1"
2022 Command =" {Binding GetValidIPsCommand}"
2123 HorizontalOptions =" FillAndExpand"
2224 VerticalOptions =" FillAndExpand" >
2325 </Button >
2426
2527 <Entry
2628 Grid.Column=" 1"
29+ Grid.Row=" 1"
2730 BackgroundColor =" DimGray"
2831 Margin =" 10"
2932 Placeholder =" enter max of ping defalt is 5000"
3033 PlaceholderColor =" White"
3134 Text =" {Binding MaxPingOfIP}" />
32-
3335 </Grid >
3436
3537 <CollectionView ItemsSource =" {Binding ValidIPs}"
4345 <HorizontalStackLayout
4446 Padding =" 15"
4547 >
46- <Label Text =" {Binding IP}" ></Label >
47- <Label Text =" ping : " ></Label >
48- <Label Text =" {Binding Ping}" ></Label >
48+ <Label Text =" {Binding IP}"
49+ TextColor =" White" ></Label >
50+ <Label Text =" ping : "
51+ TextColor =" White" ></Label >
52+ <Label Text =" {Binding Ping}"
53+ TextColor =" White" ></Label >
4954 </HorizontalStackLayout >
5055 </DataTemplate >
5156 </CollectionView .ItemTemplate>
Original file line number Diff line number Diff line change @@ -10,6 +10,5 @@ public class IPModel
1010 {
1111 public string IP { get ; set ; }
1212 public int Ping { get ; set ; }
13- public bool IsValid { get ; set ; }
1413 }
1514}
Original file line number Diff line number Diff line change @@ -31,12 +31,13 @@ public async Task<List<IPModel>> GetIpValid(int maxPing)
3131 IpAddresses . Add ( line ) ;
3232 }
3333 }
34+
3435 SocketsHttpHandler SocketsHandler = new SocketsHttpHandler ( ) ;
3536 HttpClient Client = new HttpClient ( SocketsHandler )
3637 {
3738 Timeout = TimeSpan . FromSeconds ( maxPing ) ,
3839 } ;
39- var tasks = new Task [ 20 ] ;
40+
4041 var validIp = new List < IPModel > ( ) ;
4142 for ( int i = 0 ; i < 20 ; i ++ )
4243 {
@@ -50,22 +51,14 @@ public async Task<List<IPModel>> GetIpValid(int maxPing)
5051 stopwatch . Start ( ) ;
5152 result = await Client . GetAsync ( $ "http://{ ipAddresse } ") ;
5253 stopwatch . Stop ( ) ;
53-
54-
55- //var request = (HttpWebRequest)WebRequest.Create($"http://{ipAddresse}");
56- //request.Timeout = 5000;
57- //var response = (HttpWebResponse)request.GetResponse();
58- //var responseString = new StreamReader(response.GetResponseStream()).ReadToEnd();
59-
60-
6154 var ping = Convert . ToInt32 ( stopwatch . Elapsed . TotalMilliseconds ) ;
55+
6256 lock ( validIp )
6357 {
6458 validIp . Add ( new IPModel
6559 {
6660 IP = ipAddresse ,
6761 Ping = ping ,
68- IsValid = true
6962 } ) ;
7063 }
7164 }
@@ -74,16 +67,13 @@ public async Task<List<IPModel>> GetIpValid(int maxPing)
7467 stopwatch . Reset ( ) ;
7568 }
7669 } ) ;
77- tasks [ i ] = t ;
7870 t . Start ( ) ;
7971 }
8072 await Task . Delay ( maxPing ) ;
81- //Thread.Sleep(5000);
8273 return validIp ;
8374 }
8475 string GetRandomIp ( )
8576 {
86- // var path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), @"IPAddresses.txt");
8777 Random random = new Random ( ) ;
8878 return IpAddresses [ random . Next ( IpAddresses . Count ) ] ;
8979 }
Original file line number Diff line number Diff line change 1- using System . ComponentModel . DataAnnotations ;
2- using System . Linq ;
3-
1+
42namespace fast_cf_ip_scanner . ViewModels
53{
64 public partial class MainPageViewModel : BaseViewModel
@@ -10,6 +8,7 @@ public partial class MainPageViewModel : BaseViewModel
108
119 [ ObservableProperty ]
1210 string maxPingOfIP ;
11+
1312
1413 readonly IPServices _iPServices ;
1514
@@ -57,10 +56,14 @@ int ConvertMaxPingOfIPToInt(string maxPing)
5756 }
5857
5958 [ RelayCommand ]
60- async Task CopySelectedIPAsync ( IPModel iPModel )
59+ async Task CopySelectedIPAsync ( IPModel ipModel )
6160 {
62- await Clipboard . SetTextAsync ( iPModel . IP ) ;
63- await App . Current . MainPage . DisplayAlert ( "Copied" , $ "the { iPModel . IP } is copied", "OK" ) ;
61+ if ( ipModel != null )
62+ {
63+ await Clipboard . SetTextAsync ( ipModel . IP ) ;
64+ await App . Current . MainPage . DisplayAlert ( "Copied" , $ "the { ipModel . IP } is copied", "OK" ) ;
65+ }
66+
6467 }
6568 }
6669}
Original file line number Diff line number Diff line change 1515 <ApplicationTitle >fast cf ip scanner</ApplicationTitle >
1616
1717 <!-- App Identifier -->
18- <ApplicationId >com.companyname .fast_cf_ip_scanner</ApplicationId >
18+ <ApplicationId >com.Ali1707 .fast_cf_ip_scanner</ApplicationId >
1919 <ApplicationIdGuid >4fb46e13-cf0a-419b-99f7-22b80a864ae4</ApplicationIdGuid >
2020
2121 <!-- Versions -->
3232
3333 <ItemGroup >
3434 <!-- App Icon -->
35- <MauiIcon Include =" Resources\AppIcon\appicon.svg" ForegroundFile =" Resources\AppIcon\appiconfg.svg" Color =" #512BD4" />
36-
35+ <MauiIcon Include =" Resources\AppIcon\appicon.svg" ForegroundFile =" Resources\AppIcon\appiconfg.svg" />
3736 <!-- Splash Screen -->
3837 <MauiSplashScreen Include =" Resources\Splash\splash.svg" Color =" #512BD4" BaseSize =" 128,128" />
3938
4039 <!-- Images -->
4140 <MauiImage Include =" Resources\Images\*" />
4241 <MauiImage Update =" Resources\Images\dotnet_bot.svg" BaseSize =" 168,208" />
43-
42+
4443 <!-- Custom Fonts -->
4544 <MauiFont Include =" Resources\Fonts\*" />
4645
4746 <!-- Raw Assets (also remove the "Resources\Raw" prefix) -->
4847 <MauiAsset Include =" Resources\Raw\**" LogicalName =" %(RecursiveDir)%(Filename)%(Extension)" />
49- < MauiAsset Include = " Resources\Raw\IPAddresses.txt " />
48+
5049 </ItemGroup >
5150
5251 <ItemGroup >
You can’t perform that action at this time.
0 commit comments