static void Main(string[] args) { //check for the first time Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); if (mySettings.FirstTime) { var i = new GUI.FirstTime(); i.ShowDialog(); } if (args.Length > 0) { //we have a context menu item... string filename = args[0].ToLower(); if (System.IO.File.Exists(filename)) { //check if its a valid picture format. if (Common.IsValidImage(filename)) { skImage ski = new skImage(Image.FromFile(filename), filename); Common.ShowToastForm(ski); } else if (System.IO.Path.GetExtension(filename) == ".psd") { //its a PSD file. //save a local copy of the PSD as jpeg //double check location Photoshop.PsdFile psd = new Photoshop.PsdFile(); //load the file psd.Load(filename); //decode the image Image myPsdImage = Photoshop.ImageDecoder.DecodeImage(psd); //create new image skImage ski = new skImage(myPsdImage); Common.ShowToastForm(ski); } //exit silently } } else { bool firstInstance; Mutex mutex = new Mutex(false, "Local\\" + "SkimptProgramRunning", out firstInstance); if (firstInstance) { Application.Run(new GUI.main()); } } //wait till all toast forms are closed while (Application.OpenForms.Count > 0) { Application.DoEvents(); } }