#region License Information /* HeuristicLab * Copyright (C) 2002-2010 Heuristic and Evolutionary Algorithms Laboratory (HEAL) * * This file is part of HeuristicLab. * * HeuristicLab is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * HeuristicLab is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with HeuristicLab. If not, see . */ #endregion using System; using System.Linq; using System.Windows.Forms; using HeuristicLab.MainForm; using HeuristicLab.MainForm.WindowsForms; namespace HeuristicLab.Clients.OKB { [View("OKB Query")] [Content(typeof(OKBClient), false)] public sealed partial class QueryView : HeuristicLab.MainForm.WindowsForms.View { private AndFilterView andFilterView; public QueryView() { InitializeComponent(); } protected override void OnInitialized(EventArgs e) { base.OnInitialized(e); this.Cursor = Cursors.AppStarting; Func func = () => { return OKBClient.Instance.GetFilters().OfType().FirstOrDefault(); }; func.BeginInvoke((IAsyncResult result) => { AndFilter filter = func.EndInvoke(result); if (InvokeRequired) Invoke(new Action(FinishedLoadingAndFilter), filter); else FinishedLoadingAndFilter(filter); }, null); } private void FinishedLoadingAndFilter(AndFilter filter) { if (filter != null) { andFilterView = (AndFilterView)MainFormManager.CreateView(typeof(AndFilterView)); andFilterView.Content = (AndFilter)filter.Clone(); Control control = (Control)andFilterView; control.Dock = DockStyle.Fill; filterPanel.Controls.Add(control); } this.Cursor = Cursors.Default; SetEnabledStateOfControls(); } protected override void SetEnabledStateOfControls() { base.SetEnabledStateOfControls(); resultsGroupBox.Enabled = andFilterView != null; showRunsButton.Enabled = (runCollectionView.Content != null) && (runCollectionView.Content.Count > 0); } private void refreshResultsButton_Click(object sender, EventArgs e) { DateTime start = DateTime.Now; runCollectionView.Content = OKBClient.Instance.QueryRuns(andFilterView.Content); MessageBox.Show((DateTime.Now - start).ToString()); SetEnabledStateOfControls(); } private void showRunsButton_Click(object sender, EventArgs e) { DateTime start = DateTime.Now; MainFormManager.MainForm.ShowContent(OKBClient.Instance.ConvertOKBRunsToOptimizationRuns(runCollectionView.Content)); MessageBox.Show((DateTime.Now - start).ToString()); } private void nrOfRunsButton_Click(object sender, EventArgs e) { long runs = OKBClient.Instance.QueryNumberOfRuns(andFilterView.Content); MessageBox.Show(runs.ToString()); } } }