#region License Information /* HeuristicLab * Copyright (C) 2002-2012 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 HeuristicLab.Core.Views; using HeuristicLab.MainForm; namespace HeuristicLab.HiveEngine.Views { [View("Hive Engine View")] [Content(typeof(HiveEngine), IsDefaultView = true)] public sealed partial class HiveEngineView : ItemView { public new HiveEngine Content { get { return (HiveEngine)base.Content; } set { base.Content = value; } } public HiveEngineView() { InitializeComponent(); } protected override void DeregisterContentEvents() { Content.ExecutionTimeOnHiveChanged -= new EventHandler(Content_ExecutionTimeOnHiveChanged); Content.ExecutionTimeChanged -= new EventHandler(Content_ExecutionTimeChanged); base.DeregisterContentEvents(); } protected override void RegisterContentEvents() { base.RegisterContentEvents(); Content.ExecutionTimeOnHiveChanged += new EventHandler(Content_ExecutionTimeOnHiveChanged); Content.ExecutionTimeChanged += new EventHandler(Content_ExecutionTimeChanged); } #region Event Handlers (Content) private void Content_ExecutionTimeChanged(object sender, EventArgs e) { if (InvokeRequired) { Invoke(new EventHandler(Content_ExecutionTimeChanged), sender, e); } else { executionTimeTextBox.Text = Content.ExecutionTime.ToString(); } } private void Content_ExecutionTimeOnHiveChanged(object sender, EventArgs e) { if (InvokeRequired) { Invoke(new EventHandler(Content_ExecutionTimeOnHiveChanged), sender, e); } else { executionTimeOnHiveTextBox.Text = Content.ExecutionTimeOnHive.ToString(); } } #endregion protected override void OnContentChanged() { base.OnContentChanged(); if (Content == null) { resourceIdsTextBox.Text = string.Empty; priorityTextBox.Text = string.Empty; executionTimeOnHiveTextBox.Text = string.Empty; isPrivilegedCheckBox.Checked = false; pauseOnWaitCheckbox.Checked = true; hiveExperimentListView.Content = null; logView.Content = null; } else { resourceIdsTextBox.Text = Content.ResourceNames; priorityTextBox.Text = Content.Priority.ToString(); executionTimeOnHiveTextBox.Text = Content.ExecutionTimeOnHive.ToString(); isPrivilegedCheckBox.Checked = Content.IsPrivileged; hiveExperimentListView.Content = Content.Jobs; logView.Content = Content.Log; pauseOnWaitCheckbox.Checked = Content.PauseWhileCalculatingChilds; } } protected override void SetEnabledStateOfControls() { base.SetEnabledStateOfControls(); // Enable or disable controls based on whether the content is null or the view is set readonly if (Content != null) { resourceIdsTextBox.ReadOnly = this.ReadOnly; priorityTextBox.ReadOnly = this.ReadOnly; isPrivilegedCheckBox.Enabled = Content.IsAllowedPrivileged; } else { resourceIdsTextBox.ReadOnly = false; priorityTextBox.ReadOnly = false; isPrivilegedCheckBox.Enabled = false; } } #region Event Handlers (child controls) private void resourceIdsTextBox_Validated(object sender, EventArgs e) { Content.ResourceNames = resourceIdsTextBox.Text; } private void priorityTextBox_Validated(object sender, EventArgs e) { Content.Priority = int.Parse(priorityTextBox.Text); } private void isPrivilegedCheckBox_Validated(object sender, EventArgs e) { Content.IsPrivileged = isPrivilegedCheckBox.Checked; } private void pauseOnWaitCheckbox_Validated(object sender, EventArgs e) { Content.PauseWhileCalculatingChilds = pauseOnWaitCheckbox.Checked; } #endregion } }