/// <summary> /// 高亮文本内容(已弃用,后期可考虑做搜索功能) /// </summary> /// <param name="length"></param> private void UIConsoleHighlight(int length) { try { Invoke(new Action(() => { //高亮关键字 string[] keywords = null; if (ListTool.HasElements(keywords)) { foreach (var key in keywords) { if (!StringTool.Ok(key)) { continue; //不正常关键字跳出 } int start = ConsoleLength - length; while ((start = RTBConsole.Text.IndexOf(key, start)) >= 0) { RTBConsole.Select(start, key.Length); RTBConsole.SelectionBackColor = Color.Yellow; start++; } } } })); } catch { } }
private void RTBConsole_TextChanged(object sender, TextChangedEventArgs e) { RTBConsole.ScrollToEnd(); if (RTBConsole.Document.Blocks.Count > 1000) { RTBConsole.Document.Blocks.Clear(); } }
private void UIConsoleCut() { if (ConsoleLength > MaxLength) { try { Invoke(new Action(() => { RTBConsole.Text = RTBConsole.Text.Substring(RTBConsole.TextLength / 2); //截断文本内容 ConsoleLength = RTBConsole.TextLength; //更新文本长度 RTBConsole.ScrollToCaret(); //滚动到底部 UICaption(Caption); //更新标题,带文本长度提示 })); } catch { } } }
/// <summary> /// 添加文本内容 /// </summary> /// <param name="s"></param> private void UIConsole(string s) { try { Invoke(new Action(() => { if (!CBNotWrite.Checked) { ConsoleLength += s.Length; //更新文本长度 UICaption(Caption); //更新标题,带文本长度提示 RTBConsole.AppendText(s); //追加内容到文本框 RTBConsole.ScrollToCaret(); //滚动到底部 } })); } catch { } }
public void WriteToBox(string message) { RTBConsole.AppendText("\r" + message); }
private void RTBConsole_KeyUp(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { RTBConsole.Text += "\n>>"; RTBConsole.Select(RTBConsole.Text.Length, RTBConsole.Text.Length); } if (e.KeyCode == Keys.F5) { //Core_Unit_Ref.Main = new Project("Car Expert unit"); Core_Unit_Ref.ErrorDGV = new DataGridView(); Core_Unit_Ref.Main.ErrorExplorerRef = Core_Unit_Ref.ErrorDGV; Core_Unit_Ref.Main.TExtRef = RTBConsole; string[] Data = RTBConsole.Text.Split('\n'); for (int i = Core_Unit_Ref.LineIndex; i < Data.Length; i++) { if (Data[i].Length > 2 && Data[i][0] == '>' && Data[i][1] == '>') { Data[i] = Data[i].Substring(2, Data[i].Length - 2); } else { Data[i] = ""; } } Node Root = new Node(); Root.NodeKind = "Main"; Root.isInitial = true; Root.Value = "."; Core_Unit_Ref.Main.ASTDrawRoot = new Node(); Core_Unit_Ref.Main.ASTDrawRoot.NodeKind = "Main"; Core_Unit_Ref.Main.ASTDrawRoot.isInitial = true; foreach (ES_Lib.Rule R in Core_Unit_Ref.System_Rules) { Core_Unit_Ref.Main.Rules.Add(R); } foreach (Fact F in Core_Unit_Ref.System_Facts) { Core_Unit_Ref.Main.Facts.Add(F); } Core_Unit_Ref.Main.RuleCount = Core_Unit_Ref.RuleCount; for (int i = Core_Unit_Ref.LineIndex; i < Data.Length; i++) { if (Data[i] != "" && Data[i] != ">>") { Core_Unit_Ref.Main.GET_AST(Data[i], i + 1); Node Temp = new Node(); Root.NodeKind = "Main"; Temp.nextstates.Add(Core_Unit_Ref.Main.ParseRoot); Core_Unit_Ref.Main.RUN(Temp, 0); Root.nextstates.Add(Core_Unit_Ref.Main.ParseRoot); Core_Unit_Ref.Main.ASTDrawRoot.nextstates.Add(Core_Unit_Ref.Main.ParseRoot); Core_Unit_Ref.Main.DoChaining(); } } Core_Unit_Ref.RuleCount += Core_Unit_Ref.Main.RuleCount - Core_Unit_Ref.RuleCount; Core_Unit_Ref.System_Rules = new System.Collections.ArrayList(); Core_Unit_Ref.System_Facts = new System.Collections.ArrayList(); foreach (ES_Lib.Rule R in Core_Unit_Ref.Main.Rules) { Core_Unit_Ref.System_Rules.Add(R); } foreach (Fact F in Core_Unit_Ref.Main.Facts) { Core_Unit_Ref.System_Facts.Add(F); } Core_Unit_Ref.Main.ParseRoot = Root; Data = RTBConsole.Text.Split('\n'); Core_Unit_Ref.LineIndex = Data.Length; RTBConsole.Text += "\n>>"; RTBConsole.Select(RTBConsole.Text.Length, RTBConsole.Text.Length); } }