Inspect elements (children/siblings) which are not under the mouse

This commit is contained in:
John Lewin 2017-09-20 07:15:32 -07:00
parent 153ef5259f
commit 75f11380f6
3 changed files with 122 additions and 15 deletions

View file

@ -28,20 +28,24 @@
/// </summary>
private void InitializeComponent()
{
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();
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
this.splitContainer1.Panel1.SuspendLayout();
this.splitContainer1.Panel2.SuspendLayout();
this.splitContainer1.SuspendLayout();
this.toolStrip1.SuspendLayout();
this.SuspendLayout();
//
// splitContainer1
//
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
@ -50,10 +54,11 @@
//
// splitContainer1.Panel2
//
this.splitContainer1.Panel2.Controls.Add(this.toolStrip1);
this.splitContainer1.Panel2.Controls.Add(this.propertyGrid1);
this.splitContainer1.Size = new System.Drawing.Size(951, 632);
this.splitContainer1.SplitterDistance = 590;
this.splitContainer1.SplitterWidth = 3;
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.TabIndex = 0;
//
// treeView1
@ -62,9 +67,8 @@
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(590, 632);
this.treeView1.Size = new System.Drawing.Size(884, 972);
this.treeView1.TabIndex = 0;
this.treeView1.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.treeView1_AfterSelect);
//
@ -72,26 +76,62 @@
//
this.propertyGrid1.Dock = System.Windows.Forms.DockStyle.Fill;
this.propertyGrid1.LineColor = System.Drawing.SystemColors.ControlDark;
this.propertyGrid1.Location = new System.Drawing.Point(0, 0);
this.propertyGrid1.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
this.propertyGrid1.Location = new System.Drawing.Point(0, 42);
this.propertyGrid1.Name = "propertyGrid1";
this.propertyGrid1.Size = new System.Drawing.Size(358, 632);
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;
this.toolStrip1.GripStyle = System.Windows.Forms.ToolStripGripStyle.Hidden;
this.toolStrip1.ImageScalingSize = new System.Drawing.Size(24, 24);
this.toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.btnAddSiblings,
this.btnAddChildren});
this.toolStrip1.Location = new System.Drawing.Point(2, 2);
this.toolStrip1.Name = "toolStrip1";
this.toolStrip1.Size = new System.Drawing.Size(286, 32);
this.toolStrip1.TabIndex = 2;
this.toolStrip1.Text = "toolStrip1";
//
// btnAddSiblings
//
this.btnAddSiblings.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text;
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.Text = "Add Siblings";
this.btnAddSiblings.ToolTipText = "Add Siblings";
this.btnAddSiblings.Click += new System.EventHandler(this.btnAddSiblings_Click);
//
// btnAddChildren
//
this.btnAddChildren.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text;
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.Text = "Add Children";
this.btnAddChildren.Click += new System.EventHandler(this.btnAddChildren_Click);
//
// InspectForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(951, 632);
this.ClientSize = new System.Drawing.Size(1426, 972);
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);
this.splitContainer1.Panel2.ResumeLayout(false);
this.splitContainer1.Panel2.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit();
this.splitContainer1.ResumeLayout(false);
this.toolStrip1.ResumeLayout(false);
this.toolStrip1.PerformLayout();
this.ResumeLayout(false);
}
@ -101,5 +141,8 @@
private System.Windows.Forms.SplitContainer splitContainer1;
private System.Windows.Forms.TreeView treeView1;
private System.Windows.Forms.PropertyGrid propertyGrid1;
private System.Windows.Forms.ToolStrip toolStrip1;
private System.Windows.Forms.ToolStripButton btnAddSiblings;
private System.Windows.Forms.ToolStripButton btnAddChildren;
}
}

View file

@ -129,11 +129,20 @@ namespace MatterHackers.MatterControl
this.Inspecting = false;
}
private void AddItem(GuiWidget widget, string text, TreeNode childNode = null)
private void AddItem(GuiWidget widget, string text = null, TreeNode childNode = null)
{
if (text == null)
{
text = BuildName(widget);
}
if (treeNodes.TryGetValue(widget, out TreeNode existingNode))
{
existingNode.Nodes.Add(childNode);
if (childNode != null)
{
existingNode.Nodes.Add(childNode);
}
existingNode.Expand();
}
else
@ -172,7 +181,7 @@ namespace MatterHackers.MatterControl
for (int i = 0; i < namedChildren.Count; i++)
{
var child = namedChildren[i];
AddItem(child.widget, BuildName(child.widget));
AddItem(child.widget);
}
treeView1.ResumeLayout();
@ -218,5 +227,26 @@ namespace MatterHackers.MatterControl
this.InspectedWidget = firstChild.Tag as GuiWidget;
}
}
private void btnAddSiblings_Click(object sender, EventArgs e)
{
AddAllItems(this.InspectedWidget?.Parent?.Children);
}
private void btnAddChildren_Click(object sender, EventArgs e)
{
AddAllItems(this.InspectedWidget?.Children);
}
private void AddAllItems(IEnumerable<GuiWidget> items)
{
if (items != null)
{
foreach (var item in items)
{
this.AddItem(item);
}
}
}
}
}

