public static void Write(string strInfo) { if (TextBoxLog == null) { return; } if (string.IsNullOrEmpty(strInfo)) { return; } //if (InfoDockContainerItem == null) // return; //InfoDockContainerItem.Selected = true; string strNewLine = ""; if (TextBoxLog.Text.Length > 0) { strNewLine = Environment.NewLine; } if (TextBoxLog.InvokeRequired) { AppendMessage appendMsg = delegate(string msg) { Write(msg); }; TextBoxLog.Invoke(appendMsg, new object[] { strInfo }); } else { try { string strPrefix = ""; if (OutputTime) { strPrefix = DateTime.Now.ToString("HH:mm:ss") + " "; } XStrings xstrsInfoLines = strInfo.Split('\n'); for (int i = 1; i < xstrsInfoLines.Count; i++) { xstrsInfoLines[i] = string.Empty.PadLeft(strPrefix.Length) + xstrsInfoLines[i]; } TextBoxLog.AppendText(strNewLine + strPrefix + xstrsInfoLines.ToLongString(false)); TextBoxLog.ScrollToCaret(); } catch (Exception) { // 当窗体先退出时将发生此异常 XLog.TextBoxLog = null; return; } } }
public static XStrings operator +(XStrings xstr1, XStrings xstr2) { XStrings xstrNew = new XStrings(); xstrNew.AddRange(xstr1); xstrNew.AddRange(xstr2); return(xstrNew); }
/// <summary> /// 添加字符串到XStrings末尾。注意+=操作比Add方法效率稍低 /// </summary> public static XStrings operator +(XStrings xstrs, string strNew) { XStrings xstrResult = new XStrings(); xstrResult += xstrs; xstrResult.Add(strNew); return(xstrResult); }
public XStrings SubStrings(int iStart, int length) { XStrings xStrs = new XStrings(); for (int i = 0; i < length; i++) { xStrs.Add(this[iStart + i]); } return(xStrs); }