#region License Information /* HeuristicLab * Copyright (C) 2002-2015 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.Collections.Generic; using System.ComponentModel; using System.IO; using System.Linq; using System.Text; using System.Windows.Forms; using HeuristicLab.PluginInfrastructure.Manager; namespace HeuristicLab.PluginInfrastructure.Advanced { internal partial class InstallationManagerForm : Form, IStatusView { private string pluginDir; public InstallationManagerForm(PluginManager pluginManager) : base() { InitializeComponent(); Text = "HeuristicLab Plugin Manager " + AssemblyHelpers.GetFileVersion(GetType().Assembly); pluginManager.PluginLoaded += pluginManager_PluginLoaded; pluginManager.PluginUnloaded += pluginManager_PluginUnloaded; pluginManager.Initializing += pluginManager_Initializing; pluginManager.Initialized += pluginManager_Initialized; pluginDir = Application.StartupPath; localPluginsView.StatusView = this; localPluginsView.PluginManager = pluginManager; // localPluginsView.InstallationManager = installationManager; } #region plugin manager event handlers private void pluginManager_Initialized(object sender, PluginInfrastructureEventArgs e) { SetStatusStrip("Initialized PluginInfrastructure"); } private void pluginManager_Initializing(object sender, PluginInfrastructureEventArgs e) { SetStatusStrip("Initializing PluginInfrastructure"); } private void pluginManager_PluginUnloaded(object sender, PluginInfrastructureEventArgs e) { SetStatusStrip("Unloaded " + e.Entity); } private void pluginManager_PluginLoaded(object sender, PluginInfrastructureEventArgs e) { SetStatusStrip("Loaded " + e.Entity); } #endregion #region button events private void tabControl_SelectedIndexChanged(object sender, EventArgs e) { toolStripStatusLabel.Text = string.Empty; } #endregion #region helper methods private void SetStatusStrip(string msg) { if (InvokeRequired) Invoke((Action)SetStatusStrip, msg); else { toolStripStatusLabel.Text = msg; logTextBox.Text += DateTime.Now + ": " + msg + Environment.NewLine; } } #endregion #region IStatusView Members public void ShowProgressIndicator(double percentProgress) { if (percentProgress < 0.0 || percentProgress > 1.0) throw new ArgumentException("percentProgress"); toolStripProgressBar.Visible = true; toolStripProgressBar.Style = ProgressBarStyle.Continuous; int range = toolStripProgressBar.Maximum - toolStripProgressBar.Minimum; toolStripProgressBar.Value = (int)(percentProgress * range + toolStripProgressBar.Minimum); } public void ShowProgressIndicator() { toolStripProgressBar.Visible = true; toolStripProgressBar.Style = ProgressBarStyle.Marquee; } public void HideProgressIndicator() { toolStripProgressBar.Visible = false; } public void ShowMessage(string message) { if (string.IsNullOrEmpty(toolStripStatusLabel.Text)) toolStripStatusLabel.Text = message; else toolStripStatusLabel.Text += "; " + message; } public void RemoveMessage(string message) { if (toolStripStatusLabel.Text.IndexOf("; " + message) > 0) { toolStripStatusLabel.Text = toolStripStatusLabel.Text.Replace("; " + message, ""); } toolStripStatusLabel.Text = toolStripStatusLabel.Text.Replace(message, ""); toolStripStatusLabel.Text = toolStripStatusLabel.Text.TrimStart(' ', ';'); } public void LockUI() { Cursor = Cursors.AppStarting; tabControl.Enabled = false; } public void UnlockUI() { tabControl.Enabled = true; Cursor = Cursors.Default; } public void ShowError(string shortMessage, string description) { logTextBox.Text += DateTime.Now + ": " + shortMessage + Environment.NewLine + description + Environment.NewLine; MessageBox.Show(description, shortMessage); } #endregion } }