@@ -26,6 +26,8 @@ namespace StarSharksTool
26
26
{
27
27
public partial class AccountManagement : Form
28
28
{
29
+ public int totalAccountCount = 0 ;
30
+ public int loadedAccountCount = 0 ;
29
31
private readonly IDistributedCache cache ;
30
32
public AccountManagement ( )
31
33
{
@@ -138,8 +140,18 @@ private async Task LoadAccount()
138
140
long accountCount = 0 ;
139
141
Global . Accounts . Clear ( ) ;
140
142
143
+
144
+ MethodInvoker resetLoginProgressMI = new MethodInvoker ( ( ) =>
145
+ {
146
+ this . totalAccountCount = appSettings . Accounts . Count ;
147
+ this . loadedAccountCount = 0 ;
148
+ processLbl . Text = $ "账号登录进度 0 / { appSettings . Accounts . Count } ";
149
+ progressBar1 . Value = 0 ;
150
+ } ) ;
151
+
141
152
if ( appSettings . Accounts . Count > 0 )
142
153
{
154
+ BeginInvoke ( resetLoginProgressMI ) ;
143
155
try
144
156
{
145
157
var c = appSettings . Accounts [ 0 ] . DecryptedPrivateKey ;
@@ -151,7 +163,42 @@ private async Task LoadAccount()
151
163
}
152
164
}
153
165
154
- var loginResponses = appSettings . Accounts . Select ( c => Services . Service . Login ( new Account ( c . DecryptedPrivateKey , 56 ) , c . Alias , Global . Cache ) ) . ToList ( ) ;
166
+
167
+ MethodInvoker accountLoginMI = new MethodInvoker ( ( ) =>
168
+ {
169
+ this . loadedAccountCount = this . loadedAccountCount + 1 ;
170
+ var progressPercentage = ( ( double ) this . loadedAccountCount / ( double ) this . totalAccountCount ) * 100 ;
171
+ if ( progressPercentage > 100 )
172
+ {
173
+ progressPercentage = 100 ;
174
+ }
175
+ this . progressBar1 . Value = ( int ) progressPercentage ;
176
+ processLbl . Text = $ "账号登录进度 { this . loadedAccountCount } / { appSettings . Accounts . Count } ";
177
+ } ) ;
178
+
179
+
180
+
181
+ MethodInvoker resetSharkLoadMI = new MethodInvoker ( ( ) =>
182
+ {
183
+ this . totalAccountCount = appSettings . Accounts . Count ;
184
+ this . loadedAccountCount = 0 ;
185
+ processLbl . Text = $ "鲨鱼加载进度 0 / { appSettings . Accounts . Count } ";
186
+ progressBar1 . Value = 0 ;
187
+ } ) ;
188
+
189
+ MethodInvoker sharkLoadMI = new MethodInvoker ( ( ) =>
190
+ {
191
+ this . loadedAccountCount = this . loadedAccountCount + 1 ;
192
+ var progressPercentage = ( ( double ) this . loadedAccountCount / ( double ) this . totalAccountCount ) * 100 ;
193
+ if ( progressPercentage > 100 )
194
+ {
195
+ progressPercentage = 100 ;
196
+ }
197
+ this . progressBar1 . Value = ( int ) progressPercentage ;
198
+ processLbl . Text = $ "鲨鱼加载进度 { this . loadedAccountCount } / { appSettings . Accounts . Count } ";
199
+ } ) ;
200
+
201
+ var loginResponses = appSettings . Accounts . Select ( c => Services . Service . Login ( new Account ( c . DecryptedPrivateKey , 56 ) , c . Alias , Global . Cache , 0 , ( ) => { BeginInvoke ( accountLoginMI ) ; } ) ) . ToList ( ) ;
155
202
await Task . WhenAll ( loginResponses ) ;
156
203
var accountInfos = loginResponses . ToDictionary ( c => c . Result . Address . ToLower ( ) , c => c . Result ) ;
157
204
@@ -167,6 +214,7 @@ private async Task LoadAccount()
167
214
loadFinished = true ;
168
215
break ;
169
216
}
217
+ BeginInvoke ( resetSharkLoadMI ) ;
170
218
await Parallel . ForEachAsync ( waitingLoadAddresses , new ParallelOptions { MaxDegreeOfParallelism = 4 } , async ( address , cancelToken ) =>
171
219
{
172
220
GET_RETRY :
@@ -194,8 +242,9 @@ private async Task LoadAccount()
194
242
throw new Exception ( ) ;
195
243
}
196
244
accountDetailInfo . Add ( address , ( sharkAccountInfo . Result , sharks . Result , seaBalanceOfFunctionReturn . Result , sssBalanceOfFunctionReturn . Result , bnbBalance . Result ) ) ;
245
+ BeginInvoke ( sharkLoadMI ) ;
197
246
}
198
- catch ( Exception e )
247
+ catch ( Exception e )
199
248
{
200
249
Global . GetLogger ( "AccountManagement" ) . LogError ( e , e . Message ) ;
201
250
goto GET_RETRY ;
@@ -305,7 +354,7 @@ private async Task LoadAccount()
305
354
} ;
306
355
307
356
var quickConnectButton = new Button ( ) ;
308
- quickConnectButton . Text = "ADB登录 " ;
357
+ quickConnectButton . Text = "雷电登录 " ;
309
358
quickConnectButton . Location = new Point ( 290 , 0 ) ;
310
359
quickConnectButton . Click += ( object ? sender , EventArgs e ) =>
311
360
{
@@ -341,13 +390,24 @@ private async Task LoadAccount()
341
390
} ;
342
391
343
392
var copyAddressButton = new Button ( ) ;
344
- copyAddressButton . Text = "复制 " ;
393
+ copyAddressButton . Text = "复制地址 " ;
345
394
copyAddressButton . Location = new Point ( 430 , 0 ) ;
346
395
copyAddressButton . Click += ( object ? sender , EventArgs e ) =>
347
396
{
348
397
Clipboard . SetDataObject ( bscAccount . Address ) ;
398
+ MessageBox . Show ( "复制成功" ) ;
349
399
} ;
350
400
401
+ var copyLinkButton = new Button ( ) ;
402
+ copyLinkButton . Text = "复制代打链接" ;
403
+ copyLinkButton . Location = new Point ( 500 , 0 ) ;
404
+ copyLinkButton . Width = 100 ;
405
+ copyLinkButton . Click += async ( object ? sender , EventArgs e ) =>
406
+ {
407
+ var link = await Services . Service . CopyGameToken ( bscAccount . Address ) ;
408
+ Clipboard . SetDataObject ( link ) ;
409
+ MessageBox . Show ( "复制成功" ) ;
410
+ } ;
351
411
352
412
353
413
var groupBox = new GroupBox ( ) ;
@@ -361,12 +421,13 @@ private async Task LoadAccount()
361
421
groupBox . Controls . Add ( quickConnectButton ) ;
362
422
groupBox . Controls . Add ( withdrawButton ) ;
363
423
groupBox . Controls . Add ( copyAddressButton ) ;
424
+ groupBox . Controls . Add ( copyLinkButton ) ;
364
425
365
426
flowLayoutPanel1 . Controls . Add ( groupBox ) ;
366
427
Global . Accounts . Add ( account ) ;
367
428
}
368
429
}
369
- catch ( Exception e )
430
+ catch ( Exception e )
370
431
{
371
432
Global . GetLogger ( "AccountManagement" ) . LogError ( e , e . Message ) ;
372
433
goto RETRY ;
@@ -610,7 +671,7 @@ private void AccountManagement_Resize(object sender, EventArgs e)
610
671
// Width - 29;
611
672
// Height - 154;
612
673
flowLayoutPanel1 . Width = this . Width - 29 ;
613
- flowLayoutPanel1 . Height = this . Height - 154 ;
674
+ flowLayoutPanel1 . Height = this . Height - 124 ;
614
675
}
615
676
}
616
677
}
0 commit comments