#region License Information /* HeuristicLab * Copyright (C) 2002-2016 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 HeuristicLab.Common; using HeuristicLab.Core.Views; using HeuristicLab.MainForm; using HeuristicLab.OptimizationExpertSystem.Common; using System; namespace HeuristicLab.OptimizationExpertSystem { [View("Expert-System View")] public partial class ExpertSystemViewBase : ItemView { public OptimizationExpertSystem MainForm { get { return (OptimizationExpertSystem)HeuristicLab.MainForm.MainFormManager.MainForm; } } public new ExpertSystem Content { get { return (ExpertSystem)base.Content; } set { base.Content = value; } } protected ExpertSystemViewBase() { InitializeComponent(); } protected override void RegisterContentEvents() { base.RegisterContentEvents(); Content.DownloadStarted += ContentOnDownloadStarted; } protected override void DeregisterContentEvents() { base.DeregisterContentEvents(); Content.DownloadStarted -= ContentOnDownloadStarted; } protected virtual void OnDownloadStarted() { } protected virtual void OnDownloadEnded() { } private void ContentOnDownloadStarted(object sender, EventArgs e) { if (InvokeRequired) { Invoke((Action>)ContentOnDownloadStarted, sender, e); return; } MainForm.AddOperationProgressToView(this, e.Value); e.Value.ProgressStateChanged += ProgressOnStateChanged; OnDownloadStarted(); } private void ProgressOnStateChanged(object sender, EventArgs e) { if (InvokeRequired) { Invoke((Action)ProgressOnStateChanged, sender, e); return; } var progress = (IProgress)sender; if (progress == null || progress.ProgressState == ProgressState.Started) return; OnDownloadEnded(); } } }