private void cboRoom_SelectedIndexChanged(object sender, EventArgs e) { if (loading) { return; } lstLines.Items.Clear(); txtLine.Text = ""; int room = cboRoom.SelectedIndex; int lines = TextMain.GetNumLines(room); loading2 = true; for (int i = 0; i < lines; i++) { string str = "[" + i.ToString("X3") + "] " + TextMain.GetLine(room, i).Replace(Environment.NewLine, ""); if (str.Length > 500) { lstLines.Items.Add(str.Substring(0, 500) + " [...]"); } else { lstLines.Items.Add(str); } } loading2 = false; if (lines > 0) { lstLines.SelectedIndex = 0; } }
private void lstLines_SelectedIndexChanged(object sender, EventArgs e) { if (loading2) { return; } txtLine.Text = TextMain.GetLine(cboRoom.SelectedIndex, lstLines.SelectedIndex); }
/// <summary> /// 添加状态信息 /// </summary> /// <param name="str"></param> private void AddContent(string str) { if (TextMain.InvokeRequired) { AddContentDelegate d = new AddContentDelegate(AddContent); TextMain.Invoke(d, new object[] { str }); } else { string Update_Date = DateTime.Now.Year + "-" + DateTime.Now.Month + "-" + DateTime.Now.Day; string Update_Time = string.Format("{0:00}:{1:00}:{2:00}.{3:0000}", DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second, DateTime.Now.Millisecond); TextMain.AppendText("【" + Update_Date + " " + Update_Time + "】 " + str + Environment.NewLine); TextMain.ScrollToCaret(); } }