Changeset 17444 for branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/Views/ExportJsonDialog.cs
- Timestamp:
- 02/18/20 16:28:53 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface.OptimizerIntegration/Views/ExportJsonDialog.cs
r17443 r17444 16 16 namespace HeuristicLab.JsonInterface.OptimizerIntegration { 17 17 public partial class ExportJsonDialog : Form { 18 private static SaveFileDialog SaveFileDialog { get; set; }18 private static FolderBrowserDialog FolderBrowserDialog { get; set; } 19 19 private IDictionary<int, UserControl> Hash2Control { get; set; } = new Dictionary<int, UserControl>(); 20 20 private IDictionary<TreeNode, JsonItemVMBase> Node2VM { get; set; } = new Dictionary<TreeNode, JsonItemVMBase>(); … … 71 71 72 72 private void exportButton_Click(object sender, EventArgs e) { 73 foreach (var x in VMs) {73 foreach (var x in VMs) { 74 74 if (!x.Selected) { 75 75 x.Item.Parent.Children.Remove(x.Item); … … 77 77 } 78 78 79 foreach (var x in ResultItems.Values) {79 foreach (var x in ResultItems.Values) { 80 80 x.Parent.Children.Remove(x); 81 81 } 82 82 83 foreach (var x in resultItems.CheckedItems) {84 if (ResultItems.TryGetValue((string)x, out IJsonItem item)) {83 foreach (var x in resultItems.CheckedItems) { 84 if (ResultItems.TryGetValue((string)x, out IJsonItem item)) { 85 85 Root.AddChildren(item); 86 86 } … … 88 88 89 89 IList<IJsonItem> faultyItems = new List<IJsonItem>(); 90 if(!Root.GetValidator().Validate(ref faultyItems)) { 90 91 if (!Root.GetValidator().Validate(ref faultyItems)) { 92 IList<Exception> list = new List<Exception>(); 91 93 //print faultyItems 94 foreach (var x in faultyItems) { 95 list.Add(new Exception($"Combination of value and range is not valid for {x.Name}")); 96 } 97 ErrorHandling.ShowErrorDialog(this, new AggregateException(list)); 98 } else { 99 if (FolderBrowserDialog == null) { 100 FolderBrowserDialog = new FolderBrowserDialog(); 101 FolderBrowserDialog.Description = "Select .json-Template Dictionary"; 102 } 103 104 if (FolderBrowserDialog.ShowDialog() == DialogResult.OK) { 105 Generator.GenerateTemplate(FolderBrowserDialog.SelectedPath, textBoxTemplateName.Text, Optimizer, Root); 106 } 107 108 Close(); 92 109 } 93 94 if (SaveFileDialog == null) {95 SaveFileDialog = new SaveFileDialog();96 SaveFileDialog.Title = "Export .json-Template";97 SaveFileDialog.DefaultExt = "json";98 SaveFileDialog.Filter = ".json-Template|*.json|All Files|*.*";99 SaveFileDialog.FilterIndex = 1;100 }101 102 SaveFileDialog.FileName = "template";103 104 if (SaveFileDialog.ShowDialog() == DialogResult.OK) {105 Generator.GenerateTemplate(@"C:\Users\p41997\Desktop", "template", Optimizer, Root);106 }107 108 Close();109 110 } 110 111 … … 162 163 } 163 164 } 165 166 private void textBoxTemplateName_Validating(object sender, CancelEventArgs e) { 167 if (string.IsNullOrWhiteSpace(textBoxTemplateName.Text)) { 168 errorProvider.SetError(textBoxTemplateName, "Template name must not be empty."); 169 e.Cancel = true; 170 } else { 171 errorProvider.SetError(textBoxTemplateName, null); 172 } 173 } 164 174 } 165 175 }
Note: See TracChangeset
for help on using the changeset viewer.