Esempio n. 1
0
        public void EditMaterialsMappings()
        {
            var usedMaterials = AcadInfoProvider.AllSolidsFromCurrentDrawing().GetMaterials();
            var surfacesStore = XmlSerializer <List <Surface> > .Deserialize(PluginInfoProvider.PathToSurfacesStore, Log);

            var mappingMaterials = XmlSerializer <List <MaterialAndSurface> > .Deserialize(PluginInfoProvider.PathToMappingsMaterials, Log);

            var materialMapper = new MaterialMapper(usedMaterials, surfacesStore, mappingMaterials);

            var dialogResult = materialMapper.ShowDialog();

            if (dialogResult == DialogResult.OK)
            {
                XmlSerializer <List <MaterialAndSurface> > .Serialize(materialMapper.MappingMaterials, PluginInfoProvider.PathToMappingsMaterials);
            }

            materialMapper.Dispose();
            materialMapper = null;
        }
Esempio n. 2
0
        public static IList <MaterialManager.BLL.Surface> GetAllUsedSurfaces(ILogger log)
        {
            var usedMaterials = AcadInfoProvider.AllSolidsFromCurrentDrawing().GetMaterials();
            var surfacesStore = XmlSerializer <List <MaterialManager.BLL.Surface> > .Deserialize(PluginInfoProvider.PathToSurfacesStore, log);

            var mappingMaterials = XmlSerializer <List <MaterialAndSurface> > .Deserialize(PluginInfoProvider.PathToMappingsMaterials, log);

            //var usedSuraces = from surface in surfacesStore
            //       from mapping in mappingMaterials
            //       where surface.ID == mapping.SurfaceName && usedMaterials.Contains(mapping.MaterialName)
            //       select surface;

            var usedSurfaces = new List <MaterialManager.BLL.Surface>();

            foreach (var material in usedMaterials)
            {
                var mapItem = mappingMaterials.Find(mapping => mapping.MaterialName == material);
                if (mapItem == null)
                {
                    continue;
                }

                var surf = surfacesStore.Find(surface => surface.ID == mapItem.SurfaceName);

                if (surf == null)
                {
                    continue;
                }

                if (!usedSurfaces.Contains(surf))
                {
                    usedSurfaces.Add(surf);
                }
            }


            return(usedSurfaces);
        }
Esempio n. 3
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);
            }
        }