private void button_gaussToLonlat_Click(object sender, EventArgs e) { var strs = this.richTextBoxControl_gauss.Lines; var inputs = new List <XY>(); foreach (string item in strs) { if (String.IsNullOrWhiteSpace(item)) { continue; } inputs.Add(XY.Parse(item)); } var results = new List <LonLat>(); foreach (var item in inputs) { var longlat = Coordinates.CoordTransformer.GaussXyToLonLat(item, AveGeoHeight, BeltWidth3Or6, OrinalLonDeg, YConst, Ellipsoid, AngleUnit); results.Add(longlat); } var spliter = IsOutSplitByTab? "\t":", "; StringBuilder sb = new StringBuilder(); foreach (var item in results) { sb.AppendLine(item.ToString("0.0000000000", spliter)); } this.richTextBoxControl_lonlat.Text = sb.ToString(); }
public static (int depth, XY targetLocation) GetInput() { var input = InputResources.Day22Input.Split(Environment.NewLine); var depthInput = input[0].Split(':').Last().Trim(); var targetLocationInput = input[1].Split(':').Last().Trim(); var depth = int.Parse(depthInput); var targetLocation = XY.Parse(targetLocationInput, ','); return(depth, targetLocation); }
private List <XY> GetXys(TextBoxBase TextBoxBase) { List <XY> xys = new List <XY>(); foreach (var item in TextBoxBase.Lines) { if (item == null || String.IsNullOrWhiteSpace(item.Trim())) { continue; } xys.Add(XY.Parse(item)); } return(xys); }
/// <summary> /// 获取值 /// </summary> /// <returns></returns> public XY GetXy() { return(XY.Parse(this.GetValue())); }
private static void CastToType(Type type, string text, out object result) { try { if (type == typeof(byte)) { result = byte.Parse(text); return; } if (type == typeof(int)) { result = int.Parse(text); return; } if (type == typeof(ushort)) { result = ushort.Parse(text); return; } if (type == typeof(bool)) { result = bool.Parse(text); return; } if (type == typeof(float)) { result = float.Parse(text); return; } if (type == typeof(string)) { if (!string.IsNullOrEmpty(text) && !string.IsNullOrWhiteSpace(text)) { result = text; return; } } if (type == typeof(XY)) { result = XY.Parse(text); return; } if (type == typeof(short)) { result = short.Parse(text); return; } result = null; } catch (FormatException) { result = null; MessageBox.Show(GlobalStrings.Rule_NotProperFormat + type, GlobalStrings.Error, MessageBoxButton.OK, MessageBoxImage.Error); } catch (OverflowException) { result = null; MessageBox.Show(GlobalStrings.Rule_ValueNotInRange + type, GlobalStrings.Error, MessageBoxButton.OK, MessageBoxImage.Error); } }
public static XY[] GetInput() => InputResources.Day6Input .Split(Environment.NewLine) .Select(xy => XY.Parse(xy, ',')) .ToArray();
.Select(i => new Light(XY.Parse(i.positionInput, ','), XY.Parse(i.velocityInput, ','))) .ToArray();