2019-08-29 21:45:32 +02:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
using FirstPlugin;
|
|
|
|
|
using Toolbox.Library.Forms;
|
2019-09-01 19:02:48 +02:00
|
|
|
|
using LayoutBXLYT.Cafe;
|
2019-08-29 21:45:32 +02:00
|
|
|
|
|
2019-08-29 22:33:23 +02:00
|
|
|
|
namespace LayoutBXLYT
|
2019-08-29 21:45:32 +02:00
|
|
|
|
{
|
2019-08-30 01:01:47 +02:00
|
|
|
|
public partial class LayoutHierarchy : LayoutDocked
|
2019-08-29 21:45:32 +02:00
|
|
|
|
{
|
|
|
|
|
public LayoutHierarchy()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
|
|
|
|
|
treeView1.BackColor = FormThemes.BaseTheme.FormBackColor;
|
|
|
|
|
treeView1.ForeColor = FormThemes.BaseTheme.FormForeColor;
|
|
|
|
|
|
|
|
|
|
var imgList = new ImageList();
|
2019-09-02 03:36:58 +02:00
|
|
|
|
imgList.Images.Add("folder", Toolbox.Library.Properties.Resources.Folder);
|
2019-08-29 22:33:23 +02:00
|
|
|
|
imgList.Images.Add("AlignmentPane", FirstPlugin.Properties.Resources.AlignmentPane);
|
|
|
|
|
imgList.Images.Add("WindowPane", FirstPlugin.Properties.Resources.WindowPane);
|
|
|
|
|
imgList.Images.Add("ScissorPane", FirstPlugin.Properties.Resources.ScissorPane);
|
|
|
|
|
imgList.Images.Add("BoundryPane", FirstPlugin.Properties.Resources.BoundryPane);
|
|
|
|
|
imgList.Images.Add("NullPane", FirstPlugin.Properties.Resources.NullPane);
|
|
|
|
|
imgList.Images.Add("PicturePane", FirstPlugin.Properties.Resources.PicturePane);
|
2019-09-02 03:36:58 +02:00
|
|
|
|
imgList.Images.Add("QuickAcess", FirstPlugin.Properties.Resources.QuickAccess);
|
2019-09-04 00:58:58 +02:00
|
|
|
|
imgList.Images.Add("TextPane", FirstPlugin.Properties.Resources.TextPane);
|
2019-09-02 03:36:58 +02:00
|
|
|
|
|
2019-08-29 21:45:32 +02:00
|
|
|
|
imgList.ImageSize = new Size(22,22);
|
|
|
|
|
treeView1.ImageList = imgList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private bool isLoaded = false;
|
|
|
|
|
private EventHandler OnProperySelected;
|
2019-08-31 00:53:45 +02:00
|
|
|
|
public void LoadLayout(BxlytHeader bxlyt, EventHandler onPropertySelected)
|
2019-08-29 21:45:32 +02:00
|
|
|
|
{
|
|
|
|
|
isLoaded = false;
|
|
|
|
|
OnProperySelected = onPropertySelected;
|
|
|
|
|
|
2019-09-02 03:36:58 +02:00
|
|
|
|
treeView1.BeginUpdate();
|
2019-08-29 23:17:24 +02:00
|
|
|
|
treeView1.Nodes.Clear();
|
|
|
|
|
|
2019-09-04 20:10:17 +02:00
|
|
|
|
treeView1.Nodes.Add(new TreeNode("File Settings") {Tag = bxlyt });
|
|
|
|
|
|
2019-09-02 03:36:58 +02:00
|
|
|
|
CreateQuickAccess(bxlyt);
|
2019-08-31 00:53:45 +02:00
|
|
|
|
LoadPane(bxlyt.RootGroup);
|
|
|
|
|
LoadPane(bxlyt.RootPane);
|
2019-08-29 21:45:32 +02:00
|
|
|
|
|
2019-09-02 03:36:58 +02:00
|
|
|
|
treeView1.EndUpdate();
|
|
|
|
|
|
2019-08-29 21:45:32 +02:00
|
|
|
|
isLoaded = true;
|
|
|
|
|
}
|
|
|
|
|
|
2019-08-30 01:01:47 +02:00
|
|
|
|
public void Reset()
|
|
|
|
|
{
|
|
|
|
|
treeView1.Nodes.Clear();
|
|
|
|
|
isLoaded = false;
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-02 03:36:58 +02:00
|
|
|
|
private void CreateQuickAccess(BxlytHeader bxlyt)
|
|
|
|
|
{
|
|
|
|
|
var panes = new List<BasePane>();
|
|
|
|
|
var groupPanes = new List<BasePane>();
|
|
|
|
|
GetPanes(bxlyt.RootPane,ref panes);
|
|
|
|
|
GetGroupPanes(bxlyt.RootGroup,ref groupPanes);
|
|
|
|
|
|
|
|
|
|
TreeNode node = new TreeNode("Quick Access");
|
|
|
|
|
node.ImageKey = "QuickAcess";
|
|
|
|
|
node.SelectedImageKey = "QuickAcess";
|
|
|
|
|
treeView1.Nodes.Add(node);
|
|
|
|
|
|
|
|
|
|
TreeNode nullFolder = new TreeNode("Null Panes");
|
2019-09-04 00:58:58 +02:00
|
|
|
|
TreeNode textFolder = new TreeNode("Text Boxes");
|
2019-09-02 03:36:58 +02:00
|
|
|
|
TreeNode windowFolder = new TreeNode("Window Panes");
|
|
|
|
|
TreeNode pictureFolder = new TreeNode("Picture Panes");
|
|
|
|
|
TreeNode boundryFolder = new TreeNode("Boundry Panes");
|
|
|
|
|
TreeNode partsFolder = new TreeNode("Part Panes");
|
|
|
|
|
TreeNode groupFolder = new TreeNode("Groups");
|
|
|
|
|
|
|
|
|
|
node.Nodes.Add(nullFolder);
|
2019-09-04 00:58:58 +02:00
|
|
|
|
node.Nodes.Add(textFolder);
|
2019-09-02 03:36:58 +02:00
|
|
|
|
node.Nodes.Add(windowFolder);
|
|
|
|
|
node.Nodes.Add(pictureFolder);
|
|
|
|
|
node.Nodes.Add(boundryFolder);
|
|
|
|
|
node.Nodes.Add(partsFolder);
|
|
|
|
|
node.Nodes.Add(groupFolder);
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < panes.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
var paneNode = CreatePaneWrapper(panes[i]);
|
|
|
|
|
if (panes[i] is BFLYT.WND1) windowFolder.Nodes.Add(paneNode);
|
|
|
|
|
else if (panes[i] is BCLYT.WND1) windowFolder.Nodes.Add(paneNode);
|
|
|
|
|
else if (panes[i] is BRLYT.WND1) windowFolder.Nodes.Add(paneNode);
|
|
|
|
|
else if (panes[i] is BFLYT.PIC1) pictureFolder.Nodes.Add(paneNode);
|
|
|
|
|
else if (panes[i] is BCLYT.PIC1) pictureFolder.Nodes.Add(paneNode);
|
|
|
|
|
else if (panes[i] is BRLYT.PIC1) pictureFolder.Nodes.Add(paneNode);
|
|
|
|
|
else if (panes[i] is BFLYT.BND1) boundryFolder.Nodes.Add(paneNode);
|
|
|
|
|
else if (panes[i] is BCLYT.BND1) boundryFolder.Nodes.Add(paneNode);
|
|
|
|
|
else if (panes[i] is BRLYT.BND1) boundryFolder.Nodes.Add(paneNode);
|
|
|
|
|
else if (panes[i] is BCLYT.PRT1) partsFolder.Nodes.Add(paneNode);
|
|
|
|
|
else if (panes[i] is BFLYT.PRT1) partsFolder.Nodes.Add(paneNode);
|
|
|
|
|
else if (panes[i] is BRLYT.PRT1) partsFolder.Nodes.Add(paneNode);
|
2019-09-04 00:58:58 +02:00
|
|
|
|
else if (panes[i] is BRLYT.TXT1) textFolder.Nodes.Add(paneNode);
|
|
|
|
|
else if (panes[i] is BCLYT.TXT1) textFolder.Nodes.Add(paneNode);
|
|
|
|
|
else if (panes[i] is BFLYT.TXT1) textFolder.Nodes.Add(paneNode);
|
2019-09-02 03:36:58 +02:00
|
|
|
|
else nullFolder.Nodes.Add(paneNode);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < groupPanes.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
var paneNode = CreatePaneWrapper(groupPanes[i]);
|
|
|
|
|
groupFolder.Nodes.Add(paneNode);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void GetPanes(BasePane pane, ref List<BasePane> panes)
|
|
|
|
|
{
|
|
|
|
|
panes.Add(pane);
|
|
|
|
|
foreach (var childPane in pane.Childern)
|
|
|
|
|
GetPanes(childPane,ref panes);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void GetGroupPanes(BasePane pane, ref List<BasePane> panes)
|
|
|
|
|
{
|
|
|
|
|
panes.Add(pane);
|
|
|
|
|
foreach (var childPane in pane.Childern)
|
|
|
|
|
GetPanes(childPane,ref panes);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private PaneTreeWrapper CreatePaneWrapper(BasePane pane)
|
2019-08-29 21:45:32 +02:00
|
|
|
|
{
|
|
|
|
|
PaneTreeWrapper paneNode = new PaneTreeWrapper();
|
|
|
|
|
paneNode.Checked = true;
|
|
|
|
|
paneNode.Text = pane.Name;
|
|
|
|
|
paneNode.Tag = pane;
|
|
|
|
|
|
|
|
|
|
string imageKey = "";
|
|
|
|
|
if (pane is BFLYT.WND1) imageKey = "WindowPane";
|
2019-08-31 23:24:05 +02:00
|
|
|
|
else if (pane is BCLYT.WND1) imageKey = "WindowPane";
|
|
|
|
|
else if (pane is BRLYT.WND1) imageKey = "WindowPane";
|
2019-08-29 21:45:32 +02:00
|
|
|
|
else if (pane is BFLYT.PIC1) imageKey = "PicturePane";
|
2019-08-31 23:24:05 +02:00
|
|
|
|
else if (pane is BCLYT.PIC1) imageKey = "PicturePane";
|
|
|
|
|
else if (pane is BRLYT.PIC1) imageKey = "PicturePane";
|
2019-08-29 21:45:32 +02:00
|
|
|
|
else if (pane is BFLYT.BND1) imageKey = "BoundryPane";
|
2019-08-31 00:53:45 +02:00
|
|
|
|
else if (pane is BCLYT.BND1) imageKey = "BoundryPane";
|
2019-08-31 23:24:05 +02:00
|
|
|
|
else if (pane is BRLYT.BND1) imageKey = "BoundryPane";
|
2019-09-04 00:58:58 +02:00
|
|
|
|
else if (pane is BFLYT.TXT1) imageKey = "TextPane";
|
|
|
|
|
else if (pane is BCLYT.TXT1) imageKey = "TextPane";
|
|
|
|
|
else if (pane is BRLYT.TXT1) imageKey = "TextPane";
|
2019-08-29 21:45:32 +02:00
|
|
|
|
else imageKey = "NullPane";
|
|
|
|
|
|
|
|
|
|
paneNode.ImageKey = imageKey;
|
|
|
|
|
paneNode.SelectedImageKey = imageKey;
|
|
|
|
|
|
2019-09-02 03:36:58 +02:00
|
|
|
|
return paneNode;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void LoadPane(BasePane pane, TreeNode parent = null)
|
|
|
|
|
{
|
|
|
|
|
var paneNode = CreatePaneWrapper(pane);
|
2019-08-29 21:45:32 +02:00
|
|
|
|
if (parent == null)
|
|
|
|
|
treeView1.Nodes.Add(paneNode);
|
|
|
|
|
else
|
|
|
|
|
parent.Nodes.Add(paneNode);
|
|
|
|
|
|
|
|
|
|
foreach (var childPane in pane.Childern)
|
|
|
|
|
LoadPane(childPane, paneNode);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (isLoaded)
|
|
|
|
|
OnProperySelected.Invoke("Select", e);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void treeView1_AfterCheck(object sender, TreeViewEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (isLoaded)
|
|
|
|
|
OnProperySelected.Invoke("Checked", e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|