allow stock icons in document explorer nodes

This commit is contained in:
Michael Becker 2023-06-25 00:27:26 -04:00
parent 40710188f9
commit 3a638f60e0
2 changed files with 9 additions and 4 deletions

View File

@ -38,15 +38,19 @@ namespace UniversalEditor.UserInterface
}
}
public EditorDocumentExplorerNode(string text)
public EditorDocumentExplorerNode(string text) : this(text, StockType.None) { }
public EditorDocumentExplorerNode(string text, StockType stockType)
{
Text = text;
StockType = stockType;
Nodes = new EditorDocumentExplorerNodeCollection();
}
public EditorDocumentExplorerNode.EditorDocumentExplorerNodeCollection Nodes { get; private set; } = null;
public string Text { get; set; }
public StockType StockType { get; set; } = StockType.None;
private Dictionary<string, object> _ExtraData = new Dictionary<string, object>();
public T GetExtraData<T>(string key, T defaultValue = default(T))
{

View File

@ -22,10 +22,10 @@ namespace UniversalEditor.UserInterface.Panels
lv.BeforeContextMenu += lv_BeforeContextMenu;
lv.SelectionChanged += lv_SelectionChanged;
tm = new DefaultTreeModel(new Type[] { typeof(string) });
tm = new DefaultTreeModel(new Type[] { typeof(string), typeof(MBS.Framework.UserInterface.Drawing.Image) });
lv.Model = tm;
lv.HeaderStyle = ColumnHeaderStyle.None;
lv.Columns.Add(new ListViewColumn("Item", new CellRenderer[] { new CellRendererText(tm.Columns[0]) }));
lv.Columns.Add(new ListViewColumn("Item", new CellRenderer[] { new CellRendererImage(tm.Columns[1]), new CellRendererText(tm.Columns[0]) }));
Controls.Add(lv, new BoxLayout.Constraints(true, true));
}
@ -69,7 +69,8 @@ namespace UniversalEditor.UserInterface.Panels
{
TreeModelRow row = new TreeModelRow(new TreeModelRowColumn[]
{
new TreeModelRowColumn(tm.Columns[0], node.Text)
new TreeModelRowColumn(tm.Columns[0], node.Text),
new TreeModelRowColumn(tm.Columns[1], MBS.Framework.UserInterface.Drawing.Image.FromStock(node.StockType, 16))
});
row.SetExtraData<EditorDocumentExplorerNode>("node", node);
for (int i = 0; i < node.Nodes.Count; i++)