[14380] | 1 | #region License Information
|
---|
| 2 | /* HeuristicLab
|
---|
| 3 | * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
|
---|
| 4 | *
|
---|
| 5 | * This file is part of HeuristicLab.
|
---|
| 6 | *
|
---|
| 7 | * HeuristicLab is free software: you can redistribute it and/or modify
|
---|
| 8 | * it under the terms of the GNU General Public License as published by
|
---|
| 9 | * the Free Software Foundation, either version 3 of the License, or
|
---|
| 10 | * (at your option) any later version.
|
---|
| 11 | *
|
---|
| 12 | * HeuristicLab is distributed in the hope that it will be useful,
|
---|
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 15 | * GNU General Public License for more details.
|
---|
| 16 | *
|
---|
| 17 | * You should have received a copy of the GNU General Public License
|
---|
| 18 | * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
|
---|
| 19 | */
|
---|
| 20 | #endregion
|
---|
| 21 |
|
---|
| 22 | using System;
|
---|
| 23 | using System.Windows.Forms;
|
---|
| 24 | using HeuristicLab.MainForm;
|
---|
| 25 | using HeuristicLab.Optimization;
|
---|
| 26 | using HeuristicLab.Optimization.Views;
|
---|
| 27 | using HeuristicLab.Problems.DataAnalysis;
|
---|
| 28 |
|
---|
| 29 | namespace HeuristicLab.GoalSeeking {
|
---|
| 30 | [View("GoalSeekingOptimizer View", "")]
|
---|
| 31 | [Content(typeof(GoalSeekingOptimizer), true)]
|
---|
| 32 | public partial class GoalSeekingOptimizerView : IOptimizerView {
|
---|
| 33 | public GoalSeekingOptimizerView() {
|
---|
| 34 | InitializeComponent();
|
---|
| 35 | Content = new GoalSeekingOptimizer();
|
---|
| 36 | }
|
---|
| 37 |
|
---|
| 38 | public new GoalSeekingOptimizer Content {
|
---|
| 39 | get { return (GoalSeekingOptimizer)base.Content; }
|
---|
| 40 | set { base.Content = value; }
|
---|
| 41 | }
|
---|
| 42 |
|
---|
| 43 | protected override void OnContentChanged() {
|
---|
| 44 | base.OnContentChanged();
|
---|
| 45 | if (Content == null)
|
---|
| 46 | return;
|
---|
| 47 |
|
---|
| 48 | if (Content.Optimizer != null)
|
---|
| 49 | algorithmViewHost.Content = Content.Optimizer;
|
---|
| 50 |
|
---|
| 51 | if (Content.Problem != null)
|
---|
| 52 | problemViewHost.Content = Content.Problem;
|
---|
| 53 |
|
---|
| 54 | if (Content.ProblemData != null)
|
---|
| 55 | dataViewHost.Content = Content.ProblemData;
|
---|
[14526] | 56 |
|
---|
| 57 | if (Content.Results != null)
|
---|
| 58 | resultsViewHost.Content = Content.Results;
|
---|
[14380] | 59 | }
|
---|
| 60 |
|
---|
| 61 | protected override void RegisterContentEvents() {
|
---|
| 62 | base.RegisterContentEvents();
|
---|
| 63 | Content.AlgorithmChanged += (o, e) => { algorithmViewHost.Content = Content.Optimizer; };
|
---|
| 64 | Content.ProblemChanged += (o, e) => { problemViewHost.Content = Content.Problem; };
|
---|
| 65 | Content.ProblemDataChanged += (o, e) => { dataViewHost.Content = Content.ProblemData; };
|
---|
[14526] | 66 | Content.ResultsChanged += (o, e) => { resultsViewHost.Content = Content.Results; };
|
---|
[14380] | 67 | }
|
---|
| 68 |
|
---|
| 69 | protected override void DeregisterContentEvents() {
|
---|
| 70 | base.DeregisterContentEvents();
|
---|
| 71 | }
|
---|
| 72 |
|
---|
| 73 | #region event handlers
|
---|
| 74 | private void problemTab_DragDrop(object sender, DragEventArgs e) {
|
---|
| 75 | if (e.Data.GetDataPresent(HeuristicLab.Common.Constants.DragDropDataFormat)) {
|
---|
| 76 | try {
|
---|
| 77 | Content.Problem = (IGoalSeekingProblem)e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat);
|
---|
| 78 | problemViewHost.Content = Content.Problem;
|
---|
| 79 | }
|
---|
| 80 | catch (Exception ex) {
|
---|
| 81 | MessageBox.Show(ex.Message, "Set problem", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
---|
| 82 | }
|
---|
| 83 | }
|
---|
| 84 | }
|
---|
| 85 |
|
---|
| 86 | private void problemTab_DragEnter(object sender, DragEventArgs e) {
|
---|
| 87 | e.Effect = DragDropEffects.None;
|
---|
| 88 | if (!e.Data.GetDataPresent(HeuristicLab.Common.Constants.DragDropDataFormat))
|
---|
| 89 | return;
|
---|
| 90 |
|
---|
| 91 | var data = e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat);
|
---|
| 92 |
|
---|
| 93 | if (data is IGoalSeekingProblem)
|
---|
| 94 | e.Effect = DragDropEffects.Copy;
|
---|
| 95 | }
|
---|
| 96 |
|
---|
| 97 | private void algorithmTab_DragDrop(object sender, DragEventArgs e) {
|
---|
| 98 | if (e.Data.GetDataPresent(HeuristicLab.Common.Constants.DragDropDataFormat)) {
|
---|
| 99 | try {
|
---|
| 100 | Content.Optimizer = (IAlgorithm)e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat);
|
---|
| 101 | algorithmViewHost.Content = Content.Optimizer;
|
---|
| 102 | }
|
---|
| 103 | catch (Exception ex) {
|
---|
| 104 | MessageBox.Show(ex.Message, "Set algorithm", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
---|
| 105 | }
|
---|
| 106 | }
|
---|
| 107 | }
|
---|
| 108 |
|
---|
| 109 | private void algorithmTab_DragEnter(object sender, DragEventArgs e) {
|
---|
| 110 | e.Effect = DragDropEffects.None;
|
---|
| 111 | if (!e.Data.GetDataPresent(HeuristicLab.Common.Constants.DragDropDataFormat))
|
---|
| 112 | return;
|
---|
| 113 |
|
---|
| 114 | var data = e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat);
|
---|
| 115 | if (data is IAlgorithm)
|
---|
| 116 | e.Effect = DragDropEffects.Copy;
|
---|
| 117 | }
|
---|
| 118 | #endregion
|
---|
| 119 |
|
---|
| 120 | private void dataTab_DragDrop(object sender, DragEventArgs e) {
|
---|
| 121 | if (e.Data.GetDataPresent(HeuristicLab.Common.Constants.DragDropDataFormat)) {
|
---|
| 122 | try {
|
---|
| 123 | Content.ProblemData = (IRegressionProblemData)e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat);
|
---|
| 124 | dataViewHost.Content = Content.ProblemData;
|
---|
| 125 | }
|
---|
| 126 | catch (Exception ex) {
|
---|
| 127 | // provide some information to the user
|
---|
| 128 | MessageBox.Show(ex.Message, "Set problem data", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
---|
| 129 | }
|
---|
| 130 | }
|
---|
| 131 | }
|
---|
| 132 |
|
---|
| 133 | private void dataTab_DragEnter(object sender, DragEventArgs e) {
|
---|
| 134 | e.Effect = DragDropEffects.None;
|
---|
| 135 | if (!e.Data.GetDataPresent(HeuristicLab.Common.Constants.DragDropDataFormat))
|
---|
| 136 | return;
|
---|
| 137 |
|
---|
| 138 | var data = e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat);
|
---|
| 139 | if (data is IRegressionProblemData)
|
---|
| 140 | e.Effect = DragDropEffects.Copy;
|
---|
| 141 | }
|
---|
| 142 | }
|
---|
| 143 | }
|
---|