1 | using System;
|
---|
2 | using System.Collections.Generic;
|
---|
3 | using System.Linq;
|
---|
4 | using System.Text;
|
---|
5 | using HeuristicLab.Core;
|
---|
6 | using System.IO;
|
---|
7 | using HeuristicLab.Persistence.Default.Xml;
|
---|
8 | using HeuristicLab.Persistence.Core;
|
---|
9 | using HeuristicLab.OKB.AlgorithmHost;
|
---|
10 | using System.Windows.Forms;
|
---|
11 |
|
---|
12 | namespace 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 | }
|
---|