|
|
|
@ -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
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|