2017-09-18 10:05:04 -07:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
2017-09-20 12:06:53 -07:00
|
|
|
|
using System.Drawing;
|
2017-09-18 10:05:04 -07:00
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
|
using MatterHackers.Agg;
|
|
|
|
|
|
using MatterHackers.Agg.UI;
|
2017-09-24 10:36:06 -07:00
|
|
|
|
using MatterHackers.DataConverters3D;
|
2017-10-21 08:56:08 -07:00
|
|
|
|
using MatterHackers.MatterControl.PartPreviewWindow;
|
2017-09-24 10:36:06 -07:00
|
|
|
|
using MatterHackers.MeshVisualizer;
|
2017-09-18 10:05:04 -07:00
|
|
|
|
using MatterHackers.VectorMath;
|
|
|
|
|
|
|
|
|
|
|
|
namespace MatterHackers.MatterControl
|
|
|
|
|
|
{
|
2016-12-01 22:03:15 -08:00
|
|
|
|
public partial class InspectForm : WinformsSystemWindow.FormInspector
|
2017-09-18 10:05:04 -07:00
|
|
|
|
{
|
|
|
|
|
|
private TreeNode activeTreeNode;
|
|
|
|
|
|
private GuiWidget inspectedSystemWindow;
|
|
|
|
|
|
|
|
|
|
|
|
private Vector2 mousePosition;
|
|
|
|
|
|
|
2017-09-24 10:36:06 -07:00
|
|
|
|
private Dictionary<GuiWidget, TreeNode> aggTreeNodes = new Dictionary<GuiWidget, TreeNode>();
|
|
|
|
|
|
private Dictionary<IObject3D, TreeNode> sceneTreeNodes = new Dictionary<IObject3D, TreeNode>();
|
|
|
|
|
|
|
|
|
|
|
|
private InteractiveScene scene;
|
2017-10-21 08:56:08 -07:00
|
|
|
|
private View3DWidget view3DWidget;
|
2017-09-24 10:36:06 -07:00
|
|
|
|
|
2017-10-21 08:56:08 -07:00
|
|
|
|
public InspectForm(GuiWidget inspectedSystemWindow, InteractiveScene scene, View3DWidget view3DWidget)
|
2017-09-24 10:36:06 -07:00
|
|
|
|
: this(inspectedSystemWindow)
|
|
|
|
|
|
{
|
2017-10-21 08:56:08 -07:00
|
|
|
|
this.view3DWidget = view3DWidget;
|
2017-09-24 10:36:06 -07:00
|
|
|
|
this.scene = scene;
|
2017-10-02 10:49:44 -07:00
|
|
|
|
this.scene.Children.ItemsModified += Scene_ChildrenModified;
|
2017-09-25 07:01:01 -07:00
|
|
|
|
sceneTreeView.SuspendLayout();
|
2017-10-21 08:57:21 -07:00
|
|
|
|
this.AddTree(scene, null);
|
|
|
|
|
|
|
2017-09-25 07:01:01 -07:00
|
|
|
|
sceneTreeView.ResumeLayout();
|
2017-10-21 08:56:08 -07:00
|
|
|
|
|
|
|
|
|
|
if (view3DWidget.ContainsFocus)
|
|
|
|
|
|
{
|
|
|
|
|
|
tabControl1.SelectedIndex = 1;
|
2017-10-21 08:59:20 -07:00
|
|
|
|
|
|
|
|
|
|
if (scene.HasSelection
|
|
|
|
|
|
&& sceneTreeNodes.TryGetValue(scene.SelectedItem, out TreeNode treeNodeToSelect))
|
|
|
|
|
|
{
|
|
|
|
|
|
sceneTreeView.SelectedNode = treeNodeToSelect;
|
|
|
|
|
|
}
|
2017-10-21 08:56:08 -07:00
|
|
|
|
}
|
2017-09-25 07:01:01 -07:00
|
|
|
|
}
|
2017-09-24 10:36:06 -07:00
|
|
|
|
|
2017-09-25 07:01:01 -07:00
|
|
|
|
private void Scene_ChildrenModified(object sender, EventArgs e)
|
|
|
|
|
|
{
|
2017-10-17 09:40:56 -07:00
|
|
|
|
UiThread.RunOnIdle(() =>
|
|
|
|
|
|
{
|
|
|
|
|
|
sceneTreeView.SuspendLayout();
|
|
|
|
|
|
sceneTreeView.Nodes.Clear();
|
|
|
|
|
|
sceneTreeNodes.Clear();
|
|
|
|
|
|
|
2017-10-21 08:57:21 -07:00
|
|
|
|
this.AddTree(scene, null);
|
2017-10-17 09:40:56 -07:00
|
|
|
|
sceneTreeView.ResumeLayout();
|
|
|
|
|
|
});
|
2017-09-24 10:36:06 -07:00
|
|
|
|
}
|
2017-09-18 10:05:04 -07:00
|
|
|
|
|
2017-09-20 11:13:31 -07:00
|
|
|
|
public InspectForm(GuiWidget inspectedSystemWindow)
|
2017-09-18 10:05:04 -07:00
|
|
|
|
{
|
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
|
|
2017-09-20 11:13:31 -07:00
|
|
|
|
this.inspectedSystemWindow = inspectedSystemWindow;
|
2017-09-19 08:44:43 -07:00
|
|
|
|
|
2017-09-20 11:13:31 -07:00
|
|
|
|
// Store position on move, invalidate in needed
|
|
|
|
|
|
inspectedSystemWindow.MouseMove += systemWindow_MouseMove;
|
|
|
|
|
|
inspectedSystemWindow.AfterDraw += systemWindow_AfterDraw;
|
|
|
|
|
|
inspectedSystemWindow.Invalidate();
|
2017-09-20 12:06:53 -07:00
|
|
|
|
|
2017-09-24 10:36:06 -07:00
|
|
|
|
aggTreeView.SuspendLayout();
|
2017-10-21 08:57:21 -07:00
|
|
|
|
this.AddTree(inspectedSystemWindow, null);
|
2017-09-24 10:36:06 -07:00
|
|
|
|
aggTreeView.ResumeLayout();
|
2017-09-20 13:08:32 -07:00
|
|
|
|
|
|
|
|
|
|
this.TopMost = true;
|
2017-09-20 11:13:31 -07:00
|
|
|
|
}
|
2017-09-18 10:05:04 -07:00
|
|
|
|
|
2017-09-20 11:13:31 -07:00
|
|
|
|
protected override bool ShowWithoutActivation => true;
|
2017-09-18 10:05:04 -07:00
|
|
|
|
|
2017-09-24 10:36:06 -07:00
|
|
|
|
private HashSet<GuiWidget> aggAncestryTree = new HashSet<GuiWidget>();
|
|
|
|
|
|
//private HashSet<IObject3D> sceneAncestryTree = new HashSet<IObject3D>();
|
2017-09-20 12:06:53 -07:00
|
|
|
|
|
2017-09-19 08:51:08 -07:00
|
|
|
|
private GuiWidget _inspectedWidget;
|
|
|
|
|
|
private GuiWidget InspectedWidget
|
|
|
|
|
|
{
|
|
|
|
|
|
get => _inspectedWidget;
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
2017-09-19 12:27:00 -07:00
|
|
|
|
if (_inspectedWidget == value)
|
|
|
|
|
|
{
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-09-19 08:51:08 -07:00
|
|
|
|
if (_inspectedWidget != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
_inspectedWidget.DebugShowBounds = false;
|
2017-09-19 12:27:00 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
2017-09-19 08:51:08 -07:00
|
|
|
|
_inspectedWidget = value;
|
|
|
|
|
|
|
2017-09-23 00:30:07 -07:00
|
|
|
|
this.Text = "Inspector" + (string.IsNullOrEmpty(_inspectedWidget?.Name) ? "" : " - " + _inspectedWidget.Name);
|
|
|
|
|
|
|
2017-09-19 08:51:08 -07:00
|
|
|
|
if (_inspectedWidget != null)
|
|
|
|
|
|
{
|
2017-09-24 10:36:06 -07:00
|
|
|
|
aggAncestryTree = new HashSet<GuiWidget>(_inspectedWidget.Parents<GuiWidget>());
|
|
|
|
|
|
aggAncestryTree.Add(_inspectedWidget);
|
2017-09-20 12:06:53 -07:00
|
|
|
|
|
2017-09-19 08:51:08 -07:00
|
|
|
|
propertyGrid1.SelectedObject = _inspectedWidget;
|
|
|
|
|
|
|
|
|
|
|
|
_inspectedWidget.DebugShowBounds = true;
|
|
|
|
|
|
|
2017-09-19 12:27:00 -07:00
|
|
|
|
var context = _inspectedWidget;
|
|
|
|
|
|
while(!context.CanSelect && context.Parent != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
context = context.Parent;
|
|
|
|
|
|
}
|
2017-09-19 08:51:08 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (activeTreeNode != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
activeTreeNode.Checked = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-09-24 10:36:06 -07:00
|
|
|
|
if (aggTreeNodes.TryGetValue(_inspectedWidget, out TreeNode treeNode))
|
2017-09-19 08:51:08 -07:00
|
|
|
|
{
|
2017-09-24 10:36:06 -07:00
|
|
|
|
aggTreeView.SelectedNode = treeNode;
|
|
|
|
|
|
|
2017-09-20 11:13:31 -07:00
|
|
|
|
treeNode.EnsureVisible();
|
2017-09-19 08:51:08 -07:00
|
|
|
|
activeTreeNode = treeNode;
|
2017-09-24 10:36:06 -07:00
|
|
|
|
aggTreeView.Invalidate();
|
2017-09-19 08:51:08 -07:00
|
|
|
|
}
|
2018-01-20 10:15:47 -08:00
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
this.AddItemEnsureAncestors(_inspectedWidget);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-09-19 08:51:08 -07:00
|
|
|
|
|
|
|
|
|
|
_inspectedWidget.Invalidate();
|
|
|
|
|
|
}
|
2017-09-20 12:06:53 -07:00
|
|
|
|
|
2017-09-19 08:51:08 -07:00
|
|
|
|
}
|
2017-09-24 10:36:06 -07:00
|
|
|
|
private IObject3D _inspectedObject3D = null;
|
|
|
|
|
|
public IObject3D InspectedObject3D
|
|
|
|
|
|
{
|
|
|
|
|
|
get => _inspectedObject3D;
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
if (_inspectedObject3D != value)
|
|
|
|
|
|
{
|
|
|
|
|
|
_inspectedObject3D = value;
|
|
|
|
|
|
|
|
|
|
|
|
if (_inspectedObject3D != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
propertyGrid1.SelectedObject = _inspectedObject3D;
|
|
|
|
|
|
|
|
|
|
|
|
//sceneAncestryTree = new HashSet<IObject3D>();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2017-09-19 08:51:08 -07:00
|
|
|
|
|
2018-01-20 10:15:47 -08:00
|
|
|
|
private void AddItemEnsureAncestors(GuiWidget widget, string text = null, TreeNode childNode = null, bool showAllParents = true)
|
2017-09-18 10:05:04 -07:00
|
|
|
|
{
|
2017-09-20 07:15:32 -07:00
|
|
|
|
if (text == null)
|
|
|
|
|
|
{
|
2017-09-20 12:06:53 -07:00
|
|
|
|
text = BuildDefaultName(widget);
|
2017-09-20 07:15:32 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
2017-09-24 10:36:06 -07:00
|
|
|
|
if (aggTreeNodes.TryGetValue(widget, out TreeNode existingNode))
|
2017-09-18 10:05:04 -07:00
|
|
|
|
{
|
2017-09-20 07:15:32 -07:00
|
|
|
|
if (childNode != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
existingNode.Nodes.Add(childNode);
|
|
|
|
|
|
}
|
2017-09-18 10:05:04 -07:00
|
|
|
|
existingNode.Expand();
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
var node = new TreeNode(text)
|
|
|
|
|
|
{
|
|
|
|
|
|
Tag = widget
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
if (childNode != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
node.Nodes.Add(childNode);
|
|
|
|
|
|
node.Expand();
|
|
|
|
|
|
}
|
2017-09-24 10:36:06 -07:00
|
|
|
|
aggTreeNodes.Add(widget, node);
|
2017-09-18 10:05:04 -07:00
|
|
|
|
|
2017-09-20 12:06:53 -07:00
|
|
|
|
if (showAllParents)
|
2017-09-18 10:05:04 -07:00
|
|
|
|
{
|
2017-09-20 12:06:53 -07:00
|
|
|
|
var parent = widget.Parent;
|
|
|
|
|
|
if (parent == null)
|
|
|
|
|
|
{
|
2017-09-24 10:36:06 -07:00
|
|
|
|
aggTreeView.Nodes.Add(node);
|
2017-09-20 12:06:53 -07:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2018-01-20 10:15:47 -08:00
|
|
|
|
AddItemEnsureAncestors(parent, null, node);
|
2017-09-20 12:06:53 -07:00
|
|
|
|
}
|
2017-09-18 10:05:04 -07:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2017-09-24 10:36:06 -07:00
|
|
|
|
aggTreeView.Nodes.Add(node);
|
2017-09-18 10:05:04 -07:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-10-21 08:57:21 -07:00
|
|
|
|
private TreeNode AddItem(GuiWidget widget, TreeNode parentNode)
|
2017-09-18 10:05:04 -07:00
|
|
|
|
{
|
2017-10-21 08:57:21 -07:00
|
|
|
|
var node = new TreeNode(BuildDefaultName(widget))
|
2017-09-20 12:06:53 -07:00
|
|
|
|
{
|
|
|
|
|
|
Tag = widget
|
|
|
|
|
|
};
|
2017-09-24 10:36:06 -07:00
|
|
|
|
aggTreeNodes.Add(widget, node);
|
2017-09-18 10:05:04 -07:00
|
|
|
|
|
2017-09-20 12:06:53 -07:00
|
|
|
|
if (parentNode == null)
|
2017-09-18 10:05:04 -07:00
|
|
|
|
{
|
2017-09-24 10:36:06 -07:00
|
|
|
|
aggTreeView.Nodes.Add(node);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
parentNode.Nodes.Add(node);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-09-25 07:01:01 -07:00
|
|
|
|
node.Expand();
|
|
|
|
|
|
|
2017-09-24 10:36:06 -07:00
|
|
|
|
return node;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-10-21 08:57:21 -07:00
|
|
|
|
private TreeNode AddItem(IObject3D item, TreeNode parentNode)
|
2017-09-24 10:36:06 -07:00
|
|
|
|
{
|
2017-10-21 08:57:21 -07:00
|
|
|
|
var node = new TreeNode(BuildDefaultName(item))
|
2017-09-24 10:36:06 -07:00
|
|
|
|
{
|
|
|
|
|
|
Tag = item
|
|
|
|
|
|
};
|
|
|
|
|
|
sceneTreeNodes.Add(item, node);
|
|
|
|
|
|
|
|
|
|
|
|
if (parentNode == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
sceneTreeView.Nodes.Add(node);
|
2017-09-25 07:01:01 -07:00
|
|
|
|
node.Expand();
|
|
|
|
|
|
|
2017-09-20 12:06:53 -07:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
parentNode.Nodes.Add(node);
|
2017-09-25 07:01:01 -07:00
|
|
|
|
parentNode.Expand();
|
2017-09-18 10:05:04 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
2017-09-25 07:01:01 -07:00
|
|
|
|
|
|
|
|
|
|
|
2017-09-20 12:06:53 -07:00
|
|
|
|
return node;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-10-21 08:57:21 -07:00
|
|
|
|
private void AddTree(GuiWidget widget, TreeNode parent)
|
2017-09-20 12:06:53 -07:00
|
|
|
|
{
|
|
|
|
|
|
var node = AddItem(widget, parent);
|
|
|
|
|
|
|
|
|
|
|
|
foreach(var child in widget.Children)
|
|
|
|
|
|
{
|
|
|
|
|
|
AddTree(child, node);
|
|
|
|
|
|
}
|
2017-09-18 10:05:04 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
2017-10-21 08:57:21 -07:00
|
|
|
|
private void AddTree(IObject3D item, TreeNode parent)
|
2017-09-24 10:36:06 -07:00
|
|
|
|
{
|
|
|
|
|
|
var node = AddItem(item, parent);
|
|
|
|
|
|
|
|
|
|
|
|
foreach (var child in item.Children)
|
|
|
|
|
|
{
|
|
|
|
|
|
AddTree(child, node);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-09-20 12:06:53 -07:00
|
|
|
|
private string BuildDefaultName(GuiWidget widget)
|
2017-09-18 10:05:04 -07:00
|
|
|
|
{
|
2017-10-31 13:53:27 -07:00
|
|
|
|
var type = widget.GetType();
|
|
|
|
|
|
string baseType = type == typeof(GuiWidget) || type.BaseType == typeof(GuiWidget) ? "" : $":{type.BaseType.Name}";
|
|
|
|
|
|
string controlName = string.IsNullOrEmpty(widget.Name) ? "" : $" - '{widget.Name}'";
|
2017-09-18 10:05:04 -07:00
|
|
|
|
|
2017-10-31 13:53:27 -07:00
|
|
|
|
return $"{type.Name}{baseType}{controlName}";
|
2017-09-18 10:05:04 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
2017-09-24 10:36:06 -07:00
|
|
|
|
private string BuildDefaultName(IObject3D item)
|
|
|
|
|
|
{
|
|
|
|
|
|
string nameToWrite = "";
|
|
|
|
|
|
if (!string.IsNullOrEmpty(item.Name))
|
|
|
|
|
|
{
|
|
|
|
|
|
nameToWrite += $"{item.GetType().Name} - {item.Name}";
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
nameToWrite += $"{item.GetType().Name}";
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return nameToWrite;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void AggTreeView_AfterSelect(object sender, TreeViewEventArgs e)
|
2017-09-18 10:05:04 -07:00
|
|
|
|
{
|
|
|
|
|
|
this.InspectedWidget = e.Node.Tag as GuiWidget;
|
|
|
|
|
|
}
|
2017-09-18 17:55:22 -07:00
|
|
|
|
|
2017-09-24 10:36:06 -07:00
|
|
|
|
private void SceneTreeView_AfterSelect(object sender, TreeViewEventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.InspectedObject3D = e.Node.Tag as IObject3D;
|
2017-10-21 08:56:08 -07:00
|
|
|
|
this.scene.DebugItem = this.InspectedObject3D;
|
2017-10-25 17:04:55 -07:00
|
|
|
|
view3DWidget.Invalidate();
|
2017-09-24 10:36:06 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
2017-09-18 17:55:22 -07:00
|
|
|
|
private void propertyGrid1_PropertyValueChanged(object s, PropertyValueChangedEventArgs e)
|
|
|
|
|
|
{
|
2017-10-21 08:56:08 -07:00
|
|
|
|
this.InspectedWidget?.Invalidate();
|
2017-09-18 17:55:22 -07:00
|
|
|
|
}
|
2017-09-19 08:44:43 -07:00
|
|
|
|
|
|
|
|
|
|
public void MoveUpTree()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (activeTreeNode?.Parent is TreeNode parent)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.InspectedWidget = parent.Tag as GuiWidget;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void MoveDownTree()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (activeTreeNode?.Nodes.Cast<TreeNode>().FirstOrDefault() is TreeNode firstChild)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.InspectedWidget = firstChild.Tag as GuiWidget;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2017-09-20 07:15:32 -07:00
|
|
|
|
|
2017-09-20 11:13:31 -07:00
|
|
|
|
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)
|
|
|
|
|
|
{
|
2017-10-21 08:56:08 -07:00
|
|
|
|
if (this.Inspecting
|
|
|
|
|
|
&& !inspectedSystemWindow.HasBeenClosed
|
|
|
|
|
|
&& tabControl1.SelectedIndex == 0)
|
2017-09-20 11:13:31 -07:00
|
|
|
|
{
|
|
|
|
|
|
var namedChildren = new List<GuiWidget.WidgetAndPosition>();
|
|
|
|
|
|
inspectedSystemWindow.FindNamedChildrenRecursive(
|
|
|
|
|
|
"",
|
|
|
|
|
|
namedChildren,
|
2017-10-31 12:51:16 -07:00
|
|
|
|
new RectangleDouble(mousePosition.X, mousePosition.Y, mousePosition.X + 1, mousePosition.Y + 1),
|
2017-09-20 11:13:31 -07:00
|
|
|
|
GuiWidget.SearchType.Partial,
|
|
|
|
|
|
allowDisabledOrHidden: false);
|
|
|
|
|
|
|
|
|
|
|
|
// If the context changed, update the UI
|
|
|
|
|
|
if (namedChildren.LastOrDefault()?.widget is GuiWidget firstUnderMouse
|
|
|
|
|
|
&& firstUnderMouse != this.InspectedWidget)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.InspectedWidget = firstUnderMouse;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected override void OnFormClosing(FormClosingEventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
inspectedSystemWindow.AfterDraw -= systemWindow_AfterDraw;
|
|
|
|
|
|
inspectedSystemWindow.MouseMove -= systemWindow_MouseMove;
|
|
|
|
|
|
|
2017-09-25 07:01:01 -07:00
|
|
|
|
if (scene != null)
|
|
|
|
|
|
{
|
2017-10-02 10:49:44 -07:00
|
|
|
|
scene.Children.ItemsModified -= Scene_ChildrenModified;
|
2017-10-21 08:56:08 -07:00
|
|
|
|
scene.DebugItem = null;
|
2017-09-25 07:01:01 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
2017-09-20 11:13:31 -07:00
|
|
|
|
base.OnFormClosing(e);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-09-24 10:36:06 -07:00
|
|
|
|
private void AggTreeView_DrawNode(object sender, DrawTreeNodeEventArgs e)
|
2017-09-20 11:13:31 -07:00
|
|
|
|
{
|
2017-09-20 12:06:53 -07:00
|
|
|
|
var node = e.Node;
|
|
|
|
|
|
|
|
|
|
|
|
if (node.IsVisible)
|
|
|
|
|
|
{
|
2017-09-20 13:08:32 -07:00
|
|
|
|
var widget = node.Tag as GuiWidget;
|
2017-09-20 12:06:53 -07:00
|
|
|
|
Brush brush;
|
|
|
|
|
|
if (node == activeTreeNode)
|
|
|
|
|
|
{
|
|
|
|
|
|
brush = SystemBrushes.Highlight;
|
|
|
|
|
|
}
|
2017-09-24 10:36:06 -07:00
|
|
|
|
else if (aggAncestryTree.Contains(widget))
|
2017-09-20 12:06:53 -07:00
|
|
|
|
{
|
|
|
|
|
|
brush = Brushes.LightBlue;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
brush = Brushes.Transparent;
|
|
|
|
|
|
}
|
2017-10-21 08:57:21 -07:00
|
|
|
|
|
2017-09-20 12:06:53 -07:00
|
|
|
|
e.Graphics.FillRectangle(brush, e.Node.Bounds);
|
|
|
|
|
|
|
|
|
|
|
|
TextRenderer.DrawText(
|
|
|
|
|
|
e.Graphics,
|
|
|
|
|
|
node.Text,
|
2018-01-20 10:15:47 -08:00
|
|
|
|
node.NodeFont,
|
2017-09-20 12:06:53 -07:00
|
|
|
|
new Point(node.Bounds.Left, node.Bounds.Top),
|
2017-09-20 13:08:32 -07:00
|
|
|
|
widget.ActuallyVisibleOnScreen() ? SystemColors.ControlText : SystemColors.GrayText,
|
2017-10-31 11:43:25 -07:00
|
|
|
|
System.Drawing.Color.Transparent);
|
2017-09-20 12:06:53 -07:00
|
|
|
|
}
|
2017-09-20 11:13:31 -07:00
|
|
|
|
}
|
2017-09-24 10:36:06 -07:00
|
|
|
|
|
|
|
|
|
|
private void SceneTreeView_DrawNode(object sender, DrawTreeNodeEventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
var node = e.Node;
|
|
|
|
|
|
if (node.IsVisible)
|
|
|
|
|
|
{
|
2017-10-21 08:56:08 -07:00
|
|
|
|
//var item = node.Tag as IObject3D;
|
|
|
|
|
|
e.Graphics.FillRectangle(
|
|
|
|
|
|
(sceneTreeView.SelectedNode == node) ? SystemBrushes.Highlight : Brushes.Transparent,
|
|
|
|
|
|
node.Bounds);
|
2017-09-24 10:36:06 -07:00
|
|
|
|
|
|
|
|
|
|
TextRenderer.DrawText(
|
|
|
|
|
|
e.Graphics,
|
|
|
|
|
|
node.Text,
|
2018-01-20 10:15:47 -08:00
|
|
|
|
node.NodeFont,
|
2017-09-24 10:36:06 -07:00
|
|
|
|
new Point(node.Bounds.Left, node.Bounds.Top),
|
|
|
|
|
|
SystemColors.ControlText,
|
2017-10-31 11:43:25 -07:00
|
|
|
|
System.Drawing.Color.Transparent);
|
2017-09-24 10:36:06 -07:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2017-10-21 08:56:08 -07:00
|
|
|
|
|
|
|
|
|
|
private void tabControl1_SelectedIndexChanged(object sender, EventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (this.activeTreeNode != null
|
|
|
|
|
|
&& tabControl1.SelectedIndex != 0
|
|
|
|
|
|
&& this.activeTreeNode.Tag is GuiWidget widget)
|
|
|
|
|
|
{
|
|
|
|
|
|
widget.DebugShowBounds = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (scene.DebugItem != null
|
|
|
|
|
|
&& tabControl1.SelectedIndex != 1)
|
|
|
|
|
|
{
|
|
|
|
|
|
scene.DebugItem = null;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-01-12 12:22:08 -08:00
|
|
|
|
|
|
|
|
|
|
private void debugTextWidget_CheckedChanged(object sender, EventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
TextWidget.DebugShowSize = debugTextWidget.Checked;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foreach(var widget in this.inspectedSystemWindow.Descendants<TextWidget>())
|
|
|
|
|
|
{
|
|
|
|
|
|
widget.Invalidate();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2018-01-20 10:15:47 -08:00
|
|
|
|
|
|
|
|
|
|
protected override void OnKeyUp(System.Windows.Forms.KeyEventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (e.KeyCode == System.Windows.Forms.Keys.F1)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.Inspecting = !this.Inspecting;
|
|
|
|
|
|
}
|
|
|
|
|
|
base.OnKeyUp(e);
|
|
|
|
|
|
}
|
2017-09-18 10:05:04 -07:00
|
|
|
|
}
|
|
|
|
|
|
}
|