Content Pipeline:
- Fixed wrong XML parsing in ContentProject at read time Content Compiler: - Implemented the ability to add files to a project. - Implemented showing and renaming properties of BuildItems and ContentProjects - NewProjectScreen now checks if the project already exists - Added some TreeViewExtensions
This commit is contained in:
parent
379a1bc50e
commit
4e875e2115
@ -199,6 +199,7 @@ namespace ANX.Framework.Content.Pipeline.Tasks
|
|||||||
writer.WriteEndElement();
|
writer.WriteEndElement();
|
||||||
}
|
}
|
||||||
writer.WriteEndElement();
|
writer.WriteEndElement();
|
||||||
|
writer.WriteEndElement();
|
||||||
}
|
}
|
||||||
writer.WriteEndElement();
|
writer.WriteEndElement();
|
||||||
|
|
||||||
@ -309,23 +310,36 @@ namespace ANX.Framework.Content.Pipeline.Tasks
|
|||||||
case "BuildItem":
|
case "BuildItem":
|
||||||
if (versionMajor == 1 && versionMinor >= 0)
|
if (versionMajor == 1 && versionMinor >= 0)
|
||||||
{
|
{
|
||||||
|
if (reader.NodeType != XmlNodeType.Element)
|
||||||
|
break;
|
||||||
var buildItem = new BuildItem();
|
var buildItem = new BuildItem();
|
||||||
lastBuildItem = buildItem;
|
lastBuildItem = buildItem;
|
||||||
if (reader.NodeType == XmlNodeType.Attribute)
|
reader.MoveToFirstAttribute();
|
||||||
|
while (reader.NodeType == XmlNodeType.Attribute)
|
||||||
{
|
{
|
||||||
switch (reader.Name)
|
switch (reader.Name)
|
||||||
{
|
{
|
||||||
case "AssetName":
|
case "AssetName":
|
||||||
buildItem.AssetName = reader.ReadContentAsString();
|
buildItem.AssetName = reader.ReadContentAsString();
|
||||||
|
reader.MoveToNextAttribute();
|
||||||
break;
|
break;
|
||||||
case "OutputFilename":
|
case "OutputFilename":
|
||||||
buildItem.OutputFilename = reader.ReadContentAsString();
|
buildItem.OutputFilename = reader.ReadContentAsString();
|
||||||
|
reader.MoveToNextAttribute();
|
||||||
break;
|
break;
|
||||||
case "Importer":
|
case "Importer":
|
||||||
buildItem.ImporterName = reader.ReadContentAsString();
|
buildItem.ImporterName = reader.ReadContentAsString();
|
||||||
|
reader.MoveToNextAttribute();
|
||||||
break;
|
break;
|
||||||
case "Processor":
|
case "Processor":
|
||||||
buildItem.ProcessorName = reader.ReadContentAsString();
|
buildItem.ProcessorName = reader.ReadContentAsString();
|
||||||
|
if (buildItem.AssetName == null)
|
||||||
|
reader.MoveToNextAttribute();
|
||||||
|
else
|
||||||
|
reader.Read();
|
||||||
|
break;
|
||||||
|
case "":
|
||||||
|
reader.Read();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
<ErrorReport>prompt</ErrorReport>
|
<ErrorReport>prompt</ErrorReport>
|
||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
|
<UseVSHostingProcess>true</UseVSHostingProcess>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
@ -123,6 +124,7 @@
|
|||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="Program.cs" />
|
<Compile Include="Program.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
<Compile Include="TreeViewExtensions.cs" />
|
||||||
<EmbeddedResource Include="Controls\ArrowButton.resx">
|
<EmbeddedResource Include="Controls\ArrowButton.resx">
|
||||||
<DependentUpon>ArrowButton.cs</DependentUpon>
|
<DependentUpon>ArrowButton.cs</DependentUpon>
|
||||||
</EmbeddedResource>
|
</EmbeddedResource>
|
||||||
|
@ -59,6 +59,8 @@ namespace ANX.ContentCompiler.GUI.Dialogues
|
|||||||
{
|
{
|
||||||
if (String.IsNullOrEmpty(textBoxName.Text))
|
if (String.IsNullOrEmpty(textBoxName.Text))
|
||||||
MessageBox.Show("Give your child a name!", "Missing value", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
MessageBox.Show("Give your child a name!", "Missing value", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||||||
|
else if (Directory.Exists(textBoxLocation.Text))
|
||||||
|
MessageBox.Show("A project with this name already exists in that path!", "Will not overwrite existing stuff", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
else
|
else
|
||||||
DialogResult = DialogResult.OK;
|
DialogResult = DialogResult.OK;
|
||||||
}
|
}
|
||||||
|
12
Tools/ANXContentCompilerGUI/MainWindow.Designer.cs
generated
12
Tools/ANXContentCompilerGUI/MainWindow.Designer.cs
generated
@ -259,6 +259,7 @@ namespace ANX.ContentCompiler.GUI
|
|||||||
this.treeView.Name = "treeView";
|
this.treeView.Name = "treeView";
|
||||||
this.treeView.Size = new System.Drawing.Size(219, 527);
|
this.treeView.Size = new System.Drawing.Size(219, 527);
|
||||||
this.treeView.TabIndex = 0;
|
this.treeView.TabIndex = 0;
|
||||||
|
this.treeView.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.TreeViewAfterSelect);
|
||||||
//
|
//
|
||||||
// treeViewContextMenu
|
// treeViewContextMenu
|
||||||
//
|
//
|
||||||
@ -318,7 +319,7 @@ namespace ANX.ContentCompiler.GUI
|
|||||||
this.splitContainerProperties.Panel2.Controls.Add(this.propertyGrid);
|
this.splitContainerProperties.Panel2.Controls.Add(this.propertyGrid);
|
||||||
this.splitContainerProperties.Panel2.ForeColor = System.Drawing.Color.White;
|
this.splitContainerProperties.Panel2.ForeColor = System.Drawing.Color.White;
|
||||||
this.splitContainerProperties.Size = new System.Drawing.Size(640, 549);
|
this.splitContainerProperties.Size = new System.Drawing.Size(640, 549);
|
||||||
this.splitContainerProperties.SplitterDistance = 409;
|
this.splitContainerProperties.SplitterDistance = 366;
|
||||||
this.splitContainerProperties.TabIndex = 0;
|
this.splitContainerProperties.TabIndex = 0;
|
||||||
//
|
//
|
||||||
// editingState
|
// editingState
|
||||||
@ -327,7 +328,7 @@ namespace ANX.ContentCompiler.GUI
|
|||||||
this.editingState.Font = new System.Drawing.Font("Segoe UI", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
this.editingState.Font = new System.Drawing.Font("Segoe UI", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||||
this.editingState.Location = new System.Drawing.Point(0, 0);
|
this.editingState.Location = new System.Drawing.Point(0, 0);
|
||||||
this.editingState.Name = "editingState";
|
this.editingState.Name = "editingState";
|
||||||
this.editingState.Size = new System.Drawing.Size(407, 547);
|
this.editingState.Size = new System.Drawing.Size(364, 547);
|
||||||
this.editingState.TabIndex = 1;
|
this.editingState.TabIndex = 1;
|
||||||
this.editingState.Visible = false;
|
this.editingState.Visible = false;
|
||||||
//
|
//
|
||||||
@ -337,7 +338,7 @@ namespace ANX.ContentCompiler.GUI
|
|||||||
this.startState.Font = new System.Drawing.Font("Segoe UI", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
this.startState.Font = new System.Drawing.Font("Segoe UI", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||||
this.startState.Location = new System.Drawing.Point(0, 0);
|
this.startState.Location = new System.Drawing.Point(0, 0);
|
||||||
this.startState.Name = "startState";
|
this.startState.Name = "startState";
|
||||||
this.startState.Size = new System.Drawing.Size(407, 547);
|
this.startState.Size = new System.Drawing.Size(364, 547);
|
||||||
this.startState.TabIndex = 0;
|
this.startState.TabIndex = 0;
|
||||||
this.startState.Visible = false;
|
this.startState.Visible = false;
|
||||||
//
|
//
|
||||||
@ -349,7 +350,7 @@ namespace ANX.ContentCompiler.GUI
|
|||||||
this.labelProperties.ForeColor = System.Drawing.Color.White;
|
this.labelProperties.ForeColor = System.Drawing.Color.White;
|
||||||
this.labelProperties.Location = new System.Drawing.Point(3, 0);
|
this.labelProperties.Location = new System.Drawing.Point(3, 0);
|
||||||
this.labelProperties.Name = "labelProperties";
|
this.labelProperties.Name = "labelProperties";
|
||||||
this.labelProperties.Size = new System.Drawing.Size(221, 19);
|
this.labelProperties.Size = new System.Drawing.Size(264, 19);
|
||||||
this.labelProperties.TabIndex = 2;
|
this.labelProperties.TabIndex = 2;
|
||||||
this.labelProperties.Text = "Properties";
|
this.labelProperties.Text = "Properties";
|
||||||
this.labelProperties.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
this.labelProperties.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||||
@ -370,10 +371,11 @@ namespace ANX.ContentCompiler.GUI
|
|||||||
this.propertyGrid.LineColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
|
this.propertyGrid.LineColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
|
||||||
this.propertyGrid.Location = new System.Drawing.Point(3, 22);
|
this.propertyGrid.Location = new System.Drawing.Point(3, 22);
|
||||||
this.propertyGrid.Name = "propertyGrid";
|
this.propertyGrid.Name = "propertyGrid";
|
||||||
this.propertyGrid.Size = new System.Drawing.Size(221, 503);
|
this.propertyGrid.Size = new System.Drawing.Size(264, 503);
|
||||||
this.propertyGrid.TabIndex = 0;
|
this.propertyGrid.TabIndex = 0;
|
||||||
this.propertyGrid.ViewBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(44)))), ((int)(((byte)(44)))), ((int)(((byte)(44)))));
|
this.propertyGrid.ViewBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(44)))), ((int)(((byte)(44)))), ((int)(((byte)(44)))));
|
||||||
this.propertyGrid.ViewForeColor = System.Drawing.Color.White;
|
this.propertyGrid.ViewForeColor = System.Drawing.Color.White;
|
||||||
|
this.propertyGrid.PropertyValueChanged += new System.Windows.Forms.PropertyValueChangedEventHandler(this.PropertyGridPropertyValueChanged);
|
||||||
//
|
//
|
||||||
// menuState
|
// menuState
|
||||||
//
|
//
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using ANX.ContentCompiler.GUI.Dialogues;
|
using ANX.ContentCompiler.GUI.Dialogues;
|
||||||
using ANX.Framework.Content.Pipeline;
|
using ANX.Framework.Content.Pipeline;
|
||||||
@ -103,6 +105,7 @@ namespace ANX.ContentCompiler.GUI
|
|||||||
_contentProject = new ContentProject(ProjectName)
|
_contentProject = new ContentProject(ProjectName)
|
||||||
{
|
{
|
||||||
OutputDirectory = ProjectOutputDir,
|
OutputDirectory = ProjectOutputDir,
|
||||||
|
InputDirectory = ProjectFolder,
|
||||||
Configuration = "Release",
|
Configuration = "Release",
|
||||||
Creator = "ANX Content Compiler (4.0)",
|
Creator = "ANX Content Compiler (4.0)",
|
||||||
ContentRoot = "Content",
|
ContentRoot = "Content",
|
||||||
@ -166,6 +169,42 @@ namespace ANX.ContentCompiler.GUI
|
|||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region FileMethods
|
||||||
|
private void AddFile(string file)
|
||||||
|
{
|
||||||
|
if (!File.Exists(file))
|
||||||
|
throw new FileNotFoundException();
|
||||||
|
|
||||||
|
var folder = _contentProject.ContentRoot;
|
||||||
|
var node = treeView.SelectedNode;
|
||||||
|
if (node != null)
|
||||||
|
folder = node.Name;
|
||||||
|
else
|
||||||
|
node = treeView.Nodes[0];
|
||||||
|
var absPath = ProjectFolder + Path.DirectorySeparatorChar + folder + Path.DirectorySeparatorChar + Path.GetFileName(file);
|
||||||
|
if (!Directory.Exists(Path.Combine(ProjectFolder, folder)))
|
||||||
|
Directory.CreateDirectory(Path.Combine(ProjectFolder, folder));
|
||||||
|
File.Copy(file, absPath);
|
||||||
|
var item = new BuildItem
|
||||||
|
{
|
||||||
|
AssetName = String.IsNullOrEmpty(folder) ? folder.Replace(_contentProject.ContentRoot, "") + Path.DirectorySeparatorChar + Path.GetFileNameWithoutExtension(file) : Path.GetFileNameWithoutExtension(file),
|
||||||
|
SourceFilename = absPath,
|
||||||
|
OutputFilename = ProjectOutputDir + Path.DirectorySeparatorChar + folder + Path.DirectorySeparatorChar + Path.GetFileName(file),
|
||||||
|
ImporterName = ImporterManager.GuessImporterByFileExtension(file)
|
||||||
|
};
|
||||||
|
_contentProject.BuildItems.Add(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void AddFiles(string[] files)
|
||||||
|
{
|
||||||
|
foreach (var file in files)
|
||||||
|
{
|
||||||
|
AddFile(file);
|
||||||
|
}
|
||||||
|
ChangeEnvironmentOpenProject();
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
#region EnvironmentStates
|
#region EnvironmentStates
|
||||||
public void ChangeEnvironmentStartState()
|
public void ChangeEnvironmentStartState()
|
||||||
{
|
{
|
||||||
@ -173,6 +212,8 @@ namespace ANX.ContentCompiler.GUI
|
|||||||
startState.Visible = true;
|
startState.Visible = true;
|
||||||
Text = "ANX Content Compiler 4";
|
Text = "ANX Content Compiler 4";
|
||||||
labelTitle.Text = "ANX Content Compiler 4";
|
labelTitle.Text = "ANX Content Compiler 4";
|
||||||
|
treeView.Nodes.Clear();
|
||||||
|
propertyGrid.SelectedObject = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ChangeEnvironmentOpenProject()
|
public void ChangeEnvironmentOpenProject()
|
||||||
@ -181,6 +222,68 @@ namespace ANX.ContentCompiler.GUI
|
|||||||
editingState.Visible = true;
|
editingState.Visible = true;
|
||||||
Text = ProjectName + " - ANX Content Compiler 4";
|
Text = ProjectName + " - ANX Content Compiler 4";
|
||||||
labelTitle.Text = "ANX Content Compiler 4 - " + ProjectName;
|
labelTitle.Text = "ANX Content Compiler 4 - " + ProjectName;
|
||||||
|
|
||||||
|
ProjectFolder = _contentProject.InputDirectory;
|
||||||
|
treeView.Nodes.Clear();
|
||||||
|
var rootNode = new TreeNode(ProjectName + "(" + _contentProject.ContentRoot + ")") {Name = _contentProject.ContentRoot};
|
||||||
|
treeView.Nodes.Add(rootNode);
|
||||||
|
var lastNode = rootNode;
|
||||||
|
foreach (var parts in _contentProject.BuildItems.Select(buildItem => buildItem.AssetName.Split('/')).Where(parts => parts.Length >= 2))
|
||||||
|
{
|
||||||
|
for (int i=0; i < parts.Length - 1; i++)
|
||||||
|
{
|
||||||
|
var node = new TreeNode(parts[i]) {Name = lastNode.Name + "/" + parts[i] + "/"};
|
||||||
|
if (!lastNode.Nodes.Contains(node))
|
||||||
|
{
|
||||||
|
lastNode.Nodes.Add(node);
|
||||||
|
lastNode = node;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
lastNode = lastNode.Nodes[parts[i]];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
lastNode = rootNode;
|
||||||
|
}
|
||||||
|
if (_contentProject.BuildItems.Count > 0)
|
||||||
|
{
|
||||||
|
foreach (var buildItem in _contentProject.BuildItems)
|
||||||
|
{
|
||||||
|
String[] parts = null;
|
||||||
|
if (buildItem.AssetName.Contains("\\"))
|
||||||
|
parts = buildItem.AssetName.Split('\\');
|
||||||
|
else if (buildItem.AssetName.Contains("/"))
|
||||||
|
parts = buildItem.AssetName.Split('/');
|
||||||
|
/*if (parts.Length >= 2)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < parts.Length - 1; i++)
|
||||||
|
{
|
||||||
|
lastNode = lastNode.Nodes[parts[i]];
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
string path = "";
|
||||||
|
if (parts != null)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < parts.Length - 1; i++)
|
||||||
|
{
|
||||||
|
path = parts[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!String.IsNullOrEmpty(path))
|
||||||
|
{
|
||||||
|
var node = treeView.RecursiveSearch(path);
|
||||||
|
if (node == null) throw new ArgumentNullException("Node not found!");
|
||||||
|
var item = new TreeNode(parts[parts.Length - 1]) {Name = buildItem.AssetName};
|
||||||
|
node.Nodes.Add(item);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var item = new TreeNode(buildItem.AssetName) {Name = buildItem.AssetName};
|
||||||
|
treeView.Nodes[0].Nodes.Add(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@ -295,5 +398,39 @@ namespace ANX.ContentCompiler.GUI
|
|||||||
|
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region TreeViewEvents
|
||||||
|
private void TreeViewAfterSelect(object sender, TreeViewEventArgs e)
|
||||||
|
{
|
||||||
|
if (treeView.SelectedNode == treeView.TopNode)
|
||||||
|
propertyGrid.SelectedObject = _contentProject;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
foreach (var buildItem in _contentProject.BuildItems.Where(buildItem => buildItem.AssetName.Equals(treeView.SelectedNode.Name)))
|
||||||
|
{
|
||||||
|
propertyGrid.SelectedObject = buildItem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region PropertyGridEvents
|
||||||
|
private void PropertyGridPropertyValueChanged(object s, PropertyValueChangedEventArgs e)
|
||||||
|
{
|
||||||
|
ProjectName = _contentProject.Name;
|
||||||
|
ProjectImportersDir = _contentProject.ReferenceIncludeDirectory;
|
||||||
|
ProjectFolder = _contentProject.InputDirectory;
|
||||||
|
ProjectOutputDir = _contentProject.OutputDirectory;
|
||||||
|
if (e.ChangedItem.Label.Equals("ContentRoot"))
|
||||||
|
{
|
||||||
|
foreach (BuildItem buildItem in _contentProject.BuildItems)
|
||||||
|
{
|
||||||
|
buildItem.AssetName = buildItem.AssetName.Replace((string)e.OldValue, _contentProject.ContentRoot);
|
||||||
|
}
|
||||||
|
treeView.Nodes[0].RecursivelyReplacePartOfName((string)e.OldValue, _contentProject.ContentRoot);
|
||||||
|
}
|
||||||
|
ChangeEnvironmentOpenProject();
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -58,6 +58,7 @@
|
|||||||
this.arrowButtonAddFiles.Name = "arrowButtonAddFiles";
|
this.arrowButtonAddFiles.Name = "arrowButtonAddFiles";
|
||||||
this.arrowButtonAddFiles.Size = new System.Drawing.Size(348, 64);
|
this.arrowButtonAddFiles.Size = new System.Drawing.Size(348, 64);
|
||||||
this.arrowButtonAddFiles.TabIndex = 5;
|
this.arrowButtonAddFiles.TabIndex = 5;
|
||||||
|
this.arrowButtonAddFiles.Click += new System.EventHandler(this.ArrowButtonAddFilesClick);
|
||||||
//
|
//
|
||||||
// arrowButtonCreateFolder
|
// arrowButtonCreateFolder
|
||||||
//
|
//
|
||||||
|
@ -16,5 +16,16 @@ namespace ANX.ContentCompiler.GUI.States
|
|||||||
BackColor = Settings.MainColor;
|
BackColor = Settings.MainColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void ArrowButtonAddFilesClick(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
using (var dlg = new OpenFileDialog())
|
||||||
|
{
|
||||||
|
dlg.Multiselect = true;
|
||||||
|
dlg.Title = "Add files";
|
||||||
|
if (dlg.ShowDialog() == DialogResult.OK)
|
||||||
|
MainWindow.Instance.AddFiles(dlg.FileNames);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -112,9 +112,9 @@
|
|||||||
<value>2.0</value>
|
<value>2.0</value>
|
||||||
</resheader>
|
</resheader>
|
||||||
<resheader name="reader">
|
<resheader name="reader">
|
||||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
</resheader>
|
</resheader>
|
||||||
<resheader name="writer">
|
<resheader name="writer">
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
</resheader>
|
</resheader>
|
||||||
</root>
|
</root>
|
69
Tools/ANXContentCompilerGUI/TreeViewExtensions.cs
Normal file
69
Tools/ANXContentCompilerGUI/TreeViewExtensions.cs
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace ANX.ContentCompiler.GUI
|
||||||
|
{
|
||||||
|
public static class TreeViewExtensions
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Performs a recursive search on this TreeView's nodes and its child nodes. Returns the first item found.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="treeView">The TreeView</param>
|
||||||
|
/// <param name="name">Name to search for</param>
|
||||||
|
/// <returns>The first node matching the given criteria or null</returns>
|
||||||
|
public static TreeNode RecursiveSearch(this TreeView treeView, String name)
|
||||||
|
{
|
||||||
|
foreach (TreeNode treeNode in treeView.Nodes)
|
||||||
|
{
|
||||||
|
if (treeNode.Name.Equals(name))
|
||||||
|
return treeNode;
|
||||||
|
|
||||||
|
var retNode = treeNode.RecursiveSearch(name);
|
||||||
|
if (retNode != null)
|
||||||
|
{
|
||||||
|
return retNode;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Performs a recursive search on this TreeNode's nodes and their child nodes. Returns the first item found.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="treeNode">The TreeNode</param>
|
||||||
|
/// <param name="name">Name to search for</param>
|
||||||
|
/// <returns>The first node matching the given criteria or null</returns>
|
||||||
|
public static TreeNode RecursiveSearch(this TreeNode treeNode, String name)
|
||||||
|
{
|
||||||
|
foreach (TreeNode node in treeNode.Nodes)
|
||||||
|
{
|
||||||
|
if (node.Name.Equals(name))
|
||||||
|
return node;
|
||||||
|
|
||||||
|
var ret = node.RecursiveSearch(name);
|
||||||
|
if (ret != null)
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Recursively replaces all parts of the names/texts with new values.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="tree"></param>
|
||||||
|
/// <param name="old"></param>
|
||||||
|
/// <param name="newString"></param>
|
||||||
|
public static void RecursivelyReplacePartOfName(this TreeNode tree, string old, string newString)
|
||||||
|
{
|
||||||
|
tree.Name = tree.Name.Replace(old, newString);
|
||||||
|
tree.Text = tree.Text.Replace(old, newString);
|
||||||
|
foreach (TreeNode node in tree.Nodes)
|
||||||
|
{
|
||||||
|
node.RecursivelyReplacePartOfName(old, newString);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user