Always show selection, no activate on Show, Close->unwire events
This commit is contained in:
parent
66c832466d
commit
a686e0ae2d
3 changed files with 107 additions and 63 deletions
49
Utilities/InspectForm.Designer.cs
generated
49
Utilities/InspectForm.Designer.cs
generated
|
|
@ -31,10 +31,10 @@
|
|||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(InspectForm));
|
||||
this.splitContainer1 = new System.Windows.Forms.SplitContainer();
|
||||
this.treeView1 = new System.Windows.Forms.TreeView();
|
||||
this.propertyGrid1 = new System.Windows.Forms.PropertyGrid();
|
||||
this.toolStrip1 = new System.Windows.Forms.ToolStrip();
|
||||
this.btnAddSiblings = new System.Windows.Forms.ToolStripButton();
|
||||
this.btnAddChildren = new System.Windows.Forms.ToolStripButton();
|
||||
this.propertyGrid1 = new System.Windows.Forms.PropertyGrid();
|
||||
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
|
||||
this.splitContainer1.Panel1.SuspendLayout();
|
||||
this.splitContainer1.Panel2.SuspendLayout();
|
||||
|
|
@ -46,6 +46,7 @@
|
|||
//
|
||||
this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.splitContainer1.Location = new System.Drawing.Point(0, 0);
|
||||
this.splitContainer1.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
|
||||
this.splitContainer1.Name = "splitContainer1";
|
||||
//
|
||||
// splitContainer1.Panel1
|
||||
|
|
@ -56,32 +57,26 @@
|
|||
//
|
||||
this.splitContainer1.Panel2.Controls.Add(this.toolStrip1);
|
||||
this.splitContainer1.Panel2.Controls.Add(this.propertyGrid1);
|
||||
this.splitContainer1.Panel2.Padding = new System.Windows.Forms.Padding(0, 42, 0, 0);
|
||||
this.splitContainer1.Size = new System.Drawing.Size(1426, 972);
|
||||
this.splitContainer1.SplitterDistance = 884;
|
||||
this.splitContainer1.Panel2.Padding = new System.Windows.Forms.Padding(0, 27, 0, 0);
|
||||
this.splitContainer1.Size = new System.Drawing.Size(951, 632);
|
||||
this.splitContainer1.SplitterDistance = 589;
|
||||
this.splitContainer1.SplitterWidth = 3;
|
||||
this.splitContainer1.TabIndex = 0;
|
||||
//
|
||||
// treeView1
|
||||
//
|
||||
this.treeView1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.treeView1.DrawMode = System.Windows.Forms.TreeViewDrawMode.OwnerDrawText;
|
||||
this.treeView1.FullRowSelect = true;
|
||||
this.treeView1.HideSelection = false;
|
||||
this.treeView1.Location = new System.Drawing.Point(0, 0);
|
||||
this.treeView1.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
|
||||
this.treeView1.Name = "treeView1";
|
||||
this.treeView1.Size = new System.Drawing.Size(884, 972);
|
||||
this.treeView1.Size = new System.Drawing.Size(589, 632);
|
||||
this.treeView1.TabIndex = 0;
|
||||
this.treeView1.DrawNode += new System.Windows.Forms.DrawTreeNodeEventHandler(this.treeView1_DrawNode);
|
||||
this.treeView1.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.treeView1_AfterSelect);
|
||||
//
|
||||
// propertyGrid1
|
||||
//
|
||||
this.propertyGrid1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.propertyGrid1.LineColor = System.Drawing.SystemColors.ControlDark;
|
||||
this.propertyGrid1.Location = new System.Drawing.Point(0, 42);
|
||||
this.propertyGrid1.Name = "propertyGrid1";
|
||||
this.propertyGrid1.Size = new System.Drawing.Size(538, 930);
|
||||
this.propertyGrid1.TabIndex = 0;
|
||||
this.propertyGrid1.PropertyValueChanged += new System.Windows.Forms.PropertyValueChangedEventHandler(this.propertyGrid1_PropertyValueChanged);
|
||||
//
|
||||
// toolStrip1
|
||||
//
|
||||
this.toolStrip1.Dock = System.Windows.Forms.DockStyle.None;
|
||||
|
|
@ -90,9 +85,9 @@
|
|||
this.toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.btnAddSiblings,
|
||||
this.btnAddChildren});
|
||||
this.toolStrip1.Location = new System.Drawing.Point(2, 2);
|
||||
this.toolStrip1.Location = new System.Drawing.Point(1, 1);
|
||||
this.toolStrip1.Name = "toolStrip1";
|
||||
this.toolStrip1.Size = new System.Drawing.Size(286, 32);
|
||||
this.toolStrip1.Size = new System.Drawing.Size(161, 25);
|
||||
this.toolStrip1.TabIndex = 2;
|
||||
this.toolStrip1.Text = "toolStrip1";
|
||||
//
|
||||
|
|
@ -102,7 +97,7 @@
|
|||
this.btnAddSiblings.Image = ((System.Drawing.Image)(resources.GetObject("btnAddSiblings.Image")));
|
||||
this.btnAddSiblings.ImageTransparentColor = System.Drawing.Color.Magenta;
|
||||
this.btnAddSiblings.Name = "btnAddSiblings";
|
||||
this.btnAddSiblings.Size = new System.Drawing.Size(117, 29);
|
||||
this.btnAddSiblings.Size = new System.Drawing.Size(77, 22);
|
||||
this.btnAddSiblings.Text = "Add Siblings";
|
||||
this.btnAddSiblings.ToolTipText = "Add Siblings";
|
||||
this.btnAddSiblings.Click += new System.EventHandler(this.btnAddSiblings_Click);
|
||||
|
|
@ -113,16 +108,28 @@
|
|||
this.btnAddChildren.Image = ((System.Drawing.Image)(resources.GetObject("btnAddChildren.Image")));
|
||||
this.btnAddChildren.ImageTransparentColor = System.Drawing.Color.Magenta;
|
||||
this.btnAddChildren.Name = "btnAddChildren";
|
||||
this.btnAddChildren.Size = new System.Drawing.Size(120, 29);
|
||||
this.btnAddChildren.Size = new System.Drawing.Size(81, 22);
|
||||
this.btnAddChildren.Text = "Add Children";
|
||||
this.btnAddChildren.Click += new System.EventHandler(this.btnAddChildren_Click);
|
||||
//
|
||||
// propertyGrid1
|
||||
//
|
||||
this.propertyGrid1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.propertyGrid1.LineColor = System.Drawing.SystemColors.ControlDark;
|
||||
this.propertyGrid1.Location = new System.Drawing.Point(0, 27);
|
||||
this.propertyGrid1.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
|
||||
this.propertyGrid1.Name = "propertyGrid1";
|
||||
this.propertyGrid1.Size = new System.Drawing.Size(359, 605);
|
||||
this.propertyGrid1.TabIndex = 0;
|
||||
this.propertyGrid1.PropertyValueChanged += new System.Windows.Forms.PropertyValueChangedEventHandler(this.propertyGrid1_PropertyValueChanged);
|
||||
//
|
||||
// InspectForm
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F);
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(1426, 972);
|
||||
this.ClientSize = new System.Drawing.Size(951, 632);
|
||||
this.Controls.Add(this.splitContainer1);
|
||||
this.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
|
||||
this.Name = "InspectForm";
|
||||
this.Text = "InspectForm";
|
||||
this.splitContainer1.Panel1.ResumeLayout(false);
|
||||
|
|
|
|||
|
|
@ -17,53 +17,38 @@ namespace MatterHackers.MatterControl
|
|||
|
||||
private Dictionary<GuiWidget, TreeNode> treeNodes = new Dictionary<GuiWidget, TreeNode>();
|
||||
|
||||
public InspectForm(GuiWidget inspectionSource)
|
||||
public InspectForm(GuiWidget inspectedSystemWindow)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
this.inspectedSystemWindow = inspectedSystemWindow;
|
||||
|
||||
// Store position on move, invalidate in needed
|
||||
inspectionSource.MouseMove += (s, e) =>
|
||||
{
|
||||
mousePosition = e.Position;
|
||||
|
||||
if (this.InspectedWidget?.FirstWidgetUnderMouse == false)
|
||||
{
|
||||
this.inspectedSystemWindow.Invalidate();
|
||||
}
|
||||
};
|
||||
|
||||
inspectionSource.AfterDraw += (s, e) =>
|
||||
{
|
||||
if (this.Inspecting && !inspectionSource.HasBeenClosed)
|
||||
{
|
||||
var namedChildren = new List<GuiWidget.WidgetAndPosition>();
|
||||
inspectedSystemWindow.FindNamedChildrenRecursive(
|
||||
"",
|
||||
namedChildren,
|
||||
new RectangleDouble(mousePosition.x, mousePosition.y, mousePosition.x + 1, mousePosition.y + 1),
|
||||
GuiWidget.SearchType.Partial,
|
||||
allowDisabledOrHidden: false);
|
||||
|
||||
// If the context changed, update the UI
|
||||
if (namedChildren.LastOrDefault()?.widget is GuiWidget firstUnderMouse
|
||||
&& firstUnderMouse != this.InspectedWidget)
|
||||
{
|
||||
RebuildUI(namedChildren);
|
||||
|
||||
this.InspectedWidget = firstUnderMouse;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
this.inspectedSystemWindow = inspectionSource;
|
||||
|
||||
inspectionSource.Invalidate();
|
||||
inspectedSystemWindow.MouseMove += systemWindow_MouseMove;
|
||||
inspectedSystemWindow.AfterDraw += systemWindow_AfterDraw;
|
||||
inspectedSystemWindow.Invalidate();
|
||||
}
|
||||
|
||||
public bool Inspecting { get; set; } = true;
|
||||
|
||||
private GuiWidget mouseUpWidget;
|
||||
|
||||
protected override bool ShowWithoutActivation => true;
|
||||
|
||||
protected override CreateParams CreateParams
|
||||
{
|
||||
get
|
||||
{
|
||||
CreateParams baseParams = base.CreateParams;
|
||||
|
||||
const int WS_EX_NOACTIVATE = 0x08000000;
|
||||
const int WS_EX_TOOLWINDOW = 0x00000080;
|
||||
baseParams.ExStyle |= (int)(WS_EX_NOACTIVATE | WS_EX_TOOLWINDOW);
|
||||
|
||||
return baseParams;
|
||||
}
|
||||
}
|
||||
|
||||
private GuiWidget _inspectedWidget;
|
||||
private GuiWidget InspectedWidget
|
||||
{
|
||||
|
|
@ -82,7 +67,7 @@ namespace MatterHackers.MatterControl
|
|||
|
||||
if (mouseUpWidget != null)
|
||||
{
|
||||
mouseUpWidget.MouseUp -= InspectedWidget_MouseUp;
|
||||
mouseUpWidget.MouseUp -= inspectedWidget_MouseUp;
|
||||
}
|
||||
|
||||
_inspectedWidget = value;
|
||||
|
|
@ -103,7 +88,7 @@ namespace MatterHackers.MatterControl
|
|||
{
|
||||
// Hook to stop listing on click
|
||||
mouseUpWidget = context;
|
||||
mouseUpWidget.MouseUp += InspectedWidget_MouseUp;
|
||||
mouseUpWidget.MouseUp += inspectedWidget_MouseUp;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -115,6 +100,7 @@ namespace MatterHackers.MatterControl
|
|||
if (treeNodes.TryGetValue(_inspectedWidget, out TreeNode treeNode))
|
||||
{
|
||||
treeView1.SelectedNode = treeNode;
|
||||
treeNode.EnsureVisible();
|
||||
activeTreeNode = treeNode;
|
||||
activeTreeNode.Checked = true;
|
||||
}
|
||||
|
|
@ -123,7 +109,7 @@ namespace MatterHackers.MatterControl
|
|||
}
|
||||
}
|
||||
|
||||
private void InspectedWidget_MouseUp(object sender, Agg.UI.MouseEventArgs e)
|
||||
private void inspectedWidget_MouseUp(object sender, Agg.UI.MouseEventArgs e)
|
||||
{
|
||||
// Stop listing on click
|
||||
this.Inspecting = false;
|
||||
|
|
@ -228,6 +214,39 @@ namespace MatterHackers.MatterControl
|
|||
}
|
||||
}
|
||||
|
||||
private void systemWindow_MouseMove(object sender, Agg.UI.MouseEventArgs e)
|
||||
{
|
||||
mousePosition = e.Position;
|
||||
|
||||
if (this.InspectedWidget?.FirstWidgetUnderMouse == false)
|
||||
{
|
||||
this.inspectedSystemWindow.Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
private void systemWindow_AfterDraw(object sender, EventArgs e)
|
||||
{
|
||||
if (this.Inspecting && !inspectedSystemWindow.HasBeenClosed)
|
||||
{
|
||||
var namedChildren = new List<GuiWidget.WidgetAndPosition>();
|
||||
inspectedSystemWindow.FindNamedChildrenRecursive(
|
||||
"",
|
||||
namedChildren,
|
||||
new RectangleDouble(mousePosition.x, mousePosition.y, mousePosition.x + 1, mousePosition.y + 1),
|
||||
GuiWidget.SearchType.Partial,
|
||||
allowDisabledOrHidden: false);
|
||||
|
||||
// If the context changed, update the UI
|
||||
if (namedChildren.LastOrDefault()?.widget is GuiWidget firstUnderMouse
|
||||
&& firstUnderMouse != this.InspectedWidget)
|
||||
{
|
||||
RebuildUI(namedChildren);
|
||||
|
||||
this.InspectedWidget = firstUnderMouse;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void btnAddSiblings_Click(object sender, EventArgs e)
|
||||
{
|
||||
AddAllItems(this.InspectedWidget?.Parent?.Children);
|
||||
|
|
@ -248,5 +267,23 @@ namespace MatterHackers.MatterControl
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnFormClosing(FormClosingEventArgs e)
|
||||
{
|
||||
inspectedSystemWindow.AfterDraw -= systemWindow_AfterDraw;
|
||||
inspectedSystemWindow.MouseMove -= systemWindow_MouseMove;
|
||||
|
||||
if (mouseUpWidget != null)
|
||||
{
|
||||
mouseUpWidget.MouseUp -= inspectedWidget_MouseUp;
|
||||
}
|
||||
|
||||
base.OnFormClosing(e);
|
||||
}
|
||||
|
||||
private void treeView1_DrawNode(object sender, DrawTreeNodeEventArgs e)
|
||||
{
|
||||
e.DrawDefault = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -124,7 +124,7 @@
|
|||
<data name="btnAddSiblings.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>
|
||||
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
|
||||
YQUAAAAJcEhZcwAAFiUAABYlAUlSJPAAAAIDSURBVDhPpZLrS5NhGMb3j4SWh0oRQVExD4gonkDpg4hG
|
||||
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAIDSURBVDhPpZLrS5NhGMb3j4SWh0oRQVExD4gonkDpg4hG
|
||||
YKxG6WBogkMZKgPNCEVJFBGdGETEvgwyO9DJE5syZw3PIlPEE9pgBCLZ5XvdMB8Ew8gXbl54nuf63dd9
|
||||
0OGSnwCahxbPRNPAPMw9Xpg6ZmF46kZZ0xSKzJPIrhpDWsVnpBhGkKx3nAX8Pv7z1zg8OoY/cITdn4fw
|
||||
bf/C0kYAN3Ma/w3gWfZL5kzTKBxjWyK2DftwI9tyMYCZKXbNHaD91bLYJrDXsYbrWfUKwJrPE9M2M1Oc
|
||||
|
|
@ -139,7 +139,7 @@
|
|||
<data name="btnAddChildren.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>
|
||||
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
|
||||
YQUAAAAJcEhZcwAAFiUAABYlAUlSJPAAAAIDSURBVDhPpZLrS5NhGMb3j4SWh0oRQVExD4gonkDpg4hG
|
||||
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAIDSURBVDhPpZLrS5NhGMb3j4SWh0oRQVExD4gonkDpg4hG
|
||||
YKxG6WBogkMZKgPNCEVJFBGdGETEvgwyO9DJE5syZw3PIlPEE9pgBCLZ5XvdMB8Ew8gXbl54nuf63dd9
|
||||
0OGSnwCahxbPRNPAPMw9Xpg6ZmF46kZZ0xSKzJPIrhpDWsVnpBhGkKx3nAX8Pv7z1zg8OoY/cITdn4fw
|
||||
bf/C0kYAN3Ma/w3gWfZL5kzTKBxjWyK2DftwI9tyMYCZKXbNHaD91bLYJrDXsYbrWfUKwJrPE9M2M1Oc
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue