Subversion Repositories general

Compare Revisions

Ignore whitespace Rev 1288 → Rev 1289

/TCPproxy/trunk/MainForm.cs
1131,7 → 1131,7
 
tcpListener = new TcpListener(listenPort, resendHost, resendPort);
tcpListener.Log += new TcpLogEventHandler(TcpConnectionLog);
tcpListener.NewTcp += new TcpConnectionEventHandler(AddTcpConnetion);
tcpListener.NewTcp += new TcpConnectionEventHandler(AddTcpConnection);
tcpListener.StartListening();
}
 
1289,7 → 1289,7
 
tcpListener = new TcpListener(0, null, 0);
tcpListener.Log += new TcpLogEventHandler(TcpConnectionLog);
tcpListener.NewTcp += new TcpConnectionEventHandler(AddTcpConnetion);
tcpListener.NewTcp += new TcpConnectionEventHandler(AddTcpConnection);
tcpListener.ReadBinLog(reader); // it will send us usual event
 
reader.Close();
1320,7 → 1320,7
}
}
 
private void AddTcpConnetion(object sender, TcpConnectionEventArgs e)
private void AddTcpConnection(object sender, TcpConnectionEventArgs e)
{
lock(this)
{
1436,6 → 1436,9
 
messageView.Nodes.Add(treeNode);
treeNode.EnsureVisible();
if(messageView.Nodes.Count == 1) {
messageView.SelectedNode = messageView.Nodes[0];
}
}
 
private void UpdateTcpNodeInternal(TcpConnection tcp)
2043,6 → 2046,7
{
lock(http)
{
owner.messagesBox.BeginUpdate();
owner.messagesBox.Clear();
 
// state
/TCPproxy/trunk/ViewControl.cs
55,27 → 55,28
 
private static int NEW_LINE_LENGTH = 20;
 
private ArrayList lineBackColors = new ArrayList();
private ArrayList lineFragments = new ArrayList();
private int lastLineLen = 0;
private int linesCount = 0;
private int maxLineLength = 0;
private ArrayList lineBackColors = new ArrayList();
private ArrayList lineFragments = new ArrayList();
private int lastLineLen = 0;
private int linesCount = 0;
private int linesCountToDisplay = 0;
private int maxLineLength = 0;
 
private int curLine = 0;
private int curCol = 0;
private bool updateBlocked = false;
private int linesVisible = 0;
private int colsVisible = 0;
private float fontWidth = -1.0f;
private float fontHeight = -1.0f;
private bool wordWrap = false;
private int curLine = 0;
private int curCol = 0;
private bool updateBlocked = false;
private int linesVisible = 0;
private int colsVisible = 0;
private float fontWidth = -1.0f;
private float fontHeight = -1.0f;
private bool wordWrap = false;
 
private ArrayList validMarkers = new ArrayList();
private ArrayList validMarkers = new ArrayList();
 
private ScrollBarsControl vScrollBar;
private ScrollBarsControl hScrollBar;
 
private StringFormat fontMeasureFormat = (StringFormat)System.Drawing.StringFormat.GenericTypographic.Clone();
private StringFormat fontMeasureFormat = (StringFormat)System.Drawing.StringFormat.GenericTypographic.Clone();
 
private Font normal;
private Font italic;
82,14 → 83,14
private Font bold;
private Font boldIt;
 
private int selBeginLine = -1;
private int selBeginPos = -1;
private int selBeginLineOrig = -1;
private int selBeginPosOrig = -1;
private int selEndLine = -1;
private int selEndPos = -1;
private int selEndLineOrig = -1;
private int selEndPosOrig = -1;
private int selBeginLine = -1;
private int selBeginPos = -1;
private int selBeginLineOrig = -1;
private int selBeginPosOrig = -1;
private int selEndLine = -1;
private int selEndPos = -1;
private int selEndLineOrig = -1;
private int selEndPosOrig = -1;
 
public ViewControl()
{
139,7 → 140,6
wordWrap = value;
RecalcParams();
Invalidate();
// FIXME recalc number of lines for the vertical scroll bar
}
}
 
147,32 → 147,38
{
lock(this)
{
lineBackColors = new ArrayList();
lineFragments = new ArrayList();
validMarkers = new ArrayList();
lastLineLen = 0;
linesCount = 0;
maxLineLength = 0;
curLine = 0;
curCol = 0;
selBeginLine = -1;
selBeginPos = -1;
selBeginLineOrig = -1;
selBeginPosOrig = -1;
selEndLine = -1;
selEndPos = -1;
selEndLineOrig = -1;
selEndPosOrig = -1;
lineBackColors = new ArrayList();
lineFragments = new ArrayList();
validMarkers = new ArrayList();
lastLineLen = 0;
linesCount = 0;
linesCountToDisplay = 0;
maxLineLength = 0;
curLine = 0;
curCol = 0;
selBeginLine = -1;
selBeginPos = -1;
selBeginLineOrig = -1;
selBeginPosOrig = -1;
selEndLine = -1;
selEndPos = -1;
selEndLineOrig = -1;
selEndPosOrig = -1;
 
if(!updateBlocked)
{
vScrollBar.Update(curLine, 0, linesCount, 1, 1);
UpdateHScrollBar();
Invalidate();
}
UpdateDisplayArea();
}
}
 
private void UpdateDisplayArea()
{
if(!updateBlocked)
{
vScrollBar.Update(curLine, 0, linesCountToDisplay, 1, 1);
UpdateHScrollBar();
Invalidate();
}
}
 
private void UpdateHScrollBar()
{
if(wordWrap)
190,16 → 196,16
 
lock(this)
{
state.deep = deep;
state.lineBackColors = lineBackColors;
state.lineFragments = lineFragments;
state.validMarkers = validMarkers;
state.curLine = curLine;
state.curCol = curCol;
state.selBeginLineOrig = selBeginLineOrig;
state.selBeginPosOrig = selBeginPosOrig;
state.selEndLineOrig = selEndLineOrig;
state.selEndPosOrig = selEndPosOrig;
state.deep = deep;
state.lineBackColors = lineBackColors;
state.lineFragments = lineFragments;
state.validMarkers = validMarkers;
state.curLine = curLine;
state.curCol = curCol;
state.selBeginLineOrig = selBeginLineOrig;
state.selBeginPosOrig = selBeginPosOrig;
state.selEndLineOrig = selEndLineOrig;
state.selEndPosOrig = selEndPosOrig;
}
 
return state;
218,10 → 224,13
 
lock(this)
{
lineBackColors = s.lineBackColors;
lineFragments = s.lineFragments;
linesCount = lineFragments.Count;
BeginUpdate();
 
lineBackColors = s.lineBackColors;
lineFragments = s.lineFragments;
linesCount = lineFragments.Count;
RecalcLinesCountToDisplay();
 
validMarkers = s.validMarkers;
 
lastLineLen = (linesCount > 0) ? ((LineFragment[])lineFragments[linesCount-1]).Length : 0;
257,11 → 266,7
}
 
UpdateSelection();
updateBlocked = false;
 
vScrollBar.Update(curLine, 0, linesCount, 1, linesVisible);
UpdateHScrollBar();
Invalidate();
EndUpdateInternal();
}
}
 
300,14 → 305,16
{
lock(this)
{
updateBlocked = false;
 
vScrollBar.Update(curLine, 0, linesCount, 1, linesVisible);
UpdateHScrollBar();
Invalidate();
EndUpdateInternal();
}
}
 
public void EndUpdateInternal()
{
updateBlocked = false;
UpdateDisplayArea();
}
 
public void AppendText(string text)
{
lock(this)
386,6 → 393,9
{
lineLength += lastLine[i].indent + (lastLine[i].text == null ? 0 : lastLine[i].text.Length);
}
if(wordWrap && lineLength > 0) {
linesCountToDisplay += (lineLength - 1) / GetVisibleLength();
}
if(lineLength > maxLineLength)
{
maxLineLength = lineLength;
394,10 → 404,16
 
if(!updateBlocked)
{
if(curLine + linesVisible + 1 >= lastLineLen) Invalidate();
vScrollBar.Maximum = linesCountToDisplay;
if(curLine + linesVisible + 1 >= lastLineLen) Invalidate();
}
}
 
private int GetVisibleLength()
{
return (colsVisible - 2);
}
 
public void AppendNewLine()
{
AppendNewLine(Color.Transparent);
608,6 → 624,9
{
lineLength += line[i].indent + (line[i].text == null ? 0 : line[i].text.Length);
}
if(wordWrap && lineLength > 0) {
linesCountToDisplay += (lineLength - 1) / GetVisibleLength();
}
if(lineLength > maxLineLength)
{
maxLineLength = lineLength;
617,11 → 636,12
// update screen
if(!updateBlocked)
{
vScrollBar.Maximum = linesCountToDisplay;
if(m.endLine >= curLine && m.endLine <= curLine + linesVisible + 1) Invalidate();
}
 
ShiftTextMarkers(m.endLine, m.endPos, 0, 1);
if(m.beginLine == m.endLine && m.beginPos == m.endPos) m.beginPos--; // return the begin back if empty marker
if(m.beginLine == m.endLine && m.beginPos == m.endPos) m.beginPos--; // return the begin back if empty marker
}
}
 
659,6 → 679,7
 
if(m.endLine == linesCount - 1) lastLineLen = oldLineLen - m.endPos;
linesCount++;
linesCountToDisplay++;
}
 
// update screen
665,7 → 686,7
if(!updateBlocked)
{
if(m.endLine >= curLine && m.endLine <= curLine + linesVisible + 1) Invalidate();
vScrollBar.Maximum = linesCount;
vScrollBar.Maximum = linesCountToDisplay;
}
 
ShiftTextMarkers(m.endLine, m.endPos, 1, 0);
673,6 → 694,25
}
}
 
