HamBook – Blame information for rev 16

Subversion Repositories:
Rev:
Rev Author Line No. Line
15 office 1 using Org.BouncyCastle.Crypto.Tls;
2 using System;
3 using System.Collections.Generic;
4 using System.Linq;
5 using System.Text;
6 using System.Threading.Tasks;
7  
8 namespace HamBook.Radios.Generic
9 {
10 public class MemoryRadioMode
11 {
16 office 12 public char Mode { get; set; }
15 office 13  
16 office 14 public MemoryRadioMode(string mode) : this()
15 office 15 {
16 Mode = Parse(mode);
17 }
18  
16 office 19 public MemoryRadioMode(char mode) : this()
15 office 20 {
21 Mode = Parse(mode);
22 }
23  
16 office 24 public MemoryRadioMode()
25 {
26  
27 }
28  
15 office 29 public static bool TryParse(string mode, out MemoryRadioMode memoryRadioMode)
30 {
31 switch (mode)
32 {
33  
34 case "LSB":
35 case "USB":
36 case "CW":
37 case "FM":
38 case "AM":
39 case "RTTY-LSB":
40 case "CW-R":
41 case "DATA-LSB":
42 case "RTTY-USB":
43 case "FM-N":
44 case "DATA-USB":
45 case "AM-N":
46 memoryRadioMode = new MemoryRadioMode(mode);
47 return true;
48 default:
49 memoryRadioMode = null;
50 return false;
51 }
52 }
53  
54 public static bool TryParse(char mode, out MemoryRadioMode memoryRadioMode)
55 {
56 switch (mode)
57 {
58 case '1':
59 case '2':
60 case '3':
61 case '4':
62 case '5':
63 case '6':
64 case '7':
65 case '8':
66 case '9':
67 case 'B':
68 case 'C':
69 case 'D':
70 memoryRadioMode = new MemoryRadioMode(mode);
71 return true;
72 default:
73 memoryRadioMode = null;
74 return false;
75 }
76 }
77  
78 private char Parse(string mode)
79 {
80 switch (mode)
81 {
82 case "LSB":
83 return '1';
84 case "USB":
85 return '2';
86 case "CW":
87 return '3';
88 case "FM":
89 return '4';
90 case "AM":
91 return '5';
92 case "RTTY-LSB":
93 return '6';
94 case "CW-R":
95 return '7';
96 case "DATA-LSB":
97 return '8';
98 case "RTTY-USB":
99 return '9';
100 case "FM-N":
101 return 'B';
102 case "DATA-USB":
103 return 'C';
104 case "AM-N":
105 return 'D';
106 default:
107 throw new ArgumentException();
108 }
109 }
110  
111 private char Parse(char mode)
112 {
113 switch (mode)
114 {
115 case '1':
116 case '2':
117 case '3':
118 case '4':
119 case '5':
120 case '6':
121 case '7':
122 case '8':
123 case '9':
124 case 'B':
125 case 'C':
126 case 'D':
127 return mode;
128 default:
129 throw new ArgumentException();
130 }
131 }
132  
133 public static implicit operator MemoryRadioMode(string mode)
134 {
135 return new MemoryRadioMode(mode);
136 }
137  
138 public static implicit operator string(MemoryRadioMode memoryRadioMode)
139 {
140 switch (memoryRadioMode.Mode)
141 {
142 case '1':
143 return "LSB";
144 case '2':
145 return "USB";
146 case '3':
147 return "CW";
148 case '4':
149 return "FM";
150 case '5':
151 return "AM";
152 case '6':
153 return "RTTY-USB";
154 case '7':
155 return "CW-R";
156 case '8':
157 return "DATA-LSB";
158 case '9':
159 return "RTTY-USB";
160 case 'B':
161 return "FM-N";
162 case 'C':
163 return "DATA-USB";
164 case 'D':
165 return "AM-N";
166 default:
167 throw new ArgumentException();
168 }
169 }
170  
171 public static implicit operator MemoryRadioMode(char mode)
172 {
173 return new MemoryRadioMode(mode);
174 }
175  
176 public static implicit operator char(MemoryRadioMode memoryRadioMode)
177 {
178 return memoryRadioMode.Mode;
179 }
180 }
181 }