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; namespace HeuristicLab.OKB.Cockpit.Admin.EngineEditor { public class HL3_3OperatorGraphEditor : IOperatorGraphEditor { public string PlatformName { get { return "HL 3.3"; } } private IOperator op; public void Load(byte[] data) { using (MemoryStream stream = new MemoryStream(data)) { op = (IOperator)XmlParser.Deserialize(stream); } } public System.Windows.Forms.Control CreateControl() { var operatorGraph = new OperatorGraph(); var control = new OperatorGraphView(operatorGraph); if (op != null) { operatorGraph.AddOperator(op); operatorGraph.InitialOperator = op; } return control; } private byte[] GetData(System.Windows.Forms.Control control) { var view = control as OperatorGraphView; if (view == null || view.OperatorGraph.InitialOperator == null) return new byte[0]; IOperator initialOperator = (IOperator)view.OperatorGraph.InitialOperator.Clone(); using (MemoryStream stream = new MemoryStream()) { XmlGenerator.Serialize(initialOperator, stream, ConfigurationService.Instance.GetConfiguration(new XmlFormat())); return stream.ToArray(); } } public byte[] GetAlgorithmData(System.Windows.Forms.Control control) { return GetData(control); } public byte[] GetProblemData(System.Windows.Forms.Control control) { return GetData(control); } } }