forked from VR2VYE/OpenGD77CPS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Settings.cs
1424 lines (1403 loc) · 44.4 KB
/
Settings.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
using DMR;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Serialization.Formatters.Binary;
using System.Text;
using System.Text.RegularExpressions;
using System.Windows.Forms;
using System.Xml;
using WeifenLuo.WinFormsUI.Docking;
internal class Settings
{
public enum UserMode
{
Basic,
Expert
}
public const string SZ_PWD = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\b";
public const string SZ_HEX = "0123456789ABCDEF";
public const string SZ_ATTRIBUTE_NAME = "Id";
public const string SZ_ATTRIBUTE_VALUE = "Text";
public const string SZ_NONE_NAME = "None";
public const string SZ_SELECTED_NAME = "Selected";
public const string SZ_ADD_NAME = "Add";
public const string SZ_OFF_NAME = "Off";
public const string SZ_DEVICE_NOT_FOUND_N = "DeviceNotFound";
public const string SZ_OPEN_PORT_FAIL_NAME = "OpenPortFail";
public const string SZ_COMM_ERROR_N = "CommError";
public const string SZ_MODEL_NOT_MATCH_N = "Model does not match";
public const string SZ_READ_NAME = "Read";
public const string SZ_WRITE_NAME = "Write";
public const string SZ_READ_COMPLETE_NAME = "ReadComplete";
public const string SZ_WRITE_COMPLETE_NAME = "WriteComplete";
public const string SZ_KEYPRESS_DTMF_NAME = "KeyPressDtmf";
public const string SZ_KEYPRESS_HEX_NAME = "KeyPressHex";
public const string SZ_KEYPRESS_DIGIT_N = "KeyPressDigit";
public const string SZ_KEYPRESS_PRINT_N = "KeyPressPrint";
public const string SZ_DATA_FORMAT_ERROR_N = "DataFormatError";
public const string SZ_FIRST_CH_NOT_DELETE_NAME = "FirstChNotDelete";
public const string SZ_FIRST_NOT_DELETE_N = "FirstNotDelete";
public const string SZ_NAME_EXIST = "Name exists";
public const string SZ_FILE_FORMAT_ERROR_N = "FileFormatError";
public const string SZ_OPEN_SUCCESSFULLY_N = "OpenSuccessfully";
public const string SZ_SAVE_SUCCESSFULLY_N = "SaveSuccessfully";
public const string SZ_TYPE_NOT_MATCH_N = "TypeNotMatch";
public const string SZ_EXPORT_SUCCESS_N = "ExportSuccess";
public const string SZ_IMPORT_SUCCESS_N = "ImportSuccess";
public const string SZ_ID_NOT_EMPTY_N = "IdNotEmpty";
public const string SZ_ID_OUT_OF_RANGE_N = "IdOutOfRange";
public const string SZ_ID_ALREADY_EXISTS_N = "IdAlreadyExists";
public const string SZ_NOT_SELECT_ITEM_NOT_COPYITEM_NAME = "NotSelectItemNotCopyItem";
public const string SZ_PROMPT_KEY1_NAME = "PromptKey1";
public const string SZ_PROMPT_KEY2_NAME = "PromptKey2";
public const string SZ_APP_SCAN_SELECTED_NAME = "ScanSelected";
public const string SZ_UNABLE = "Unable to operate selected";
public const string SZ_PROMPT_NAME = "Prompt";
public const string SZ_ERROR_NAME = "Error";
public const string SZ_WARNING_NAME = "Warning";
public const int FREQ_STEP_1 = 250;
public const int FREQ_STEP_2 = 625;
public const string SUPER_PWD = "DT8168";
public const int LEN_NAME_MCU = 15;
private static UserMode curUserMode;
public static readonly byte[] CUR_MODEL;
public static string SZ_NONE;
public static string SZ_NA;
public static string SZ_SELECTED;
public static string SZ_ADD;
public static string SZ_OFF;
public static string SZ_DEVICE_NOT_FOUND;
public static string SZ_OPEN_PORT_FAIL;
public static string SZ_COMM_ERROR;
public static string SZ_MODEL_NOT_MATCH;
public static string SZ_READ;
public static string SZ_WRITE;
public static string SZ_READ_COMPLETE;
public static string SZ_WRITE_COMPLETE;
public static string SZ_CODEPLUG_READ_CONFIRM;
public static string SZ_CODEPLUG_WRITE_CONFIRM;
public static string SZ_PLEASE_CONFIRM;
public static string SZ_USER_AGREEMENT = "This software is supplied 'as is' with no warranties. You use it at your own risk to both your PC and to your DMR Radio. By pressing the Yes button you agree and understand.";
public static string SZ_KEYPRESS_DTMF;
public static string SZ_KEYPRESS_HEX;
public static string SZ_KEYPRESS_DIGIT;
public static string SZ_KEYPRESS_PRINT;
public static string SZ_DATA_FORMAT_ERROR;
public static string SZ_FIRST_CH_NOT_DELETE;
public static string SZ_FIRST_NOT_DELETE;
public static string SZ_NAME_EXIST_NAME;
public static string SZ_FILE_FORMAT_ERROR;
public static string SZ_OPEN_SUCCESSFULLY;
public static string SZ_SAVE_SUCCESSFULLY;
public static string SZ_TYPE_NOT_MATCH;
public static string SZ_EXPORT_SUCCESS;
public static string SZ_IMPORT_SUCCESS;
public static string SZ_ID_NOT_EMPTY;
public static string SZ_ID_OUT_OF_RANGE;
public static string SZ_ID_ALREADY_EXISTS;
public static string SZ_NOT_SELECT_ITEM_NOT_COPYITEM;
public static string SZ_PROMPT_KEY1;
public static string SZ_PROMPT_KEY2;
public static string SZ_PROMPT;
public static string SZ_ERROR;
public static string SZ_WARNING;
public static string SZ_DOWNLOADCONTACTS_REGION_EMPTY = "Please enter the 3 digit Region previx code. e.g. 505 for Australia.";
public static string SZ_DOWNLOADCONTACTS_MESSAGE_ADDED = "There are {0} new ID's which are not already in your contacts";
public static string SZ_DOWNLOADCONTACTS_DOWNLOADING = "Downloading...";
public static string SZ_DOWNLOADCONTACTS_SELECT_CONTACTS_TO_IMPORT = "Please select the contacts you would like to import";
public static string SZ_DOWNLOADCONTACTS_TOO_MANY = "Not all contacts could be imported because the maximum number of Digital Contacts has been reached";
public static string SZ_UNABLEDOWNLOADFROMINTERNET = "Unable to download data. Please check your Internet connection";
public static string SZ_IMPORT_COMPLETE = "Import complete";
public static string SZ_CODEPLUG_UPGRADE_NOTICE = "This appears to be a V3.0.6 Codeplug. It will be converted to V3.1.x";
public static string SZ_CODEPLUG_UPGRADE_WARNING_TO_MANY_RX_GROUPS = "Version 3.1.x can only have 76 Rx Groups. Additional Rx Groups have been ignored";
public static string SZ_CODEPLUG_READ = "Reading codeplug from GD-77";
public static string SZ_CODEPLUG_WRITE = "Writing codeplug to GD-77";
public static string SZ_DMRID_READ = "Reading DMR ID database from GD-77";
public static string SZ_DMRID_WRITE = "Writing DMR ID database to GD-77";
public static string SZ_CALIBRATION_READ = "Reading calibration data from GD-77";
public static string SZ_CALIBRATION_WRITE = "Writing calibration data to GD-77";
public static string SZ_CONTACT_DUPLICATE_NAME = "Warning. Duplicate contact name.";
public static string SZ_EnableMemoryAccessMode = "The GD-77 does not seem to be in Memory Access mode\nHold keys SK2 (Blue side key), Green Menu and * when turning on the transceiver.\nand try again";
public static string SZ_dataRead = "Reading data from GD-77";
public static string SZ_dataWrite ="Writing data to GD-77";
public static string SZ_DMRIdContcatsTotal = "Total number of IDs = {0}. Max of 10920 can be uploaded";
public static string SZ_ErrorParsingData = "Error while parsing data";
public static string SZ_DMRIdIntroMessage = "Data is downloaded from Ham-digital.org and appended any existing data";
public static int CUR_MODE;
public static readonly uint[] MIN_FREQ;
public static readonly uint[] MAX_FREQ;
public static readonly uint[] VALID_MIN_FREQ;
public static readonly uint[] VALID_MAX_FREQ;
public static int CUR_CH_GROUP;
public static int CUR_ZONE_GROUP;
public static int CUR_ZONE;
public static string CUR_PWD;
public static readonly uint EEROM_SPACE = 0x20000;//0x40000; // Increased to 256k (0x40000) to store DMR ID as well as codeplug 0x20000;// 0131072u;
public static readonly int SPACE_DEVICE_INFO;
public static readonly int ADDR_DEVICE_INFO;
public static readonly int OFS_LAST_PRG_TIME;
public static readonly int OFS_CPS_SW_VER;
public static readonly int OFS_MODEL;
public static readonly int SPACE_GENERAL_SET;
public static readonly int ADDR_GENERAL_SET;
public static readonly int ADDR_PWD;
public static readonly int SPACE_BUTTON;
public static readonly int ADDR_BUTTON;
public static readonly int SPACE_ONE_TOUCH;
public static readonly int ADDR_ONE_TOUCH;
public static readonly int SPACE_TEXT_MSG;
public static readonly int ADDR_TEXT_MSG;
public static readonly int SPACE_ENCRYPT;
public static readonly int ADDR_ENCRYPT;
public static readonly int SPACE_SIGNALING_BASIC;
public static readonly int ADDR_SIGNALING_BASIC;
public static readonly int SPACE_DTMF_BASIC;
public static readonly int ADDR_DTMF_BASIC;
public static readonly int SPACE_EMG_SYSTEM;
public static readonly int ADDR_EMG_SYSTEM;
public static readonly int SPACE_DMR_CONTACT;
public static readonly int ADDR_DMR_CONTACT;
public static readonly int SPACE_DMR_CONTACT_EX;
public static readonly int ADDR_DMR_CONTACT_EX;
public static readonly int SPACE_DTMF_CONTACT;
public static readonly int ADDR_DTMF_CONTACT;
public static readonly int SPACE_RX_GRP_LIST;
public static readonly int ADDR_RX_GRP_LIST_EX;
public static readonly int ADDR_ZONE_BASIC;
public static readonly int ADDR_ZONE_LIST;
public static readonly int ADDR_CHANNEL;
public static readonly int SPACE_SCAN_BASIC;
public static readonly int ADDR_SCAN;
public static readonly int SPACE_SCAN_LIST;
public static readonly int ADDR_SCAN_LIST;
public static readonly int SPACE_BOOT_ITEM;
public static readonly int ADDR_BOOT_ITEM;
public static readonly int SPACE_DIGITAL_KEY_CONTACT;
public static readonly int ADDR_DIGITAL_KEY_CONTACT;
public static readonly int SPACE_MENU_CONFIG;
public static readonly int ADDR_MENU_CONFIG;
public static readonly int SPACE_BOOT_CONTENT;
public static readonly int ADDR_BOOT_CONTENT;
public static readonly int SPACE_ATTACHMENT;
public static readonly int ADDR_ATTACHMENT;
public static readonly int SPACE_VFO;
public static readonly int ADDR_VFO;
public static readonly int SPACE_EX_ZONE;
public static readonly int ADDR_EX_ZONE;
public static readonly int ADDR_EX_ZONE_BASIC;
public static readonly int ADDR_EX_ZONE_LIST;
public static readonly int SPACE_EX_SCAN;
public static readonly int ADDR_EX_SCAN;
public static readonly int ADDR_EX_SCAN_PRI_CH1;
public static readonly int ADDR_EX_SCAN_PRI_CH2;
public static readonly int ADDR_EX_SCAN_SPECIFY_CH;
public static readonly int ADDR_EX_SCAN_CH_LIST;
public static readonly int SPACE_EX_EMERGENCY;
public static readonly int ADDR_EX_EMERGENCY;
public static readonly int SPACE_EX_CH;
public static readonly int ADDR_EX_CH;
public static readonly int ADDR_UNUSED_START = 0x1EE60;
public static Dictionary<string, string> dicCommon = new Dictionary<string, string>();
private static XmlDocument _languageXML=null;
public static string LanguageFile="";
public static XmlDocument languageXML
{
get { return _languageXML; }
}
public static void setLanguageXMLFile(string xmlFile)
{
Settings.LanguageFile = Path.GetFileName(xmlFile);
_languageXML = new XmlDocument();
_languageXML.Load(xmlFile);
}
static string HelpFilename;
[CompilerGenerated]
public static string GetHelpFilename()
{
return Settings.HelpFilename;
}
[CompilerGenerated]
public static void SetHelpFilename(string string_0)
{
Settings.HelpFilename = string_0;// "";
}
public static UserMode getUserExpertSettings()
{
return Settings.UserMode.Expert;
}
public static void smethod_5(UserMode userMode_0)
{
Settings.curUserMode = userMode_0;
}
static SizeF _003CFactor_003Ek__BackingField;
[CompilerGenerated]
public static SizeF smethod_6()
{
return Settings._003CFactor_003Ek__BackingField;
}
[CompilerGenerated]
public static void smethod_7(SizeF sizeF_0)
{
Settings._003CFactor_003Ek__BackingField = sizeF_0;
}
static string _003CCurUserPwd_003Ek__BackingField;
[CompilerGenerated]
public static string smethod_8()
{
return Settings._003CCurUserPwd_003Ek__BackingField;
}
[CompilerGenerated]
public static void smethod_9(string string_0)
{
Settings._003CCurUserPwd_003Ek__BackingField = string_0;
}
public static void smethod_10()
{
Settings.smethod_76("None", ref Settings.SZ_NONE);
Settings.smethod_76("Selected", ref Settings.SZ_SELECTED);
Settings.smethod_76("Add", ref Settings.SZ_ADD);
Settings.smethod_76("Off", ref Settings.SZ_OFF);
Settings.smethod_76("DeviceNotFound", ref Settings.SZ_DEVICE_NOT_FOUND);
Settings.smethod_76("CommError", ref Settings.SZ_COMM_ERROR);
Settings.smethod_76("Model does not match", ref Settings.SZ_MODEL_NOT_MATCH);
Settings.smethod_76("DataFormatError", ref Settings.SZ_DATA_FORMAT_ERROR);
Settings.smethod_76("N/A", ref Settings.SZ_NA);
}
public static void smethod_11(ref byte byte_0, byte byte_1, byte byte_2, byte byte_3)
{
if (!Settings.smethod_12(byte_0, byte_1, byte_2))
{
byte_0 = byte_3;
}
}
public static bool smethod_12(byte byte_0, byte byte_1, byte byte_2)
{
if (byte_0 >= byte_1 && byte_0 <= byte_2)
{
return true;
}
return false;
}
public static bool smethod_13(int int_0, int int_1, int int_2)
{
if (int_0 >= int_1 && int_0 <= int_2)
{
return true;
}
return false;
}
public static int smethod_14(byte byte_0, int int_0, int int_1)
{
int num = (int)Math.Pow(2.0, (double)int_1) - 1;
return byte_0 >> int_0 & num;
}
public static void smethod_15(ref byte byte_0, int int_0, int int_1)
{
int num = (int)Math.Pow(2.0, (double)int_1) - 1;
byte_0 &= (byte)(~(num << int_0));
}
public static void smethod_16(ref byte byte_0, int int_0, int int_1, int int_2)
{
int num = (int)Math.Pow(2.0, (double)int_1) - 1;
byte_0 &= (byte)(~(num << int_0));
byte_0 |= (byte)((int_2 & num) << int_0);
}
public static void smethod_17(ref ushort ushort_0, int int_0, int int_1)
{
int num = (int)Math.Pow(2.0, (double)int_1) - 1;
ushort_0 &= (ushort)(~(num << int_0));
}
public static bool smethod_18(byte[] byte_0, byte[] byte_1, int int_0)
{
if (byte_0.Length < int_0)
{
return false;
}
if (byte_1.Length < int_0)
{
return false;
}
int num = 0;
while (true)
{
if (num < int_0)
{
if (byte_0[num] == byte_1[num])
{
num++;
continue;
}
break;
}
return true;
}
return false;
}
public static int smethod_19(double double_0, ref uint uint_0)
{
int num = 0;
uint_0 = 0u;
num = 0;
while (true)
{
if (num < Settings.MIN_FREQ.Length)
{
if (Settings.MIN_FREQ[num] < Settings.MAX_FREQ[num] && uint_0 == 0)
{
// Set the frequency to the nearest in range band.
if (double_0 < Settings.MIN_FREQ[1])
{
uint_0 = Settings.MIN_FREQ[1];
}
if (double_0 > Settings.MAX_FREQ[1] && double_0 < Settings.MIN_FREQ[0])
{
uint midPointFreq = ((Settings.MIN_FREQ[0] - Settings.MAX_FREQ[1]) / 2) + Settings.MAX_FREQ[1];
if (double_0 >= midPointFreq)
{
uint_0 = Settings.MIN_FREQ[0];
}
else
{
uint_0 = Settings.MAX_FREQ[1];
}
}
if (double_0 > Settings.MAX_FREQ[0])
{
uint_0 = Settings.MAX_FREQ[0];
}
}
if (double_0 >= (double)Settings.MIN_FREQ[num] && !(double_0 > (double)Settings.MAX_FREQ[num]))
{
break;
}
num++;
continue;
}
return -1;
}
return num;
}
public static int smethod_20(double double_0, double double_1)
{
int num = 0;
int num2 = -1;
int num3 = -1;
num = 0;
while (num < Settings.MIN_FREQ.Length)
{
if (!(double_0 >= (double)Settings.MIN_FREQ[num]) || double_0 > (double)Settings.MAX_FREQ[num])
{
num++;
continue;
}
num2 = num;
break;
}
num = 0;
while (num < Settings.MAX_FREQ.Length)
{
if (!(double_1 >= (double)Settings.MIN_FREQ[num]) || double_1 > (double)Settings.MAX_FREQ[num])
{
num++;
continue;
}
num3 = num;
break;
}
if (num2 == num3 && num2 != -1)
{
return num2;
}
return -1;
}
public static int smethod_21(uint uint_0, ref int int_0)
{
int num = 0;
int_0 = -1;
num = 0;
while (true)
{
if (num < Settings.MIN_FREQ.Length)
{
if (Settings.VALID_MIN_FREQ[num] < Settings.VALID_MAX_FREQ[num] && int_0 < 0)
{
int_0 = num;
}
if (uint_0 >= Settings.VALID_MIN_FREQ[num] && uint_0 <= Settings.VALID_MAX_FREQ[num])
{
break;
}
num++;
continue;
}
return -1;
}
return num;
}
public static int smethod_22(double double_0, double double_1)
{
int num = 0;
int num2 = -1;
int num3 = -1;
num = 0;
while (num < Settings.VALID_MIN_FREQ.Length)
{
if (!(double_0 >= (double)Settings.VALID_MIN_FREQ[num]) || double_0 > (double)Settings.VALID_MAX_FREQ[num])
{
num++;
continue;
}
num2 = num;
break;
}
num = 0;
while (num < Settings.VALID_MAX_FREQ.Length)
{
if (!(double_1 >= (double)Settings.VALID_MIN_FREQ[num]) || double_1 > (double)Settings.VALID_MAX_FREQ[num])
{
num++;
continue;
}
num3 = num;
break;
}
if (num2 == num3 && num2 != -1)
{
return num2;
}
return -1;
}
public static byte[] smethod_23(string string_0)
{
return Settings.smethod_24(string_0, "gb2312");
}
public static byte[] smethod_24(string string_0, string string_1)
{
Encoding encoding = Encoding.GetEncoding(string_1);
if (encoding == null)
{
encoding = Encoding.Default;
}
return encoding.GetBytes(string_0);
}
public static string smethod_25(byte[] byte_0)
{
return Settings.smethod_26(byte_0, "gb2312");
}
public static string smethod_26(byte[] byte_0, string string_0)
{
Encoding encoding = Encoding.GetEncoding(string_0);
if (encoding == null)
{
encoding = Encoding.Default;
}
int num = Array.IndexOf(byte_0, (byte)255);
if (num == -1)
{
num = Array.IndexOf(byte_0, (byte)0);
if (num == -1)
{
num = byte_0.Length;
}
}
return encoding.GetString(byte_0, 0, num);
}
public static int smethod_27(double double_0, double double_1)
{
decimal d = Convert.ToDecimal(double_0);
decimal d2 = Convert.ToDecimal(double_1);
return Convert.ToInt32(d * d2);
}
public static double smethod_28(int int_0, int int_1)
{
decimal d = Convert.ToDecimal(int_0);
decimal d2 = Convert.ToDecimal(int_1);
return Convert.ToDouble(d / d2);
}
public static void smethod_29(ref int int_0, int int_1, int int_2)
{
int num = int_0 % int_1;
int num2 = int_0 % int_2;
if (num != 0 && num2 != 0)
{
int num3 = 250 - num;
int num4 = 625 - num2;
if (num3 < num4)
{
int_0 += num3;
}
else
{
int_0 += num4;
}
}
}
public static void smethod_30(ref int int_0, int int_1, int int_2)
{
int num = 1;
int num2 = 0;
int num3 = 0;
int[] array = new int[4]
{
int_0 % int_1,
0,
0,
0
};
array[1] = int_1 - array[0];
array[2] = int_0 % int_2;
array[3] = int_2 - array[2];
num2 = array[0];
for (num = 1; num < array.Length; num++)
{
if (array[num] < num2)
{
num2 = array[num];
num3 = num;
}
}
if (num3 % 2 == 0)
{
int_0 -= num2;
}
else
{
int_0 += num2;
}
}
public static void smethod_31(ref int int_0)
{
int num = int_0 % 625;
if (num != 0)
{
int num2 = 0;
while (num2 < 3)
{
num += 25;
if (num % 625 != 0)
{
num2++;
continue;
}
int_0 += (num2 + 1) * 25;
break;
}
if (num2 == 3)
{
int_0 = (int_0 + 250) / 250 * 250;
}
}
}
public static ushort smethod_32(ushort ushort_0)
{
int num = 0;
int num2 = 0;
ushort num3 = 0;
for (num = 0; num < 4; num++)
{
num2 = (ushort_0 & 0xF);
ushort_0 = (ushort)(ushort_0 >> 4);
num3 = (ushort)((double)(int)num3 + (double)num2 * Math.Pow(10.0, (double)num));
}
return num3;
}
public static ushort smethod_33(ushort ushort_0)
{
int num = 0;
int num2 = 0;
ushort num3 = 0;
for (num = 0; num < 4; num++)
{
num2 = (int)ushort_0 % 10;
ushort_0 = (ushort)((int)ushort_0 / 10);
num3 = (ushort)((double)(int)num3 + (double)num2 * Math.Pow(16.0, (double)num));
}
return num3;
}
public static uint smethod_34(uint uint_0)
{
int num = 0;
uint num2 = 0u;
uint num3 = 0u;
for (num = 0; num < 8; num++)
{
num2 = (uint_0 & 0xF);
uint_0 >>= 4;
num3 += num2 * (uint)Math.Pow(10.0, (double)num);
}
return num3;
}
public static uint smethod_35(uint uint_0)
{
int num = 0;
uint num2 = 0u;
uint num3 = 0u;
for (num = 0; num < 8; num++)
{
num2 = uint_0 % 10u;
uint_0 /= 10u;
num3 += num2 * (uint)Math.Pow(16.0, (double)num);
}
return num3;
}
public static void smethod_36(CustomNumericUpDown class12_0, Class13 class13_0)
{
if (class13_0.method_6() < 0m)
{
class12_0.Minimum = (decimal)class13_0.method_2() * class13_0.method_6();
class12_0.Maximum = (decimal)class13_0.method_0() * class13_0.method_6();
class12_0.Increment = Math.Abs((decimal)class13_0.method_4() * class13_0.method_6());
}
else
{
class12_0.Minimum = (decimal)class13_0.method_0() * class13_0.method_6();
class12_0.Maximum = (decimal)class13_0.method_2() * class13_0.method_6();
class12_0.Increment = (decimal)class13_0.method_4() * class13_0.method_6();
}
class12_0.method_0(class13_0.method_8());
}
public static void smethod_37(ComboBox comboBox_0, string[] string_0)
{
int num = 0;
comboBox_0.Items.Clear();
for (num = 0; num < string_0.Length; num++)
{
comboBox_0.Items.Add(string_0[num]);
}
}
public static void smethod_38(ComboBox comboBox_0, string[] string_0, int int_0)
{
int num = 0;
int num2 = Math.Min(string_0.Length, int_0);
comboBox_0.Items.Clear();
for (num = 0; num < num2; num++)
{
comboBox_0.Items.Add(string_0[num]);
}
}
public static void smethod_39(CustomCombo class4_0, string[] string_0)
{
int num = 0;
class4_0.method_0();
foreach (string string_ in string_0)
{
class4_0.method_1(string_, num++);
}
}
public static void smethod_40(CustomCombo class4_0, string[] string_0, int[] int_0)
{
class4_0.method_0();
foreach (int num in int_0)
{
class4_0.method_1(string_0[num], num);
}
}
public static void smethod_41(ComboBox comboBox_0, int int_0, int int_1)
{
int num = 0;
comboBox_0.Items.Clear();
for (num = int_0; num <= int_1; num++)
{
comboBox_0.Items.Add(num);
}
}
public static void smethod_42(ComboBox comboBox_0, string string_0, int int_0, int int_1)
{
int num = 0;
comboBox_0.Items.Clear();
comboBox_0.Items.Add(string_0);
for (num = int_0; num <= int_1; num++)
{
comboBox_0.Items.Add(num);
}
}
public static void smethod_43(ComboBox comboBox_0, int int_0, int int_1, int int_2, string string_0)
{
int i = 0;
comboBox_0.Items.Clear();
for (i = int_0; i <= int_1; i++)
{
if (int_2 == i)
{
comboBox_0.Items.Add(string_0);
}
else
{
comboBox_0.Items.Add(i.ToString());
}
}
}
public static void smethod_44(CustomCombo class4_0, IData idata_0, string noneText=null)
{
int num = 0;
string text = "";
class4_0.method_0();
if (noneText == null)
{
class4_0.method_1(Settings.SZ_NONE, 0);
}
else
{
class4_0.method_1(noneText, 0);
}
for (num = 0; num < idata_0.Count; num++)
{
if (idata_0.DataIsValid(num))
{
text = idata_0.GetName(num);
class4_0.method_1(text, num + 1);
}
}
}
public static void smethod_45(CustomCombo class4_0, string[] string_0, IData idata_0)
{
int num = 0;
string text = "";
class4_0.method_0();
for (num = 0; num < string_0.Length; num++)
{
class4_0.method_1(string_0[num], num);
}
for (num = 0; num < idata_0.Count; num++)
{
if (idata_0.DataIsValid(num))
{
text = string.Format("{0:d3}:{1}", num + 1, idata_0.GetName(num));
class4_0.method_1(text, num + string_0.Length);
}
}
}
public static void smethod_46(CustomCombo class4_0, string[] string_0, ListBox listBox_0)
{
int num = 0;
string text = "";
class4_0.method_0();
for (num = 0; num < string_0.Length; num++)
{
class4_0.method_1(string_0[num], num);
}
for (num = 0; num < listBox_0.Items.Count; num++)
{
text = listBox_0.Items[num].ToString();
SelectedItemUtils @class = listBox_0.Items[num] as SelectedItemUtils;
if (@class != null)
{
class4_0.method_1(text, @class.Value);
}
}
}
public static int smethod_47(ListBox listBox_0, SelectedItemUtils class14_0)
{
int num = 0;
num = 0;
while (true)
{
if (num < listBox_0.Items.Count)
{
SelectedItemUtils @class = (SelectedItemUtils)listBox_0.Items[num];
if (class14_0.Value < @class.Value)
{
break;
}
num++;
continue;
}
return num;
}
return num;
}
public static void smethod_48(TreeNode treeNode_0, int int_0)
{
if (int_0 >= treeNode_0.Level)
{
treeNode_0.Expand();
foreach (TreeNode node in treeNode_0.Nodes)
{
Settings.smethod_48(node, int_0);
}
}
}
public static void smethod_49(TreeView treeView_0, int int_0)
{
foreach (TreeNode node in treeView_0.Nodes)
{
Settings.smethod_48(node, int_0);
}
}
public static bool smethod_50(TreeNode treeNode_0, string string_0)
{
if (string.IsNullOrEmpty(string_0))
{
return true;
}
foreach (TreeNode node in treeNode_0.Parent.Nodes)
{
if (node != treeNode_0 && node.Text.Trim() == string_0.Trim())
{
return true;
}
}
return false;
}
public static bool smethod_51(TreeNode treeNode_0, string string_0)
{
if (string.IsNullOrEmpty(string_0))
{
return true;
}
foreach (TreeNode node in treeNode_0.Nodes)
{
if (node.Text.Trim() == string_0.Trim())
{
return true;
}
}
return false;
}
public static void smethod_52(object sender, DataGridViewCellEventArgs e)
{
DataGridView dataGridView = sender as DataGridView;
string helpId = dataGridView.FindForm().Name + "_" + dataGridView.Columns[e.ColumnIndex].Name;
MainForm mainForm = Application.OpenForms[0] as MainForm;
if (mainForm != null)
{
mainForm.ShowHelp(helpId);
}
}
public static void smethod_53(object sender, KeyPressEventArgs e)
{
if (e.KeyChar >= '\0' && e.KeyChar <= '\u007f')
{
return;
}
if (e.KeyChar != '\b' && e.KeyChar != '.')
{
MessageBox.Show(Settings.dicCommon["KeyPressPrint"]);
e.Handled = true;
}
}
public static void smethod_54(object sender, KeyPressEventArgs e)
{
}
public static void smethod_55(object sender, KeyPressEventArgs e)
{
if (!char.IsControl(e.KeyChar))
{
NumberFormatInfo numberFormat = CultureInfo.CurrentCulture.NumberFormat;
if (e.KeyChar >= '0' && e.KeyChar <= '9')
{
return;
}
if (!numberFormat.NumberDecimalSeparator.Contains(e.KeyChar))
{
MessageBox.Show(string.Format(Settings.dicCommon["KeyPressDigit"], numberFormat.NumberDecimalSeparator));
e.Handled = true;
}
}
}
public static bool smethod_56(string string_0)
{
char[] array = string_0.ToCharArray();
int num = 0;
while (true)
{
if (num < array.Length)
{
char c = array[num];
if (c < '\0')
{
break;
}
if (c > '\u007f')
{
break;
}
num++;
continue;
}
return true;
}
return false;
}
public static void smethod_57(object sender, KeyPressEventArgs e)
{
if ("0123456789ABCD*#\b".IndexOf(char.ToUpper(e.KeyChar)) < 0 && e.KeyChar != '\b' && e.KeyChar != '.')
{
string str = Regex.Replace("0123456789ABCD*#\b", "[^\\dA-D\\*#]*", "");
MessageBox.Show(Settings.dicCommon["KeyPressDtmf"] + str);
e.Handled = true;
}
}
public static void smethod_58(object sender, KeyPressEventArgs e)
{
if ("0123456789ABCDEF".IndexOf(char.ToUpper(e.KeyChar)) < 0 && e.KeyChar != '\b' && e.KeyChar != '.')
{
MessageBox.Show("KeyPressHex0123456789ABCDEF");
e.Handled = true;
}
}
public static void smethod_59(Control.ControlCollection controlCollection_0)
{
foreach (Control item in controlCollection_0)
{
if (!(item is Button) && !(item is TextBox) && !(item is ListBox) && !(item is NumericUpDown) && !(item is ComboBox) && !(item is CheckBox))
{
if (item is DataGridView)
{
DataGridView dataGridView = item as DataGridView;
dataGridView.CellEnter += Settings.smethod_52;
}
else if (item.Controls.Count > 0)
{
Settings.smethod_59(item.Controls);
}
}
else
{
item.Enter += Settings.smethod_60;
}
}
}
public static void smethod_60(object sender, EventArgs e)
{
Control control = sender as Control;
string helpId = control.FindForm().Name + "_" + control.Name;
MainForm mainForm = Application.OpenForms[0] as MainForm;
if (mainForm != null)
{
mainForm.ShowHelp(helpId);
}
}
public static byte[] objectToByteArray(object object_0, int int_0)
{
byte[] array = new byte[int_0];
IntPtr intPtr = Marshal.AllocHGlobal(int_0);
Marshal.StructureToPtr(object_0, intPtr, false);
Marshal.Copy(intPtr, array, 0, int_0);
Marshal.FreeHGlobal(intPtr);
return array;
}
public static object smethod_62(byte[] byte_0, Type type_0)
{
int num = Marshal.SizeOf(type_0);
if (num > byte_0.Length)
{