#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.Text.RegularExpressions;
using System.Windows.Forms;
using HeuristicLab.BioBoost.Representation;
using HeuristicLab.Core;
using HeuristicLab.Core.Views;
using HeuristicLab.MainForm;
namespace HeuristicLab.BioBoost.Views {
[Content(typeof (ItemCollection), false)]
public partial class BioBoostSolutionHistoryView : MovieView {
private string firstFileName;
private readonly SaveFileDialog saveFileDialog = new SaveFileDialog();
public BioBoostSolutionHistoryView() {
InitializeComponent();
}
protected override void playButton_Click(object sender, EventArgs e) {
if (saveFileDialog.ShowDialog() == DialogResult.OK) {
firstFileName = saveFileDialog.FileName;
}
base.playButton_Click(sender, e);
}
private static readonly Regex FILENAME_REGEX = new Regex(@"(.*)(-\d+)?(\.png)?", RegexOptions.IgnoreCase);
protected override void trackBar_ValueChanged(object sender, EventArgs e) {
base.trackBar_ValueChanged(sender, e);
var solution = viewHost.Content as BioBoostCompoundSolution;
var view = viewHost.ActiveView as BioBoostCompoundSolutionView;
if (view != null && solution != null) {
var filename = firstFileName.Replace(".png", string.Format("-{0:000000}.png", trackBar.Value));
view.SaveMapViewToPNG(filename);
}
}
}
}