Browse Source

Use shadows, improved colors for debugger tooltip.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@686 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 20 years ago
parent
commit
fa98de1bd8
  1. 3
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Service/DynamicTreeDebuggerRow.cs
  2. 40
      src/Libraries/ICSharpCode.TextEditor/Project/Src/Gui/CompletionWindow/AbstractCompletionWindow.cs
  3. 16
      src/Libraries/ICSharpCode.TextEditor/Project/Src/Gui/CompletionWindow/DeclarationViewWindow.cs
  4. 91
      src/Main/Base/Project/Src/Gui/TreeGrid/DynamicList.cs
  5. 74
      src/Main/Base/Project/Src/Gui/TreeGrid/DynamicListColumn.cs
  6. 130
      src/Main/Base/Project/Src/Gui/TreeGrid/DynamicListItem.cs
  7. 7
      src/Main/Base/Project/Src/Gui/TreeGrid/DynamicListRow.cs
  8. 381
      src/Main/Base/Project/Src/Gui/TreeGrid/DynamicTreeRow.cs
  9. 12
      src/Main/Base/Project/Src/Services/Debugger/DebuggerGridControl.cs

3
src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Service/DynamicTreeDebuggerRow.cs

@ -40,9 +40,10 @@ namespace ICSharpCode.SharpDevelop.Services @@ -40,9 +40,10 @@ namespace ICSharpCode.SharpDevelop.Services
this.variable = variable;
this.ChildWindowCaption = variable.Name;
this[2].Text = variable.Name;
this[3].Text = variable.ToString();
this.ShowMinusWhileExpanded = true;
}
}
}

40
src/Libraries/ICSharpCode.TextEditor/Project/Src/Gui/CompletionWindow/AbstractCompletionWindow.cs

