コード例 #1
0
        /// <summary>
        /// Creates a <see cref="UpdateInfo"/> object for a <see cref="PipingFailureMechanismSectionsContext"/>.
        /// </summary>
        /// <param name="inquiryHelper">Object responsible for inquiring required data.</param>
        /// <returns>An <see cref="UpdateInfo"/> object.</returns>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="inquiryHelper"/>
        /// is <c>null</c>.</exception>
        public static UpdateInfo <PipingFailureMechanismSectionsContext> CreateFailureMechanismSectionsUpdateInfo(
            IInquiryHelper inquiryHelper)
        {
            if (inquiryHelper == null)
            {
                throw new ArgumentNullException(nameof(inquiryHelper));
            }

            return(new UpdateInfo <PipingFailureMechanismSectionsContext>
            {
                Name = RiskeerCommonFormsResources.FailureMechanismSections_DisplayName,
                Category = RiskeerCommonFormsResources.Riskeer_Category,
                Image = RiskeerCommonFormsResources.SectionsIcon,
                FileFilterGenerator = new FileFilterGenerator(RiskeerCommonIOResources.Shape_file_filter_Extension,
                                                              RiskeerCommonIOResources.Shape_file_filter_Description),
                IsEnabled = context => context.WrappedData.FailureMechanismSectionSourcePath != null,
                CurrentPath = context => context.WrappedData.FailureMechanismSectionSourcePath,
                CreateFileImporter = (context, filePath) => new FailureMechanismSectionsImporter(
                    context.WrappedData,
                    context.AssessmentSection.ReferenceLine,
                    filePath,
                    new PipingFailureMechanismSectionUpdateStrategy((PipingFailureMechanism)context.WrappedData,
                                                                    new AdoptableWithProfileProbabilityFailureMechanismSectionResultUpdateStrategy()),
                    new UpdateMessageProvider()),
                VerifyUpdates = context =>
                {
                    var changeHandler = new PipingFailureMechanismCalculationChangeHandler(
                        (PipingFailureMechanism)context.WrappedData,
                        Resources.PipingUpdateInfoFactory_CreateFailureMechanismSectionsUpdateInfo_When_updating_sections_probabilistic_calculation_output_will_be_cleared_confirm,
                        inquiryHelper);
                    return !changeHandler.RequireConfirmation() || changeHandler.InquireConfirmation();
                }
            });
        }
コード例 #2
0
        private ContextMenuStrip CalculationsStateFailureMechanismContextMenuStrip(CalculationsStateFailureMechanismContext context,
                                                                                   object parentData,
                                                                                   TreeViewControl treeViewControl)
        {
            IEnumerable <StructuresCalculation <ClosingStructuresInput> > calculations = context.WrappedData
                                                                                         .Calculations
                                                                                         .Cast <StructuresCalculation <ClosingStructuresInput> >();
            IInquiryHelper inquiryHelper = GetInquiryHelper();

            var builder = new RiskeerContextMenuBuilder(Gui.Get(context, treeViewControl));

            return(builder.AddOpenItem()
                   .AddSeparator()
                   .AddValidateAllCalculationsInFailureMechanismItem(
                       context,
                       ValidateAllInFailureMechanism,
                       EnableValidateAndCalculateMenuItemForFailureMechanism)
                   .AddPerformAllCalculationsInFailureMechanismItem(
                       context,
                       CalculateAllInFailureMechanism,
                       EnableValidateAndCalculateMenuItemForFailureMechanism)
                   .AddSeparator()
                   .AddClearAllCalculationOutputInFailureMechanismItem(context.WrappedData)
                   .AddClearIllustrationPointsOfCalculationsInFailureMechanismItem(() => IllustrationPointsHelper.HasIllustrationPoints(calculations),
                                                                                   CreateChangeHandler(inquiryHelper, calculations))
                   .AddSeparator()
                   .AddCollapseAllItem()
                   .AddExpandAllItem()
                   .AddSeparator()
                   .AddPropertiesItem()
                   .Build());
        }
