public static bool TryParse(string input, out CoordinateUSNG usng) { CoordinateMGRS mgrs = new CoordinateMGRS(); usng = new CoordinateUSNG(mgrs.GZD, mgrs.GS, mgrs.Easting, mgrs.Northing); if (string.IsNullOrWhiteSpace(input)) return false; if (CoordinateMGRS.TryParse(input, out mgrs)) { usng = new CoordinateUSNG(mgrs.GZD, mgrs.GS, mgrs.Easting, mgrs.Northing); return true; } usng = null; return false; }
public static bool TryParse(string input, out CoordinateUSNG usng) { CoordinateMGRS mgrs = new CoordinateMGRS(); usng = new CoordinateUSNG(mgrs.GZD, mgrs.GS, mgrs.Easting, mgrs.Northing); if (string.IsNullOrWhiteSpace(input)) { return(false); } if (CoordinateMGRS.TryParse(input, out mgrs)) { usng = new CoordinateUSNG(mgrs.GZD, mgrs.GS, mgrs.Easting, mgrs.Northing); return(true); } usng = null; return(false); }
private void UpdateSample() { var type = GetCoordinateType(); switch(type) { case CoordinateType.DD: var dd = new CoordinateDD(); if (ctdict.ContainsKey(CoordinateType.DD)) { CoordinateDD.TryParse(ctdict[type], out dd); } Sample = dd.ToString(Format, new CoordinateDDFormatter()); break; case CoordinateType.DDM: var ddm = new CoordinateDDM(); if(ctdict.ContainsKey(type)) { CoordinateDDM.TryParse(ctdict[type], out ddm); } Sample = ddm.ToString(Format, new CoordinateDDMFormatter()); break; case CoordinateType.DMS: var dms = new CoordinateDMS(); if(ctdict.ContainsKey(type)) { CoordinateDMS.TryParse(ctdict[type], out dms); } Sample = dms.ToString(Format, new CoordinateDMSFormatter()); break; case CoordinateType.GARS: var gars = new CoordinateGARS(); if(ctdict.ContainsKey(type)) { CoordinateGARS.TryParse(ctdict[type], out gars); } Sample = gars.ToString(Format, new CoordinateGARSFormatter()); break; case CoordinateType.MGRS: var mgrs = new CoordinateMGRS(); if(ctdict.ContainsKey(type)) { CoordinateMGRS.TryParse(ctdict[type], out mgrs); } Sample = mgrs.ToString(Format, new CoordinateMGRSFormatter()); break; case CoordinateType.USNG: var usng = new CoordinateUSNG(); if(ctdict.ContainsKey(type)) { CoordinateUSNG.TryParse(ctdict[type], out usng); } Sample = usng.ToString(Format, new CoordinateMGRSFormatter()); break; case CoordinateType.UTM: var utm = new CoordinateUTM(); if(ctdict.ContainsKey(type)) { CoordinateUTM.TryParse(ctdict[type], out utm); } Sample = utm.ToString(Format, new CoordinateUTMFormatter()); break; default: break; } RaisePropertyChanged(() => Sample); }