#region License Information
/* HeuristicLab
* Copyright (C) 2002-2018 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.Windows.Forms;
using HeuristicLab.MainForm;
using HeuristicLab.MainForm.WindowsForms;
namespace HeuristicLab.DataPreprocessing.Views {
[View("Transformation View")]
[Content(typeof(TransformationContent), true)]
public partial class TransformationView : AsynchronousContentView {
public new TransformationContent Content {
get { return (TransformationContent)base.Content; }
set { base.Content = value; }
}
public TransformationView() {
InitializeComponent();
}
protected override void OnContentChanged() {
base.OnContentChanged();
if (Content == null) {
transformationListView.Content = null;
transformationListView.PreprocessingData = null;
} else {
transformationListView.Content = Content.TransformationList;
transformationListView.PreprocessingData = Content.PreprocessingData;
CheckFilters();
}
}
protected override void RegisterContentEvents() {
Content.PreprocessingData.FilterChanged += FilterLogic_FilterChanged;
}
protected override void DeregisterContentEvents() {
Content.PreprocessingData.FilterChanged -= FilterLogic_FilterChanged;
}
void FilterLogic_FilterChanged(object sender, EventArgs e) {
if (Content != null) {
CheckFilters();
}
}
private void CheckFilters() {
if (Content.PreprocessingData.IsFiltered) {
applyButton.Enabled = false;
lblFilterNotice.Visible = true;
} else {
applyButton.Enabled = true;
lblFilterNotice.Visible = false;
}
}
private void applyButton_Click(object sender, EventArgs e) {
bool success = Content.ApplyTransformations(out IEnumerable errorMessages);
if (success) {
//Content.TransformationList.Clear();
MessageBox.Show(this, "Transformations applied.", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
} else {
MessageBox.Show(this, string.Join(Environment.NewLine, errorMessages), "Transformation failed", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
}
}
}