HamBook – Blame information for rev

Subversion Repositories:
Rev:
Rev Author Line No. Line
3 office 1 using System;
2 using System.Collections.Generic;
15 office 3 using System.ComponentModel;
3 office 4 using System.Linq;
5 using System.Text;
6 using System.Threading.Tasks;
7  
8 namespace HamBook.Radios.Generic
9 {
15 office 10 public class CtcssMode
3 office 11 {
16 office 12 public int Mode { get; set; }
15 office 13  
16 office 14 public CtcssMode(string mode) : this()
15 office 15 {
16 Mode = Parse(mode);
17 }
18  
16 office 19 public CtcssMode(int mode) : this()
15 office 20 {
21 Mode = Parse(mode);
22 }
23  
16 office 24 public CtcssMode()
25 {
26  
27 }
28  
15 office 29 public static bool TryParse(string mode, out CtcssMode ctcssMode)
30 {
31 switch (mode)
32 {
33 case "Off":
34 case "Enc/Dec":
35 case "Enc":
36 ctcssMode = new CtcssMode(mode);
37 return true;
38 default:
39 ctcssMode = null;
40 return false;
41 }
42 }
43  
44 public static bool TryParse(int mode, out CtcssMode ctcssMode)
45 {
46 switch (mode)
47 {
48 case 0:
49 case 1:
50 case 2:
51 ctcssMode = new CtcssMode(mode);
52 return true;
53 default:
54 ctcssMode = null;
55 return false;
56 }
57 }
58  
59 private int Parse(string mode)
60 {
61 switch (mode)
62 {
63 case "Off":
64 return 0;
65 case "Enc/Dec":
66 return 1;
67 case "Enc":
68 return 2;
69 default:
70 throw new ArgumentException();
71 }
72 }
73  
74 private int Parse(int mode)
75 {
76 switch (mode)
77 {
78 case 0:
79 case 1:
80 case 2:
81 return mode;
82 default:
83 throw new ArgumentException();
84 }
85 }
86  
87 public static implicit operator CtcssMode(string mode)
88 {
89 return new CtcssMode(mode);
90 }
91  
92 public static implicit operator string(CtcssMode ctcssMode)
93 {
94 switch (ctcssMode.Mode)
95 {
96 case 0:
97 return "Off";
98 case 1:
99 return "Enc/Dec";
100 case 2:
101 return "Enc";
102 default:
103 throw new ArgumentException();
104 }
105 }
106  
107 public static implicit operator CtcssMode(int mode)
108 {
109 return new CtcssMode(mode);
110 }
111  
112 public static implicit operator int(CtcssMode ctcssMode)
113 {
114 return ctcssMode.Mode;
115 }
3 office 116 }
117 }