private void RecalcLinesCountToDisplay()
{
if(wordWrap) {
linesCountToDisplay = 0;
 
int visibleLen = GetVisibleLength();
foreach(LineFragment[] line in lineFragments) {
int lineLength = 0;
foreach(LineFragment fragment in line) {
lineLength += fragment.indent + (fragment.text == null ? 0 : fragment.text.Length);
}
linesCountToDisplay += (lineLength - 1) / visibleLen + 1;
}
}
else {
linesCountToDisplay = linesCount;
}
}
 
private void ShiftTextMarkers(int line, int pos, int lineDelta, int posDelta)
{
for(int i = validMarkers.Count-1; i >= 0; i--)
739,8 → 779,9
lineFragments.Add(lastLine);
 
linesCount++;
linesCountToDisplay++;
 
if(!updateBlocked) vScrollBar.Maximum = linesCount;
if(!updateBlocked) vScrollBar.Maximum = linesCountToDisplay;
 
return lastLine;
}
774,21 → 815,28
{
fontHeight = this.Font.GetHeight();
linesVisible = (fontHeight > 0) ? (int)Math.Ceiling(this.ClientSize.Height / fontHeight) : 0;
vScrollBar.LargeChange = linesVisible;
 
RecalcColsVisible();
}
RecalcColsVisible();
RecalcLinesCountToDisplay();
 
