refactor Template subclasses and add ObjectModel empty template prefix parameter
This commit is contained in:
parent
9430517126
commit
35549b1059
@ -2,6 +2,6 @@
|
||||
<UniversalEditor Version="4.0">
|
||||
<ObjectModels>
|
||||
<ObjectModel TypeName="UniversalEditor.ObjectModels.FileSystem.FileSystemObjectModel"
|
||||
Visible="true" />
|
||||
Visible="true" EmptyTemplatePrefix="EmptyFileSystem" />
|
||||
</ObjectModels>
|
||||
</UniversalEditor>
|
||||
|
||||
@ -6,6 +6,7 @@
|
||||
<Title>Windows filesystem</Title>
|
||||
<Description>Creates a standard Windows NT file structure.</Description>
|
||||
<IconPath LargeFileName="windows_32x32.png" SmallFileName="windows_16x16.png" />
|
||||
<Prefix>WindowsFileSystem</Prefix>
|
||||
<Path>
|
||||
<Part>General</Part>
|
||||
<Part>File system/archive</Part>
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
<ProjectTemplate ID="{BAB6BF34-F163-46A4-A34C-8FC0B08BC607}" TypeID="{B37FAACC-9946-454A-B4DB-4FAB8D044316}">
|
||||
<Information>
|
||||
<Title>Empty File System</Title>
|
||||
<ProjectNamePrefix>FileSystem</ProjectNamePrefix>
|
||||
<Prefix>FileSystem</Prefix>
|
||||
<Description>Creates an empty FileSystem project for packaging files in various archive formats.</Description>
|
||||
<IconPath LargeFileName="Images/FileSystem_32x32.png" SmallFileName="Images/FileSystem_16x16.png" />
|
||||
<Path>
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
<ProjectTemplate ID="{BAB6BF34-F163-46A4-A34C-8FC0B08BC607}" TypeID="{8E28DA96-1267-4077-910E-91D5E863C557}">
|
||||
<Information>
|
||||
<Title>Empty Torrent</Title>
|
||||
<ProjectNamePrefix>Torrent</ProjectNamePrefix>
|
||||
<Prefix>Torrent</Prefix>
|
||||
<Description>Creates an empty Torrent project for distributing files over peer-to-peer networks.</Description>
|
||||
<IconPath LargeFileName="Images/Torrent_32x32.png" SmallFileName="Images/Torrent_16x16.png" />
|
||||
<Path>
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
<ProjectTemplate ID="{b6aa9ce4-0212-448c-aadb-0a55d82262de}" TypeID="{642aa8e1-5279-430a-a57b-4d846bd0801f}">
|
||||
<Information>
|
||||
<Title>Empty Project</Title>
|
||||
<ProjectNamePrefix>Project</ProjectNamePrefix>
|
||||
<Prefix>Project</Prefix>
|
||||
<Description>Creates an empty project.</Description>
|
||||
<IconPath LargeFileName="Images/EmptyProject_32x32.png" SmallFileName="Images/EmptyProject_16x16.png" />
|
||||
<Path>
|
||||
|
||||
@ -11,7 +11,7 @@
|
||||
</ProjectTypes>
|
||||
<Information>
|
||||
<Title>Basic PlayStation(R) Mobile Project</Title>
|
||||
<ProjectNamePrefix>PsmApp</ProjectNamePrefix>
|
||||
<Prefix>PsmApp</Prefix>
|
||||
<Description>Creates a basic PlayStation Mobile app for developing on PlayStation Vita and PlayStation 3.</Description>
|
||||
<IconPath LargeFileName="Images/Psm_32x32.png" SmallFileName="Images/Psm_16x16.png" />
|
||||
<Path>
|
||||
|
||||
@ -238,6 +238,7 @@ namespace UniversalEditor
|
||||
private bool mvarVisible = true;
|
||||
public bool Visible { get { return mvarVisible; } set { mvarVisible = value; } }
|
||||
|
||||
public string EmptyTemplatePrefix { get; set; } = null;
|
||||
|
||||
private static Dictionary<Guid, ObjectModelReference> _referencesByGUID = new Dictionary<Guid, ObjectModelReference>();
|
||||
private static Dictionary<string, ObjectModelReference> _referencesByTypeName = new Dictionary<string, ObjectModelReference>();
|
||||
|
||||
@ -531,61 +531,8 @@ namespace UniversalEditor.DataFormats.UEPackage
|
||||
template.ID = new Guid(attID.Value);
|
||||
}
|
||||
|
||||
MarkupTagElement tagInformation = (tagTemplate.Elements["Information"] as MarkupTagElement);
|
||||
LoadTemplateCommonInformation(template, tagTemplate);
|
||||
|
||||
#region Information
|
||||
{
|
||||
if (tagInformation != null)
|
||||
{
|
||||
if (tagInformation.Elements["Title"] != null)
|
||||
{
|
||||
template.Title = tagInformation.Elements["Title"].Value;
|
||||
}
|
||||
if (tagInformation.Elements["Description"] != null)
|
||||
{
|
||||
template.Description = tagInformation.Elements["Description"].Value;
|
||||
}
|
||||
|
||||
MarkupTagElement tagPath = (tagInformation.Elements["Path"] as MarkupTagElement);
|
||||
if (tagPath != null)
|
||||
{
|
||||
List<string> pathParts = new List<string>();
|
||||
foreach (MarkupElement elPart in tagPath.Elements)
|
||||
{
|
||||
MarkupTagElement tagPart = (elPart as MarkupTagElement);
|
||||
if (tagPart == null) continue;
|
||||
if (tagPart.FullName != "Part") continue;
|
||||
pathParts.Add(tagPart.Value);
|
||||
}
|
||||
template.Path = pathParts.ToArray();
|
||||
}
|
||||
|
||||
MarkupTagElement tagIconPath = (tagInformation.Elements["IconPath"] as MarkupTagElement);
|
||||
if (tagIconPath != null)
|
||||
{
|
||||
MarkupAttribute attFileName = tagIconPath.Attributes["FileName"];
|
||||
if (attFileName != null)
|
||||
{
|
||||
string ImageFileName = attFileName.Value;
|
||||
template.LargeIconImageFileName = ImageFileName;
|
||||
template.SmallIconImageFileName = ImageFileName;
|
||||
}
|
||||
MarkupAttribute attLargeFileName = tagIconPath.Attributes["LargeFileName"];
|
||||
if (attLargeFileName != null)
|
||||
{
|
||||
string ImageFileName = attLargeFileName.Value;
|
||||
template.LargeIconImageFileName = ImageFileName;
|
||||
}
|
||||
MarkupAttribute attSmallFileName = tagIconPath.Attributes["SmallFileName"];
|
||||
if (attSmallFileName != null)
|
||||
{
|
||||
string ImageFileName = attSmallFileName.Value;
|
||||
template.SmallIconImageFileName = ImageFileName;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
#region Variables
|
||||
{
|
||||
MarkupTagElement tagVariables = (tagTemplate.Elements["Variables"] as MarkupTagElement);
|
||||
@ -727,72 +674,8 @@ namespace UniversalEditor.DataFormats.UEPackage
|
||||
}
|
||||
}
|
||||
|
||||
#region Information
|
||||
MarkupTagElement tagInformation = (tagTemplate.Elements["Information"] as MarkupTagElement);
|
||||
if (tagInformation != null)
|
||||
{
|
||||
MarkupTagElement tagTitle = (tagInformation.Elements["Title"] as MarkupTagElement);
|
||||
if (tagTitle != null) template.Title = tagTitle.Value;
|
||||
LoadTemplateCommonInformation(template, tagTemplate);
|
||||
|
||||
MarkupTagElement tagDescription = (tagInformation.Elements["Description"] as MarkupTagElement);
|
||||
if (tagDescription != null) template.Description = tagDescription.Value;
|
||||
|
||||
if (tagInformation.Elements["ProjectNamePrefix"] != null)
|
||||
{
|
||||
template.ProjectNamePrefix = tagInformation.Elements["ProjectNamePrefix"].Value;
|
||||
}
|
||||
|
||||
MarkupTagElement tagPath = (tagInformation.Elements["Path"] as MarkupTagElement);
|
||||
if (tagPath != null)
|
||||
{
|
||||
List<string> pathParts = new List<string>();
|
||||
foreach (MarkupElement elPart in tagPath.Elements)
|
||||
{
|
||||
MarkupTagElement tagPart = (elPart as MarkupTagElement);
|
||||
if (tagPart == null) continue;
|
||||
if (tagPart.FullName != "Part") continue;
|
||||
pathParts.Add(tagPart.Value);
|
||||
}
|
||||
template.Path = pathParts.ToArray();
|
||||
}
|
||||
|
||||
MarkupTagElement tagIconPath = (tagInformation.Elements["IconPath"] as MarkupTagElement);
|
||||
if (tagIconPath != null)
|
||||
{
|
||||
#region All Icons
|
||||
{
|
||||
MarkupAttribute attFileName = tagIconPath.Attributes["FileName"];
|
||||
if (attFileName != null)
|
||||
{
|
||||
string FileName = attFileName.Value;
|
||||
if (System.IO.File.Exists(FileName)) template.LargeIconImageFileName = FileName;
|
||||
if (System.IO.File.Exists(FileName)) template.SmallIconImageFileName = FileName;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
#region Large Icon
|
||||
{
|
||||
MarkupAttribute attLargeFileName = tagIconPath.Attributes["LargeFileName"];
|
||||
if (attLargeFileName != null)
|
||||
{
|
||||
string FileName = attLargeFileName.Value;
|
||||
if (System.IO.File.Exists(FileName)) template.LargeIconImageFileName = FileName;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
#region Small Icon
|
||||
{
|
||||
MarkupAttribute attSmallFileName = tagIconPath.Attributes["SmallFileName"];
|
||||
if (attSmallFileName != null)
|
||||
{
|
||||
string FileName = attSmallFileName.Value;
|
||||
if (System.IO.File.Exists(FileName)) template.SmallIconImageFileName = FileName;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
#region FileSystem
|
||||
{
|
||||
MarkupTagElement tagFileSystem = (tagTemplate.Elements["FileSystem"] as MarkupTagElement);
|
||||
@ -1126,6 +1009,74 @@ namespace UniversalEditor.DataFormats.UEPackage
|
||||
#endregion
|
||||
}
|
||||
|
||||
private void LoadTemplateCommonInformation(Template template, MarkupTagElement tagTemplate)
|
||||
{
|
||||
MarkupTagElement tagInformation = (tagTemplate.Elements["Information"] as MarkupTagElement);
|
||||
if (tagInformation != null)
|
||||
{
|
||||
MarkupTagElement tagTitle = (tagInformation.Elements["Title"] as MarkupTagElement);
|
||||
if (tagTitle != null) template.Title = tagTitle.Value;
|
||||
|
||||
MarkupTagElement tagDescription = (tagInformation.Elements["Description"] as MarkupTagElement);
|
||||
if (tagDescription != null) template.Description = tagDescription.Value;
|
||||
|
||||
if (tagInformation.Elements["Prefix"] != null)
|
||||
{
|
||||
template.Prefix = tagInformation.Elements["Prefix"].Value;
|
||||
}
|
||||
|
||||
MarkupTagElement tagPath = (tagInformation.Elements["Path"] as MarkupTagElement);
|
||||
if (tagPath != null)
|
||||
{
|
||||
List<string> pathParts = new List<string>();
|
||||
foreach (MarkupElement elPart in tagPath.Elements)
|
||||
{
|
||||
MarkupTagElement tagPart = (elPart as MarkupTagElement);
|
||||
if (tagPart == null) continue;
|
||||
if (tagPart.FullName != "Part") continue;
|
||||
pathParts.Add(tagPart.Value);
|
||||
}
|
||||
template.Path = pathParts.ToArray();
|
||||
}
|
||||
|
||||
MarkupTagElement tagIconPath = (tagInformation.Elements["IconPath"] as MarkupTagElement);
|
||||
if (tagIconPath != null)
|
||||
{
|
||||
#region All Icons
|
||||
{
|
||||
MarkupAttribute attFileName = tagIconPath.Attributes["FileName"];
|
||||
if (attFileName != null)
|
||||
{
|
||||
string FileName = attFileName.Value;
|
||||
if (System.IO.File.Exists(FileName)) template.LargeIconImageFileName = FileName;
|
||||
if (System.IO.File.Exists(FileName)) template.SmallIconImageFileName = FileName;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
#region Large Icon
|
||||
{
|
||||
MarkupAttribute attLargeFileName = tagIconPath.Attributes["LargeFileName"];
|
||||
if (attLargeFileName != null)
|
||||
{
|
||||
string FileName = attLargeFileName.Value;
|
||||
if (System.IO.File.Exists(FileName)) template.LargeIconImageFileName = FileName;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
#region Small Icon
|
||||
{
|
||||
MarkupAttribute attSmallFileName = tagIconPath.Attributes["SmallFileName"];
|
||||
if (attSmallFileName != null)
|
||||
{
|
||||
string FileName = attSmallFileName.Value;
|
||||
if (System.IO.File.Exists(FileName)) template.SmallIconImageFileName = FileName;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private CustomDataFormatStructure CreateStructure(MarkupTagElement tag, Dictionary<string, object> localVariables)
|
||||
{
|
||||
MarkupAttribute attID = tag.Attributes["ID"];
|
||||
|
||||
@ -70,6 +70,18 @@ namespace UniversalEditor
|
||||
private Guid mvarID = Guid.Empty;
|
||||
public Guid ID { get { return mvarID; } set { mvarID = value; } }
|
||||
|
||||
private string[] mvarPath = null;
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string[] Path { get { return mvarPath; } set { mvarPath = value; } }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the template file name prefix.
|
||||
/// </summary>
|
||||
/// <value>The template file name prefix.</value>
|
||||
public string Prefix { get; set; } = String.Empty;
|
||||
|
||||
private string mvarTitle = String.Empty;
|
||||
/// <summary>
|
||||
/// The title of the document template.
|
||||
@ -131,12 +143,6 @@ namespace UniversalEditor
|
||||
/// </summary>
|
||||
public MarkupObjectModel TemplateContent { get { return mvarTemplateContent; } }
|
||||
|
||||
private string[] mvarPath = null;
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string[] Path { get { return mvarPath; } set { mvarPath = value; } }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes the template's ObjectModel with the content specified in <see cref="TemplateContent" />.
|
||||
/// </summary>
|
||||
@ -223,17 +229,8 @@ namespace UniversalEditor
|
||||
|
||||
}
|
||||
|
||||
private string[] mvarPath = null;
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string[] Path { get { return mvarPath; } set { mvarPath = value; } }
|
||||
|
||||
public ProjectType.ProjectTypeCollection ProjectTypes { get; } = new ProjectType.ProjectTypeCollection();
|
||||
|
||||
private string mvarProjectNamePrefix = String.Empty;
|
||||
public string ProjectNamePrefix { get { return mvarProjectNamePrefix; } set { mvarProjectNamePrefix = value; } }
|
||||
|
||||
private ProjectFileSystem mvarFileSystem = new ProjectFileSystem();
|
||||
public ProjectFileSystem FileSystem { get { return mvarFileSystem; } }
|
||||
|
||||
|
||||
@ -230,15 +230,24 @@ namespace UniversalEditor.UserInterface.Dialogs
|
||||
row.SetExtraData<List<DocumentTemplate>>("dts", dts);
|
||||
}
|
||||
|
||||
DocumentTemplate dtEmpty = new DocumentTemplate();
|
||||
dtEmpty.ObjectModelReference = omr;
|
||||
dtEmpty.Title = String.Format("Blank {0} Document", path[path.Length - 1]);
|
||||
DocumentTemplate dtEmpty = CreateEmptyDocumentTemplate(omr);
|
||||
dts.Add(dtEmpty);
|
||||
}
|
||||
|
||||
InitializeObjectModelTreeViewRow(tm, row, omr, index + 1);
|
||||
}
|
||||
|
||||
private DocumentTemplate CreateEmptyDocumentTemplate(ObjectModelReference omr)
|
||||
{
|
||||
string[] path = omr.Path;
|
||||
DocumentTemplate dtEmpty = new DocumentTemplate();
|
||||
dtEmpty.ObjectModelReference = omr;
|
||||
|
||||
dtEmpty.Title = String.Format("Blank {0} Document", path[path.Length - 1]);
|
||||
dtEmpty.Prefix = omr.EmptyTemplatePrefix ?? String.Format("Empty{0}Document", path[path.Length - 1]);
|
||||
return dtEmpty;
|
||||
}
|
||||
|
||||
[EventHandler(nameof(cmdOK), "Click")]
|
||||
private void cmdOK_Click(object sender, EventArgs e)
|
||||
{
|
||||
@ -512,7 +521,7 @@ namespace UniversalEditor.UserInterface.Dialogs
|
||||
|
||||
if (!txtFileName.IsChangedByUser)
|
||||
{
|
||||
string projectNamePrefix = pt.ProjectNamePrefix;
|
||||
string projectNamePrefix = pt.Prefix;
|
||||
if (String.IsNullOrEmpty(projectNamePrefix))
|
||||
{
|
||||
projectNamePrefix = pt.Title.Replace(" ", String.Empty);
|
||||
@ -527,7 +536,13 @@ namespace UniversalEditor.UserInterface.Dialogs
|
||||
if (pt == null) return;
|
||||
if (!txtFileName.IsChangedByUser)
|
||||
{
|
||||
// txtFileName.Text = projectNamePrefix + "1";
|
||||
string projectNamePrefix = pt.Prefix;
|
||||
if (String.IsNullOrEmpty(projectNamePrefix))
|
||||
{
|
||||
projectNamePrefix = pt.Title.Replace(" ", String.Empty).Replace("/", String.Empty);
|
||||
// projectNamePrefix = "Project";
|
||||
}
|
||||
txtFileName.Text = projectNamePrefix + "1";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -509,16 +509,22 @@ namespace UniversalEditor.UserInterface
|
||||
MarkupAttribute attTypeName = tag.Attributes["TypeName"];
|
||||
MarkupAttribute attID = tag.Attributes["ID"];
|
||||
MarkupAttribute attVisible = tag.Attributes["Visible"];
|
||||
MarkupAttribute attEmptyTemplatePrefix = tag.Attributes["EmptyTemplatePrefix"];
|
||||
|
||||
ObjectModelReference omr = null;
|
||||
if (attTypeName != null)
|
||||
{
|
||||
ObjectModelReference omr = UniversalEditor.Common.Reflection.GetAvailableObjectModelByTypeName(attTypeName.Value);
|
||||
if (attVisible != null) omr.Visible = (attVisible.Value == "true");
|
||||
omr = UniversalEditor.Common.Reflection.GetAvailableObjectModelByTypeName(attTypeName.Value);
|
||||
}
|
||||
else
|
||||
{
|
||||
ObjectModelReference omr = UniversalEditor.Common.Reflection.GetAvailableObjectModelByID(new Guid(attID.Value));
|
||||
omr = UniversalEditor.Common.Reflection.GetAvailableObjectModelByID(new Guid(attID.Value));
|
||||
}
|
||||
|
||||
if (omr != null)
|
||||
{
|
||||
if (attVisible != null) omr.Visible = (attVisible.Value == "true");
|
||||
if (attEmptyTemplatePrefix != null) omr.EmptyTemplatePrefix = attEmptyTemplatePrefix.Value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user