Beispiel #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;
        }
Beispiel #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);
        }