using System; using System.Collections.Generic; using System.Linq; using System.Text; using HeuristicLab.Core; using System.IO; using HeuristicLab.Persistence.Default.Xml; using HeuristicLab.Persistence.Core; using HeuristicLab.OKB.AlgorithmHost; using System.Windows.Forms; namespace HeuristicLab.OKB.Cockpit.Admin.ItemEditor { public class HL3_3OperatorGraphEditor : IOperatorGraphEditor { public string PlatformName { get { return "HL 3.3"; } } private ParameterizedNamedItemContainer container; public void Load(byte[] data) { using (var stream = new MemoryStream(data)) { container = (ParameterizedNamedItemContainer)XmlParser.Deserialize(stream); } } public Control CreateAlgorithmControl() { var view = new AlgorithmContainerView(); if (container == null) view.Content = new AlgorithmContainer(); else view.Content = (AlgorithmContainer)container; return (Control)view; } public Control CreateProblemControl() { var view = new ParameterizedNamedItemContainerView(); if (container == null) view.Content = new ProblemContainer(); else view.Content = container; return (Control)view; } private byte[] GetData(Control control) { var view = control as ParameterizedNamedItemContainerView; if (view == null || view.Content == null) return new byte[0]; using (MemoryStream stream = new MemoryStream()) { XmlGenerator.Serialize(view.Content, stream, ConfigurationService.Instance.GetConfiguration(new XmlFormat())); return stream.ToArray(); } } public byte[] GetAlgorithmData(Control control) { return GetData(control); } public byte[] GetProblemData(Control control) { return GetData(control); } } }