Free cookie consent management tool by TermsFeed Policy Generator

source: branches/OKB/HeuristicLab.OKB.Cockpit.Admin.EngineEditor/HL3_3OperatorGraphEditor.cs @ 5867

Last change on this file since 5867 was 4311, checked in by swagner, 14 years ago

Integrated OKB clients for HL 3.3 (#1166)

File size: 1.7 KB
RevLine 
[4311]1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using HeuristicLab.Core;
6using System.IO;
7using HeuristicLab.Persistence.Default.Xml;
8using HeuristicLab.Persistence.Core;
9
10namespace HeuristicLab.OKB.Cockpit.Admin.EngineEditor {
11  public class HL3_3OperatorGraphEditor : IOperatorGraphEditor {
12
13    public string PlatformName {
14      get { return "HL 3.3"; }
15    }
16
17    private IOperator op;
18
19    public void Load(byte[] data) {
20      using (MemoryStream stream = new MemoryStream(data)) {
21        op = (IOperator)XmlParser.Deserialize(stream);
22      }
23    }
24
25    public System.Windows.Forms.Control CreateControl() {
26      var operatorGraph = new OperatorGraph();
27      var control = new OperatorGraphView(operatorGraph);
28      if (op != null) {
29        operatorGraph.AddOperator(op);
30        operatorGraph.InitialOperator = op;
31      }
32      return control;
33    }
34
35    private byte[] GetData(System.Windows.Forms.Control control) {
36      var view = control as OperatorGraphView;
37      if (view == null || view.OperatorGraph.InitialOperator == null)
38        return new byte[0];
39      IOperator initialOperator = (IOperator)view.OperatorGraph.InitialOperator.Clone();
40      using (MemoryStream stream = new MemoryStream()) {
41        XmlGenerator.Serialize(initialOperator, stream,
42          ConfigurationService.Instance.GetConfiguration(new XmlFormat()));
43        return stream.ToArray();
44      }
45    }
46
47    public byte[] GetAlgorithmData(System.Windows.Forms.Control control) {
48      return GetData(control);
49    }
50
51    public byte[] GetProblemData(System.Windows.Forms.Control control) {
52      return GetData(control);
53    }
54
55  }
56}
Note: See TracBrowser for help on using the repository browser.