2019-08-01 23:47:35 +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;
|
2019-08-29 21:45:32 +02:00
|
|
|
|
using Toolbox.Library.Forms;
|
|
|
|
|
using WeifenLuo.WinFormsUI.Docking;
|
|
|
|
|
using WeifenLuo.WinFormsUI.ThemeVS2015;
|
|
|
|
|
using Toolbox.Library.IO;
|
|
|
|
|
using Toolbox.Library;
|
2019-08-01 23:47:35 +02:00
|
|
|
|
|
2019-08-27 22:38:06 +02:00
|
|
|
|
namespace FirstPlugin.Forms
|
2019-08-01 23:47:35 +02:00
|
|
|
|
{
|
2019-08-29 21:45:32 +02:00
|
|
|
|
public partial class LayoutEditor : Form
|
2019-08-01 23:47:35 +02:00
|
|
|
|
{
|
2019-08-27 22:38:06 +02:00
|
|
|
|
public List<BFLYT.Header> LayoutFiles = new List<BFLYT.Header>();
|
|
|
|
|
|
2019-08-28 03:14:37 +02:00
|
|
|
|
private BFLYT.Header ActiveLayout;
|
|
|
|
|
|
2019-08-27 22:38:06 +02:00
|
|
|
|
public enum DockLayout
|
|
|
|
|
{
|
|
|
|
|
Default,
|
|
|
|
|
Animation,
|
|
|
|
|
}
|
|
|
|
|
|
2019-08-29 21:45:32 +02:00
|
|
|
|
public EventHandler ObjectSelected;
|
|
|
|
|
public EventHandler ObjectChanged;
|
|
|
|
|
|
2019-08-01 23:47:35 +02:00
|
|
|
|
public LayoutEditor()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
2019-08-29 21:45:32 +02:00
|
|
|
|
|
|
|
|
|
var theme = new VS2015DarkTheme();
|
|
|
|
|
this.dockPanel1.Theme = theme;
|
|
|
|
|
this.dockPanel1.BackColor = FormThemes.BaseTheme.FormBackColor;
|
|
|
|
|
this.BackColor = FormThemes.BaseTheme.FormBackColor;
|
|
|
|
|
|
|
|
|
|
viewportBackColorCB.Items.Add("Back Color : Default");
|
|
|
|
|
viewportBackColorCB.Items.Add("Back Color : Custom");
|
|
|
|
|
viewportBackColorCB.SelectedIndex = 0;
|
|
|
|
|
|
|
|
|
|
ObjectSelected += OnObjectSelected;
|
|
|
|
|
ObjectChanged += OnObjectChanged;
|
2019-08-01 23:47:35 +02:00
|
|
|
|
}
|
2019-08-27 22:38:06 +02:00
|
|
|
|
|
2019-08-29 21:45:32 +02:00
|
|
|
|
private DockContent TextureListDock;
|
|
|
|
|
private DockContent GroupTreeDock;
|
|
|
|
|
private DockContent PaneTreeDock;
|
|
|
|
|
private DockContent ColorDock;
|
|
|
|
|
private DockContent PropertiesDock;
|
|
|
|
|
|
|
|
|
|
private List<LayoutViewer> Viewports = new List<LayoutViewer>();
|
|
|
|
|
private LayoutViewer ActiveViewport;
|
|
|
|
|
|
2019-08-28 03:14:37 +02:00
|
|
|
|
private bool isLoaded = false;
|
2019-08-27 22:38:06 +02:00
|
|
|
|
public void LoadBflyt(BFLYT.Header header, string fileName)
|
|
|
|
|
{
|
2019-08-29 21:45:32 +02:00
|
|
|
|
LayoutFiles.Add(header);
|
|
|
|
|
ActiveLayout = header;
|
2019-08-28 03:14:37 +02:00
|
|
|
|
|
2019-08-29 21:45:32 +02:00
|
|
|
|
LayoutViewer Viewport = new LayoutViewer(header);
|
|
|
|
|
Viewport.Dock = DockStyle.Fill;
|
|
|
|
|
DockShow(Viewport, fileName, DockState.Document);
|
|
|
|
|
Viewports.Add(Viewport);
|
|
|
|
|
ActiveViewport = Viewport;
|
|
|
|
|
|
|
|
|
|
if (!isLoaded)
|
|
|
|
|
InitializeDockPanels();
|
2019-08-28 03:14:37 +02:00
|
|
|
|
|
|
|
|
|
isLoaded = true;
|
2019-08-27 22:38:06 +02:00
|
|
|
|
}
|
|
|
|
|
|
2019-08-29 21:45:32 +02:00
|
|
|
|
private void InitializeDockPanels()
|
|
|
|
|
{
|
|
|
|
|
ShowTextureList();
|
|
|
|
|
ShowPaneHierarchy();
|
|
|
|
|
ShowGroupsHierarchy();
|
|
|
|
|
ShowPropertiesPanel();
|
|
|
|
|
|
|
|
|
|
UpdateBackColor();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnObjectChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnProperyChanged()
|
|
|
|
|
{
|
|
|
|
|
if (ActiveViewport != null)
|
|
|
|
|
ActiveViewport.UpdateViewport();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private bool isChecked = false;
|
|
|
|
|
private void OnObjectSelected(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (isChecked) return;
|
|
|
|
|
|
|
|
|
|
ActiveViewport.SelectedPanes.Clear();
|
|
|
|
|
|
|
|
|
|
if (PropertiesDock != null && (string)sender == "Select")
|
|
|
|
|
{
|
|
|
|
|
if (e is TreeViewEventArgs) {
|
|
|
|
|
var node = ((TreeViewEventArgs)e).Node;
|
|
|
|
|
var pane = (BFLYT.BasePane)node.Tag;
|
|
|
|
|
|
|
|
|
|
((LayoutProperties)PropertiesDock.Controls[0]).LoadProperties(pane, OnProperyChanged);
|
|
|
|
|
|
|
|
|
|
ActiveViewport.SelectedPanes.Add(pane);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (ActiveViewport != null)
|
|
|
|
|
{
|
|
|
|
|
if (e is TreeViewEventArgs && (string)sender == "Checked" && !isChecked) {
|
|
|
|
|
isChecked = true;
|
|
|
|
|
var node = ((TreeViewEventArgs)e).Node;
|
|
|
|
|
ToggleChildern(node, node.Checked);
|
|
|
|
|
isChecked = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ActiveViewport.UpdateViewport();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ToggleChildern(TreeNode node, bool isChecked)
|
|
|
|
|
{
|
|
|
|
|
if (node.Tag is BFLYT.BasePane)
|
|
|
|
|
((BFLYT.BasePane)node.Tag).DisplayInEditor = isChecked;
|
|
|
|
|
|
|
|
|
|
node.Checked = isChecked;
|
|
|
|
|
foreach (TreeNode child in node.Nodes)
|
|
|
|
|
ToggleChildern(child, isChecked);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private DockContent DockShow(UserControl control, string text, DockAlignment dockState, DockContent dockSide = null, float Alignment = 0)
|
|
|
|
|
{
|
|
|
|
|
DockContent content = CreateContent(control, text);
|
|
|
|
|
content.Show(dockSide.Pane, dockState, Alignment);
|
|
|
|
|
return content;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private DockContent DockShow(UserControl control, string text, DockState dockState)
|
|
|
|
|
{
|
|
|
|
|
DockContent content = CreateContent(control, text);
|
|
|
|
|
content.Show(dockPanel1, dockState);
|
|
|
|
|
return content;
|
|
|
|
|
}
|
2019-08-28 03:14:37 +02:00
|
|
|
|
|
2019-08-29 21:45:32 +02:00
|
|
|
|
private DockContent CreateContent(UserControl control, string text)
|
|
|
|
|
{
|
|
|
|
|
DockContent content = new DockContent();
|
|
|
|
|
content.Text = text;
|
|
|
|
|
control.Dock = DockStyle.Fill;
|
|
|
|
|
content.Controls.Add(control);
|
|
|
|
|
return content;
|
|
|
|
|
}
|
2019-08-28 03:14:37 +02:00
|
|
|
|
|
2019-08-27 22:38:06 +02:00
|
|
|
|
public void LoadBflan()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void InitalizeEditors()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
2019-08-28 03:14:37 +02:00
|
|
|
|
|
|
|
|
|
private void LayoutEditor_ParentChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (this.ParentForm == null) return;
|
|
|
|
|
}
|
|
|
|
|
|
2019-08-29 21:45:32 +02:00
|
|
|
|
private void textureListToolStripMenuItem_Click(object sender, EventArgs e) {
|
|
|
|
|
ShowTextureList();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ShowGroupsHierarchy()
|
|
|
|
|
{
|
|
|
|
|
dockPanel1.GetContainerControl();
|
|
|
|
|
|
|
|
|
|
LayoutHierarchy hierarchyList = new LayoutHierarchy();
|
|
|
|
|
hierarchyList.LoadLayout(ActiveLayout,ObjectSelected, true);
|
|
|
|
|
GroupTreeDock = DockShow(hierarchyList, "Groups", DockAlignment.Top, TextureListDock, 0.5f);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ShowPropertiesPanel()
|
|
|
|
|
{
|
|
|
|
|
LayoutProperties properties = new LayoutProperties();
|
|
|
|
|
PropertiesDock = DockShow(properties, "Properties", DockAlignment.Top, TextureListDock, 0.5f);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ShowPaneHierarchy()
|
|
|
|
|
{
|
|
|
|
|
LayoutHierarchy hierarchyList = new LayoutHierarchy();
|
|
|
|
|
hierarchyList.LoadLayout(ActiveLayout, ObjectSelected);
|
|
|
|
|
PaneTreeDock = DockShow(hierarchyList, "Panes", DockAlignment.Top, TextureListDock, 0.5f);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ShowTextureList()
|
2019-08-28 03:14:37 +02:00
|
|
|
|
{
|
|
|
|
|
LayoutTextureList textureListForm = new LayoutTextureList();
|
|
|
|
|
textureListForm.LoadTextures(ActiveLayout);
|
2019-08-29 21:45:32 +02:00
|
|
|
|
TextureListDock = DockShow(textureListForm, "Texture List", DockState.DockRight);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void stComboBox1_MouseDoubleClick(object sender, MouseEventArgs e)
|
|
|
|
|
{
|
2019-08-28 03:14:37 +02:00
|
|
|
|
|
2019-08-29 21:45:32 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private bool isBGUpdating = false;
|
|
|
|
|
private void viewportBackColorCB_SelectedIndexChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (ActiveViewport == null || isBGUpdating) return;
|
|
|
|
|
UpdateBackColor();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void UpdateBackColor()
|
|
|
|
|
{
|
|
|
|
|
if (viewportBackColorCB.SelectedIndex == 0)
|
|
|
|
|
{
|
|
|
|
|
ActiveViewport.UpdateBackgroundColor(Color.FromArgb(130, 130, 130));
|
|
|
|
|
backColorDisplay.BackColor = Color.FromArgb(130, 130, 130);
|
|
|
|
|
}
|
2019-08-28 03:14:37 +02:00
|
|
|
|
else
|
2019-08-29 21:45:32 +02:00
|
|
|
|
{
|
|
|
|
|
ColorDialog dlg = new ColorDialog();
|
|
|
|
|
if (dlg.ShowDialog() == DialogResult.OK)
|
|
|
|
|
{
|
|
|
|
|
ActiveViewport.UpdateBackgroundColor(dlg.Color);
|
|
|
|
|
backColorDisplay.BackColor = dlg.Color;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
viewportBackColorCB.SelectedIndex = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void backColorDisplay_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
isBGUpdating = true;
|
|
|
|
|
|
|
|
|
|
ColorDialog dlg = new ColorDialog();
|
|
|
|
|
if (dlg.ShowDialog() == DialogResult.OK)
|
|
|
|
|
{
|
|
|
|
|
ActiveViewport.UpdateBackgroundColor(dlg.Color);
|
|
|
|
|
backColorDisplay.BackColor = dlg.Color;
|
|
|
|
|
|
|
|
|
|
if (viewportBackColorCB.SelectedIndex == 0)
|
|
|
|
|
viewportBackColorCB.SelectedIndex = 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
isBGUpdating = false;
|
2019-08-28 03:14:37 +02:00
|
|
|
|
}
|
2019-08-01 23:47:35 +02:00
|
|
|
|
}
|
|
|
|
|
}
|