Rev | Line | |
---|
[4311] | 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 |
|
---|
| 10 | namespace 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.