Subversion Repositories general

Compare Revisions

Ignore whitespace Rev 1289 → Rev 1288

/TCPproxy/trunk/MainForm.cs
1131,7 → 1131,7
 
tcpListener = new TcpListener(listenPort, resendHost, resendPort);
tcpListener.Log += new TcpLogEventHandler(TcpConnectionLog);
tcpListener.NewTcp += new TcpConnectionEventHandler(AddTcpConnection);
tcpListener.NewTcp += new TcpConnectionEventHandler(AddTcpConnetion);
tcpListener.StartListening();
}
 
1289,7 → 1289,7
 
tcpListener = new TcpListener(0, null, 0);
tcpListener.Log += new TcpLogEventHandler(TcpConnectionLog);
tcpListener.NewTcp += new TcpConnectionEventHandler(AddTcpConnection);
tcpListener.NewTcp += new TcpConnectionEventHandler(AddTcpConnetion);
tcpListener.ReadBinLog(reader); // it will send us usual event
 
reader.Close();
1320,7 → 1320,7
}
}
 
private void AddTcpConnection(object sender, TcpConnectionEventArgs e)
private void AddTcpConnetion(object sender, TcpConnectionEventArgs e)
{
lock(this)
{
1436,9 → 1436,6
 
messageView.Nodes.Add(treeNode);
treeNode.EnsureVisible();
if(messageView.Nodes.Count == 1) {
messageView.SelectedNode = messageView.Nodes[0];
}
}
 
private void UpdateTcpNodeInternal(TcpConnection tcp)
2046,7 → 2043,6
{
lock(http)
{
owner.messagesBox.BeginUpdate();
owner.messagesBox.Clear();
 
// state
/TCPproxy/trunk/ViewControl.cs
55,28 → 55,27
 
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 linesCountToDisplay = 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 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;
83,14 → 82,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()
{
140,6 → 139,7
wordWrap = value;
RecalcParams();
Invalidate();
// FIXME recalc number of lines for the vertical scroll bar
}
}
 
147,38 → 147,32
{
lock(this)
{
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;
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;
 
UpdateDisplayArea();
if(!updateBlocked)
{
vScrollBar.Update(curLine, 0, linesCount, 1, 1);
UpdateHScrollBar();
Invalidate();
}
}
}
 
private void UpdateDisplayArea()
{
if(!updateBlocked)
{
vScrollBar.Update(curLine, 0, linesCountToDisplay, 1, 1);
UpdateHScrollBar();
Invalidate();
}
}
 
private void UpdateHScrollBar()
{
if(wordWrap)
196,16 → 190,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;
224,13 → 218,10
 
lock(this)
{
BeginUpdate();
lineBackColors = s.lineBackColors;
lineFragments = s.lineFragments;
linesCount = lineFragments.Count;
 
lineBackColors = s.lineBackColors;
lineFragments = s.lineFragments;
linesCount = lineFragments.Count;
RecalcLinesCountToDisplay();
 
validMarkers = s.validMarkers;
 
lastLineLen = (linesCount > 0) ? ((LineFragment[])lineFragments[linesCount-1]).Length : 0;
266,7 → 257,11
}
 
UpdateSelection();
EndUpdateInternal();
updateBlocked = false;
 
vScrollBar.Update(curLine, 0, linesCount, 1, linesVisible);
UpdateHScrollBar();
Invalidate();
}
}
 
305,16 → 300,14
{
lock(this)
{
EndUpdateInternal();
updateBlocked = false;
 
vScrollBar.Update(curLine, 0, linesCount, 1, linesVisible);
UpdateHScrollBar();
Invalidate();
}
}
 
public void EndUpdateInternal()
{
updateBlocked = false;
UpdateDisplayArea();
}
 
public void AppendText(string text)
{
lock(this)
393,9 → 386,6
{
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;
404,16 → 394,10
 
if(!updateBlocked)
{
vScrollBar.Maximum = linesCountToDisplay;
if(curLine + linesVisible + 1 >= lastLineLen) Invalidate();
if(curLine + linesVisible + 1 >= lastLineLen) Invalidate();
}
}
 
private int GetVisibleLength()
{
return (colsVisible - 2);
}
 
public void AppendNewLine()
{
AppendNewLine(Color.Transparent);
624,9 → 608,6
{
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;
636,12 → 617,11
// 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
}
}
 
679,7 → 659,6
 
if(m.endLine == linesCount - 1) lastLineLen = oldLineLen - m.endPos;
linesCount++;
linesCountToDisplay++;
}
 
// update screen
686,7 → 665,7
if(!updateBlocked)
{
if(m.endLine >= curLine && m.endLine <= curLine + linesVisible + 1) Invalidate();
vScrollBar.Maximum = linesCountToDisplay;
vScrollBar.Maximum = linesCount;
}
 
ShiftTextMarkers(m.endLine, m.endPos, 1, 0);
694,25 → 673,6
}
}
 
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--)
779,9 → 739,8
lineFragments.Add(lastLine);
 
linesCount++;
linesCountToDisplay++;
 
if(!updateBlocked) vScrollBar.Maximum = linesCountToDisplay;
if(!updateBlocked) vScrollBar.Maximum = linesCount;
 
return lastLine;
}
815,28 → 774,21
{
fontHeight = this.Font.GetHeight();
linesVisible = (fontHeight > 0) ? (int)Math.Ceiling(this.ClientSize.Height / fontHeight) : 0;
vScrollBar.LargeChange = linesVisible;
 
RecalcColsVisible();
RecalcLinesCountToDisplay();
RecalcColsVisible();
}
 
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)
938,7 → 890,7
// FIXME test if wrap is in fragment indent
if(wordWrap)
{
int visibleLen = GetVisibleLength();
int visibleLen = colsVisible - 2;
int availableLen = visibleLen - indent - curIndent;
if(textLen > availableLen)
{
1169,7 → 1121,7
private void MoveToVertical(int pos, bool invalidate)
{
curLine = pos;
if(curLine + linesVisible > linesCountToDisplay) curLine = linesCountToDisplay - linesVisible + 1;
if(curLine + linesVisible > linesCount) curLine = linesCount - linesVisible + 1;
if(curLine < 0) curLine = 0;
vScrollBar.Value = curLine;
if(invalidate) this.Invalidate();
1277,7 → 1229,7
lock(this)
{
MoveToHorizontal(0, false);
MoveToVertical(linesCountToDisplay - linesVisible + 1, true);
MoveToVertical(linesCount - linesVisible + 1, true);
}
break;
 
1580,7 → 1532,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;