コード例 #3
0
        /// <summary>
        /// Creates a <see cref="StrictContextMenuItem"/> which is bound to the action of updating
        /// the <see cref="ForeshoreProfile"/> of the <paramref name="calculations"/>.
        /// </summary>
        /// <typeparam name="TCalculationInput">The type of calculation input that can have a foreshore profile.</typeparam>
        /// <param name="calculations">The calculations to update.</param>
        /// <param name="inquiryHelper">Object responsible for inquiring the required data.</param>
        /// <param name="updateAction">The action to perform when the foreshore profile is updated.</param>
        /// <returns>The created <see cref="StrictContextMenuItem"/>.</returns>
        public static StrictContextMenuItem CreateUpdateForeshoreProfileOfCalculationsItem <TCalculationInput>(
            IEnumerable <ICalculation <TCalculationInput> > calculations,
            IInquiryHelper inquiryHelper,
            Action <ICalculation <TCalculationInput> > updateAction)
            where TCalculationInput : ICalculationInput, IHasForeshoreProfile
        {
            var    contextMenuEnabled = true;
            string toolTipMessage     = Resources.CreateUpdateForeshoreProfileOfCalculationsItem_Update_calculations_with_ForeshoreProfile_ToolTip;

            ICalculation <TCalculationInput>[] calculationsToUpdate = calculations
                                                                      .Where(c => c.InputParameters.ForeshoreProfile != null && !c.InputParameters.IsForeshoreProfileInputSynchronized)
                                                                      .ToArray();

            if (!calculationsToUpdate.Any())
            {
                contextMenuEnabled = false;
                toolTipMessage     = Resources.CreateUpdateContextMenuItem_No_calculations_to_update_ToolTip;
            }

            return(new StrictContextMenuItem(
                       Resources.CreateUpdateForeshoreProfileOfCalculationsItem_Update_ForeshoreProfile_data,
                       toolTipMessage,
                       Resources.UpdateItemIcon,
                       (o, args) =>
            {
                UpdateForeshoreProfileDependentDataOfCalculation(calculationsToUpdate,
                                                                 inquiryHelper,
                                                                 Resources.VerifyUpdate_Confirm_calculation_outputs_cleared,
                                                                 updateAction);
            })
            {
                Enabled = contextMenuEnabled
            });
        }
コード例 #4
0
        /// <summary>
        /// Gets the folder path to export to.
        /// </summary>
        /// <param name="inquiryHelper">Helper responsible for performing information inquiries.</param>
        /// <returns>A path to a folder, or <c>null</c> if no location was chosen.</returns>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="inquiryHelper"/>
        /// is <c>null</c>.</exception>
        public static string GetFolderPath(IInquiryHelper inquiryHelper)
        {
            if (inquiryHelper == null)
            {
                throw new ArgumentNullException(nameof(inquiryHelper));
            }

            return(inquiryHelper.GetTargetFolderLocation());
        }
コード例 #5
0
        /// <summary>
        /// Returns the <see cref="IInquiryHelper"/>.
        /// </summary>
        /// <returns>The <see cref="IInquiryHelper"/>.</returns>
        /// <exception cref="InvalidOperationException">Thrown when <see cref="Gui"/>
        /// is <c>null</c>.</exception>
        protected IInquiryHelper GetInquiryHelper()
        {
            if (Gui == null)
            {
                throw new InvalidOperationException("Gui cannot be null");
            }

            return(inquiryHelper ?? (inquiryHelper = new DialogBasedInquiryHelper(Gui.MainWindow)));
        }
コード例 #6
0
        /// <summary>
        /// Creates a new instance of <see cref="AssessmentSectionMergeFilePathProvider"/>.
        /// </summary>
        /// <param name="inquiryHelper">Object responsible for inquiring the required data.</param>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="inquiryHelper"/>
        /// is <c>null</c>.</exception>
        public AssessmentSectionMergeFilePathProvider(IInquiryHelper inquiryHelper)
        {
            if (inquiryHelper == null)
            {
                throw new ArgumentNullException(nameof(inquiryHelper));
            }

            this.inquiryHelper = inquiryHelper;
        }
