Made the terminal window in 32 bit be limited to 10 megs of cache.
This commit is contained in:
parent
fd6fa0814d
commit
eec0211b3b
3 changed files with 69 additions and 44 deletions
|
|
@ -328,14 +328,12 @@ namespace MatterHackers.MatterControl.ConfigurationPage
|
|||
});
|
||||
}
|
||||
|
||||
void openGcodeTerminalButton_Click(object sender, EventArgs mouseEvent)
|
||||
void openGcodeTerminalButton_Click(object sender, EventArgs mouseEvent)
|
||||
{
|
||||
|
||||
UiThread.RunOnIdle((state) =>
|
||||
{
|
||||
TerminalWindow.Show();
|
||||
});
|
||||
|
||||
{
|
||||
TerminalWindow.Show();
|
||||
});
|
||||
}
|
||||
|
||||
private void onPrinterStatusChanged(object sender, EventArgs e)
|
||||
|
|
|
|||
|
|
@ -55,9 +55,21 @@ namespace MatterHackers.MatterControl
|
|||
}
|
||||
}
|
||||
|
||||
static bool Is32Bit()
|
||||
{
|
||||
if (IntPtr.Size == 4)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public List<string> PrinterLines = new List<string>();
|
||||
|
||||
public RootedObjectEventHandler HasChanged = new RootedObjectEventHandler();
|
||||
int maxLinesToBuffer = int.MaxValue - 1;
|
||||
|
||||
event EventHandler unregisterEvents;
|
||||
PrinterOutputCache()
|
||||
|
|
@ -65,11 +77,20 @@ namespace MatterHackers.MatterControl
|
|||
PrinterConnectionAndCommunication.Instance.ConnectionFailed.RegisterEvent(Instance_ConnectionFailed, ref unregisterEvents);
|
||||
PrinterConnectionAndCommunication.Instance.CommunicationUnconditionalFromPrinter.RegisterEvent(FromPrinter, ref unregisterEvents);
|
||||
PrinterConnectionAndCommunication.Instance.CommunicationUnconditionalToPrinter.RegisterEvent(ToPrinter, ref unregisterEvents);
|
||||
if (Is32Bit())
|
||||
{
|
||||
// About 10 megs worth. Average line length in gcode file is about 14 and we store strings as chars (16 bit) so 450,000 lines.
|
||||
maxLinesToBuffer = 450000;
|
||||
}
|
||||
}
|
||||
|
||||
void OnHasChanged(EventArgs e)
|
||||
{
|
||||
HasChanged.CallEvents(this, e);
|
||||
if (PrinterLines.Count > maxLinesToBuffer)
|
||||
{
|
||||
Clear();
|
||||
}
|
||||
}
|
||||
|
||||
void FromPrinter(Object sender, EventArgs e)
|
||||
|
|
|
|||
|
|
@ -135,12 +135,15 @@ namespace MatterHackers.MatterControl
|
|||
|
||||
void CreateFilteredList()
|
||||
{
|
||||
visibleLines = new List<string>();
|
||||
List<string> allSourceLinesTemp = new List<string>(allSourceLines);
|
||||
foreach (string line in allSourceLinesTemp)
|
||||
{
|
||||
ConditionalyAddToVisible(line);
|
||||
}
|
||||
using (TimedLock.Lock(this, "CreatingFilteredList"))
|
||||
{
|
||||
visibleLines = new List<string>();
|
||||
List<string> allSourceLinesTemp = new List<string>(allSourceLines);
|
||||
foreach (string line in allSourceLinesTemp)
|
||||
{
|
||||
ConditionalyAddToVisible(line);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void SetLineStartFilter(string[] startLineStringsToFilter)
|
||||
|
|
@ -178,39 +181,42 @@ namespace MatterHackers.MatterControl
|
|||
int numLinesToDraw = NumVisibleLines;
|
||||
|
||||
double y = LocalBounds.Bottom + printer.TypeFaceStyle.EmSizeInPixels * numLinesToDraw;
|
||||
int startLineIndex = visibleLines.Count - numLinesToDraw;
|
||||
if (forceStartLine != -1)
|
||||
{
|
||||
y = LocalBounds.Top;
|
||||
using (TimedLock.Lock(this, "DrawingLines"))
|
||||
{
|
||||
int startLineIndex = visibleLines.Count - numLinesToDraw;
|
||||
if (forceStartLine != -1)
|
||||
{
|
||||
y = LocalBounds.Top;
|
||||
|
||||
if (forceStartLine > visibleLines.Count - numLinesToDraw)
|
||||
{
|
||||
forceStartLine = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
// make sure we show all the lines we can
|
||||
startLineIndex = Math.Min(forceStartLine, startLineIndex);
|
||||
}
|
||||
}
|
||||
int endLineIndex = visibleLines.Count;
|
||||
for (int lineIndex = startLineIndex; lineIndex < endLineIndex; lineIndex++)
|
||||
{
|
||||
if (lineIndex >= 0)
|
||||
{
|
||||
if (visibleLines[lineIndex] != null)
|
||||
{
|
||||
printer.Text = visibleLines[lineIndex];
|
||||
printer.Origin = new Vector2(Bounds.Left + 2, y);
|
||||
printer.Render(graphics2D, TextColor);
|
||||
}
|
||||
}
|
||||
y -= printer.TypeFaceStyle.EmSizeInPixels;
|
||||
if (y < -printer.TypeFaceStyle.EmSizeInPixels)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (forceStartLine > visibleLines.Count - numLinesToDraw)
|
||||
{
|
||||
forceStartLine = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
// make sure we show all the lines we can
|
||||
startLineIndex = Math.Min(forceStartLine, startLineIndex);
|
||||
}
|
||||
}
|
||||
int endLineIndex = visibleLines.Count;
|
||||
for (int lineIndex = startLineIndex; lineIndex < endLineIndex; lineIndex++)
|
||||
{
|
||||
if (lineIndex >= 0)
|
||||
{
|
||||
if (visibleLines[lineIndex] != null)
|
||||
{
|
||||
printer.Text = visibleLines[lineIndex];
|
||||
printer.Origin = new Vector2(Bounds.Left + 2, y);
|
||||
printer.Render(graphics2D, TextColor);
|
||||
}
|
||||
}
|
||||
y -= printer.TypeFaceStyle.EmSizeInPixels;
|
||||
if (y < -printer.TypeFaceStyle.EmSizeInPixels)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
base.OnDraw(graphics2D);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue