Exemplo n.º 1
0
 private void Calculate(ClosingStructuresCalculationScenarioContext context)
 {
     ActivityProgressDialogRunner.Run(Gui.MainWindow,
                                      ClosingStructuresCalculationActivityFactory.CreateCalculationActivity(context.WrappedData,
                                                                                                            context.FailureMechanism,
                                                                                                            context.AssessmentSection));
 }
Exemplo n.º 2
0
 private void Calculate(WaveImpactAsphaltCoverWaveConditionsCalculationContext context)
 {
     ActivityProgressDialogRunner.Run(Gui.MainWindow,
                                      WaveImpactAsphaltCoverWaveConditionsCalculationActivityFactory.CreateCalculationActivity(context.WrappedData,
                                                                                                                               context.FailureMechanism,
                                                                                                                               context.AssessmentSection));
 }
Exemplo n.º 3
0
 private void Calculate(GrassCoverErosionOutwardsWaveConditionsCalculationContext context)
 {
     ActivityProgressDialogRunner.Run(Gui.MainWindow,
                                      GrassCoverErosionOutwardsCalculationActivityFactory.CreateWaveConditionsCalculationActivity(context.WrappedData,
                                                                                                                                  context.FailureMechanism,
                                                                                                                                  context.AssessmentSection));
 }
Exemplo n.º 4
0
 private void CalculateAllInFailureMechanism(HydraulicLoadsStateFailureMechanismContext context)
 {
     ActivityProgressDialogRunner.Run(
         Gui.MainWindow,
         WaveImpactAsphaltCoverWaveConditionsCalculationActivityFactory.CreateCalculationActivities(context.WrappedData,
                                                                                                    context.Parent));
 }
Exemplo n.º 5
0
        private ContextMenuStrip HydraulicLoadsStateFailureMechanismContextMenuStrip(HydraulicLoadsStateFailureMechanismContext context,
                                                                                     object parentData,
                                                                                     TreeViewControl treeViewControl)
        {
            var builder = new RiskeerContextMenuBuilder(Gui.Get(context, treeViewControl));

            IAssessmentSection assessmentSection = context.Parent;
            var calculateAllItem = new StrictContextMenuItem(
                RiskeerCommonFormsResources.Calculate_All,
                RiskeerCommonFormsResources.Calculate_All_ToolTip,
                RiskeerCommonFormsResources.CalculateAllIcon,
                (sender, args) =>
            {
                ActivityProgressDialogRunner.Run(
                    Gui.MainWindow,
                    GrassCoverErosionOutwardsCalculationActivityFactory
                    .CreateWaveConditionsCalculationActivities(context.WrappedData.CalculationsGroup,
                                                               context.WrappedData,
                                                               assessmentSection));
            });

            SetHydraulicsMenuItemEnabledStateAndTooltip(assessmentSection,
                                                        calculateAllItem);

            return(builder.AddOpenItem()
                   .AddSeparator()
                   .AddCustomItem(calculateAllItem)
                   .AddSeparator()
                   .AddCollapseAllItem()
                   .AddExpandAllItem()
                   .AddSeparator()
                   .AddPropertiesItem()
                   .Build());
        }
Exemplo n.º 6
0
 private void CalculateAllInCalculationGroup(HeightStructuresCalculationGroupContext context)
 {
     ActivityProgressDialogRunner.Run(
         Gui.MainWindow,
         HeightStructuresCalculationActivityFactory.CreateCalculationActivities(context.WrappedData,
                                                                                context.FailureMechanism,
                                                                                context.AssessmentSection));
 }
Exemplo n.º 7
0
 private void CalculateAllInCalculationGroup(StabilityStoneCoverCalculationGroupContext context)
 {
     ActivityProgressDialogRunner.Run(
         Gui.MainWindow,
         StabilityStoneCoverWaveConditionsCalculationActivityFactory.CreateCalculationActivities(context.WrappedData,
                                                                                                 context.FailureMechanism,
                                                                                                 context.AssessmentSection));
 }
