protected override void itemsListView_DragDrop(object sender, DragEventArgs e) { if (e.Effect != DragDropEffects.Copy) { return; } IDataAnalysisProblemData problemData = null; var dropData = e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat); if (dropData is IDataAnalysisProblemData) { problemData = (IDataAnalysisProblemData)dropData; } else if (dropData is IDataAnalysisProblem) { problemData = ((IDataAnalysisProblem)dropData).ProblemData; } else if (dropData is IValueParameter) { var param = (IValueParameter)dropData; problemData = param.Value as DataAnalysisProblemData; } if (problemData == null) { return; } problemData = (IDataAnalysisProblemData)problemData.Clone(); try { problemData.AdjustProblemDataProperties(Content.ProblemData); Content.ProblemData = problemData; if (!Content.Name.EndsWith(" with changed problemData")) { Content.Name += " with changed problemData"; } Content.Filename = string.Empty; MainFormManager.GetMainForm <HeuristicLab.MainForm.WindowsForms.MainForm>().UpdateTitle(); } catch (InvalidOperationException invalidOperationException) { ErrorHandling.ShowErrorDialog(this, invalidOperationException); } catch (ArgumentException argumentException) { ErrorHandling.ShowErrorDialog(this, argumentException); } }
protected virtual void loadProblemDataButton_Click(object sender, EventArgs e) { if (loadProblemDataFileDialog.ShowDialog(this) != DialogResult.OK) { return; } try { object hlFile = XmlParser.Deserialize(loadProblemDataFileDialog.FileName); IDataAnalysisProblemData problemData = null; if (hlFile is IDataAnalysisProblemData) { problemData = (IDataAnalysisProblemData)hlFile; } else if (hlFile is IDataAnalysisProblem) { problemData = ((IDataAnalysisProblem)hlFile).ProblemData; } else if (hlFile is IDataAnalysisSolution) { problemData = ((IDataAnalysisSolution)hlFile).ProblemData; } if (problemData == null) { throw new InvalidOperationException("The chosen HeuristicLab file does not contain a ProblemData, Problem, or DataAnalysisSolution."); } var solution = (IDataAnalysisSolution)Content.Clone(); problemData.AdjustProblemDataProperties(solution.ProblemData); solution.ProblemData = problemData; if (!solution.Name.EndsWith(" with loaded problemData")) { solution.Name += " with loaded problemData"; } MainFormManager.MainForm.ShowContent(solution); } catch (InvalidOperationException invalidOperationException) { ErrorHandling.ShowErrorDialog(this, invalidOperationException); } catch (ArgumentException argumentException) { ErrorHandling.ShowErrorDialog(this, argumentException); } }
protected override void itemsListView_DragDrop(object sender, DragEventArgs e) { if (e.Effect == DragDropEffects.None) { return; } IDataAnalysisProblemData problemData = null; var dropData = e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat); if (dropData is IDataAnalysisProblemData) { problemData = (IDataAnalysisProblemData)dropData; } else if (dropData is IDataAnalysisProblem) { problemData = ((IDataAnalysisProblem)dropData).ProblemData; } else if (dropData is IValueParameter) { var param = (IValueParameter)dropData; problemData = param.Value as DataAnalysisProblemData; } if (problemData == null) { return; } try { problemData.AdjustProblemDataProperties(Content.ProblemData); Content.ProblemData = problemData; if (!Content.Name.EndsWith(" with changed problemData")) { Content.Name += " with changed problemData"; } } catch (InvalidOperationException invalidOperationException) { ErrorHandling.ShowErrorDialog(this, invalidOperationException); } catch (ArgumentException argumentException) { ErrorHandling.ShowErrorDialog(this, argumentException); } }