/* * private bool _highlight; * public bool Highlight * { * get { return _highlight; } * set * { * if (_highlight != value) * { * _highlight = value; * // Send value to radio * RaisePropertyChanged("Highlight"); * } * } * } * * private Color _highlightColor; * public Color HighlightColor * { * get { return _highlightColor; } * set * { * if (_highlightColor != value) * { * _highlightColor = value; * // Send value to radio * RaisePropertyChanged("HighlightColor"); * } * } * } */ private string FMToneModeToString(FMToneMode mode) { string ret_val = ""; switch (mode) { case FMToneMode.Off: ret_val = "off"; break; case FMToneMode.CTCSS_TX: ret_val = "ctcss_tx"; break; } return(ret_val); }
private bool TryParseFMToneMode(string s, out FMToneMode mode) { bool ret_val = true; mode = FMToneMode.Off; // default out param switch (s.ToLower()) { case "off": mode = FMToneMode.Off; break; case "ctcss_tx": mode = FMToneMode.CTCSS_TX; break; default: ret_val = false; break; } return(ret_val); }
public void StatusUpdate(string s) { string[] words = s.Split(' '); foreach (string kv in words) { string[] tokens = kv.Split('='); if (tokens.Length != 2) { Debug.WriteLine("Memory::StatusUpdate: Invalid key/value pair (" + kv + ")"); continue; } string key = tokens[0]; string value = tokens[1]; switch (key.ToLower()) { case "owner": { _owner = value.Replace('\u007f', ' '); // convert back to spaces RaisePropertyChanged("Owner"); } break; case "group": { _group = value.Replace('\u007f', ' '); // convert back to spaces RaisePropertyChanged("Group"); } break; case "freq": { double temp; // in MHz bool b = StringHelper.DoubleTryParse(value, out temp); if (!b) { Debug.WriteLine("Memory::StatusUpdate: Invalid value (" + kv + ")"); continue; } _freq = temp; RaisePropertyChanged("Freq"); } break; case "name": { _name = value.Replace('\u007f', ' '); // convert back to spaces RaisePropertyChanged("Name"); } break; case "mode": { _mode = value; RaisePropertyChanged("Mode"); } break; case "step": { int temp; // in Hz bool b = int.TryParse(value, out temp); if (!b) { Debug.WriteLine("Memory::StatusUpdate: Invalid value (" + kv + ")"); continue; } _step = temp; RaisePropertyChanged("Step"); } break; case "repeater": { FMTXOffsetDirection dir; bool b = TryParseFMTXOffsetDirection(value, out dir); if (!b) { Debug.WriteLine("Memory::StatusUpdate: Invalid value (" + kv + ")"); continue; } _offsetDirection = dir; RaisePropertyChanged("OffsetDirection"); } break; case "repeater_offset": { double temp; // in MHz bool b = StringHelper.DoubleTryParse(value, out temp); if (!b) { Debug.WriteLine("Memory::StatusUpdate: Invalid value (" + kv + ")"); continue; } _repeaterOffset = temp; RaisePropertyChanged("RepeaterOffset"); } break; case "tone_mode": { FMToneMode mode; bool b = TryParseFMToneMode(value, out mode); if (!b) { Debug.WriteLine("Memory::StatusUpdate: Invalid value (" + kv + ")"); continue; } _toneMode = mode; RaisePropertyChanged("ToneMode"); } break; case "tone_value": { _toneValue = value; RaisePropertyChanged("ToneValue"); } break; case "squelch": { byte temp; bool b = byte.TryParse(value, out temp); if (!b || temp > 1) { Debug.WriteLine("Memory::StatusUpdate: Invalid value (" + kv + ")"); continue; } _squelchOn = Convert.ToBoolean(temp); RaisePropertyChanged("SquelchOn"); } break; case "squelch_level": { int temp; bool b = int.TryParse(value, out temp); if (!b) { Debug.WriteLine("Memory::StatusUpdate: Invalid value (" + kv + ")"); continue; } _squelchLevel = temp; RaisePropertyChanged("SquelchLevel"); } break; case "power": { int temp; bool b = int.TryParse(value, out temp); if (!b) { Debug.WriteLine("Memory::StatusUpdate: Invalid value (" + kv + ")"); continue; } _rfPower = temp; RaisePropertyChanged("RFPower"); } break; case "rx_filter_low": { int temp; // in Hz bool b = int.TryParse(value, out temp); if (!b) { Debug.WriteLine("Memory::StatusUpdate: Invalid value (" + kv + ")"); continue; } _rxFilterLow = temp; RaisePropertyChanged("RXFilterLow"); } break; case "rx_filter_high": { int temp; bool b = int.TryParse(value, out temp); if (!b) { Debug.WriteLine("Memory::StatusUpdate: Invalid value (" + kv + ")"); continue; } _rxFilterHigh = temp; RaisePropertyChanged("RXFilterHigh"); } break; case "rtty_mark": { int temp; bool b = int.TryParse(value, out temp); if (!b) { Debug.WriteLine("Memory::StatusUpdate: Invalid value (" + kv + ")"); continue; } _rttyMark = temp; RaisePropertyChanged("RTTYMark"); } break; case "rtty_shift": { int temp; bool b = int.TryParse(value, out temp); if (!b) { Debug.WriteLine("Memory::StatusUpdate: Invalid value (" + kv + ")"); continue; } _rttyShift = temp; RaisePropertyChanged("RTTYShift"); } break; case "digl_offset": { int temp; bool b = int.TryParse(value, out temp); if (!b) { Debug.WriteLine("Memory::StatusUpdate: Invalid value (" + kv + ")"); continue; } _diglOffset = temp; RaisePropertyChanged("DIGLOffset"); } break; case "digu_offset": { int temp; bool b = int.TryParse(value, out temp); if (!b) { Debug.WriteLine("Memory::StatusUpdate: Invalid value (" + kv + ")"); continue; } _diguOffset = temp; RaisePropertyChanged("DIGUOffset"); } break; case "highlight": case "highlight_color": // keep these from showing up in the debug output break; default: Debug.WriteLine("Memory::StatusUpdate: Key not parsed (" + kv + ")"); break; } } if (!_radioAck) { RadioAck = true; } }