// Copyright (C) Stichting Deltares 2016. All rights reserved.
//
// This file is part of Ringtoets.
//
// Ringtoets 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.
//
// This program 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 this program. If not, see .
//
// All names, logos, and references to "Deltares" are registered trademarks of
// Stichting Deltares and remain full property of Stichting Deltares at all times.
// All rights reserved.
using System.Collections;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Windows.Forms;
using Core.Common.Base;
using Core.Common.Controls.TreeView;
using Core.Common.Gui.ContextMenu;
using Core.Common.Gui.Forms;
using Core.Common.Gui.Forms.ProgressDialog;
using Core.Common.Gui.Plugin;
using Ringtoets.Common.Data;
using Ringtoets.Common.Data.AssessmentSection;
using Ringtoets.Common.Data.Calculation;
using Ringtoets.Common.Forms.Helpers;
using Ringtoets.Common.Forms.PresentationObjects;
using Ringtoets.Common.Forms.TreeNodeInfos;
using Ringtoets.Piping.Data;
using Ringtoets.Piping.Forms;
using Ringtoets.Piping.Forms.PresentationObjects;
using Ringtoets.Piping.Forms.PropertyClasses;
using Ringtoets.Piping.Forms.Views;
using Ringtoets.Piping.Plugin.FileImporter;
using Ringtoets.Piping.Primitives;
using Ringtoets.Piping.Service;
using PipingDataResources = Ringtoets.Piping.Data.Properties.Resources;
using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources;
using RingtoetsCommonDataResources = Ringtoets.Common.Data.Properties.Resources;
using PipingFormsResources = Ringtoets.Piping.Forms.Properties.Resources;
using PipingPluginResources = Ringtoets.Piping.Plugin.Properties.Resources;
using BaseResources = Core.Common.Base.Properties.Resources;
namespace Ringtoets.Piping.Plugin
{
///
/// The plug-in for the .
///
public class PipingPlugin : PluginBase
{
public override IRibbonCommandHandler RibbonCommandHandler
{
get
{
return new PipingRibbon();
}
}
public override IEnumerable GetPropertyInfos()
{
yield return new PropertyInfo();
yield return new PropertyInfo();
yield return new PropertyInfo();
yield return new PropertyInfo();
yield return new PropertyInfo();
yield return new PropertyInfo();
}
public override IEnumerable GetImportInfos()
{
yield return new ImportInfo
{
Name = PipingFormsResources.PipingSurfaceLinesCollection_DisplayName,
Category = RingtoetsCommonFormsResources.Ringtoets_Category,
Image = PipingFormsResources.PipingSurfaceLineIcon,
FileFilter = string.Format("{0} {1}",
PipingFormsResources.PipingSurfaceLinesCollection_DisplayName,
RingtoetsCommonFormsResources.DataTypeDisplayName_csv_file_filter),
IsEnabled = context => context.AssessmentSection.ReferenceLine != null,
CreateFileImporter = (context, filePath) => new PipingSurfaceLinesCsvImporter(context.WrappedData,
context.AssessmentSection.ReferenceLine,
filePath)
};
yield return new ImportInfo
{
Name = PipingFormsResources.StochasticSoilModelCollection_DisplayName,
Category = RingtoetsCommonFormsResources.Ringtoets_Category,
Image = PipingFormsResources.PipingSoilProfileIcon,
FileFilter = string.Format("{0} (*.soil)|*.soil", PipingPluginResources.Soil_file_name),
IsEnabled = context => context.AssessmentSection.ReferenceLine != null,
CreateFileImporter = (context, filePath) => new PipingSoilProfilesImporter(context.WrappedData,
filePath)
};
}
public override IEnumerable GetViewInfos()
{
yield return new ViewInfo
{
GetViewName = (view, mechanism) => PipingDataResources.PipingFailureMechanism_DisplayName,
Image = RingtoetsCommonFormsResources.CalculationIcon,
CloseForData = ClosePipingFailureMechanismViewForData,
AdditionalDataCheck = context => context.WrappedData.IsRelevant
};
yield return new ViewInfo<
FailureMechanismSectionResultContext,
IEnumerable,
PipingFailureMechanismResultView>
{
GetViewName = (v, o) => RingtoetsCommonFormsResources.FailureMechanism_AssessmentResult_DisplayName,
Image = RingtoetsCommonFormsResources.FailureMechanismSectionResultIcon,
CloseForData = CloseFailureMechanismResultViewForData,
GetViewData = context => context.WrappedData,
AfterCreate = (view, context) => view.FailureMechanism = context.FailureMechanism
};
yield return new ViewInfo
{
GetViewData = context => context.WrappedData,
GetViewName = (view, calculationGroup) => calculationGroup.Name,
Image = RingtoetsCommonFormsResources.GeneralFolderIcon,
AdditionalDataCheck = context => context.WrappedData == context.FailureMechanism.CalculationsGroup,
CloseForData = ClosePipingCalculationsViewForData,
AfterCreate = (view, context) =>
{
view.ApplicationSelection = Gui;
view.AssessmentSection = context.AssessmentSection;
view.PipingFailureMechanism = context.FailureMechanism;
}
};
yield return new ViewInfo
{
GetViewData = context => context.PipingCalculation,
GetViewName = (view, input) => RingtoetsCommonFormsResources.Calculation_Input,
Image = PipingFormsResources.PipingInputIcon,
CloseForData = ClosePipingInputViewForData
};
yield return new ViewInfo
{
GetViewData = context => context.WrappedData,
GetViewName = (view, calculationGroup) => RingtoetsCommonFormsResources.Scenarios_DisplayName,
Image = RingtoetsCommonFormsResources.ScenariosIcon,
AdditionalDataCheck = context => context.WrappedData == context.ParentFailureMechanism.CalculationsGroup,
CloseForData = ClosePipingScenariosViewForData,
AfterCreate = (view, context) => { view.PipingFailureMechanism = context.ParentFailureMechanism; }
};
}
public override IEnumerable GetTreeNodeInfos()
{
yield return RingtoetsTreeNodeInfoFactory.CreateFailureMechanismContextTreeNodeInfo(
FailureMechanismEnabledChildNodeObjects,
FailureMechanismDisabledChildNodeObjects,
FailureMechanismEnabledContextMenuStrip,
FailureMechanismDisabledContextMenuStrip);
yield return RingtoetsTreeNodeInfoFactory.CreateCalculationContextTreeNodeInfo(
PipingCalculationContextChildNodeObjects,
PipingCalculationContextContextMenuStrip,
PipingCalculationContextOnNodeRemoved);
yield return RingtoetsTreeNodeInfoFactory.CreateCalculationGroupContextTreeNodeInfo(
PipingCalculationGroupContextChildNodeObjects,
PipingCalculationGroupContextContextMenuStrip,
PipingCalculationGroupContextOnNodeRemoved);
yield return new TreeNodeInfo>
{
Text = context => RingtoetsCommonFormsResources.FailureMechanism_AssessmentResult_DisplayName,
Image = context => RingtoetsCommonFormsResources.FailureMechanismSectionResultIcon,
ContextMenuStrip = (nodeData, parentData, treeViewControl) => Gui.Get(nodeData, treeViewControl)
.AddOpenItem()
.Build()
};
yield return new TreeNodeInfo
{
Text = pipingInputContext => RingtoetsCommonFormsResources.Calculation_Input,
Image = pipingInputContext => PipingFormsResources.PipingInputIcon,
ContextMenuStrip = (nodeData, parentData, treeViewControl) => Gui.Get(nodeData, treeViewControl)
.AddOpenItem()
.AddSeparator()
.AddPropertiesItem()
.Build()
};
yield return new TreeNodeInfo
{
Text = ringtoetsPipingSurfaceLine => PipingFormsResources.PipingSurfaceLinesCollection_DisplayName,
Image = ringtoetsPipingSurfaceLine => RingtoetsCommonFormsResources.GeneralFolderIcon,
ForeColor = ringtoetsPipingSurfaceLine => ringtoetsPipingSurfaceLine.WrappedData.Any() ? Color.FromKnownColor(KnownColor.ControlText) : Color.FromKnownColor(KnownColor.GrayText),
ChildNodeObjects = ringtoetsPipingSurfaceLine => ringtoetsPipingSurfaceLine.WrappedData.Cast