vScrollBar.LargeChange = linesVisible;
vScrollBar.Maximum = linesCountToDisplay;
 
UpdateHScrollBar();
}
 
private void UpdateFontWidth(Graphics g)
{
fontWidth = g.MeasureString("x", this.Font, int.MaxValue, fontMeasureFormat).Width;
RecalcColsVisible();
}
RecalcLinesCountToDisplay();
 
UpdateHScrollBar();
}
 
private void RecalcColsVisible()
{
colsVisible = (fontWidth > 0) ? (int)Math.Ceiling(this.ClientSize.Width / fontWidth) : 0;
UpdateHScrollBar();
}
 
protected override void OnSystemColorsChanged(EventArgs e)
890,7 → 938,7
// FIXME test if wrap is in fragment indent
if(wordWrap)
{
int visibleLen = colsVisible - 2;
int visibleLen = GetVisibleLength();
int availableLen = visibleLen - indent - curIndent;
if(textLen > availableLen)
{
1121,7 → 1169,7
private void MoveToVertical(int pos, bool invalidate)
{
curLine = pos;
if(curLine + linesVisible > linesCount) curLine = linesCount - linesVisible + 1;
if(curLine + linesVisible > linesCountToDisplay) curLine = linesCountToDisplay - linesVisible + 1;
if(curLine < 0) curLine = 0;
vScrollBar.Value = curLine;
if(invalidate) this.Invalidate();
1229,7 → 1277,7
lock(this)
{
MoveToHorizontal(0, false);
MoveToVertical(linesCount - linesVisible + 1, true);
MoveToVertical(linesCountToDisplay - linesVisible + 1, true);
}
break;
 
1532,7 → 1580,7
 
public void Update(int value, int minimum, int maximum, int smallChange, int largeChange)
{
this.currentValue = value;
this.currentValue = value;
this.minimum = minimum;
this.maximum = maximum;
this.smallChange = smallChange;