private void DrawBorders(System.Windows.Media.DrawingContext dc) { dc.PushClip(new RectangleGeometry(new Rect(0, 0, Width, Height))); int lineNumber = StartLine; if (lineNumber > 0) { lineNumber--; } while (lineNumber > 0 && !REPLData.KindIsGap(LineKinds[lineNumber])) { lineNumber--; } while (true) { double topY = (lineNumber - StartLine) * LineHeight + 2; lineNumber++; while (lineNumber < Lines.Count && !REPLData.KindIsGap(LineKinds[lineNumber])) { lineNumber++; } double bottomY = (lineNumber - StartLine) * LineHeight + 2; dc.DrawRoundedRectangle(InsideBrush, BorderPen, new Rect(SpaceWidth / 2, topY + topOffset, Width - SpaceWidth, bottomY - topY - LineHeight / 3), SpaceWidth, SpaceWidth); if (lineNumber >= Lines.Count - 1 || lineNumber > StartLine + Height / LineHeight) { break; } } ; dc.Pop(); }
public REPLRenderingPanel(REPLData theData, Func <ReadOnlyCollection <string>, string> command, FontFamily family, double fontSize) : base(family, fontSize) { TheData = theData; SetUpLines(); CursorLine = 1; CursorX = 2; Command = command; MakeCaret(Colors.Black, 600); }
public void ChangeData(List <REPLData.Packet> list) { if (TheData == null) { TheData = new REPLData(); } TheData.Packets = list; SetUpLines(); SetCursorToFirstLineOfLastPacket(); SendScrolleeInfo(); InvalidateVisual(); }
private REPL(TypeParser parser) { DisplayData = new REPLData() { Packets = { new REPLData.Packet() { User ={ "" } } } }; Parser = parser; Maker = new MakeClass(Parser); }
private bool MakeSureEmptyPacketExists() { bool changed = false; if (TheData != null) { if (TheData.Packets.Count == 0) { TheData.Packets.Add(new REPLData.Packet() { User = new List <string> () { "" } }); changed = true; } else if (TheData.Packets[TheData.Packets.Count - 1].User.Count != 1 || TheData.Packets[TheData.Packets.Count - 1].User[0] != "") { TheData.Packets.Add(new REPLData.Packet() { User = new List <string> () { "" } }); changed = true; } } else { TheData = new REPLData() { Packets = new List <REPLData.Packet>() { new REPLData.Packet() { User = new List <string>() { "" } } } }; changed = true; } return(changed); }
protected override void JustifyCursor(ref int line, int previousLine, ref int x, int previousX) { int originalLine = line; int originalX = x; if (line >= LineKinds.Count || REPLData.KindIsGap(LineKinds[line])) { if (previousLine < originalLine) { line++; } else { line--; } if (line >= Lines.Count - 1) { line = Lines.Count - 2; } else if (line < 1) { line = 1; } } if (x < 2) { x = 2; } int originalStartX = StartX; if (x - StartX < 2) { StartX = x - 2; } if (StartX < 0) { StartX = 0; } if (x == 2) { StartX = 0; } if (originalLine != line || originalX != x || originalStartX != StartX) { SendScrolleeInfo(); } }