diff --git a/CSharp/Engines/WindowsForms/Engines/UniversalEditor.UserInterface.WindowsForms.DesktopApplication/Dialogs/NewDialog.cs b/CSharp/Engines/WindowsForms/Engines/UniversalEditor.UserInterface.WindowsForms.DesktopApplication/Dialogs/NewDialog.cs index 46d11978..a8b92146 100644 --- a/CSharp/Engines/WindowsForms/Engines/UniversalEditor.UserInterface.WindowsForms.DesktopApplication/Dialogs/NewDialog.cs +++ b/CSharp/Engines/WindowsForms/Engines/UniversalEditor.UserInterface.WindowsForms.DesktopApplication/Dialogs/NewDialog.cs @@ -89,7 +89,56 @@ namespace UniversalEditor.UserInterface.WindowsForms.Dialogs return; } - mvarSelectedItem = (lvProjectTemplates.SelectedItems[0].Data as Template); + ProjectTemplate template = (lvProjectTemplates.SelectedItems[0].Data as ProjectTemplate); + if (template.ProjectType.Variables.Count > 0) + { + CustomOption.CustomOptionCollection coll = new CustomOption.CustomOptionCollection(); + foreach (ProjectTypeVariable ptv in template.ProjectType.Variables) + { + switch (ptv.Type) + { + case ProjectTypeVariableType.Choice: + { + List choices = new List(); + foreach (KeyValuePair kvp in ptv.ValidValues) + { + choices.Add(new CustomOptionFieldChoice(kvp.Key, kvp.Value, kvp.Value == ptv.DefaultValue)); + } + + CustomOptionChoice co = new CustomOptionChoice(ptv.Name, ptv.Title, true, choices.ToArray()); + coll.Add(co); + break; + } + case ProjectTypeVariableType.FileOpen: + { + CustomOptionFile co = new CustomOptionFile(ptv.Name, ptv.Title); + co.DialogMode = CustomOptionFileDialogMode.Open; + coll.Add(co); + break; + } + case ProjectTypeVariableType.FileSave: + { + CustomOptionFile co = new CustomOptionFile(ptv.Name, ptv.Title); + co.DialogMode = CustomOptionFileDialogMode.Save; + coll.Add(co); + break; + } + } + } + + if (!Engine.CurrentEngine.ShowCustomOptionDialog(ref coll, template.ProjectType.Title + " properties")) + { + return; + } + + foreach (CustomOption co in coll) + { + // template.ProjectType.Variables[co.PropertyName].Value = co.GetValue().ToString(); + // TODO: Figure out how to assign variable values to the newly + // created project from the template + } + } + mvarSelectedItem = template; break; } } diff --git a/CSharp/Plugins/UniversalEditor.Essential/DataFormats/UEPackage/UEPackageXMLDataFormat.cs b/CSharp/Plugins/UniversalEditor.Essential/DataFormats/UEPackage/UEPackageXMLDataFormat.cs index 62a97a53..d429d7f4 100644 --- a/CSharp/Plugins/UniversalEditor.Essential/DataFormats/UEPackage/UEPackageXMLDataFormat.cs +++ b/CSharp/Plugins/UniversalEditor.Essential/DataFormats/UEPackage/UEPackageXMLDataFormat.cs @@ -444,6 +444,69 @@ namespace UniversalEditor.DataFormats.UEPackage } } #endregion + #region Variables + { + MarkupTagElement tagVariables = (tagProjectType.Elements["Variables"] as MarkupTagElement); + if (tagVariables != null) + { + foreach (MarkupElement el in tagVariables.Elements) + { + MarkupTagElement tag = (el as MarkupTagElement); + if (tag == null) continue; + if (tag.FullName != "Variable") continue; + + ProjectTypeVariable varr = new ProjectTypeVariable(); + varr.Name = (tag.Attributes["Name"] == null ? String.Empty : tag.Attributes["Name"].Value); + varr.Title = (tag.Attributes["Title"] == null ? String.Empty : tag.Attributes["Title"].Value); + + MarkupAttribute attType = tag.Attributes["Type"]; + if (attType != null) + { + switch (attType.Value.ToLower()) + { + case "choice": + { + varr.Type = ProjectTypeVariableType.Choice; + break; + } + case "fileopen": + { + varr.Type = ProjectTypeVariableType.FileOpen; + break; + } + case "filesave": + { + varr.Type = ProjectTypeVariableType.FileSave; + break; + } + default: + { + varr.Type = ProjectTypeVariableType.Text; + break; + } + } + } + + MarkupTagElement tagValidValues = (tag.Elements["ValidValues"] as MarkupTagElement); + if (tagValidValues != null) + { + foreach (MarkupElement elValidValue in tagValidValues.Elements) + { + MarkupTagElement tagValidValue = (elValidValue as MarkupTagElement); + if (tagValidValue == null) continue; + if (tagValidValue.FullName != "ValidValue") continue; + + string value = (tagValidValue.Attributes["Value"] == null ? String.Empty : tagValidValue.Attributes["Value"].Value); + string title = (tagValidValue.Attributes["Title"] == null ? value : tagValidValue.Attributes["Title"].Value); + + varr.ValidValues.Add(title, value); + } + } + projtype.Variables.Add(varr); + } + } + } + #endregion package.ProjectTypes.Add(projtype); } @@ -1077,17 +1140,15 @@ namespace UniversalEditor.DataFormats.UEPackage } } #endregion - #region ProjectVariables + #region Variables { - /* - if (projtype.ProjectVariables.Count > 0) + if (projtype.Variables.Count > 0) { - MarkupTagElement tagProjectVariables = new MarkupTagElement(); - tagProjectVariables.FullName = "ProjectVariables"; + MarkupTagElement tagVariables = new MarkupTagElement(); + tagVariables.FullName = "Variables"; - tagProjectType.Elements.Add(tagProjectVariables); + tagProjectType.Elements.Add(tagVariables); } - */ } #endregion diff --git a/CSharp/Plugins/UniversalEditor.Essential/ProjectType.cs b/CSharp/Plugins/UniversalEditor.Essential/ProjectType.cs index c99fa491..f0479599 100644 --- a/CSharp/Plugins/UniversalEditor.Essential/ProjectType.cs +++ b/CSharp/Plugins/UniversalEditor.Essential/ProjectType.cs @@ -33,6 +33,9 @@ namespace UniversalEditor private ProjectTypeItemShortcut.ProjectTypeItemShortcutCollection mvarItemShortcuts = new ProjectTypeItemShortcut.ProjectTypeItemShortcutCollection(); public ProjectTypeItemShortcut.ProjectTypeItemShortcutCollection ItemShortcuts { get { return mvarItemShortcuts; } } + + private ProjectTypeVariable.ProjectTypeVariableCollection mvarVariables = new ProjectTypeVariable.ProjectTypeVariableCollection(); + public ProjectTypeVariable.ProjectTypeVariableCollection Variables { get { return mvarVariables; } } } /// /// A shortcut placed in the "Add New Item" menu when the project is selected. When diff --git a/CSharp/Plugins/UniversalEditor.Essential/UniversalEditor.Essential.csproj b/CSharp/Plugins/UniversalEditor.Essential/UniversalEditor.Essential.csproj index 20118887..de87e9c9 100644 --- a/CSharp/Plugins/UniversalEditor.Essential/UniversalEditor.Essential.csproj +++ b/CSharp/Plugins/UniversalEditor.Essential/UniversalEditor.Essential.csproj @@ -116,6 +116,7 @@ +