Program.cs
1 // Copyright (c) Microsoft Corporation 2 // The Microsoft Corporation licenses this file to you under the MIT license. 3 // See the LICENSE file in the project root for more information. 4 5 using System.Globalization; 6 7 namespace Microsoft.PowerToys.ThumbnailHandler.Pdf 8 { 9 internal static class Program 10 { 11 private static PdfThumbnailProvider _thumbnailProvider; 12 13 /// <summary> 14 /// The main entry point for the application. 15 /// </summary> 16 [STAThread] 17 public static void Main(string[] args) 18 { 19 ApplicationConfiguration.Initialize(); 20 if (args != null) 21 { 22 if (args.Length == 2) 23 { 24 string filePath = args[0]; 25 uint cx = Convert.ToUInt32(args[1], 10); 26 27 _thumbnailProvider = new PdfThumbnailProvider(filePath); 28 Bitmap thumbnail = _thumbnailProvider.GetThumbnail(cx); 29 if (thumbnail != null) 30 { 31 filePath = filePath.Replace(".pdf", ".bmp"); 32 thumbnail.Save(filePath, System.Drawing.Imaging.ImageFormat.Bmp); 33 } 34 } 35 else 36 { 37 MessageBox.Show("Gcode thumbnail - wrong number of args: " + args.Length.ToString(CultureInfo.InvariantCulture)); 38 } 39 } 40 } 41 } 42 }