コード例 #7
0
        /// <summary>
        /// Creates a new instance of <see cref="ClearIllustrationPointsOfCalculationCollectionChangeHandlerBase"/>.
        /// </summary>
        /// <param name="inquiryHelper">Object responsible for inquiring confirmation.</param>
        /// <exception cref="ArgumentNullException">Thrown when any parameter is <c>null</c>.</exception>
        protected ClearIllustrationPointsOfCalculationCollectionChangeHandlerBase(IInquiryHelper inquiryHelper)
        {
            if (inquiryHelper == null)
            {
                throw new ArgumentNullException(nameof(inquiryHelper));
            }

            this.inquiryHelper = inquiryHelper;
        }
コード例 #8
0
        private static bool ForeshoreProfileDependentDataShouldUpdate(IEnumerable <ICalculation> calculations,
                                                                      string query,
                                                                      IInquiryHelper inquiryHelper)
        {
            var changeHandler = new CalculationChangeHandler(calculations,
                                                             query,
                                                             inquiryHelper);

            return(!changeHandler.RequireConfirmation() || changeHandler.InquireConfirmation());
        }
        /// <summary>
        /// Creates a new instance of <see cref="ClearIllustrationPointsOfStructureCalculationCollectionChangeHandler"/>.
        /// </summary>
        /// <param name="inquiryHelper">Object responsible for inquiring confirmation.</param>
        /// <param name="calculations">The calculations for which the illustration points should be cleared.</param>
        /// <exception cref="ArgumentNullException">Thrown when any parameter is <c>null</c>.</exception>
        public ClearIllustrationPointsOfStructureCalculationCollectionChangeHandler(IInquiryHelper inquiryHelper,
                                                                                    IEnumerable <IStructuresCalculation> calculations)
            : base(inquiryHelper)
        {
            if (calculations == null)
            {
                throw new ArgumentNullException(nameof(calculations));
            }

            this.calculations = calculations;
        }
コード例 #10
0
 /// <summary>
 /// Creates a new instance of <see cref="StorageCommandHandler"/>.
 /// </summary>
 /// <param name="projectStorage">Class responsible to storing and loading the application project.</param>
 /// <param name="projectMigrator">Class responsible for the migration of the application projects.</param>
 /// <param name="projectFactory">The factory to use when creating new projects.</param>
 /// <param name="projectOwner">The class owning the application project.</param>
 /// <param name="inquiryHelper">The object facilitating user interaction.</param>
 /// <param name="mainWindowController">The object owning the parent controller for UI.</param>
 public StorageCommandHandler(IStoreProject projectStorage, IMigrateProject projectMigrator,
                              IProjectFactory projectFactory, IProjectOwner projectOwner,
                              IInquiryHelper inquiryHelper, IMainWindowController mainWindowController)
 {
     projectPersister          = projectStorage;
     this.projectMigrator      = projectMigrator;
     this.projectFactory       = projectFactory;
     this.projectOwner         = projectOwner;
     this.inquiryHelper        = inquiryHelper;
     this.mainWindowController = mainWindowController;
 }
コード例 #11
0
 private static void UpdateForeshoreProfileDependentDataOfCalculation <TCalculationInput>(
     ICalculation <TCalculationInput>[] calculations,
     IInquiryHelper inquiryHelper,
     string confirmOutputMessage,
     Action <ICalculation <TCalculationInput> > updateAction)
     where TCalculationInput : ICalculationInput, IHasForeshoreProfile
 {
     if (ForeshoreProfileDependentDataShouldUpdate(calculations, confirmOutputMessage, inquiryHelper))
     {
         calculations.ForEachElementDo(updateAction);
     }
 }