Exemplo n.º 8
0
        private void RunUpdateActivity(IFileImporter importer, string updateName)
        {
            var activity = new FileImportActivity(importer,
                                                  !string.IsNullOrEmpty(updateName)
                                                      ? string.Format(Resources.GuiUpdateHandler_RunUpdateActivity_Updating_0_, updateName)
                                                      : string.Empty);

            ActivityProgressDialogRunner.Run(dialogParent, activity);
        }
Exemplo n.º 9
0
        /// <summary>
        /// Starts an activity that can migrate the project if required, then opens the project.
        /// </summary>
        /// <param name="filePath">The project file to open.</param>
        /// <param name="migrationProperties">The construction properties related to migrating
        /// a project. Can be <c>null</c>.</param>
        /// <returns>Returns <c>true</c> if the operation completed successfully; Returns
        /// <c>false</c> otherwise (for example when the operation failed or was cancelled).</returns>
        /// <exception cref="ArgumentException">Thrown when <paramref name="filePath"/> is
        /// not a valid file path.</exception>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="filePath"/>
        /// is <c>null</c>.</exception>
        private bool MigrateAndOpenProject(string filePath, OpenProjectActivity.ProjectMigrationConstructionProperties migrationProperties)
        {
            var openProjectProperties = new OpenProjectActivity.OpenProjectConstructionProperties
            {
                FilePath       = filePath,
                ProjectOwner   = projectOwner,
                ProjectFactory = projectFactory,
                ProjectStorage = projectPersister
            };
            var activity = new OpenProjectActivity(openProjectProperties, migrationProperties);

            ActivityProgressDialogRunner.Run(mainWindowController.MainWindow, activity);

            return(activity.State == ActivityState.Finished);
        }
Exemplo n.º 10
0
        public bool SaveProjectAs()
        {
            IProject project  = projectOwner.Project;
            string   filePath = OpenProjectSaveFileDialog(project.Name);

            if (string.IsNullOrWhiteSpace(filePath))
            {
                return(false);
            }

            var activity = new SaveProjectActivity(project, filePath, false, projectPersister, projectOwner);

            ActivityProgressDialogRunner.Run(mainWindowController.MainWindow, activity);
            return(activity.State == ActivityState.Finished);
        }
Exemplo n.º 11
0
        public bool SaveProject()
        {
            IProject project  = projectOwner.Project;
            string   filePath = projectOwner.ProjectFilePath;

            // If file path is not set, go to SaveAs
            if (string.IsNullOrWhiteSpace(filePath) || !File.Exists(filePath))
            {
                return(SaveProjectAs());
            }

            var activity = new SaveProjectActivity(project, filePath, true, projectPersister, projectOwner);

            ActivityProgressDialogRunner.Run(mainWindowController.MainWindow, activity);
            return(activity.State == ActivityState.Finished);
        }
Exemplo n.º 12
0
        private void RunActivities(HydraulicBoundaryDatabase hydraulicBoundaryDatabase, IEnumerable <CalculatableActivity> activities)
        {
            string validationProblem = HydraulicBoundaryDatabaseHelper.ValidateFilesForCalculation(
                hydraulicBoundaryDatabase.FilePath,
                hydraulicBoundaryDatabase.HydraulicLocationConfigurationSettings.FilePath,
                hydraulicBoundaryDatabase.EffectivePreprocessorDirectory(),
                hydraulicBoundaryDatabase.HydraulicLocationConfigurationSettings.UsePreprocessorClosure);

            if (string.IsNullOrEmpty(validationProblem))
            {
                ActivityProgressDialogRunner.Run(viewParent, activities);
            }
            else
            {
                log.ErrorFormat(Resources.CalculateHydraulicBoundaryLocation_Start_calculation_failed_0_,
                                validationProblem);
            }
        }
