11using System ;
22using System . Collections . Generic ;
33using System . Windows ;
4+ using System . Windows . Controls ;
45using System . Windows . Shell ;
56using Advanced_PortChecker . Classes ;
67
@@ -93,15 +94,14 @@ private async void BtnScan_Click(object sender, RoutedEventArgs e)
9394 TaskbarItemInfo . ProgressState = TaskbarItemProgressState . Normal ;
9495 TaskbarItemInfo . ProgressValue = 0 ;
9596
96- List < LvCheck > lv = new List < LvCheck > ( ) ;
9797 _oI = new OperationInformation
9898 {
9999 Progress = new Progress < int > ( value =>
100100 {
101101 PgbStatus . Value = value ;
102102 TaskbarItemInfo . ProgressValue = value / ( PgbStatus . Maximum - PgbStatus . Minimum ) ;
103103 } ) ,
104- Preview = new Progress < LvCheck > ( value => { LvPorts . Items . Add ( value ) ; } ) ,
104+ ItemProgress = new Progress < LvCheck > ( value => { LvPorts . Items . Add ( value ) ; } ) ,
105105 IsCancelled = false
106106 } ;
107107
@@ -114,23 +114,17 @@ private async void BtnScan_Click(object sender, RoutedEventArgs e)
114114 switch ( CbaMethod . Text )
115115 {
116116 case "TCP" :
117- lv = await PortChecker . CheckTCP ( TxtAddress . Text , ( int ) IntStart . Value , ( int ) IntStop . Value , _oI , true ) ;
117+ await PortChecker . CheckTCP ( TxtAddress . Text , ( int ) IntStart . Value , ( int ) IntStop . Value , _oI , true ) ;
118118 break ;
119119 case "UDP" :
120- lv = await PortChecker . CheckUDP ( TxtAddress . Text , ( int ) IntStart . Value , ( int ) IntStop . Value , _oI , true ) ;
120+ await PortChecker . CheckUDP ( TxtAddress . Text , ( int ) IntStart . Value , ( int ) IntStop . Value , _oI , true ) ;
121121 break ;
122122 case "Both" :
123- lv = await PortChecker . CheckTCPUDP ( TxtAddress . Text , ( int ) IntStart . Value , ( int ) IntStop . Value , _oI ) ;
123+ await PortChecker . CheckTCPUDP ( TxtAddress . Text , ( int ) IntStart . Value , ( int ) IntStop . Value , _oI ) ;
124124 break ;
125125 }
126126 }
127127 }
128- LvPorts . Items . Clear ( ) ;
129- foreach ( LvCheck l in lv )
130- {
131- LvPorts . Items . Add ( l ) ;
132- }
133-
134128 ControlsEnabled ( true ) ;
135129
136130 TaskbarItemInfo . ProgressState = TaskbarItemProgressState . None ;
@@ -144,6 +138,8 @@ private void Exit_Click(object sender, RoutedEventArgs e)
144138
145139 private void BtnCancel_Click ( object sender , RoutedEventArgs e )
146140 {
141+ if ( _oI == null ) return ;
142+
147143 _oI . IsCancelled = true ;
148144 ControlsEnabled ( true ) ;
149145
@@ -191,5 +187,27 @@ private void BtnDeleteAllItems_Click(object sender, RoutedEventArgs e)
191187 {
192188 LvPorts . Items . Clear ( ) ;
193189 }
190+
191+ private void BtnDelete_Click ( object sender , RoutedEventArgs e )
192+ {
193+ List < LvCheck > delete = new List < LvCheck > ( ) ;
194+ foreach ( LvCheck l in LvPorts . SelectedItems )
195+ {
196+ delete . Add ( l ) ;
197+ }
198+
199+ foreach ( LvCheck lv in delete )
200+ {
201+ LvPorts . Items . Remove ( lv ) ;
202+ }
203+ }
204+
205+ private void BtnCopy_Click ( object sender , RoutedEventArgs e )
206+ {
207+ if ( LvPorts . SelectedItems . Count == 0 ) return ;
208+
209+ LvCheck selected = ( LvCheck ) LvPorts . SelectedItems [ 0 ] ;
210+ Clipboard . SetText ( selected . Address + " " + selected . Port + " " + selected . Type + " " + selected . Description ) ;
211+ }
194212 }
195213}
0 commit comments