コード例 #12
0
 /// <summary>
 /// Adds an item to the <see cref="ContextMenuStrip"/>, which is bound to the action
 /// of updating the <see cref="ForeshoreProfile"/> of the <paramref name="calculations"/>.
 /// </summary>
 /// <typeparam name="TCalculationInput">The type of calculation input that can have
 /// a foreshore profile.</typeparam>
 /// <param name="calculations">The calculations to update.</param>
 /// <param name="inquiryHelper">Object responsible for inquiring the required data.</param>
 /// <param name="updateAction">The action to perform when the foreshore profile is updated.</param>
 /// <returns>The <see cref="RiskeerContextMenuBuilder"/> itself.</returns>
 public RiskeerContextMenuBuilder AddUpdateForeshoreProfileOfCalculationsItem <TCalculationInput>(
     IEnumerable <ICalculation <TCalculationInput> > calculations,
     IInquiryHelper inquiryHelper,
     Action <ICalculation <TCalculationInput> > updateAction)
     where TCalculationInput : ICalculationInput, IHasForeshoreProfile
 {
     contextMenuBuilder.AddCustomItem(RiskeerContextMenuItemFactory.CreateUpdateForeshoreProfileOfCalculationsItem(
                                          calculations,
                                          inquiryHelper,
                                          updateAction));
     return(this);
 }
コード例 #13
0
        /// <summary>
        /// Gets the file path to export to.
        /// </summary>
        /// <param name="inquiryHelper">Helper responsible for performing information inquiries.</param>
        /// <param name="fileFilterGenerator">The file filter generator to use.</param>
        /// <returns>A path to a file, which may or may not exist yet, or <c>null</c> if no location
        /// was chosen.</returns>
        /// <exception cref="ArgumentNullException">Thrown when any parameter is <c>null</c>.</exception>
        public static string GetFilePath(IInquiryHelper inquiryHelper, FileFilterGenerator fileFilterGenerator)
        {
            if (inquiryHelper == null)
            {
                throw new ArgumentNullException(nameof(inquiryHelper));
            }

            if (fileFilterGenerator == null)
            {
                throw new ArgumentNullException(nameof(fileFilterGenerator));
            }

            return(inquiryHelper.GetTargetFileLocation(fileFilterGenerator.Filter, null));
        }
コード例 #14
0
 /// <summary>
 /// Creates a <see cref="ExportInfo"/> object for a calculation configuration
 /// of the type <typeparamref name="TCalculationContext"/>.
 /// </summary>
 /// <typeparam name="TCalculationContext">The type of calculation context
 /// to create the <see cref="ExportInfo"/> for.</typeparam>
 /// <param name="createFileExporter">The function to create the relevant exporter.</param>
 /// <param name="inquiryHelper">Helper responsible for performing information inquiries.</param>
 /// <returns>An <see cref="ExportInfo"/> object.</returns>
 public static ExportInfo <TCalculationContext> CreateCalculationConfigurationExportInfo <TCalculationContext>(
     Func <TCalculationContext, string, IFileExporter> createFileExporter,
     IInquiryHelper inquiryHelper)
     where TCalculationContext : ICalculationContext <ICalculation, ICalculatableFailureMechanism>
 {
     return(new ExportInfo <TCalculationContext>
     {
         Name = context => Resources.CalculationConfigurationExporter_DisplayName,
         Extension = Resources.DataTypeDisplayName_xml_file_filter_Extension,
         CreateFileExporter = createFileExporter,
         IsEnabled = context => true,
         GetExportPath = () => ExportHelper.GetFilePath(
             inquiryHelper, new FileFilterGenerator(Resources.DataTypeDisplayName_xml_file_filter_Extension,
                                                    Resources.DataTypeDisplayName_xml_file_filter_Description))
     });
 }
コード例 #15
0
ファイル: ProjectMigrator.cs プロジェクト: Deltares/Riskeer
        /// <summary>
        /// Creates a new instance of <see cref="ProjectMigrator"/>.
        /// </summary>
        /// <param name="inquiryHelper">Object responsible for inquiring the data.</param>
        public ProjectMigrator(IInquiryHelper inquiryHelper)
        {
            if (inquiryHelper == null)
            {
                throw new ArgumentNullException(nameof(inquiryHelper));
            }

            migrationLogPath = Path.Combine(SettingsHelper.Instance.GetLocalUserTemporaryDirectory(),
                                            "RiskeerMigrationLog.sqlite");

            this.inquiryHelper = inquiryHelper;
            fileMigrator       = new ProjectFileMigrator
            {
                LogPath = migrationLogPath
            };
            fileFilter = new FileFilterGenerator(Resources.RiskeerProject_FileExtension,
                                                 Resources.Project_TypeDescription);
        }
