@@ -274,24 +274,14 @@ private void btn_apply_Click(object sender, EventArgs e)
274
274
var tagslotIndex = int . Parse ( cb . Name . Substring ( cb . Name . Length - 1 ) ) ;
275
275
if ( tagslotIndex <= 0 ) continue ;
276
276
277
- //SETTINGMY=tagslotIndex-1
278
277
SendCommandWithoutResult ( $ "SETTING{ _cmdExtension } =" + ( tagslotIndex - _tagslotIndexOffset ) ) ;
279
278
280
- //SETTINGMY? -> SHOULD BE "NO."+tagslotIndex
281
- var selectedSlot = SendCommand ( $ "SETTING{ _cmdExtension } ?") . ToString ( ) ;
282
- if ( ! selectedSlot . Contains ( ( tagslotIndex - _tagslotIndexOffset ) . ToString ( ) ) )
283
- {
284
- this . Cursor = Cursors . Default ;
285
- return ;
286
- }
287
-
288
279
var selectedMode = string . Empty ;
289
-
290
- var cb_mode = FindControls < ComboBox > ( Controls , $ "cb_mode{ tagslotIndex } ") . FirstOrDefault ( ) ;
291
- if ( cb_mode != null )
280
+ var mode = FindControls < ComboBox > ( Controls , $ "cb_mode{ tagslotIndex } ") . FirstOrDefault ( ) ;
281
+ if ( mode != null )
292
282
{
293
- SendCommandWithoutResult ( $ "CONFIG{ _cmdExtension } ={ cb_mode . SelectedItem } ") ;
294
- selectedMode = cb_mode . SelectedItem . ToString ( ) ;
283
+ SendCommandWithoutResult ( $ "CONFIG{ _cmdExtension } ={ mode . SelectedItem } ") ;
284
+ selectedMode = mode . SelectedItem . ToString ( ) ;
295
285
}
296
286
297
287
switch ( _CurrentDevType )
@@ -318,21 +308,34 @@ private void btn_apply_Click(object sender, EventArgs e)
318
308
var txtUid = FindControls < TextBox > ( Controls , $ "txt_uid{ tagslotIndex } ") . FirstOrDefault ( ) ;
319
309
if ( txtUid != null )
320
310
{
321
- string uid = txtUid . Text ;
311
+ var uid = txtUid . Text ;
322
312
// always set UID, either with user provided or random. Is that acceptable?
323
313
if ( ! string . IsNullOrEmpty ( uid ) && ! string . IsNullOrEmpty ( selectedMode ) && IsUidValid ( uid , selectedMode ) )
324
314
{
325
315
SendCommandWithoutResult ( $ "UID{ _cmdExtension } ={ uid } ") ;
326
316
}
327
317
else
328
318
{
329
- // set a random UID
330
- SendCommandWithoutResult ( $ "UID{ _cmdExtension } =?") ;
319
+ var tmpuid = "11223344" ;
320
+ if ( selectedMode . StartsWith ( "MF_ULTRALIGHT" ) )
321
+ {
322
+ tmpuid = "11223344556677" ;
323
+ }
324
+ SendCommandWithoutResult ( $ "UID{ _cmdExtension } ={ tmpuid } ") ;
331
325
}
332
326
}
333
- }
334
327
328
+ // Set MEMSIZE
329
+ var slotMemSize = SendCommand ( $ "MEMSIZE{ _cmdExtension } ?") . ToString ( ) ;
330
+ if ( ! string . IsNullOrEmpty ( slotMemSize ) && ! slotMemSize . StartsWith ( "202:" ) )
331
+ {
332
+ FindControls < TextBox > ( Controls , $ "txt_size{ tagslotIndex } ") . ForEach ( a => a . Text = slotMemSize ) ;
333
+ }
334
+
335
+ RefreshSlot ( tagslotIndex ) ;
336
+ }
335
337
RestoreActiveSlot ( ) ;
338
+
336
339
this . Cursor = Cursors . Default ;
337
340
}
338
341
@@ -496,7 +499,7 @@ private void btn_download_Click(object sender, EventArgs e)
496
499
else
497
500
{
498
501
// Get UID first
499
- var uid = SendCommand ( "UID" + _cmdExtension + " ?") . ToString ( ) ;
502
+ var uid = SendCommand ( $ "UID{ _cmdExtension } ?") . ToString ( ) ;
500
503
501
504
if ( ! string . IsNullOrEmpty ( uid ) )
502
505
{
@@ -554,56 +557,49 @@ private void btn_clear_Click(object sender, EventArgs e)
554
557
// Get all selected indices
555
558
foreach ( var cb in FindControls < CheckBox > ( Controls , "checkBox" ) )
556
559
{
557
- if ( cb . Checked )
558
- {
559
- var tagslotIndex = int . Parse ( cb . Name . Substring ( cb . Name . Length - 1 ) ) ;
560
- if ( tagslotIndex <= 0 )
561
- {
562
- this . Cursor = Cursors . Default ;
563
- return ;
564
- }
565
-
566
- //SETTINGMY=tagslotIndex-1
567
- SendCommandWithoutResult ( $ "SETTING{ _cmdExtension } =" + ( tagslotIndex - _tagslotIndexOffset ) ) ;
568
-
569
- SendCommandWithoutResult ( $ "DETECTION{ _cmdExtension } =CLOSED") ;
560
+ if ( ! cb . Checked ) continue ;
570
561
571
- SendCommandWithoutResult ( $ "CLEAR{ _cmdExtension } ") ;
562
+ var tagslotIndex = int . Parse ( cb . Name . Substring ( cb . Name . Length - 1 ) ) ;
563
+ if ( tagslotIndex <= 0 ) continue ;
564
+
565
+ SendCommandWithoutResult ( $ "SETTING{ _cmdExtension } ={ tagslotIndex - _tagslotIndexOffset } ") ;
566
+ SendCommandWithoutResult ( $ "CLEAR{ _cmdExtension } ") ;
572
567
573
- // Set every field to a default value
574
- FindControls < ComboBox > ( Controls , $ "cb_mode{ tagslotIndex } ") . ForEach ( a => SendCommandWithoutResult ( $ "CONFIG{ _cmdExtension } ={ a . Items [ 0 ] } ") ) ;
568
+ // Set every field to a default value
569
+
570
+ FindControls < ComboBox > ( Controls , $ "cb_mode{ tagslotIndex } ") . ForEach ( a => SendCommandWithoutResult ( $ "CONFIG{ _cmdExtension } =CLOSED") ) ;
575
571
576
- switch ( _CurrentDevType )
572
+ switch ( _CurrentDevType )
573
+ {
574
+ case DeviceType . RevG :
577
575
{
578
- case DeviceType . RevG :
579
- {
580
- FindControls < ComboBox > ( Controls , $ "cb_Lbutton{ tagslotIndex } ") . ForEach ( a => SendCommandWithoutResult ( $ "LBUTTON{ _cmdExtension } ={ a . Items [ 0 ] } ") ) ;
581
- FindControls < ComboBox > ( Controls , $ "cb_Lbuttonlong{ tagslotIndex } ") . ForEach ( a => SendCommandWithoutResult ( $ "LBUTTON_LONG{ _cmdExtension } ={ a . Items [ 0 ] } ") ) ;
582
- FindControls < ComboBox > ( Controls , $ "cb_Rbutton{ tagslotIndex } ") . ForEach ( a => SendCommandWithoutResult ( $ "RBUTTON{ _cmdExtension } ={ a . Items [ 0 ] } ") ) ;
583
- FindControls < ComboBox > ( Controls , $ "cb_Rbuttonlong{ tagslotIndex } ") . ForEach ( a => SendCommandWithoutResult ( $ "RBUTTON_LONG{ _cmdExtension } ={ a . Items [ 0 ] } ") ) ;
584
- FindControls < ComboBox > ( Controls , $ "cb_ledgreen{ tagslotIndex } ") . ForEach ( a => SendCommandWithoutResult ( $ "LEDGREEN{ _cmdExtension } ={ a . Items [ 0 ] } ") ) ;
585
- FindControls < ComboBox > ( Controls , $ "cb_ledred{ tagslotIndex } ") . ForEach ( a => SendCommandWithoutResult ( $ "LEDRED{ _cmdExtension } ={ a . Items [ 0 ] } ") ) ;
586
- break ;
587
- }
588
- default :
576
+ FindControls < ComboBox > ( Controls , $ "cb_Lbutton{ tagslotIndex } ") . ForEach ( a => SendCommandWithoutResult ( $ "LBUTTON{ _cmdExtension } ={ a . Items [ 0 ] } ") ) ;
577
+ FindControls < ComboBox > ( Controls , $ "cb_Lbuttonlong{ tagslotIndex } ") . ForEach ( a => SendCommandWithoutResult ( $ "LBUTTON_LONG{ _cmdExtension } ={ a . Items [ 0 ] } ") ) ;
578
+ FindControls < ComboBox > ( Controls , $ "cb_Rbutton{ tagslotIndex } ") . ForEach ( a => SendCommandWithoutResult ( $ "RBUTTON{ _cmdExtension } ={ a . Items [ 0 ] } ") ) ;
579
+ FindControls < ComboBox > ( Controls , $ "cb_Rbuttonlong{ tagslotIndex } ") . ForEach ( a => SendCommandWithoutResult ( $ "RBUTTON_LONG{ _cmdExtension } ={ a . Items [ 0 ] } ") ) ;
580
+ FindControls < ComboBox > ( Controls , $ "cb_ledgreen{ tagslotIndex } ") . ForEach ( a => SendCommandWithoutResult ( $ "LEDGREEN{ _cmdExtension } ={ a . Items [ 0 ] } ") ) ;
581
+ FindControls < ComboBox > ( Controls , $ "cb_ledred{ tagslotIndex } ") . ForEach ( a => SendCommandWithoutResult ( $ "LEDRED{ _cmdExtension } ={ a . Items [ 0 ] } ") ) ;
582
+ break ;
583
+ }
584
+ default :
585
+ {
586
+ FindControls < ComboBox > ( Controls , $ "cb_Lbutton{ tagslotIndex } ") . ForEach ( a => SendCommandWithoutResult ( $ "BUTTON{ _cmdExtension } =SWITCHCARD") ) ;
587
+ FindControls < ComboBox > ( Controls , $ "cb_Lbuttonlong{ tagslotIndex } ") . ForEach ( a =>
588
+ {
589
+ if ( a . Items . Count > 0 )
589
590
{
590
- FindControls < ComboBox > ( Controls , $ "cb_Lbutton{ tagslotIndex } ") . ForEach ( a => SendCommandWithoutResult ( $ "BUTTON{ _cmdExtension } ={ a . Items [ 0 ] } ") ) ;
591
- FindControls < ComboBox > ( Controls , $ "cb_Lbuttonlong{ tagslotIndex } ") . ForEach ( a =>
592
- {
593
- if ( a . Items . Count > 0 )
594
- {
595
- SendCommandWithoutResult ( $ "BUTTON_LONG{ _cmdExtension } ={ a . Items [ 0 ] } ") ;
596
- }
597
-
598
- } ) ;
599
- break ;
591
+ SendCommandWithoutResult ( $ "BUTTON_LONG{ _cmdExtension } ={ a . Items [ 0 ] } ") ;
600
592
}
593
+
594
+ } ) ;
595
+ break ;
601
596
}
602
- RefreshSlot ( tagslotIndex ) ;
603
597
}
604
598
}
605
-
606
599
RestoreActiveSlot ( ) ;
600
+
601
+ RefreshAllSlots ( ) ;
602
+
607
603
this . Cursor = Cursors . Default ;
608
604
}
609
605
@@ -1309,7 +1305,7 @@ private void OpenChameleonSerialPort()
1309
1305
1310
1306
1311
1307
// try without the "MY" extension first
1312
- FirmwareVersion = SendCommand ( "VERSION?" ) as string ;
1308
+ FirmwareVersion = SendCommand ( "VERSION?" ) . ToString ( ) ;
1313
1309
if ( ! string . IsNullOrEmpty ( _firmwareVersion ) && _firmwareVersion . Contains ( "Chameleon" ) )
1314
1310
{
1315
1311
_cmdExtension = string . Empty ;
@@ -1319,7 +1315,7 @@ private void OpenChameleonSerialPort()
1319
1315
return ;
1320
1316
}
1321
1317
1322
- FirmwareVersion = SendCommand ( "VERSIONMY?" ) as string ;
1318
+ FirmwareVersion = SendCommand ( "VERSIONMY?" ) . ToString ( ) ;
1323
1319
if ( ! string . IsNullOrEmpty ( _firmwareVersion ) && _firmwareVersion . Contains ( "Chameleon" ) )
1324
1320
{
1325
1321
_cmdExtension = "MY" ;
@@ -1363,7 +1359,7 @@ private void OpenChameleonSerialPort()
1363
1359
_CurrentDevType = DeviceType . Unknown ;
1364
1360
_tagslotIndexOffset = 1 ;
1365
1361
1366
- FirmwareVersion = SendCommand ( "VERSION?" ) as string ;
1362
+ FirmwareVersion = SendCommand ( "VERSION?" ) . ToString ( ) ;
1367
1363
if ( ! string . IsNullOrEmpty ( _firmwareVersion ) && _firmwareVersion . Contains ( "Chameleon" ) )
1368
1364
{
1369
1365
_cmdExtension = string . Empty ;
@@ -1376,7 +1372,7 @@ private void OpenChameleonSerialPort()
1376
1372
return ;
1377
1373
}
1378
1374
1379
- FirmwareVersion = SendCommand ( "VERSIONMY?" ) as string ;
1375
+ FirmwareVersion = SendCommand ( "VERSIONMY?" ) . ToString ( ) ;
1380
1376
if ( ! string . IsNullOrEmpty ( _firmwareVersion ) && _firmwareVersion . Contains ( "Chameleon" ) )
1381
1377
{
1382
1378
_cmdExtension = "MY" ;
@@ -2047,19 +2043,19 @@ internal void UploadDump(string filename)
2047
2043
internal void DownloadAndSaveDump ( string filename )
2048
2044
{
2049
2045
// First get the current memory size of the slot
2050
- var memsizeStr = SendCommand ( $ "MEMSIZE{ _cmdExtension } ?") ;
2046
+ var memsizeStr = SendCommand ( $ "MEMSIZE{ _cmdExtension } ?") . ToString ( ) ;
2051
2047
2052
2048
// Default value
2053
2049
int memsize = 4096 ;
2054
2050
2055
- if ( ! string . IsNullOrEmpty ( ( string ) memsizeStr ) )
2051
+ if ( ! string . IsNullOrEmpty ( memsizeStr ) )
2056
2052
{
2057
- int . TryParse ( ( string ) memsizeStr , out memsize ) ;
2053
+ int . TryParse ( memsizeStr , out memsize ) ;
2058
2054
}
2059
2055
2060
2056
// Also check if the tag is UL to save the counters too
2061
- var configStr = SendCommand ( $ "CONFIG{ _cmdExtension } ?") as string ;
2062
- if ( ( configStr != null ) && ( configStr . Contains ( "ULTRALIGHT" ) ) )
2057
+ var configStr = SendCommand ( $ "CONFIG{ _cmdExtension } ?") . ToString ( ) ;
2058
+ if ( ! string . IsNullOrWhiteSpace ( configStr ) && ( configStr . Contains ( "ULTRALIGHT" ) ) )
2063
2059
{
2064
2060
if ( memsize < 4069 )
2065
2061
{
@@ -2555,5 +2551,10 @@ private void RestoreActiveSlot()
2555
2551
HighlightActiveSlot ( ) ;
2556
2552
}
2557
2553
#endregion
2554
+
2555
+ private void cb_mode1_SelectedIndexChanged ( object sender , EventArgs e )
2556
+ {
2557
+
2558
+ }
2558
2559
}
2559
2560
}
0 commit comments