1 | #region License Information
|
---|
2 | /* HeuristicLab
|
---|
3 | * Copyright (C) 2002-2010 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.Linq;
|
---|
24 | using System.Windows.Forms;
|
---|
25 | using HeuristicLab.MainForm;
|
---|
26 | using HeuristicLab.MainForm.WindowsForms;
|
---|
27 |
|
---|
28 | namespace HeuristicLab.Clients.OKB {
|
---|
29 | [View("OKB Query")]
|
---|
30 | [Content(typeof(OKBClient), false)]
|
---|
31 | public sealed partial class QueryView : HeuristicLab.MainForm.WindowsForms.View {
|
---|
32 | private AndFilterView andFilterView;
|
---|
33 |
|
---|
34 | public QueryView() {
|
---|
35 | InitializeComponent();
|
---|
36 | }
|
---|
37 |
|
---|
38 | protected override void OnInitialized(EventArgs e) {
|
---|
39 | base.OnInitialized(e);
|
---|
40 | this.Cursor = Cursors.AppStarting;
|
---|
41 |
|
---|
42 | Func<AndFilter> func = () => {
|
---|
43 | return OKBClient.Instance.GetFilters().OfType<AndFilter>().FirstOrDefault();
|
---|
44 | };
|
---|
45 |
|
---|
46 | func.BeginInvoke((IAsyncResult result) => {
|
---|
47 | AndFilter filter = func.EndInvoke(result);
|
---|
48 | if (InvokeRequired) Invoke(new Action<AndFilter>(FinishedLoadingAndFilter), filter);
|
---|
49 | else FinishedLoadingAndFilter(filter);
|
---|
50 | }, null);
|
---|
51 | }
|
---|
52 |
|
---|
53 | private void FinishedLoadingAndFilter(AndFilter filter) {
|
---|
54 | if (filter != null) {
|
---|
55 | andFilterView = (AndFilterView)MainFormManager.CreateView(typeof(AndFilterView));
|
---|
56 | andFilterView.Content = (AndFilter)filter.Clone();
|
---|
57 | Control control = (Control)andFilterView;
|
---|
58 | control.Dock = DockStyle.Fill;
|
---|
59 | filterPanel.Controls.Add(control);
|
---|
60 | }
|
---|
61 | this.Cursor = Cursors.Default;
|
---|
62 | SetEnabledStateOfControls();
|
---|
63 | }
|
---|
64 |
|
---|
65 | protected override void SetEnabledStateOfControls() {
|
---|
66 | base.SetEnabledStateOfControls();
|
---|
67 | resultsGroupBox.Enabled = andFilterView != null;
|
---|
68 | showRunsButton.Enabled = (runCollectionView.Content != null) && (runCollectionView.Content.Count > 0);
|
---|
69 | }
|
---|
70 |
|
---|
71 | private void refreshResultsButton_Click(object sender, EventArgs e) {
|
---|
72 | DateTime start = DateTime.Now;
|
---|
73 | runCollectionView.Content = OKBClient.Instance.QueryRuns(andFilterView.Content);
|
---|
74 | MessageBox.Show((DateTime.Now - start).ToString());
|
---|
75 | SetEnabledStateOfControls();
|
---|
76 | }
|
---|
77 |
|
---|
78 | private void showRunsButton_Click(object sender, EventArgs e) {
|
---|
79 | DateTime start = DateTime.Now;
|
---|
80 | MainFormManager.MainForm.ShowContent(OKBClient.Instance.ConvertOKBRunsToOptimizationRuns(runCollectionView.Content));
|
---|
81 | MessageBox.Show((DateTime.Now - start).ToString());
|
---|
82 | }
|
---|
83 |
|
---|
84 | private void nrOfRunsButton_Click(object sender, EventArgs e) {
|
---|
85 | long runs = OKBClient.Instance.QueryNumberOfRuns(andFilterView.Content);
|
---|
86 | MessageBox.Show(runs.ToString());
|
---|
87 | }
|
---|
88 | }
|
---|
89 | }
|
---|