コード例 #16
0
        /// <summary>
        /// Creates a <see cref="StrictContextMenuItem"/> which is bound to the action of updating
        /// the <see cref="ForeshoreProfile"/> of a <paramref name="calculation"/>.
        /// </summary>
        /// <typeparam name="TCalculationInput">The type of calculation input that can have a foreshore profile.</typeparam>
        /// <param name="calculation">The calculation to update.</param>
        /// <param name="inquiryHelper">Object responsible for inquiring the required data.</param>
        /// <param name="updateAction">The action to perform when the foreshore profile is updated.</param>
        /// <returns>The created <see cref="StrictContextMenuItem"/>.</returns>
        public static StrictContextMenuItem CreateUpdateForeshoreProfileOfCalculationItem <TCalculationInput>(
            ICalculation <TCalculationInput> calculation,
            IInquiryHelper inquiryHelper,
            Action <ICalculation <TCalculationInput> > updateAction)
            where TCalculationInput : ICalculationInput, IHasForeshoreProfile
        {
            var               contextMenuEnabled         = true;
            string            toolTipMessage             = Resources.CreateUpdateForeshoreProfileItem_Update_calculation_with_ForeshoreProfile_ToolTip;
            TCalculationInput calculationInputParameters = calculation.InputParameters;

            if (calculationInputParameters.ForeshoreProfile == null)
            {
                contextMenuEnabled = false;
                toolTipMessage     = Resources.CreateUpdateForeshoreProfileItem_Update_calculation_no_ForeshoreProfile_ToolTip;
            }
            else if (calculationInputParameters.IsForeshoreProfileInputSynchronized)
            {
                contextMenuEnabled = false;
                toolTipMessage     = Resources.CalculationItem_No_changes_to_update_ToolTip;
            }

            var menuItem = new StrictContextMenuItem(
                Resources.CreateUpdateForeshoreProfileItem_Update_ForeshoreProfile_data,
                toolTipMessage,
                Resources.UpdateItemIcon,
                (o, args) =>
            {
                UpdateForeshoreProfileDependentDataOfCalculation(new[]
                {
                    calculation
                },
                                                                 inquiryHelper,
                                                                 Resources.VerifyUpdate_Confirm_calculation_output_cleared,
                                                                 updateAction);
            })
            {
                Enabled = contextMenuEnabled
            };

            return(menuItem);
        }
コード例 #17
0
ファイル: GuiImportHandler.cs プロジェクト: Deltares/Riskeer
        /// <summary>
        /// Initializes a new instance of the <see cref="GuiImportHandler"/> class.
        /// </summary>
        /// <param name="dialogParent">The parent window to show dialogs on top.</param>
        /// <param name="importInfos">An enumeration of <see cref="ImportInfo"/>.</param>
        /// <param name="inquiryHelper">Helper responsible for performing information inquiries.</param>
        /// <exception cref="ArgumentNullException">Thrown when any input parameter is <c>null</c>.</exception>
        public GuiImportHandler(IViewParent dialogParent, IEnumerable <ImportInfo> importInfos, IInquiryHelper inquiryHelper)
        {
            if (dialogParent == null)
            {
                throw new ArgumentNullException(nameof(dialogParent));
            }

            if (importInfos == null)
            {
                throw new ArgumentNullException(nameof(importInfos));
            }

            if (inquiryHelper == null)
            {
                throw new ArgumentNullException(nameof(inquiryHelper));
            }

            this.dialogParent  = dialogParent;
            this.importInfos   = importInfos;
            this.inquiryHelper = inquiryHelper;
        }
