From 99993ddb8604a3b81e768b5c29759c2c11815ea4 Mon Sep 17 00:00:00 2001 From: alcexhim Date: Tue, 21 Apr 2015 08:33:23 -0400 Subject: [PATCH] Added warning message for ProjectTemplates that do not have ProjectTypes --- .../Dialogs/NewDialog.cs | 84 +++++++++++-------- 1 file changed, 48 insertions(+), 36 deletions(-) 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 a8b92146..e0e1d841 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 @@ -90,53 +90,65 @@ namespace UniversalEditor.UserInterface.WindowsForms.Dialogs } ProjectTemplate template = (lvProjectTemplates.SelectedItems[0].Data as ProjectTemplate); - if (template.ProjectType.Variables.Count > 0) + if (template.ProjectType != null) { - CustomOption.CustomOptionCollection coll = new CustomOption.CustomOptionCollection(); - foreach (ProjectTypeVariable ptv in template.ProjectType.Variables) + if (template.ProjectType.Variables.Count > 0) { - switch (ptv.Type) + CustomOption.CustomOptionCollection coll = new CustomOption.CustomOptionCollection(); + foreach (ProjectTypeVariable ptv in template.ProjectType.Variables) { - case ProjectTypeVariableType.Choice: + switch (ptv.Type) { - List choices = new List(); - foreach (KeyValuePair kvp in ptv.ValidValues) - { - choices.Add(new CustomOptionFieldChoice(kvp.Key, kvp.Value, kvp.Value == ptv.DefaultValue)); - } + 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; + 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")) + 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 + } + } + } + else + { +#if DEBUG + if (MessageBox.Show("The specified template does not have a ProjectType set! This may cause problems with certain features that expect a ProjectType.\r\n\r\nIt is recommended that you specify a ProjectType for all project templates.\r\n\r\nYou are using the Debug build of Universal Editor. This message will not be shown in the Release build. Please fix this issue before release to ensure there are no unexpected problems in the future.", "Warning", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == System.Windows.Forms.DialogResult.Cancel) { 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 - } +#endif } mvarSelectedItem = template; break;