Free cookie consent management tool by TermsFeed Policy Generator

source: branches/OKB/HeuristicLab.OKB.Cockpit.Admin.ItemEditor/HL3_3OperatorGraphEditor.cs @ 5754

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

Integrated OKB clients for HL 3.3 (#1166)

File size: 1.9 KB
Line 
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;
9using HeuristicLab.OKB.AlgorithmHost;
10using System.Windows.Forms;
11
12namespace HeuristicLab.OKB.Cockpit.Admin.ItemEditor {
13  public class HL3_3OperatorGraphEditor : IOperatorGraphEditor {
14
15    public string PlatformName {
16      get { return "HL 3.3"; }
17    }
18
19    private ParameterizedNamedItemContainer container;
20
21    public void Load(byte[] data) {
22      using (var stream = new MemoryStream(data)) {
23        container = (ParameterizedNamedItemContainer)XmlParser.Deserialize(stream);
24      }
25    }
26
27    public Control CreateAlgorithmControl() {
28      var view = new AlgorithmContainerView();
29      if (container == null)
30        view.Content = new AlgorithmContainer();
31      else
32        view.Content = (AlgorithmContainer)container;
33      return (Control)view;
34    }
35
36    public Control CreateProblemControl() {
37      var view = new ParameterizedNamedItemContainerView();
38      if (container == null)
39        view.Content = new ProblemContainer();
40      else
41        view.Content = container;
42      return (Control)view;
43    }
44
45    private byte[] GetData(Control control) {     
46      var view = control as ParameterizedNamedItemContainerView;     
47      if (view == null || view.Content == null)
48        return new byte[0];     
49      using (MemoryStream stream = new MemoryStream()) {       
50        XmlGenerator.Serialize(view.Content, stream,
51          ConfigurationService.Instance.GetConfiguration(new XmlFormat()));
52        return stream.ToArray();
53      }       
54    }
55
56    public byte[] GetAlgorithmData(Control control) {
57      return GetData(control);
58    }
59
60    public byte[] GetProblemData(Control control) {
61      return GetData(control);
62    }
63
64  }
65}
Note: See TracBrowser for help on using the repository browser.