|
@@ -11,6 +11,9 @@ namespace Max2Babylon
|
|
private readonly BabylonExportActionItem babylonExportAction;
|
|
private readonly BabylonExportActionItem babylonExportAction;
|
|
private BabylonExporter exporter;
|
|
private BabylonExporter exporter;
|
|
|
|
|
|
|
|
+ TreeNode currentNode = null;
|
|
|
|
+ int currentRank = 0;
|
|
|
|
+
|
|
public ExporterForm(BabylonExportActionItem babylonExportAction)
|
|
public ExporterForm(BabylonExportActionItem babylonExportAction)
|
|
{
|
|
{
|
|
InitializeComponent();
|
|
InitializeComponent();
|
|
@@ -36,53 +39,54 @@ namespace Max2Babylon
|
|
Kernel.Scene.RootNode.SetLocalData(txtFilename.Text);
|
|
Kernel.Scene.RootNode.SetLocalData(txtFilename.Text);
|
|
|
|
|
|
exporter = new BabylonExporter();
|
|
exporter = new BabylonExporter();
|
|
- TreeNode currentNode = null;
|
|
|
|
- TreeNode previousNode = null;
|
|
|
|
|
|
|
|
treeView.Nodes.Clear();
|
|
treeView.Nodes.Clear();
|
|
|
|
|
|
- exporter.OnImportProgressChanged += progress =>
|
|
|
|
|
|
+ exporter.OnImportProgressChanged += progress =>
|
|
{
|
|
{
|
|
progressBar.Value = progress;
|
|
progressBar.Value = progress;
|
|
Application.DoEvents();
|
|
Application.DoEvents();
|
|
};
|
|
};
|
|
|
|
|
|
- exporter.OnWarning += (warning, asChild) =>
|
|
|
|
|
|
+ exporter.OnWarning += (warning, rank) =>
|
|
{
|
|
{
|
|
- previousNode = new TreeNode(warning) { ForeColor = Color.Orange };
|
|
|
|
-
|
|
|
|
- currentNode = CreateTreeNode(asChild, currentNode, previousNode);
|
|
|
|
-
|
|
|
|
- previousNode.EnsureVisible();
|
|
|
|
|
|
+ try
|
|
|
|
+ {
|
|
|
|
+ currentNode = CreateTreeNode(rank, warning, Color.Orange);
|
|
|
|
+ currentNode.EnsureVisible();
|
|
|
|
+ }
|
|
|
|
+ catch
|
|
|
|
+ {
|
|
|
|
+ }
|
|
Application.DoEvents();
|
|
Application.DoEvents();
|
|
};
|
|
};
|
|
|
|
|
|
- exporter.OnError += (error, asChild) =>
|
|
|
|
|
|
+ exporter.OnError += (error, rank) =>
|
|
{
|
|
{
|
|
- previousNode = new TreeNode(error) { ForeColor = Color.Red };
|
|
|
|
-
|
|
|
|
- currentNode = CreateTreeNode(asChild, currentNode, previousNode);
|
|
|
|
-
|
|
|
|
- previousNode.EnsureVisible();
|
|
|
|
|
|
+ try
|
|
|
|
+ {
|
|
|
|
+ currentNode = CreateTreeNode(rank, error, Color.Red);
|
|
|
|
+ currentNode.EnsureVisible();
|
|
|
|
+ }
|
|
|
|
+ catch
|
|
|
|
+ {
|
|
|
|
+ }
|
|
Application.DoEvents();
|
|
Application.DoEvents();
|
|
};
|
|
};
|
|
|
|
|
|
- exporter.OnMessage += (message, asChild, emphasis, embed, color) =>
|
|
|
|
|
|
+ exporter.OnMessage += (message, color, rank, emphasis) =>
|
|
{
|
|
{
|
|
- var oldPrevious = previousNode;
|
|
|
|
-
|
|
|
|
- previousNode = new TreeNode(message) {ForeColor = color};
|
|
|
|
-
|
|
|
|
- if (emphasis)
|
|
|
|
|
|
+ try
|
|
{
|
|
{
|
|
- previousNode.ForeColor = Color.Green;
|
|
|
|
- }
|
|
|
|
|
|
+ currentNode = CreateTreeNode(rank, message, color);
|
|
|
|
|
|
- currentNode = CreateTreeNode(asChild || embed, embed ? oldPrevious : currentNode, previousNode);
|
|
|
|
-
|
|
|
|
- if (emphasis)
|
|
|
|
|
|
+ if (emphasis)
|
|
|
|
+ {
|
|
|
|
+ currentNode.EnsureVisible();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ catch
|
|
{
|
|
{
|
|
- previousNode.EnsureVisible();
|
|
|
|
}
|
|
}
|
|
Application.DoEvents();
|
|
Application.DoEvents();
|
|
};
|
|
};
|
|
@@ -96,15 +100,13 @@ namespace Max2Babylon
|
|
}
|
|
}
|
|
catch (OperationCanceledException)
|
|
catch (OperationCanceledException)
|
|
{
|
|
{
|
|
- progressBar.Value = 0;
|
|
|
|
|
|
+ progressBar.Value = 0;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
catch (Exception ex)
|
|
{
|
|
{
|
|
- previousNode = new TreeNode("Exportation cancelled: " + ex.Message) { ForeColor = Color.Red };
|
|
|
|
-
|
|
|
|
- currentNode = CreateTreeNode(false, currentNode, previousNode);
|
|
|
|
|
|
+ currentNode = CreateTreeNode(0, "Exportation cancelled: " + ex.Message, Color.Red);
|
|
|
|
|
|
- previousNode.EnsureVisible();
|
|
|
|
|
|
+ currentNode.EnsureVisible();
|
|
progressBar.Value = 0;
|
|
progressBar.Value = 0;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -112,26 +114,35 @@ namespace Max2Babylon
|
|
butExport.Enabled = true;
|
|
butExport.Enabled = true;
|
|
}
|
|
}
|
|
|
|
|
|
- private TreeNode CreateTreeNode(bool asChild, TreeNode currentNode, TreeNode treeNode)
|
|
|
|
|
|
+ private TreeNode CreateTreeNode(int rank, string text, Color color)
|
|
{
|
|
{
|
|
- if (asChild)
|
|
|
|
|
|
+ var newNode = new TreeNode(text) { ForeColor = color };
|
|
|
|
+ if (rank == 0)
|
|
{
|
|
{
|
|
- currentNode.Nodes.Add(treeNode);
|
|
|
|
|
|
+ treeView.Nodes.Add(newNode);
|
|
}
|
|
}
|
|
- else
|
|
|
|
|
|
+ else if (rank == currentRank + 1)
|
|
{
|
|
{
|
|
- treeView.Nodes.Add(treeNode);
|
|
|
|
|
|
+ currentNode.Nodes.Add(newNode);
|
|
}
|
|
}
|
|
-
|
|
|
|
- if (!asChild)
|
|
|
|
|
|
+ else
|
|
{
|
|
{
|
|
- currentNode = treeNode;
|
|
|
|
|
|
+ var parentNode = currentNode;
|
|
|
|
+ while (currentRank != rank - 1)
|
|
|
|
+ {
|
|
|
|
+ parentNode = parentNode.Parent;
|
|
|
|
+ currentRank--;
|
|
|
|
+ }
|
|
|
|
+ parentNode.Nodes.Add(newNode);
|
|
}
|
|
}
|
|
- return currentNode;
|
|
|
|
|
|
+
|
|
|
|
+ currentRank = rank;
|
|
|
|
+ return newNode;
|
|
}
|
|
}
|
|
|
|
|
|
private void ExporterForm_FormClosed(object sender, FormClosedEventArgs e)
|
|
private void ExporterForm_FormClosed(object sender, FormClosedEventArgs e)
|
|
{
|
|
{
|
|
|
|
+ exporter.IsCancelled = true;
|
|
babylonExportAction.Close();
|
|
babylonExportAction.Close();
|
|
}
|
|
}
|
|
|
|
|