Browse Source

Fixed a null reference exception that occurred when opening the Component Inspector in a release build.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/3.0@3427 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Matt Ward 17 years ago
parent
commit
cb386ead2a
  1. 36
      src/AddIns/Misc/ComponentInspector/ComponentInspector.Core/Src/Controls/TreeListPanel.cs

36
src/AddIns/Misc/ComponentInspector/ComponentInspector.Core/Src/Controls/TreeListPanel.cs

@ -8,6 +8,7 @@
using System; using System;
using System.Collections; using System.Collections;
using System.Drawing; using System.Drawing;
using System.Runtime.InteropServices;
using System.Windows.Forms; using System.Windows.Forms;
using ICSharpCode.Core; using ICSharpCode.Core;
@ -26,11 +27,12 @@ namespace NoGoop.Controls
internal ArrayList _columnHeaderPanels; internal ArrayList _columnHeaderPanels;
internal ArrayList _columnHeaderSplitters; internal ArrayList _columnHeaderSplitters;
protected int _scrollPos; protected int _scrollPos;
protected static IntPtr _greyPen; protected static Pen _greyPen;
static TreeListPanel() static TreeListPanel()
{ {
_greyPen = Windows.CreatePen(Windows.PS_SOLID, 1, Windows.GREY); SolidBrush brush = new SolidBrush(Color.LightGray);
_greyPen = new Pen(brush, 1);
} }
public TreeListPanel() public TreeListPanel()
@ -127,47 +129,31 @@ namespace NoGoop.Controls
internal void HandleColumnsDrawing(TreeListNode tlNode, NMCUSTOMDRAW cd) internal void HandleColumnsDrawing(TreeListNode tlNode, NMCUSTOMDRAW cd)
{ {
IntPtr oldPos;
RECT newRect = cd.rc; RECT newRect = cd.rc;
// Make text align correctly - seems to be off a pixel // Make text align correctly - seems to be off a pixel
newRect.top += 1; newRect.top += 1;
using (Graphics g = Graphics.FromHdc(cd.hdc)) {
// Do each of the columns defined for the tree // Do each of the columns defined for the tree
for (int i = 0; i < _treeView.Columns.Count; i++) { for (int i = 0; i < _treeView.Columns.Count; i++) {
newRect.left = cd.rc.left + ((Splitter)_columnHeaderSplitters[i]).Bounds.X - _scrollPos; newRect.left = cd.rc.left + ((Splitter)_columnHeaderSplitters[i]).Bounds.X - _scrollPos;
Object colData = tlNode.ColumnData[i]; Object colData = tlNode.ColumnData[i];
if (i == 0) { if (i == 0) {
// Clear out the data for the column (first time) // Clear out the data for the column (first time)
Windows.SelectObject(cd.hdc, g.FillRectangle(SystemBrushes.Window, newRect.left - PIXEL_PADDING, cd.rc.top, cd.rc.right, cd.rc.bottom);
Windows.GetSysColorBrush
(Windows.SYSCOLOR_WINDOW));
Windows.SelectObject(cd.hdc,
Windows.GetStockObject
(Windows.WHITE_PEN));
// Clear out where all of the columns go; start a little
// before the line
Windows.Rectangle(cd.hdc,
newRect.left - PIXEL_PADDING,
cd.rc.top,
cd.rc.right,
cd.rc.bottom);
// Set up for drawing grey lines
Windows.SelectObject(cd.hdc, _greyPen);
} }
// Vertical line to separate the columns // Vertical line to separate the columns
Windows.MoveToEx(cd.hdc, newRect.left, cd.rc.top, out oldPos); g.DrawLine(_greyPen, newRect.left, cd.rc.top, newRect.left, cd.rc.bottom);
Windows.LineTo(cd.hdc, newRect.left, cd.rc.bottom);
// Write the actual text // Write the actual text
if (colData != null) { if (colData != null) {
// Start the text one pixel after the line // Start the text one pixel after the line
newRect.left += PIXEL_PADDING; newRect.left += PIXEL_PADDING;
Windows.DrawText(cd.hdc, colData.ToString(), -1, ref newRect, 0); g.DrawString(colData.ToString(), _treeView.Font, SystemBrushes.ControlText, newRect.left, newRect.top);
} }
} }
// Draw the horizontal grid lines // Draw the horizontal grid lines
Windows.MoveToEx(cd.hdc, cd.rc.left, cd.rc.top, out oldPos); g.DrawLine(_greyPen, cd.rc.left, cd.rc.top, cd.rc.right, cd.rc.top);
Windows.LineTo(cd.hdc, cd.rc.right, cd.rc.top); g.DrawLine(_greyPen, cd.rc.left, cd.rc.bottom, cd.rc.right, cd.rc.bottom);
Windows.MoveToEx(cd.hdc, cd.rc.left, cd.rc.bottom, out oldPos); }
Windows.LineTo(cd.hdc, cd.rc.right, cd.rc.bottom);
} }
protected override void WndProc(ref Message m) protected override void WndProc(ref Message m)

Loading…
Cancel
Save