public void Worker() { for (int i = 0; i < medias.Count && !stopflag; i++) { System.Threading.Thread.Sleep(50 * 1); mediaTrans.translate(medias[i]); pb.ThreadSafePerformStep(); } pb.ThreadSafeClose(); }
public void Worker() { for (int i = 0; i < medias.Count && !stopflag; i++) { byte contentType = medias[i].content_type; System.Threading.Thread.Sleep(50 * 1); string fullName = PathUtils.GenerateAbsoluteMediaPath(medias[i].large_url); FileInfo fileInfo = new FileInfo(fullName); Image image = Bitmap.FromFile(fullName); int originalWidth = image.Width; int originalHeight = image.Height; image.Dispose(); Image smallLogoImg = null; Image mediumLogoImg = null; Image largeLogoImg = null; if (resizeConfig.smallLogo != null && File.Exists(resizeConfig.smallLogo)) { smallLogoImg = Bitmap.FromFile(resizeConfig.smallLogo); } if (resizeConfig.mediumLogo != null && File.Exists(resizeConfig.mediumLogo)) { mediumLogoImg = Bitmap.FromFile(resizeConfig.mediumLogo); } if (resizeConfig.largeLogo != null && File.Exists(resizeConfig.largeLogo)) { largeLogoImg = Bitmap.FromFile(resizeConfig.largeLogo); } int smallWidth = this.resizeConfig.floorplan_smallWidth; int smallHeight = this.resizeConfig.floorplan_smallHeight; int mediumWidth = this.resizeConfig.floorplan_mediumWidth; int mediumHeight = this.resizeConfig.floorplan_mediumHeight; switch (contentType) { case Media.CONTENT_TYPE_FLOORPLAN: smallWidth = this.resizeConfig.floorplan_smallWidth; smallHeight = this.resizeConfig.floorplan_smallHeight; mediumWidth = this.resizeConfig.floorplan_mediumWidth; mediumHeight = this.resizeConfig.floorplan_mediumHeight; break; case Media.CONTENT_TYPE_FLOORPLATE: case Media.CONTENT_TYPE_OTHERS: case Media.CONTENT_TYPE_PHOTOGRAPH: case Media.CONTENT_TYPE_RENDER_INTERNAL: case Media.CONTENT_TYPE_RENDER_EXTERNAL: case Media.CONTENT_TYPE_PROJECT_OVERVIEW: case Media.CONTENT_TYPE_PROJECT_DESCRIPTION: case Media.CONTENT_TYPE_PROJECT_FEATURE: case Media.CONTENT_TYPE_PROJECT_SCHEME: default: smallWidth = this.resizeConfig.overview_smallWidth; smallHeight = this.resizeConfig.overview_smallHeight; mediumWidth = this.resizeConfig.overview_mediumWidth; mediumHeight = this.resizeConfig.overview_mediumHeight; break; } bool enableLogo = this.resizeConfig.enableLogo && this.resizeConfig.enableLogoTypes.Contains(contentType); resizePicture(fileInfo, enableLogo, smallLogoImg, "small", smallWidth, smallHeight); resizePicture(fileInfo, enableLogo, mediumLogoImg, "medium", mediumWidth, mediumHeight); resizePicture(fileInfo, enableLogo, largeLogoImg, "large", originalWidth, originalHeight); pb.ThreadSafePerformStep(); } pb.ThreadSafeClose(); }