@ -19,7 +19,7 @@ using ICSharpCode.TextEditor; @@ -19,7 +19,7 @@ using ICSharpCode.TextEditor;
namespace ICSharpCode.TextEditor.Gui.CompletionWindow
{
/// <summary>
/// Description of AbstractCompletionWindow.
/// Description of AbstractCompletionWindow.
/// </summary>
public abstract class AbstractCompletionWindow : System.Windows.Forms.Form
{
@ -79,21 +79,47 @@ namespace ICSharpCode.TextEditor.Gui.CompletionWindow @@ -79,21 +79,47 @@ namespace ICSharpCode.TextEditor.Gui.CompletionWindow
Bounds = bounds;
}
const int SW_SHOWNA = 8;
protected override CreateParams CreateParams {
get {
CreateParams p = base.CreateParams;
AddShadowToWindow(p);
return p;
}
}
[DllImport("user32")]
static extern int ShowWindow(IntPtr hWnd, int nCmdShow);
static int shadowStatus;
public static void ShowWindowWithoutFocus(Control control)
/// <summary>
/// Adds a shadow to the create params if it is supported by the operating system.
/// </summary>
public static void AddShadowToWindow(CreateParams createParams)
{
ShowWindow(control.Handle, SW_SHOWNA);
if (shadowStatus == 0) {
// Test OS version
shadowStatus = -1; // shadow not supported
if (Environment.OSVersion.Platform == PlatformID.Win32NT) {
Version ver = Environment.OSVersion.Version;
if (ver.Major > 5 || ver.Major == 5 && ver.Minor >= 1) {
shadowStatus = 1;
}
}
}
if (shadowStatus == 1) {
createParams.ClassStyle |= 0x00020000; // set CS_DROPSHADOW
}
}
protected override bool ShowWithoutActivation {
get {
return true;
}
}
protected void ShowCompletionWindow()
{
Owner = parentForm;
Enabled = true;
ShowWindowWithoutFocus(this);
this.Show();
control.Focus();

16
src/Libraries/ICSharpCode.TextEditor/Project/Src/Gui/CompletionWindow/DeclarationViewWindow.cs

@ -61,6 +61,20 @@ namespace ICSharpCode.TextEditor.Gui.CompletionWindow @@ -61,6 +61,20 @@ namespace ICSharpCode.TextEditor.Gui.CompletionWindow
base.CreateHandle();
}
protected override CreateParams CreateParams {
get {
CreateParams p = base.CreateParams;
AbstractCompletionWindow.AddShadowToWindow(p);
return p;
}
}
protected override bool ShowWithoutActivation {
get {
return true;
}
}
protected override void OnClick(EventArgs e)
{
base.OnClick(e);
@ -69,7 +83,7 @@ namespace ICSharpCode.TextEditor.Gui.CompletionWindow @@ -69,7 +83,7 @@ namespace ICSharpCode.TextEditor.Gui.CompletionWindow
public void ShowDeclarationViewWindow()
{
AbstractCompletionWindow.ShowWindowWithoutFocus(this);
Show();
}
public void CloseDeclarationViewWindow()

91
src/Main/Base/Project/Src/Gui/TreeGrid/DynamicList.cs

@ -52,7 +52,7 @@ namespace ICSharpCode.SharpDevelop.Gui.TreeGrid @@ -52,7 +52,7 @@ namespace ICSharpCode.SharpDevelop.Gui.TreeGrid
RecalculateColumnWidths();
}
public new static readonly Color DefaultBackColor = SystemColors.ControlLightLight;
public new static readonly Color DefaultBackColor = Color.White;
protected override void Dispose(bool disposing)
{
@ -256,14 +256,17 @@ namespace ICSharpCode.SharpDevelop.Gui.TreeGrid @@ -256,14 +256,17 @@ namespace ICSharpCode.SharpDevelop.Gui.TreeGrid
}
int controlIndex = 0;
int xPos;
int yPos = -scrollOffset;
int clientHeight = ClientSize.Height;
Size clientSize = ClientSize;
foreach (DynamicListRow row in Rows) {
if (yPos + row.Height > 0 && yPos < clientHeight) {
columnIndex = 0;
int xPos = 0;
foreach (DynamicListColumn col in Columns) {
if (yPos + row.Height > 0 && yPos < clientSize.Height) {
xPos = 0;
for (columnIndex = 0; columnIndex < columns.Count; columnIndex++) {
DynamicListColumn col = columns[columnIndex];
Rectangle rect = new Rectangle(xPos, yPos, col.Width, row.Height);
if (columnIndex == columns.Count - 1)
rect.Width = clientSize.Width - 1 - rect.Left;
DynamicListItem item = row[columnIndex];
Control ctl = item.Control;
if (ctl != null) {
@ -276,14 +279,40 @@ namespace ICSharpCode.SharpDevelop.Gui.TreeGrid @@ -276,14 +279,40 @@ namespace ICSharpCode.SharpDevelop.Gui.TreeGrid
}
controlIndex += 1;
} else {
item.PaintTo(e.Graphics, rect, col, item == itemAtMousePosition);
item.PaintTo(e.Graphics, rect, this, col, item == itemAtMousePosition);
}
xPos += col.Width + 1;
columnIndex += 1;
}
}
yPos += row.Height + lineMarginY;
}
xPos = 0;
Form containerForm = FindForm();
bool isFocused;
if (containerForm is IActivatable)
isFocused = (containerForm as IActivatable).IsActivated;
else
isFocused = this.Focused;
for (columnIndex = 0; columnIndex < columns.Count - 1; columnIndex++) {
DynamicListColumn col = columns[columnIndex];
xPos += col.Width + 1;
Color separatorColor;
if (isFocused) {
separatorColor = col.ColumnSeperatorColor;
if (separatorColor.IsEmpty)
separatorColor = col.ColumnSeperatorColorInactive;
} else {
separatorColor = col.ColumnSeperatorColorInactive;
if (separatorColor.IsEmpty)
separatorColor = col.ColumnSeperatorColor;
}
if (separatorColor.IsEmpty) separatorColor = BackColor;
using (Pen separatorPen = new Pen(separatorColor)) {
e.Graphics.DrawLine(separatorPen, xPos - 1, 1, xPos - 1, Math.Min(clientSize.Height, yPos) - 2);
}
}
removedControls.Clear();
foreach (Control ctl in Controls) {
if (!allowedControls.Contains(ctl))
@ -299,6 +328,19 @@ namespace ICSharpCode.SharpDevelop.Gui.TreeGrid @@ -299,6 +328,19 @@ namespace ICSharpCode.SharpDevelop.Gui.TreeGrid
base.OnPaint(e);
}
/// <summary>
/// Gets if the parent form of this list is the active window.
/// </summary>
public bool IsActivated {
get {
Form containerForm = FindForm();
if (containerForm is IActivatable)
return (containerForm as IActivatable).IsActivated;
else
return this.Focused;
}
}
protected override void OnSizeChanged(EventArgs e)
{
base.OnSizeChanged(e);
@ -393,11 +435,34 @@ namespace ICSharpCode.SharpDevelop.Gui.TreeGrid @@ -393,11 +435,34 @@ namespace ICSharpCode.SharpDevelop.Gui.TreeGrid
}
DynamicListItem itemAtMousePosition;
DynamicListRow rowAtMousePosition;
public DynamicListItem ItemAtMousePosition {
get {
return itemAtMousePosition;
}
}
public DynamicListRow RowAtMousePosition {
get {
return rowAtMousePosition;
}
}
protected override void OnMouseMove(MouseEventArgs e)
{
base.OnMouseMove(e);
DynamicListItem item = GetItemFromPoint(e.Location);
DynamicListRow row = GetRowFromPoint(e.Y);
if (rowAtMousePosition != row) {
rowAtMousePosition = row;
Invalidate();
}
if (row == null)
return;
int columnIndex = GetColumnIndexFromPoint(e.X);
if (columnIndex < 0)
return;
DynamicListItem item = row[columnIndex];
if (itemAtMousePosition != item) {
if (itemAtMousePosition != null) {
OnLeaveItem(itemAtMousePosition);
@ -431,6 +496,7 @@ namespace ICSharpCode.SharpDevelop.Gui.TreeGrid @@ -431,6 +496,7 @@ namespace ICSharpCode.SharpDevelop.Gui.TreeGrid
protected override void OnMouseLeave(EventArgs e)
{
rowAtMousePosition = null;
if (itemAtMousePosition != null) {
OnLeaveItem(itemAtMousePosition);
itemAtMousePosition = null;
@ -462,4 +528,11 @@ namespace ICSharpCode.SharpDevelop.Gui.TreeGrid @@ -462,4 +528,11 @@ namespace ICSharpCode.SharpDevelop.Gui.TreeGrid
}
}
}
public interface IActivatable
{
bool IsActivated { get; }
event EventHandler Activated;
event EventHandler Deactivate;
}
}

74
src/Main/Base/Project/Src/Gui/TreeGrid/DynamicListColumn.cs

@ -19,26 +19,20 @@ namespace ICSharpCode.SharpDevelop.Gui.TreeGrid @@ -19,26 +19,20 @@ namespace ICSharpCode.SharpDevelop.Gui.TreeGrid
bool allowGrow = true;
bool autoSize = false;
Brush backgroundBrush = SystemBrushes.ControlLight;
public static readonly Color DefaultBackColor = SystemColors.ControlLight;
public static readonly Color DefaultBackColor = Color.FromArgb(247, 245, 233);
public static readonly Brush DefaultBackBrush = new SolidBrush(DefaultBackColor);
public static readonly Color DefaultRowHighlightBackColor = Color.FromArgb(221, 218, 203);
public static readonly Brush DefaultRowHighlightBrush = new SolidBrush(DefaultRowHighlightBackColor);
public static readonly Color DefaultInactiveBackColor = Color.FromArgb(242, 240, 228);
public static readonly Brush DefaultInactiveBackBrush = new SolidBrush(DefaultInactiveBackColor);
public DynamicListColumn()
{
}
/// <summary>Copy constructor</summary>
protected DynamicListColumn(DynamicListColumn col)
{
width = col.width;
minimumWidth = col.minimumWidth;
allowGrow = col.allowGrow;
autoSize = col.autoSize;
backgroundBrush = col.backgroundBrush;
}
Brush backgroundBrush = DefaultBackBrush;
Brush backgroundBrushInactive = DefaultInactiveBackBrush;
Brush rowHighlightBrush = DefaultRowHighlightBrush;
public virtual DynamicListColumn Clone()
{
return new DynamicListColumn(this);
return (DynamicListColumn)base.MemberwiseClone();
}
object ICloneable.Clone()
@ -111,6 +105,54 @@ namespace ICSharpCode.SharpDevelop.Gui.TreeGrid @@ -111,6 +105,54 @@ namespace ICSharpCode.SharpDevelop.Gui.TreeGrid
backgroundBrush = value;
}
}
public Brush BackgroundBrushInactive {
get {
return backgroundBrushInactive;
}
set {
if (value == null)
throw new ArgumentNullException("value");
backgroundBrushInactive = value;
}
}
public Brush RowHighlightBrush {
get {
return rowHighlightBrush;
}
set {
rowHighlightBrush = value;
}
}
Color columnSeperatorColor = Color.Empty;
/// <summary>
/// Sets the color that is used to the right of this column as separator color.
/// </summary>
public Color ColumnSeperatorColor {
get {
return columnSeperatorColor;
}
set {
columnSeperatorColor = value;
}
}
Color columnSeperatorColorInactive = Color.Empty;
/// <summary>
/// Sets the color that is used to the right of this column as separator color.
/// </summary>
public Color ColumnSeperatorColorInactive {
get {
return columnSeperatorColorInactive;
}
set {
columnSeperatorColorInactive = value;
}
}
#endregion
}
}

130
src/Main/Base/Project/Src/Gui/TreeGrid/DynamicListItem.cs

@ -21,13 +21,19 @@ namespace ICSharpCode.SharpDevelop.Gui.TreeGrid @@ -21,13 +21,19 @@ namespace ICSharpCode.SharpDevelop.Gui.TreeGrid
this.row = row;
}
void OnItemChanged()
public void RaiseItemChanged()
{
row.RaiseItemChanged(this);
}
Cursor cursor;
public DynamicListRow Row {
get {
return row;
}
}
public Cursor Cursor {
get {
return cursor;
@ -47,7 +53,21 @@ namespace ICSharpCode.SharpDevelop.Gui.TreeGrid @@ -47,7 +53,21 @@ namespace ICSharpCode.SharpDevelop.Gui.TreeGrid
set {
if (backgroundBrush != value) {
backgroundBrush = value;
OnItemChanged();
RaiseItemChanged();
}
}
}
Brush backgroundBrushInactive;
public Brush BackgroundBrushInactive {
get {
return backgroundBrushInactive;
}
set {
if (backgroundBrushInactive != value) {
backgroundBrushInactive = value;
RaiseItemChanged();
}
}
}
@ -61,7 +81,7 @@ namespace ICSharpCode.SharpDevelop.Gui.TreeGrid @@ -61,7 +81,7 @@ namespace ICSharpCode.SharpDevelop.Gui.TreeGrid
set {
if (highlightBrush != value) {
highlightBrush = value;
OnItemChanged();
RaiseItemChanged();
}
}
}
@ -75,7 +95,7 @@ namespace ICSharpCode.SharpDevelop.Gui.TreeGrid @@ -75,7 +95,7 @@ namespace ICSharpCode.SharpDevelop.Gui.TreeGrid
set {
if (control != value) {
control = value;
OnItemChanged();
RaiseItemChanged();
}
}
}
@ -97,21 +117,36 @@ namespace ICSharpCode.SharpDevelop.Gui.TreeGrid @@ -97,21 +117,36 @@ namespace ICSharpCode.SharpDevelop.Gui.TreeGrid
}
}
public event PaintEventHandler Paint;
public event EventHandler<ItemPaintEventArgs> Paint;
internal void PaintTo(Graphics g, Rectangle rectangle, DynamicListColumn column, bool isMouseEntered)
internal void PaintTo(Graphics g, Rectangle rectangle, DynamicList list, DynamicListColumn column, bool isMouseEntered)
{
if (highlightBrush != null && isMouseEntered)
g.FillRectangle(highlightBrush, rectangle);
else
g.FillRectangle(backgroundBrush ?? column.BackgroundBrush, rectangle);
Rectangle fillRectangle = rectangle;
fillRectangle.Width += 1;
if (highlightBrush != null && isMouseEntered) {
g.FillRectangle(highlightBrush, fillRectangle);
} else {
bool isActivated = list.IsActivated;
Brush bgBrush = GetBrush(isActivated, backgroundBrush, backgroundBrushInactive);
if (bgBrush == null) {
bgBrush = GetBrush(isActivated, column.BackgroundBrush, column.BackgroundBrushInactive);
if (isActivated && list.RowAtMousePosition == row && column.RowHighlightBrush != null)
bgBrush = column.RowHighlightBrush;
}
g.FillRectangle(bgBrush, fillRectangle);
}
if (Paint != null) {
Paint(this, new PaintEventArgs(g, rectangle));
Paint(this, new ItemPaintEventArgs(g, rectangle, fillRectangle, list, column, this, isMouseEntered));
}
if (text.Length > 0) {
g.DrawString(text, font, textBrush, rectangle, textFormat);
}
}
Brush GetBrush(bool isActive, Brush activeBrush, Brush inactiveBrush)
{
return isActive ? (activeBrush ?? inactiveBrush) : (inactiveBrush ?? activeBrush);
}
#endregion
#region Text drawing
@ -126,7 +161,7 @@ namespace ICSharpCode.SharpDevelop.Gui.TreeGrid @@ -126,7 +161,7 @@ namespace ICSharpCode.SharpDevelop.Gui.TreeGrid
throw new ArgumentNullException("value", "Use string.Empty instead of null!");
if (text != value) {
text = value;
OnItemChanged();
RaiseItemChanged();
}
}
}
@ -142,7 +177,7 @@ namespace ICSharpCode.SharpDevelop.Gui.TreeGrid @@ -142,7 +177,7 @@ namespace ICSharpCode.SharpDevelop.Gui.TreeGrid
throw new ArgumentNullException("value");
if (font != value) {
font = value;
OnItemChanged();
RaiseItemChanged();
}
}
}
@ -158,7 +193,7 @@ namespace ICSharpCode.SharpDevelop.Gui.TreeGrid @@ -158,7 +193,7 @@ namespace ICSharpCode.SharpDevelop.Gui.TreeGrid
throw new ArgumentNullException("value");
if (textBrush != value) {
textBrush = value;
OnItemChanged();
RaiseItemChanged();
}
}
}
@ -186,7 +221,7 @@ namespace ICSharpCode.SharpDevelop.Gui.TreeGrid @@ -186,7 +221,7 @@ namespace ICSharpCode.SharpDevelop.Gui.TreeGrid
throw new ArgumentNullException("value");
if (textFormat != value) {
textFormat = value;
OnItemChanged();
RaiseItemChanged();
}
}
}
@ -226,7 +261,7 @@ namespace ICSharpCode.SharpDevelop.Gui.TreeGrid @@ -226,7 +261,7 @@ namespace ICSharpCode.SharpDevelop.Gui.TreeGrid
if (MouseLeave != null) {
MouseLeave(this, new DynamicListEventArgs(list));
}
if (highlightBrush != null) OnItemChanged();
if (highlightBrush != null) RaiseItemChanged();
}
public event EventHandler<DynamicListEventArgs> MouseEnter;
@ -236,7 +271,7 @@ namespace ICSharpCode.SharpDevelop.Gui.TreeGrid @@ -236,7 +271,7 @@ namespace ICSharpCode.SharpDevelop.Gui.TreeGrid
if (MouseEnter != null) {
MouseEnter(this, new DynamicListEventArgs(list));
}
if (highlightBrush != null) OnItemChanged();
if (highlightBrush != null) RaiseItemChanged();
}
public event EventHandler<DynamicListMouseEventArgs> MouseMove;
@ -287,11 +322,11 @@ namespace ICSharpCode.SharpDevelop.Gui.TreeGrid @@ -287,11 +322,11 @@ namespace ICSharpCode.SharpDevelop.Gui.TreeGrid
{
if (!allowLabelEdit)
return;
if (BeginLabelEdit != null)
BeginLabelEdit(this, new DynamicListEventArgs(list));
TextBox txt = new TextBox();
txt.Text = this.Text;
AssignControlUntilFocusChange(txt);
if (BeginLabelEdit != null)
BeginLabelEdit(this, new DynamicListEventArgs(list));
bool escape = false;
txt.KeyDown += delegate(object sender2, KeyEventArgs e2) {
if (e2.KeyData == Keys.Enter || e2.KeyData == Keys.Escape) {
@ -403,4 +438,61 @@ namespace ICSharpCode.SharpDevelop.Gui.TreeGrid @@ -403,4 +438,61 @@ namespace ICSharpCode.SharpDevelop.Gui.TreeGrid
this.graphics = graphics;
}
}
public class ItemPaintEventArgs : PaintEventArgs
{
DynamicList list;
DynamicListColumn column;
DynamicListItem item;
bool isMouseEntered;
Rectangle fillRectangle;
public Rectangle FillRectangle {
get {
return fillRectangle;
}
}
public DynamicList List {
get {
return list;
}
}
public DynamicListColumn Column {
get {
return column;
}
}
public DynamicListRow Row {
get {
return item.Row;
}
}
public DynamicListItem Item {
get {
return item;
}
}
public bool IsMouseEntered {
get {
return isMouseEntered;
}
}
public ItemPaintEventArgs(Graphics graphics, Rectangle rectangle, Rectangle fillRectangle,
DynamicList list, DynamicListColumn column,
DynamicListItem item, bool isMouseEntered)
: base(graphics, rectangle)
{
this.fillRectangle = fillRectangle;
this.list = list;
this.column = column;
this.item = item;
this.isMouseEntered = isMouseEntered;
}
}
}

7
src/Main/Base/Project/Src/Gui/TreeGrid/DynamicListRow.cs

@ -69,10 +69,15 @@ namespace ICSharpCode.SharpDevelop.Gui.TreeGrid @@ -69,10 +69,15 @@ namespace ICSharpCode.SharpDevelop.Gui.TreeGrid
}
DynamicListItem item = items[columnIndex];
if (item == null) {
items[columnIndex] = item = new DynamicListItem(this);
items[columnIndex] = item = CreateItem();
}
return item;
}
}
protected virtual DynamicListItem CreateItem()
{
return new DynamicListItem(this);
}
}
}

381
src/Main/Base/Project/Src/Gui/TreeGrid/DynamicTreeRow.cs

@ -6,6 +6,7 @@ @@ -6,6 +6,7 @@
// </file>
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;
@ -25,6 +26,7 @@ namespace ICSharpCode.SharpDevelop.Gui.TreeGrid @@ -25,6 +26,7 @@ namespace ICSharpCode.SharpDevelop.Gui.TreeGrid
ShowPlus = true;
}
#region Plus painting
bool showPlus;
public bool ShowPlus {
@ -48,41 +50,224 @@ namespace ICSharpCode.SharpDevelop.Gui.TreeGrid @@ -48,41 +50,224 @@ namespace ICSharpCode.SharpDevelop.Gui.TreeGrid
}
}
static readonly Color PlusBorder = Color.FromArgb(120, 152, 181);
static readonly Color LightPlusBorder = Color.FromArgb(176, 194, 221);
public static readonly Color DefaultExpandedRowColor = Color.FromArgb(235, 229, 209);
public static void DrawPlusSign(Graphics graphics, Rectangle r, bool drawMinus)
{
using (Brush b = new LinearGradientBrush(r, Color.White, DynamicListColumn.DefaultRowHighlightBackColor, 66f)) {
graphics.FillRectangle(b, r);
}
using (Pen p = new Pen(PlusBorder)) {
graphics.DrawRectangle(p, r);
}
using (Brush b = new SolidBrush(LightPlusBorder)) {
graphics.FillRectangle(b, new Rectangle(r.X, r.Y, 1, 1));
graphics.FillRectangle(b, new Rectangle(r.Right, r.Y, 1, 1));
graphics.FillRectangle(b, new Rectangle(r.X, r.Bottom, 1, 1));
graphics.FillRectangle(b, new Rectangle(r.Right, r.Bottom, 1, 1));
}
graphics.DrawLine(Pens.Black, r.Left + 2, r.Top + r.Height / 2, r.Right - 2, r.Top + r.Height / 2);
if (!drawMinus) {
graphics.DrawLine(Pens.Black, r.Left + r.Width / 2, r.Top + 2, r.Left + r.Width / 2, r.Bottom - 2);
}
}
protected virtual void OnPlusPaint(object sender, ItemPaintEventArgs e)
{
Rectangle r = e.ClipRectangle;
r.Inflate(-4, -4);
DrawPlusSign(e.Graphics, r, expandedIn != null && expandedIn.Contains(e.List));
}
protected override DynamicListItem CreateItem()
{
DynamicListItem item = base.CreateItem();
item.Paint += delegate(object sender, ItemPaintEventArgs e) {
if (e.Item != plus && expandedIn != null && !expandedRowColor.IsEmpty && expandedIn.Contains(e.List)) {
using (Brush b = new SolidBrush(expandedRowColor)) {
e.Graphics.FillRectangle(b, e.FillRectangle);
}
}
};
return item;
}
List<DynamicList> expandedIn;
Color expandedRowColor = DefaultExpandedRowColor;
public bool ShowMinusWhileExpanded {
get {
return expandedIn != null;
}
set {
if (this.ShowMinusWhileExpanded == value)
return;
expandedIn = value ? new List<DynamicList>() : null;
}
}
/// <summary>
/// Gets/Sets the row color used when the row is expanded. Only works together with ShowMinusWhileExpanded.
/// </summary>
public Color ExpandedRowColor {
get {
return expandedRowColor;
}
set {
expandedRowColor = value;
}
}
#endregion
#region Events
public event EventHandler<DynamicListEventArgs> Expanding;
public event EventHandler<DynamicListEventArgs> Expanded;
public event EventHandler<DynamicListEventArgs> Collapsed;
public event EventHandler ShowPlusChanged;
protected virtual void OnExpanding(DynamicListEventArgs e)
{
if (Expanding != null) {
Expanding(this, e);
}
}
protected virtual void OnExpanded(DynamicListEventArgs e)
{
if (Expanded != null) {
Expanded(this, e);
}
}
protected virtual void OnCollapsed(DynamicListEventArgs e)
{
if (Collapsed != null) {
Collapsed(this, e);
}
}
public virtual void OnShowPlusChanged(EventArgs e)
{
if (ShowPlusChanged != null) {
ShowPlusChanged(this, e);
}
}
#endregion
static readonly Color PlusBorder = Color.FromArgb(120, 152, 181);
static readonly Color LightPlusBorder = Color.FromArgb(176, 194, 221);
#region Properties
public CollectionWithEvents<DynamicListColumn> ChildColumns {
get {
return childColumns;
}
set {
if (value == null)
throw new ArgumentNullException("value");
childColumns = value;
}
}
public CollectionWithEvents<DynamicListRow> ChildRows {
get {
return childRows;
}
set {
if (value == null)
throw new ArgumentNullException("value");
childRows = value;
}
}
public static readonly Color DefaultBorderColor = Color.FromArgb(195, 192, 175);
Color childBorderColor = DefaultBorderColor;
public Color ChildBorderColor {
get {
return childBorderColor;
}
set {
childBorderColor = value;
}
}
#endregion
#region Child form
static bool isOpeningChild;
protected virtual void OnPlusPaint(object sender, PaintEventArgs e)
protected virtual void OnPlusClick(object sender, DynamicListEventArgs e)
{
Rectangle r = e.ClipRectangle;
r.Inflate(-4, -4);
using (Brush b = new LinearGradientBrush(r, Color.White, Color.FromArgb(221, 218, 203), 66f)) {
e.Graphics.FillRectangle(b, r);
OnExpanding(e);
ChildForm frm = new ChildForm();
frm.Closed += delegate {
if (expandedIn != null)
expandedIn.Remove(e.List);
OnCollapsed(e);
plus.RaiseItemChanged();
};
Point p = e.List.PointToScreen(e.List.GetPositionFromRow(this));
p.Offset(e.List.Columns[0].Width, Height);
frm.StartPosition = FormStartPosition.Manual;
frm.BackColor = childBorderColor;
frm.Location = p;
frm.ShowInTaskbar = false;
frm.Owner = e.List.FindForm();
VerticalScrollContainer scrollContainer = new VerticalScrollContainer();
scrollContainer.Dock = DockStyle.Fill;
DynamicList childList = new DynamicList(childColumns, childRows);
childList.Dock = DockStyle.Fill;
childList.KeyDown += delegate(object sender2, KeyEventArgs e2) {
if (e2.KeyData == Keys.Escape) {
frm.Close();
// workaround focus problem: sometimes the mainform gets focus after this
e.List.FindForm().Focus();
}
};
scrollContainer.Controls.Add(childList);
frm.Controls.Add(scrollContainer);
int screenHeight = Screen.FromPoint(p).WorkingArea.Bottom - p.Y;
screenHeight -= frm.Size.Height - frm.ClientSize.Height;
int requiredHeight = childList.TotalRowHeight + 4;
int formHeight = Math.Min(requiredHeight, screenHeight);
if (formHeight < requiredHeight) {
int missingHeight = Math.Min(100, requiredHeight - formHeight);
formHeight += missingHeight;
frm.Top -= missingHeight;
}
using (Pen p = new Pen(PlusBorder)) {
e.Graphics.DrawRectangle(p, r);
// Autosize child window
int formWidth;
using (Graphics g = childList.CreateGraphics()) {
formWidth = 8 + childList.GetRequiredWidth(g);
}
using (Brush b = new SolidBrush(LightPlusBorder)) {
e.Graphics.FillRectangle(b, new Rectangle(r.X, r.Y, 1, 1));
e.Graphics.FillRectangle(b, new Rectangle(r.Right, r.Y, 1, 1));
e.Graphics.FillRectangle(b, new Rectangle(r.X, r.Bottom, 1, 1));
e.Graphics.FillRectangle(b, new Rectangle(r.Right, r.Bottom, 1, 1));
int screenWidth = Screen.FromPoint(p).WorkingArea.Right - p.X;
if (formWidth > screenWidth) {
int missingWidth = Math.Min(100, formWidth - screenWidth);
formWidth = screenWidth + missingWidth;
frm.Left -= missingWidth;
}
e.Graphics.DrawLine(Pens.Black, r.Left + 2, r.Top + r.Height / 2, r.Right - 2, r.Top + r.Height / 2);
e.Graphics.DrawLine(Pens.Black, r.Left + r.Width / 2, r.Top + 2, r.Left + r.Width / 2, r.Bottom - 2);
frm.ClientSize = new Size(formWidth, formHeight);
frm.MinimumSize = new Size(100, Math.Min(50, formHeight));
isOpeningChild = true;
frm.Show();
isOpeningChild = false;
childList.Focus();
if (expandedIn != null)
expandedIn.Add(e.List);
OnExpanded(e);
plus.RaiseItemChanged();
}
public class ChildForm : Form
public class ChildForm : Form, IActivatable
{
bool isActive = true;
bool isActivated = true;
public bool IsActivated {
get {
return isActivated;
}
}
bool allowResizing = true;
@ -102,7 +287,32 @@ namespace ICSharpCode.SharpDevelop.Gui.TreeGrid @@ -102,7 +287,32 @@ namespace ICSharpCode.SharpDevelop.Gui.TreeGrid
{
this.FormBorderStyle = FormBorderStyle.None;
this.DockPadding.All = 2;
this.BackColor = Color.FromArgb(195, 192, 175);
this.BackColor = DefaultBorderColor;
}
bool showWindowWithoutActivation;
public bool ShowWindowWithoutActivation {
get {
return showWindowWithoutActivation;
}
set {
showWindowWithoutActivation = value;
}
}
protected override bool ShowWithoutActivation {
get {
return showWindowWithoutActivation;
}
}
protected override CreateParams CreateParams {
get {
CreateParams p = base.CreateParams;
ICSharpCode.TextEditor.Gui.CompletionWindow.AbstractCompletionWindow.AddShadowToWindow(p);
return p;
}
}
#region Resizing the form
@ -183,16 +393,19 @@ namespace ICSharpCode.SharpDevelop.Gui.TreeGrid @@ -183,16 +393,19 @@ namespace ICSharpCode.SharpDevelop.Gui.TreeGrid
protected override void OnActivated(EventArgs e)
{
isActivated = true;
base.OnActivated(e);
isActive = true;
Refresh();
}
protected override void OnDeactivate(EventArgs e)
{
isActivated = false;
base.OnDeactivate(e);
isActive = false;
if (isOpeningChild)
if (isOpeningChild) {
Refresh();
return;
}
BeginInvoke(new MethodInvoker(CloseOnDeactivate));
}
@ -200,7 +413,7 @@ namespace ICSharpCode.SharpDevelop.Gui.TreeGrid @@ -200,7 +413,7 @@ namespace ICSharpCode.SharpDevelop.Gui.TreeGrid
{
ChildForm owner = Owner as ChildForm;
if (owner != null) {
if (owner.isActive)
if (owner.isActivated)
Close();
else
owner.CloseOnDeactivate();
@ -209,126 +422,6 @@ namespace ICSharpCode.SharpDevelop.Gui.TreeGrid @@ -209,126 +422,6 @@ namespace ICSharpCode.SharpDevelop.Gui.TreeGrid
}
}
}
static bool isOpeningChild;
protected virtual void OnPlusClick(object sender, DynamicListEventArgs e)
{
OnExpanding(e);
ChildForm frm = new ChildForm();
frm.Closed += delegate {
frm = null;
OnCollapsed(EventArgs.Empty);
};
Point p = e.List.PointToScreen(e.List.GetPositionFromRow(this));
p.Offset(e.List.Columns[0].Width, Height);
frm.StartPosition = FormStartPosition.Manual;
frm.Location = p;
frm.ShowInTaskbar = false;
frm.Text = childWindowCaption;
frm.Owner = e.List.FindForm();
VerticalScrollContainer scrollContainer = new VerticalScrollContainer();
scrollContainer.Dock = DockStyle.Fill;
DynamicList childList = new DynamicList(childColumns, childRows);
childList.Dock = DockStyle.Fill;
childList.KeyDown += delegate(object sender2, KeyEventArgs e2) {
if (e2.KeyData == Keys.Escape) {
frm.Close();
// workaround focus problem: sometimes the mainform gets focus after this
e.List.FindForm().Focus();
}
};
scrollContainer.Controls.Add(childList);
frm.Controls.Add(scrollContainer);
int screenHeight = Screen.FromPoint(p).WorkingArea.Bottom - p.Y;
screenHeight -= frm.Size.Height - frm.ClientSize.Height;
int requiredHeight = childList.TotalRowHeight + 4;
int formHeight = Math.Min(requiredHeight, screenHeight);
if (formHeight < requiredHeight) {
int missingHeight = Math.Min(100, requiredHeight - formHeight);
formHeight += missingHeight;
frm.Top -= missingHeight;
}
// Autosize child window
int formWidth;
using (Graphics g = childList.CreateGraphics()) {
formWidth = 8 + childList.GetRequiredWidth(g);
}
int screenWidth = Screen.FromPoint(p).WorkingArea.Right - p.X;
if (formWidth > screenWidth) {
int missingWidth = Math.Min(100, formWidth - screenWidth);
formWidth = screenWidth + missingWidth;
frm.Left -= missingWidth;
}
frm.ClientSize = new Size(formWidth, formHeight);
frm.MinimumSize = new Size(100, Math.Min(50, formHeight));
isOpeningChild = true;
frm.Show();
isOpeningChild = false;
childList.Focus();
OnExpanded(e);
}
public event EventHandler Expanding;
public event EventHandler Expanded;
public event EventHandler Collapsed;
protected virtual void OnExpanding(EventArgs e)
{
if (Expanding != null) {
Expanding(this, e);
}
}
protected virtual void OnExpanded(EventArgs e)
{
if (Expanded != null) {
Expanded(this, e);
}
}
protected virtual void OnCollapsed(EventArgs e)
{
if (Collapsed != null) {
Collapsed(this, e);
}
}
string childWindowCaption = "Child window";
public string ChildWindowCaption {
get {
return childWindowCaption;
}
set {
if (value == null)
throw new ArgumentNullException();
childWindowCaption = value;
}
}
public CollectionWithEvents<DynamicListColumn> ChildColumns {
get {
return childColumns;
}
set {
if (value == null)
throw new ArgumentNullException("value");
childColumns = value;
}
}
public CollectionWithEvents<DynamicListRow> ChildRows {
get {
return childRows;
}
set {
if (value == null)
throw new ArgumentNullException("value");
childRows = value;
}
}
#endregion
}
}

12
src/Main/Base/Project/Src/Services/Debugger/DebuggerGridControl.cs

@ -29,13 +29,20 @@ namespace ICSharpCode.Core @@ -29,13 +29,20 @@ namespace ICSharpCode.Core
columns.Add(new DynamicListColumn());
columns.Add(new DynamicListColumn());
columns.Add(new DynamicListColumn());
columns[0].BackgroundBrush = SystemBrushes.ControlLightLight;
columns[0].BackgroundBrush = Brushes.White;
columns[0].BackgroundBrushInactive = Brushes.White;
columns[0].RowHighlightBrush = null;
// default is allowgrow = true and autosize = false
columns[0].AllowGrow = false;
columns[1].AllowGrow = false;
columns[1].Width = 18;
columns[1].ColumnSeperatorColor = Color.Transparent;
columns[1].ColumnSeperatorColorInactive = Color.Transparent;
columns[2].AutoSize = true;
columns[2].MinimumWidth = 75;
columns[2].ColumnSeperatorColor = Color.White;
columns[2].ColumnSeperatorColorInactive = Color.FromArgb(172, 168, 153);
columns[3].AutoSize = true;
columns[3].MinimumWidth = 75;
}
@ -81,7 +88,8 @@ namespace ICSharpCode.Core @@ -81,7 +88,8 @@ namespace ICSharpCode.Core
frm.ClientSize = new Size(Width + 2, row.Height + 2);
Dock = DockStyle.Fill;
frm.Controls.Add(this);
ICSharpCode.TextEditor.Gui.CompletionWindow.AbstractCompletionWindow.ShowWindowWithoutFocus(frm);
frm.ShowWindowWithoutActivation = true;
frm.Show();
textArea.Click += OnTextAreaClick;
textArea.KeyDown += OnTextAreaClick;
frm.ClientSize = new Size(frm.ClientSize.Width, row.Height + 2);

Loading…
Cancel
Save