コード例 #18
0
ファイル: GuiUpdateHandler.cs プロジェクト: Deltares/Riskeer
        /// <summary>
        /// Initializes a new instance of the <see cref="GuiUpdateHandler"/> class.
        /// </summary>
        /// <param name="dialogParent">The parent window to show dialogs on top.</param>
        /// <param name="updateInfos">An enumeration of <see cref="UpdateInfo"/>.</param>
        /// <param name="inquiryHelper">Helper responsible for performing information inquiries.</param>
        /// <exception cref="ArgumentNullException">Thrown when any input parameter is <c>null</c>.</exception>
        public GuiUpdateHandler(IViewParent dialogParent, IEnumerable <UpdateInfo> updateInfos, IInquiryHelper inquiryHelper)
        {
            if (dialogParent == null)
            {
                throw new ArgumentNullException(nameof(dialogParent));
            }

            if (updateInfos == null)
            {
                throw new ArgumentNullException(nameof(updateInfos));
            }

            if (inquiryHelper == null)
            {
                throw new ArgumentNullException(nameof(inquiryHelper));
            }

            this.dialogParent  = dialogParent;
            this.updateInfos   = updateInfos;
            this.inquiryHelper = inquiryHelper;
        }
コード例 #19
0
ファイル: PluginBaseTest.cs プロジェクト: Deltares/Riskeer
        public void GetInquiryHelper_WithGui_ReturnsDialogBasedInquiryHelper()
        {
            // Setup
            var mocks      = new MockRepository();
            var mainWindow = mocks.Stub <IMainWindow>();
            var gui        = mocks.Stub <IGui>();

            gui.Stub(g => g.MainWindow).Return(mainWindow);
            mocks.ReplayAll();

            var plugin = new SimplePlugin
            {
                Gui = gui
            };

            // Call
            IInquiryHelper inquiryHelper = plugin.GetInquiryHelperFromBase();

            // Assert
            Assert.IsInstanceOf <DialogBasedInquiryHelper>(inquiryHelper);
            mocks.VerifyAll();
        }
コード例 #20
0
        /// <summary>
        /// Creates a new instance of <see cref="FailureMechanismCalculationChangeHandler"/>.
        /// </summary>
        /// <param name="failureMechanism">Failure mechanism for which to handle changes.</param>
        /// <param name="query">The query which should be displayed when inquiring for a confirmation.</param>
        /// <param name="inquiryHandler">Object responsible for inquiring required data.</param>
        /// <exception cref="ArgumentNullException">Thrown when any input parameter is <c>null</c>.</exception>
        public FailureMechanismCalculationChangeHandler(ICalculatableFailureMechanism failureMechanism,
                                                        string query,
                                                        IInquiryHelper inquiryHandler)
        {
            if (failureMechanism == null)
            {
                throw new ArgumentNullException(nameof(failureMechanism));
            }

            if (query == null)
            {
                throw new ArgumentNullException(nameof(query));
            }

            if (inquiryHandler == null)
            {
                throw new ArgumentNullException(nameof(inquiryHandler));
            }

            FailureMechanism    = failureMechanism;
            this.query          = query;
            this.inquiryHandler = inquiryHandler;
        }
コード例 #21
0
        /// <summary>
        /// Creates a new instance of <see cref="CalculationChangeHandler"/>.
        /// </summary>
        /// <param name="calculations">The calculations for which to handle changes.</param>
        /// <param name="query">The query which should be displayed when inquiring for a confirmation.</param>
        /// <param name="inquiryHandler">Object responsible for inquiring the required data.</param>
        /// <exception cref="ArgumentNullException">Thrown when any parameter is <c>null</c>.</exception>
        public CalculationChangeHandler(IEnumerable <ICalculation> calculations,
                                        string query,
                                        IInquiryHelper inquiryHandler)
        {
            if (calculations == null)
            {
                throw new ArgumentNullException(nameof(calculations));
            }

            if (query == null)
            {
                throw new ArgumentNullException(nameof(query));
            }

            if (inquiryHandler == null)
            {
                throw new ArgumentNullException(nameof(inquiryHandler));
            }

            this.calculations   = calculations;
            this.query          = query;
            this.inquiryHandler = inquiryHandler;
        }
