/// <summary>Gibt einen CADdy formatierten String zurück</summary> /// <param name="settings"></param> /// <returns></returns> public String getCADdyFormatString(Settings settings) { String result = new String(' ', 255); String temp = ClassStringTools.lSetFull(_punktnummer, settings.PointName_Length, " "); ClassStringTools.overrideSubStr(ref result, temp, settings.PointName_Start - 1, settings.PointName_Length); temp = ClassStringTools.rSetFull(ClassConverters.ToString(this._rechtswert, settings.Decimalseperator, "", settings.Koord_RW_E_Decimals, settings.Koord_RW_E_Decimals, false), settings.Koord_RW_E_Length, " "); ClassStringTools.overrideSubStr(ref result, temp, settings.Koord_RW_E_Start - 1, settings.Koord_RW_E_Length); temp = ClassStringTools.rSetFull(ClassConverters.ToString(this._hochwert, settings.Decimalseperator, "", settings.Koord_HW_N_Decimals, settings.Koord_HW_N_Decimals, false), settings.Koord_HW_N_Length, " "); ClassStringTools.overrideSubStr(ref result, temp, settings.Koord_HW_N_Start - 1, settings.Koord_HW_N_Length); temp = ClassStringTools.rSetFull(ClassConverters.ToString(this._hoehe, settings.Decimalseperator, "", settings.Koord_Elev_Decimals, settings.Koord_Elev_Decimals, false), settings.Koord_Elev_Length, " "); ClassStringTools.overrideSubStr(ref result, temp, settings.Koord_Elev_Start - 1, settings.Koord_Elev_Length); temp = ClassStringTools.lSetFull(_code, settings.Koord_Code_Length, " "); ClassStringTools.overrideSubStr(ref result, temp, settings.Koord_Code_Start - 1, settings.Koord_Code_Length); if (!ClassStringTools.IsNullOrWhiteSpace(_bemerkung)) { temp = ClassStringTools.lSetFull(_bemerkung, settings.Koord_Descript_Length, " "); ClassStringTools.overrideSubStr(ref result, temp, settings.Koord_Descript_Start - 1, settings.Koord_Descript_Length); } return(result.TrimEnd(' ')); }
/// <summary>Setzt den vorhanden Code auf den angegebenen Code</summary> /// <param name="oldCode"></param> /// <param name="newCode"></param> /// <returns>true = es wurde mind. ein Code geändert</returns> public Boolean setOldCodeToNewCode(String oldCode, String newCode) { Boolean allPoints = false; Boolean hasAnyChanged = false; if (ClassStringTools.IsNullOrWhiteSpace(oldCode)) { oldCode = "*"; } if (!ClassStringTools.IsNullOrWhiteSpace(newCode)) { ClassRegexTools regexT = null; if (oldCode == "*") { allPoints = true; } else { regexT = new ClassRegexTools(oldCode); } foreach (ClassCADdyPunkt item in Punkte) { if (allPoints || regexT.isMatch(item.Code)) { item.Code = newCode; hasAnyChanged = true; } } } return(hasAnyChanged); }
/// <summary>Gibt einen CADdy formatierten String zurück</summary> /// <param name="settings"></param> /// <returns></returns> public String getCADdyFormatString(Settings settings) { String result = new String(' ', 255); String temp = ClassStringTools.lSetFull(Zielpunkt, settings.PointName_Length, " "); ClassStringTools.overrideSubStr(ref result, temp, settings.PointName_Start - 1, settings.PointName_Length); temp = ClassStringTools.rSetFull(ClassConverters.ToString(this.Hz, settings.Decimalseperator, "", settings.Messd_Hz_Decimals, settings.Messd_Hz_Decimals, false), settings.Messd_Hz_Length, " "); ClassStringTools.overrideSubStr(ref result, temp, settings.Messd_Hz_Start - 1, settings.Messd_Hz_Length); temp = ClassStringTools.rSetFull(ClassConverters.ToString(this.S, settings.Decimalseperator, "", settings.Messd_S_Decimals, settings.Messd_S_Decimals, false), settings.Messd_S_Length, " "); ClassStringTools.overrideSubStr(ref result, temp, settings.Messd_S_Start - 1, settings.Messd_S_Length); temp = ClassStringTools.rSetFull(ClassConverters.ToString(this.V, settings.Decimalseperator, "", settings.Messd_V_Decimals, settings.Messd_V_Decimals, false), settings.Messd_V_Length, " "); ClassStringTools.overrideSubStr(ref result, temp, settings.Messd_V_Start - 1, settings.Messd_V_Length); temp = ClassStringTools.rSetFull(ClassConverters.ToString(this.D, settings.Decimalseperator, "", settings.Messd_D_Decimals, settings.Messd_D_Decimals, false), settings.Messd_D_Length, " "); ClassStringTools.overrideSubStr(ref result, temp, settings.Messd_D_Start - 1, settings.Messd_D_Length); temp = ClassStringTools.lSetFull(Code, settings.Messd_Code_Length, " "); ClassStringTools.overrideSubStr(ref result, temp, settings.Messd_Code_Start - 1, settings.Messd_Code_Length); if (!ClassStringTools.IsNullOrWhiteSpace(Bemerkung)) { temp = ClassStringTools.lSetFull(Bemerkung, settings.Messd_Descript_Length, " "); ClassStringTools.overrideSubStr(ref result, temp, settings.Messd_Descript_Start - 1, settings.Messd_Descript_Length); } return(result.TrimEnd(' ')); }
/// <summary>Trennt die Punkte aus dem angegebenen Text</summary> /// <param name="settings"></param> /// <param name="editor"></param> public void getPointsFromEditor(Settings settings, IScintillaGateway editor) { punkte.Clear(); if (editor != null) { Int32 countLines = editor.GetLineCount(); for (Int32 lc = 0; lc < countLines; lc++) { String cuLine = editor.GetLine(lc); // Auch Excel Splitbar machen ;-) cuLine = cuLine.Replace('\t', ' '); // Tab durch Leerzeichen ersetzten cuLine = cuLine.Replace(',', settings.Decimalseperator[0]); // , durch . ersetzten String[] split = ClassStringTools.GetFieldsManyDelimiters(cuLine, ' ', true); if (split != null) { if (split.Length >= 4) // mind PNR R H E { ClassCADdyPunkt newPoint = new ClassCADdyPunkt(); { newPoint.Punktnummer = ClassStringTools.trimToEmpty(split[settings.PointName_Column - 1]); if (settings.PointName_ToUpper) { newPoint.Punktnummer = newPoint.Punktnummer.ToUpper(); } if (!ClassStringTools.IsNullOrWhiteSpace(newPoint.Punktnummer)) { Double temp = Double.NaN; if (ClassConverters.StringToDouble(split[settings.Koord_RW_E_Column - 1], out temp)) { newPoint.Rechtswert = temp; if (ClassConverters.StringToDouble(split[settings.Koord_HW_N_Column - 1], out temp)) { newPoint.Hochwert = temp; if (ClassConverters.StringToDouble(split[settings.Koord_Elev_Column - 1], out temp)) { newPoint.Hoehe = temp; newPoint.LineNumber = lc; if (split.Length >= 5) { // code newPoint.Code = ClassStringTools.trimToEmpty(split[settings.Koord_Code_Column - 1]); if (split.Length >= 6) { // code newPoint.Bemerkung = ClassStringTools.trimToEmpty(split[settings.Koord_Descript_Column - 1]); } } punkte.Add(newPoint); } } } } } } } } } hasPunkte = punkte.Count > 0; }
/// <summary>Setzt die Punktnummern auf den angegebenen Code</summary> /// <param name="pointnumber"></param> /// <param name="newCode"></param> /// <returns>true = es wurde mind. ein Code geändert</returns> public Boolean setPointNumberToCode(String pointnumber, String newCode) { Boolean allPoints = false; Boolean hasAnyChanged = false; if (ClassStringTools.IsNullOrWhiteSpace(pointnumber)) { pointnumber = "*"; } if (!ClassStringTools.IsNullOrWhiteSpace(newCode)) { IScintillaGateway editor = new ScintillaGateway(PluginBase.GetCurrentScintilla()); int sLnrStart = -1; int sLnrEnd = -1; if (editor != null) { sLnrStart = editor.LineFromPosition(editor.GetSelectionStart()); sLnrEnd = editor.LineFromPosition(editor.GetSelectionEnd()); if (editor.GetColumn(editor.GetSelectionEnd()) < 2) { sLnrEnd--; } } ClassRegexTools regexT = null; if (pointnumber == "*") { allPoints = true; } else { regexT = new ClassRegexTools(pointnumber); } foreach (ClassCADdyPunkt item in Punkte) { if (allPoints || regexT.isMatch(item.Punktnummer)) { if ((sLnrStart >= 0) && (sLnrEnd >= 0)) { if ((item.LineNumber >= sLnrStart) && (item.LineNumber <= sLnrEnd)) { item.Code = newCode; hasAnyChanged = true; } } else { item.Code = newCode; hasAnyChanged = true; } } } } return(hasAnyChanged); }
/// <summary>Gibt einen EXCELFormatiertenString zurück</summary> /// <returns></returns> public String getExcelFormatString() { String result = Punktnummer + "\t\t\t\t"; result += ClassConverters.ToString(this.I, ",", "") + "\t"; result += Code + "\t"; if (!ClassStringTools.IsNullOrWhiteSpace(Bemerkung)) { result += Bemerkung; } return(result); }
/// <summary>Gibt einen EXCELFormatiertenString zurück</summary> /// <returns></returns> public String getExcelFormatString() { String result = _punktnummer + "\t"; result += ClassConverters.ToString(this._rechtswert, ",", "") + "\t"; result += ClassConverters.ToString(this._hochwert, ",", "") + "\t"; result += ClassConverters.ToString(this._hoehe, ",", "") + "\t"; result += _code + "\t"; if (!ClassStringTools.IsNullOrWhiteSpace(_bemerkung)) { result += _bemerkung; } return(result); }
/// <summary>Gibt eine unsortierte Liste der Codes zurück</summary> /// <returns></returns> public List <String> getDestinctCodes() { List <String> result = new List <String>(); foreach (ClassCADdyPunkt item in Punkte) { if (!ClassStringTools.IsNullOrWhiteSpace(item.Code)) { if (!result.Contains(item.Code)) { result.Add(item.Code); } } } return(result); }
/// <summary>Setzt die Punktnummern auf den angegebenen Code</summary> /// <param name="pointnumber"></param> /// <param name="i_d"></param> /// <returns>true = es wurde mind. ein Code geändert</returns> public Boolean setPointNumberToIDe(String pointnumber, Double i_d) { Boolean allPoints = false; Boolean hasAnyChanged = false; if (ClassStringTools.IsNullOrWhiteSpace(pointnumber)) { pointnumber = "*"; } if (!Double.IsNaN(i_d)) { ClassRegexTools regexT = null; if (pointnumber == "*") { allPoints = true; } else { regexT = new ClassRegexTools(pointnumber); } foreach (ClassCADdyStandpunkt item in standpunkte) { if (allPoints || regexT.isMatch(item.Punktnummer.Substring(1))) { item.I = i_d; hasAnyChanged = true; } foreach (ClassCADdyZielung ziel in item.Zielungen) { if (allPoints || regexT.isMatch(ziel.Zielpunkt)) { ziel.D = i_d; hasAnyChanged = true; } } } } return(hasAnyChanged); }
/// <summary>Die aktuellen Punktnummern und Codes auslesen</summary> public void readCuDatas() { cbListSrc.Items.Clear(); cbListDest.Items.Clear(); List <String> fileNames = ClassNPPTools.getOpenFileNames(); if ((fileNames != null) && (fileNames.Count > 0)) { if (fileNames.Count > 1) { if (fileNames[fileNames.Count - 1].ToLower().Equals("new 1")) { fileNames.RemoveAt(fileNames.Count - 1); } } cbListSrc.Items.AddRange(fileNames.ToArray()); cbListDest.Items.AddRange(fileNames.ToArray()); } if ((fileNames.Count == 2) && (ClassStringTools.IsNullOrWhiteSpace(cbListSrc.Text)) && ClassStringTools.IsNullOrWhiteSpace(cbListDest.Text)) { cbListSrc.SelectedIndex = 0; cbListDest.SelectedIndex = 1; } else { if ((!ClassStringTools.IsNullOrWhiteSpace(cbListSrc.Text)) && (!fileNames.Contains(cbListSrc.Text))) { cbListSrc.Text = ""; resetTransform(); } if ((!ClassStringTools.IsNullOrWhiteSpace(cbListDest.Text)) && (!fileNames.Contains(cbListDest.Text))) { cbListDest.Text = ""; resetTransform(); } } }
/// <summary>Trennt die Punkte aus dem Aktuellem Text</summary> /// <param name="settings"></param> public void getMeasuresFromCurrentCADdy(Settings settings) { IScintillaGateway editor = new ScintillaGateway(PluginBase.GetCurrentScintilla()); standpunkte.Clear(); if (editor != null) { Int32 countLines = editor.GetLineCount(); ClassCADdyStandpunkt cuStandpunkt = null; for (Int32 lc = 0; lc < countLines; lc++) { String cuLine = editor.GetLine(lc); // Auch Excel Splitbar machen ;-) cuLine = cuLine.Replace('\t', ' '); // Tab durch Leerzeichen ersetzten cuLine = cuLine.Replace(',', settings.Decimalseperator[0]); // , durch . ersetzten String[] split = ClassStringTools.GetFieldsManyDelimiters(cuLine, ' ', true); if (split != null) { if ((4 >= split.Length) && (split.Length >= 3)) // Standpunkt { if (split[0].StartsWith("-")) { if (cuStandpunkt != null) { standpunkte.Add(cuStandpunkt); } cuStandpunkt = new ClassCADdyStandpunkt(); cuStandpunkt.LineNumber = lc; cuStandpunkt.Punktnummer = ClassStringTools.trimToEmpty(split[settings.PointName_Column - 1]); if (settings.PointName_ToUpper) { cuStandpunkt.Punktnummer = cuStandpunkt.Punktnummer.ToUpper(); } Double temp = Double.NaN; if (ClassConverters.StringToDouble(split[settings.Messd_I_Column - 1], out temp)) { cuStandpunkt.I = temp; // code cuStandpunkt.Code = ClassStringTools.trimToEmpty(split[settings.Messd_STPKCode_Column - 1]); if (split.Length == 4) { // code cuStandpunkt.Bemerkung = ClassStringTools.trimToEmpty(split[settings.Messd_STPKDescript_Column - 1]); } } } } if (split.Length >= 5) // = Zielpunkt { if (cuStandpunkt != null) { ClassCADdyZielung zielung = new ClassCADdyZielung(); { zielung.Zielpunkt = ClassStringTools.trimToEmpty(split[settings.PointName_Column - 1]); if (settings.PointName_ToUpper) { zielung.Zielpunkt = zielung.Zielpunkt.ToUpper(); } if (!ClassStringTools.IsNullOrWhiteSpace(zielung.Zielpunkt)) { Double temp = Double.NaN; if (ClassConverters.StringToDouble(split[settings.Messd_Hz_Column - 1], out temp)) { zielung.Hz = temp; if (ClassConverters.StringToDouble(split[settings.Messd_S_Column - 1], out temp)) { zielung.S = temp; if (ClassConverters.StringToDouble(split[settings.Messd_V_Column - 1], out temp)) { zielung.V = temp; if (ClassConverters.StringToDouble(split[settings.Messd_D_Column - 1], out temp)) { zielung.D = temp; if (split.Length >= 6) { // code zielung.Code = ClassStringTools.trimToEmpty(split[settings.Messd_Code_Column - 1]); if (split.Length >= 7) { // Beschreibung zielung.Bemerkung = ClassStringTools.trimToEmpty(split[settings.Messd_Descript_Column - 1]); } } } zielung.LineNumber = lc; cuStandpunkt.Zielungen.Add(zielung); } } } } } } } } } // den letzten nicht vergessen if (cuStandpunkt != null) { standpunkte.Add(cuStandpunkt); } } hasMessdaten = standpunkte.Count > 0; }