public void CalculationInfoTest()
        {
            var calculationInfo = new CalculationInfo();

            calculationInfo.ShowDialog();
        }
Example #2
0
        public void RunCalculationInFds()
        {
            // Todo : Bad practice to use such kind of exception handling.
            try
            {
                #region Check if config exists

                var pluginConfig = new DefaultFactory(Log).CreateFdsConfig();

                if (pluginConfig == null)
                {
                    var fdsConfig = new PluginOptions(Log);
                    fdsConfig.ShowDialog();
                    pluginConfig = fdsConfig.PluginConfig;
                    fdsConfig.Dispose();
                    fdsConfig = null;
                }

                #endregion

                #region Collect information

                // Ask user to configure calculation
                var calculationInfo = new CalculationInfo();
                var dialogResult    = calculationInfo.ShowDialog();

                var calcTime   = calculationInfo.CalculationTime;
                var workingDir = calculationInfo.OutputPath;

                calculationInfo.Dispose();
                calculationInfo = null;

                if (dialogResult == DialogResult.Cancel)
                {
                    return;
                }

                EditMaterialsMappings();

                // get solids
                var selectedSolids = AcadInfoProvider.AskUserToSelectSolids();

                if (selectedSolids.Count < 1)
                {
                    return;
                }

                #endregion

                #region Start Calculations

                var fdsStartInfo = new FdsStartInfo
                {
                    // Arguments = string.Concat("\"", pathToFile, "\""),
                    CalculationTime  = calcTime,
                    DocumentName     = AcadInfoProvider.GetDocumentName(),
                    PathToFds        = pluginConfig.PathToFds,
                    SelectedSolids   = selectedSolids,
                    UsedSurfaces     = CommonHelper.GetAllUsedSurfaces(Log),
                    WorkingDirectory = workingDir
                };

                var progressWindow     = new ConversionProgress(fdsStartInfo.SelectedSolids.Count);
                var calculationManager = new ThreadedCalculationManager(fdsStartInfo, Log, progressWindow);
                progressWindow.Shown += (s, e) => calculationManager.WaitEvent.Set();
                calculationManager.StartCalculation();

                progressWindow.ShowDialog();
                progressWindow.Dispose();
                progressWindow = null;

                #endregion
            }
            catch (System.Exception exception)
            {
                Log.LogError(exception);
                UserNotifier.ShowError(exception.Message);
            }
        }