コード例 #22
0
ファイル: PluginBaseTest.cs プロジェクト: Deltares/Riskeer
        public void GivenPluginWithGui_WhenGetInquiryHelperCalled_ThenAlwaysSameInquiryHelperReturned()
        {
            // Given
            var mocks      = new MockRepository();
            var mainWindow = mocks.Stub <IMainWindow>();
            var gui        = mocks.Stub <IGui>();

            gui.Stub(g => g.MainWindow).Return(mainWindow);
            mocks.ReplayAll();

            var plugin = new SimplePlugin
            {
                Gui = gui
            };

            // When
            IInquiryHelper inquiryHelper1 = plugin.GetInquiryHelperFromBase();
            IInquiryHelper inquiryHelper2 = plugin.GetInquiryHelperFromBase();

            // Then
            Assert.AreSame(inquiryHelper1, inquiryHelper2);
            mocks.VerifyAll();
        }
コード例 #23
0
        private ContextMenuStrip WaveConditionsCalculationContextMenuStrip(GrassCoverErosionOutwardsWaveConditionsCalculationContext nodeData,
                                                                           object parentData,
                                                                           TreeViewControl treeViewControl)
        {
            IInquiryHelper inquiryHelper = GetInquiryHelper();
            var            builder       = new RiskeerContextMenuBuilder(Gui.Get(nodeData, treeViewControl));

            GrassCoverErosionOutwardsWaveConditionsCalculation calculation = nodeData.WrappedData;

            return(builder
                   .AddExportItem()
                   .AddSeparator()
                   .AddDuplicateCalculationItem(calculation, nodeData)
                   .AddSeparator()
                   .AddRenameItem()
                   .AddUpdateForeshoreProfileOfCalculationItem(calculation, inquiryHelper,
                                                               SynchronizeCalculationWithForeshoreProfileHelper.UpdateForeshoreProfileDerivedCalculationInput)
                   .AddSeparator()
                   .AddValidateCalculationItem(
                       nodeData,
                       Validate,
                       EnableValidateAndCalculateMenuItemForCalculation)
                   .AddPerformCalculationItem <GrassCoverErosionOutwardsWaveConditionsCalculation, GrassCoverErosionOutwardsWaveConditionsCalculationContext>(
                       nodeData,
                       Calculate,
                       EnableValidateAndCalculateMenuItemForCalculation)
                   .AddSeparator()
                   .AddClearCalculationOutputItem(calculation)
                   .AddDeleteItem()
                   .AddSeparator()
                   .AddCollapseAllItem()
                   .AddExpandAllItem()
                   .AddSeparator()
                   .AddPropertiesItem()
                   .Build());
        }
コード例 #24
0
 public TestClearIllustrationPointsOfCalculationCollectionChangeHandler(IInquiryHelper helper) : base(helper)
 {
 }
コード例 #25
0
 public TestClearIllustrationPointsOfCalculationChangeHandler(IInquiryHelper inquiryHelper, TestCalculation calculation)
     : base(inquiryHelper, calculation)
 {
 }
コード例 #26
0
 /// <summary>
 /// Creates a new instance of <see cref="ClearIllustrationPointsOfStructuresCalculationHandler"/>.
 /// </summary>
 /// <param name="inquiryHelper">Object responsible for inquiring confirmation.</param>
 /// <param name="calculation">The calculation to clear the illustration points for.</param>
 /// <exception cref="ArgumentNullException">Thrown when any parameter is <c>null</c>.</exception>
 public ClearIllustrationPointsOfStructuresCalculationHandler(IInquiryHelper inquiryHelper,
                                                              IStructuresCalculation calculation)
     : base(inquiryHelper, calculation)
 {
 }
コード例 #27
0
 private ClearIllustrationPointsOfStructureCalculationCollectionChangeHandler CreateChangeHandler(
     IInquiryHelper inquiryHelper, IEnumerable <StructuresCalculation <ClosingStructuresInput> > calculations)
 {
     return(new ClearIllustrationPointsOfStructureCalculationCollectionChangeHandler(inquiryHelper, calculations));
 }
 private static ImportInfo <PipingFailureMechanismSectionsContext> GetImportInfo(IInquiryHelper inquiryHelper)
 {
     return(PipingImportInfoFactory.CreateFailureMechanismSectionsImportInfo(inquiryHelper));
 }
        /// <summary>
        /// Creates a new instance of <see cref="ClearIllustrationPointsOfGrassCoverErosionInwardsCalculationCollectionChangeHandler"/>.
        /// </summary>
        /// <param name="inquiryHelper">Object responsible for inquiring confirmation.</param>
        /// <param name="calculations">The calculations for which the illustration points should be cleared.</param>
        /// <exception cref="System.ArgumentNullException">Thrown when any parameter is <c>null</c>.</exception>
        public ClearIllustrationPointsOfGrassCoverErosionInwardsCalculationCollectionChangeHandler(IInquiryHelper inquiryHelper,
                                                                                                   IEnumerable <GrassCoverErosionInwardsCalculation> calculations)
            : base(inquiryHelper)
        {
            if (calculations == null)
            {
                throw new ArgumentNullException(nameof(calculations));
            }

            this.calculations = calculations;
        }
コード例 #30
0
        private ContextMenuStrip CalculationGroupContextContextMenuStrip(ClosingStructuresCalculationGroupContext context,
                                                                         object parentData,
                                                                         TreeViewControl treeViewControl)
        {
            CalculationGroup group         = context.WrappedData;
            IInquiryHelper   inquiryHelper = GetInquiryHelper();
            var  builder       = new RiskeerContextMenuBuilder(Gui.Get(context, treeViewControl));
            bool isNestedGroup = parentData is ClosingStructuresCalculationGroupContext;

            StructuresCalculation <ClosingStructuresInput>[] calculations = group
                                                                            .GetCalculations()
                                                                            .Cast <StructuresCalculation <ClosingStructuresInput> >().ToArray();

            if (!isNestedGroup)
            {
                builder.AddOpenItem()
                .AddSeparator();
            }

            builder.AddImportItem()
            .AddExportItem()
            .AddSeparator();

            if (isNestedGroup)
            {
                builder.AddDuplicateCalculationItem(group, context)
                .AddSeparator();
            }
            else
            {
                builder.AddCustomItem(CreateGenerateClosingStructuresCalculationsItem(context))
                .AddSeparator();
            }

            builder.AddCreateCalculationGroupItem(group)
            .AddCreateCalculationItem(context, AddCalculation, CalculationType.Probabilistic)
            .AddSeparator();

            if (isNestedGroup)
            {
                builder.AddRenameItem();
            }

            builder.AddUpdateForeshoreProfileOfCalculationsItem(calculations, inquiryHelper,
                                                                SynchronizeCalculationWithForeshoreProfileHelper.UpdateForeshoreProfileDerivedCalculationInput)
            .AddCustomItem(CreateUpdateAllStructuresItem(calculations))
            .AddSeparator()
            .AddValidateAllCalculationsInGroupItem(
                context,
                ValidateAllInCalculationGroup,
                EnableValidateAndCalculateMenuItemForCalculationGroup)
            .AddPerformAllCalculationsInGroupItem(
                context,
                CalculateAllInCalculationGroup,
                EnableValidateAndCalculateMenuItemForCalculationGroup)
            .AddSeparator()
            .AddClearAllCalculationOutputInGroupItem(group)
            .AddClearIllustrationPointsOfCalculationsInGroupItem(() => IllustrationPointsHelper.HasIllustrationPoints(calculations),
                                                                 CreateChangeHandler(inquiryHelper, calculations));

            if (isNestedGroup)
            {
                builder.AddDeleteItem();
            }
            else
            {
                builder.AddRemoveAllChildrenItem();
            }

            return(builder.AddSeparator()
                   .AddCollapseAllItem()
                   .AddExpandAllItem()
                   .AddSeparator()
                   .AddPropertiesItem()
                   .Build());
        }