// Exports MSMX background with customizable text labels public void ExportMSMXBackground(string variant, string number = null, string name = null) { VGCore.ShapeRange kit = this.appDraw.ActiveSelectionRange; if (CheckKitDimensions(kit)) { VGCore.Shape msmx = ImportBackground("msmx.cdr"); ArrangeExportAndCleanup(kit, msmx, cdrFilter.cdrJPEG, 1000, 779, variant, number, name); } }
// Checks whether the dimensions for the kit are valid and if not, shows an error message private bool CheckKitDimensions(VGCore.ShapeRange kit) { if (kit.SizeHeight > kit.SizeWidth) { MessageBox.Show("The kit's width must be bigger than it's height!"); return(false); } else { return(true); } }
//exports image private void ExportImage(VGCore.ShapeRange kit, VGCore.Shape background, cdrFilter imageType, int width, int height, string variant = null, string number = null, string name = null) { ShapeRange exportRange = kit; exportRange.Add(background); exportRange.CreateSelection(); String fileName = this.appDraw.ActiveDocument.FileName; String filePath = this.appDraw.ActiveDocument.FilePath; fileName = fileName.Remove(fileName.Length - 4, 4); String suffix = ""; ExportFilter expFil; if (variant == null) { if (background.Name != "FMR_W.cdr") { suffix = " -" + background.Name.ElementAt(4); } if (imageType == cdrFilter.cdrPNG) { suffix += ".png"; } expFil = this.appDraw.ActiveDocument.ExportBitmap(filePath + fileName + suffix, imageType, cdrExportRange.cdrSelection, cdrImageType.cdrRGBColorImage, width, height, 300, 300); } else { if (imageType == cdrFilter.cdrJPEG) { suffix += ".jpg"; } //fileName = variant + fileName.Substring(6); expFil = this.appDraw.ActiveDocument.ExportBitmap(filePath + fileName + suffix, imageType, cdrExportRange.cdrSelection, cdrImageType.cdrRGBColorImage, width, height, 300, 300, cdrAntiAliasingType.cdrNormalAntiAliasing, false, false, true, false, cdrCompressionType.cdrCompressionJPEG); } expFil.Finish(); }
//runs ArrangeBackground, ExportImage and deletes background to keep the file sizes low. private void ArrangeExportAndCleanup(VGCore.ShapeRange kit, VGCore.Shape background, cdrFilter filter, int Width, int Height, string variant = null, string number = null, string name = null) { ArrangeBackground(kit, background, variant, number, name); ExportImage(kit, background, filter, Width, Height, variant, number, name); background.Delete(); }