View file

@ -117,4 +117,38 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="toolStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="btnAddSiblings.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAJcEhZcwAAFiUAABYlAUlSJPAAAAIDSURBVDhPpZLrS5NhGMb3j4SWh0oRQVExD4gonkDpg4hG
YKxG6WBogkMZKgPNCEVJFBGdGETEvgwyO9DJE5syZw3PIlPEE9pgBCLZ5XvdMB8Ew8gXbl54nuf63dd9
0OGSnwCahxbPRNPAPMw9Xpg6ZmF46kZZ0xSKzJPIrhpDWsVnpBhGkKx3nAX8Pv7z1zg8OoY/cITdn4fw
bf/C0kYAN3Ma/w3gWfZL5kzTKBxjWyK2DftwI9tyMYCZKXbNHaD91bLYJrDXsYbrWfUKwJrPE9M2M1Oc
VzOOpHI7Jr376Hi9ogHqFIANO0/MmmmbmSmm9a8ze+I4MrNWAdjtoJgWcx+PSzg166yZZ8xM8XvXDix9
c4jIqFYAjoriBV9AhEPv1mH/sonogha0afbZMMZz+yreTGyhpusHwtNNCsA5U1zS4BLxzJIfg299qO32
Ir7UJtZfftyATqeT+8o2D8JSjQrAJblrncYL7ZJ2+bfaFnC/1S1NjL3diRat7qrO7wLRP3HjWsojBeCo
mDEo5mNjuweFGvjWg2EBhCbpkW78htSHHwRyNdmgAFzPEee2iFkzayy2OLXzT4gr6UdUnlXrullsxxQ+
kx0g8BTA3aZlButjSTyjODq/WcQcW/B/Je4OQhLvKQDnzN1mp0nnkvAhR8VuMzNrpm1mpjgkoVwB/v8D
TgDQASA1MVpwzwAAAABJRU5ErkJggg==
</value>
</data>
<data name="btnAddChildren.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAJcEhZcwAAFiUAABYlAUlSJPAAAAIDSURBVDhPpZLrS5NhGMb3j4SWh0oRQVExD4gonkDpg4hG
YKxG6WBogkMZKgPNCEVJFBGdGETEvgwyO9DJE5syZw3PIlPEE9pgBCLZ5XvdMB8Ew8gXbl54nuf63dd9
0OGSnwCahxbPRNPAPMw9Xpg6ZmF46kZZ0xSKzJPIrhpDWsVnpBhGkKx3nAX8Pv7z1zg8OoY/cITdn4fw
bf/C0kYAN3Ma/w3gWfZL5kzTKBxjWyK2DftwI9tyMYCZKXbNHaD91bLYJrDXsYbrWfUKwJrPE9M2M1Oc
VzOOpHI7Jr376Hi9ogHqFIANO0/MmmmbmSmm9a8ze+I4MrNWAdjtoJgWcx+PSzg166yZZ8xM8XvXDix9
c4jIqFYAjoriBV9AhEPv1mH/sonogha0afbZMMZz+yreTGyhpusHwtNNCsA5U1zS4BLxzJIfg299qO32
Ir7UJtZfftyATqeT+8o2D8JSjQrAJblrncYL7ZJ2+bfaFnC/1S1NjL3diRat7qrO7wLRP3HjWsojBeCo
mDEo5mNjuweFGvjWg2EBhCbpkW78htSHHwRyNdmgAFzPEee2iFkzayy2OLXzT4gr6UdUnlXrullsxxQ+
kx0g8BTA3aZlButjSTyjODq/WcQcW/B/Je4OQhLvKQDnzN1mp0nnkvAhR8VuMzNrpm1mpjgkoVwB/v8D
TgDQASA1MVpwzwAAAABJRU5ErkJggg==
</value>
</data>
</root>