Exemplo n.º 13
0
        public void ImportHydraulicLocationConfigurationSettings(HydraulicLocationConfigurationSettings hydraulicLocationConfigurationSettings, string hlcdFilePath)
        {
            if (hydraulicLocationConfigurationSettings == null)
            {
                throw new ArgumentNullException(nameof(hydraulicLocationConfigurationSettings));
            }

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

            var importSettingsActivity = new FileImportActivity(
                new HydraulicLocationConfigurationDatabaseImporter(hydraulicLocationConfigurationSettings,
                                                                   updateHandler,
                                                                   hydraulicBoundaryDatabase,
                                                                   hlcdFilePath),
                Resources.HydraulicLocationConfigurationDatabaseImportHandler_ImportHydraulicLocationConfigurationSettings_Description);

            ActivityProgressDialogRunner.Run(viewParent, importSettingsActivity);
        }
Exemplo n.º 14
0
        public AssessmentSection GetAssessmentSection(string filePath)
        {
            if (filePath == null)
            {
                throw new ArgumentNullException(nameof(filePath));
            }

            var assessmentSectionOwner = new AssessmentSectionOwner();

            ActivityProgressDialogRunner.Run(viewParent,
                                             LoadAssessmentSectionActivityFactory.CreateLoadAssessmentSectionActivity(
                                                 assessmentSectionOwner, new LoadAssessmentSectionService(projectStorage),
                                                 filePath));

            if (assessmentSectionOwner.AssessmentSection == null)
            {
                throw new AssessmentSectionProviderException();
            }

            return(assessmentSectionOwner.AssessmentSection);
        }
Exemplo n.º 15
0
        /// <summary>
        /// Performs all <paramref name="calculations"/>.
        /// </summary>
        /// <param name="calculations">The collection of <see cref="DuneLocationCalculation"/> to perform.</param>
        /// <param name="assessmentSection">The assessment section the calculations belong to.</param>
        /// <param name="targetProbability">The target probability to use during the calculations.</param>
        /// <param name="calculationIdentifier">The calculation identifier to use in all messages.</param>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="calculations"/> or
        /// <paramref name="assessmentSection"/> is <c>null</c>.</exception>
        /// <exception cref="ArgumentException">Thrown when <paramref name="calculationIdentifier"/> is <c>null</c> or empty.</exception>
        public void Calculate(IEnumerable <DuneLocationCalculation> calculations,
                              IAssessmentSection assessmentSection,
                              double targetProbability,
                              string calculationIdentifier)
        {
            if (calculations == null)
            {
                throw new ArgumentNullException(nameof(calculations));
            }

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

            string hydraulicBoundaryDatabaseFilePath = assessmentSection.HydraulicBoundaryDatabase.FilePath;
            string preprocessorDirectory             = assessmentSection.HydraulicBoundaryDatabase.EffectivePreprocessorDirectory();
            HydraulicLocationConfigurationSettings hydraulicLocationConfigurationSettings = assessmentSection.HydraulicBoundaryDatabase.HydraulicLocationConfigurationSettings;

            string validationProblem = HydraulicBoundaryDatabaseHelper.ValidateFilesForCalculation(hydraulicBoundaryDatabaseFilePath,
                                                                                                   hydraulicLocationConfigurationSettings.FilePath,
                                                                                                   preprocessorDirectory,
                                                                                                   hydraulicLocationConfigurationSettings.UsePreprocessorClosure);

            if (!string.IsNullOrEmpty(validationProblem))
            {
                log.ErrorFormat(RiskeerCommonFormsResources.CalculateHydraulicBoundaryLocation_Start_calculation_failed_0_,
                                validationProblem);
                return;
            }

            ActivityProgressDialogRunner.Run(viewParent,
                                             DuneLocationCalculationActivityFactory.CreateCalculationActivities(calculations,
                                                                                                                assessmentSection,
                                                                                                                targetProbability,
                                                                                                                calculationIdentifier));
        }
Exemplo n.º 16
0
 private void CalculateAllInFailureMechanism(CalculationsStateFailureMechanismContext context)
 {
     ActivityProgressDialogRunner.Run(Gui.MainWindow,
                                      ClosingStructuresCalculationActivityFactory.CreateCalculationActivities(context.WrappedData, context.Parent));
 }