protected virtual void Initialize(WorkerTask task, WorkflowWizardGUIOptions gui)
        {
            if (task != null)
            {
                this.Config = task.WorkflowConfig;
                this.Text = Application.ProductName + " - Workflow - " + task.Info.Job.GetDescription();
            }
            else
            {
                this.Text = Application.ProductName;
            }

            tcMain.TabPages.Clear();
            tcMain.TabPages.Add(tpOutputs);

            if (gui != null)
            {
                gbTasks.Visible = false;
                this.MinimumSize = new System.Drawing.Size(this.Width - gbTasks.Width, this.Height);
                this.Width = this.MinimumSize.Width;
                this.GUI = gui;
            }
            if (task != null)
            {
                this.Task = task;
            }
        }
        public static string PrepareFilename(Workflow workflow, Image img, EImageFormat imageFormat, NameParser parser)
        {
            string ext = "png";

            switch (imageFormat)
            {
                case EImageFormat.PNG:
                    ext = "png";
                    break;
                case EImageFormat.JPEG:
                    ext = "jpg";
                    break;
                case EImageFormat.GIF:
                    ext = "gif";
                    break;
                case EImageFormat.BMP:
                    ext = "bmp";
                    break;
                case EImageFormat.TIFF:
                    ext = "tif";
                    break;
            }

            string pattern = workflow.ConfigFileNaming.EntireScreenPattern;
            switch (parser.Type)
            {
                case NameParserType.ActiveWindow:
                    pattern = workflow.ConfigFileNaming.ActiveWindowPattern;
                    break;
                default:
                    pattern = workflow.ConfigFileNaming.EntireScreenPattern;
                    break;
            }
            string fn = parser.Convert(pattern);
            if (Engine.ConfigWorkflow != null)
            {
                Engine.ConfigWorkflow.ConfigFileNaming.AutoIncrement = parser.AutoIncrementNumber; // issue 577; Engine.Workflow.AutoIncrement has to be updated
            }

            string fileName = string.Format("{0}.{1}", fn, ext);

            return FileSystem.GetUniqueFileName(workflow, fileName);
        }
        public List<Workflow> CreateDefaultWorkflows()
        {
            List<Workflow> workflows = new List<Workflow>();

            Workflow entireScreen = new Workflow("Desktop to file");
            entireScreen.Job = WorkerTask.JobLevel2.CaptureEntireScreen;
            entireScreen.DestConfig.Outputs.Add(OutputEnum.Clipboard);
            entireScreen.DestConfig.Outputs.Add(OutputEnum.LocalDisk);
            entireScreen.Hotkey = new HelpersLib.Hotkey.HotkeySetting(Keys.PrintScreen);
            workflows.Add(entireScreen);

            Workflow activeWindow = new Workflow("Active Window to clipboard");
            activeWindow.Job = WorkerTask.JobLevel2.CaptureActiveWindow;
            activeWindow.DestConfig.Outputs.Add(OutputEnum.Clipboard);
            activeWindow.Hotkey = new HelpersLib.Hotkey.HotkeySetting(Keys.Alt | Keys.PrintScreen);
            workflows.Add(activeWindow);

            return workflows;
        }
        public JBirdWorkflowWizard(WorkerTask task = null, Workflow workflow = null, WorkflowWizardGUIOptions gui = null)
        {
            base.InitializeComponent();
            InitializeComponent();
            base.Initialize(task, gui);

            HotkeyManager tempHotkeyMgr;
            this.Task = new WorkerTask(workflow);
            this.Config = workflow;
            Program.HotkeyMgrs.TryGetValue(this.Config.ID, out tempHotkeyMgr);
            if (tempHotkeyMgr != null)
            {
                hmcHotkeys.PrepareHotkeys(tempHotkeyMgr);
            }
            else
            {
                HotkeyManager hm = new HotkeyManager(Program.CoreUI, ZAppType.JBird);
                hm.AddHotkey(JBirdHotkey.Workflow, Config.Hotkey, Config.Start);
                hmcHotkeys.PrepareHotkeys(hm);
            }
        }
        public static MemoryStream PrepareImage(Workflow wf, ZScreenOptions zo, Image img, out EImageFormat imageFormat,
            bool bConvert = true, bool bTargetFileSize = true)
        {
            imageFormat = wf.ImageFormat;
            MemoryStream stream = img.SaveImage(wf, wf.ImageFormat);

            if (bConvert)
            {
                long streamLength = stream.Length / 1024;
                int sizeLimit = zo.ConfigImageEffects.ImageSizeLimit * 1024;

                if (wf.ImageFormat != wf.ImageFormat2 && sizeLimit > 0 && stream.Length > sizeLimit)
                {
                    stream = img.SaveImage(wf, wf.ImageFormat2);

                    if (bTargetFileSize)
                    {
                        DebugHelper.WriteLine(ConvertImageString(streamLength, wf, stream));
                        while (stream.Length > sizeLimit && wf.ImageFormat2 == EImageFormat.JPEG)
                        {
                            if (wf.ImageJpegQuality == FreeImageJpegQualityType.JPEG_QUALITYBAD)
                            {
                                break;
                            }

                            wf.ImageJpegQuality = wf.ImageJpegQuality - 1;
                            stream = img.SaveImage(wf, EImageFormat.JPEG);
                            DebugHelper.WriteLine(ConvertImageString(streamLength, wf, stream));
                        }
                    }

                    imageFormat = wf.ImageFormat2;
                }
            }

            stream.Position = 0;

            return stream;
        }
        /// <summary>Captures a screenshot of a window using the Windows DWM</summary>
        /// <param name="handle">handle of the window to capture</param>
        /// <returns>the captured window image with or without cursor</returns>
        public static Image CaptureWithDWM(Workflow wfdwm, IntPtr handle)
        {
            DebugHelper.WriteLine("Capturing with DWM");
            Image windowImageDwm = null;
            Bitmap redBGImage = null;

            Rectangle windowRect = CaptureHelpers.GetWindowRectangle(handle);
            if (windowRect.Width == 0)
            {
                System.Threading.Thread.Sleep(250);
                windowRect = CaptureHelpers.GetWindowRectangle(handle); // try again
            }

            if (windowRect.Width > 0 && NativeMethods.IsDWMEnabled())
            {
                if (wfdwm.ActiveWindowDwmUseCustomBackground)
                {
                    windowImageDwm = CaptureWindowWithDWM(handle, windowRect, out redBGImage, wfdwm.ActiveWindowDwmBackColor);
                }
                else if (wfdwm.ActiveWindowClearBackground)
                {
                    windowImageDwm = CaptureWindowWithDWM(handle, windowRect, out redBGImage, Color.White);
                }
            }

            if (windowImageDwm == null)
            {
                DebugHelper.WriteLine("Standard capture (no transparency)");
                windowImageDwm = Screenshot.CaptureRectangleNative(windowRect);
            }

            Image result = RemoveCorners(handle, windowImageDwm, redBGImage, windowRect);
            if (result != null)
            {
                windowImageDwm = result;
            }

            if (wfdwm.ActiveWindowIncludeShadows)
            {
                // Draw shadow manually to be able to have shadows in every case
                windowImageDwm = HelpersLib.GraphicsHelper.Core.AddBorderShadow((Bitmap)windowImageDwm, true);

                if (wfdwm.DrawCursor)
                {
                    Point shadowOffset = HelpersLib.GraphicsHelper.Core.ShadowOffset;
            #if DEBUG
                    DebugHelper.WriteLine("Fixed cursor position (before): " + windowRect.ToString());
            #endif
                    windowRect.X -= shadowOffset.X;
                    windowRect.Y -= shadowOffset.Y;
            #if DEBUG
                    DebugHelper.WriteLine("Fixed cursor position (after):  " + windowRect.ToString());
            #endif
                }
            }

            if (wfdwm.DrawCursor)
            {
                CaptureHelpers.DrawCursorToImage(windowImageDwm, windowRect.Location);
            }

            return windowImageDwm;
        }
        /// <summary>Captures a screenshot of a window using Windows GDI</summary>
        /// <param name="handle">handle of the window to capture</param>
        /// <returns>the captured window image</returns>
        private static Image CaptureWithGDI(Workflow wfgdi, IntPtr handle, out Rectangle windowRect)
        {
            DebugHelper.WriteLine("Capturing with GDI");

            windowRect = CaptureHelpers.GetWindowRectangle(handle);

            Image windowImageGdi = null;

            if (wfgdi.ActiveWindowClearBackground)
            {
                windowImageGdi = CaptureWindowWithGDI(wfgdi, handle, out windowRect);
            }

            if (windowImageGdi == null)
            {
                using (new Freeze(wfgdi, handle))
                {
                    windowImageGdi = Screenshot.CaptureRectangleNative(windowRect);
                }

                Image result = RemoveCorners(handle, windowImageGdi, null, windowRect);
                if (result != null)
                {
                    windowImageGdi = result;
                }
            }

            return windowImageGdi;
        }
        /// <summary>Captures a screenshot of a window using Windows GDI. Captures transparency.</summary>
        /// <param name="handle">handle of the window to capture</param>
        /// <returns>the captured window image</returns>
        private static Image CaptureWindowWithGDI(Workflow wfgdi, IntPtr handle, out Rectangle windowRect)
        {
            Image windowImageGdi = null;
            Bitmap whiteBGImage = null, blackBGImage = null, white2BGImage = null;

            if (wfgdi.ActiveWindowTryCaptureChildren)
            {
                windowRect = new WindowRectangle(handle).CalculateWindowRectangle();
            }
            else
            {
                windowRect = CaptureHelpers.GetWindowRectangle(handle);
            }

            try
            {
                using (new Freeze(wfgdi, handle))
                using (Form form = new Form())
                {
                    form.BackColor = Color.White;
                    form.FormBorderStyle = FormBorderStyle.None;
                    form.ShowInTaskbar = false;

                    int offset = wfgdi.ActiveWindowIncludeShadows && !NativeMethods.IsWindowMaximized(handle) ? 20 : 0;

                    windowRect.Inflate(offset, offset);
                    windowRect.Intersect(CaptureHelpers.GetScreenBounds());

                    NativeMethods.ShowWindow(form.Handle, (int)WindowShowStyle.ShowNormalNoActivate);
                    NativeMethods.SetWindowPos(form.Handle, handle, windowRect.X, windowRect.Y, windowRect.Width, windowRect.Height, NativeMethods.SWP_NOACTIVATE);
                    Application.DoEvents();

                    whiteBGImage = (Bitmap)Screenshot.CaptureRectangleNative2(windowRect);

                    form.BackColor = Color.Black;
                    Application.DoEvents();

                    blackBGImage = (Bitmap)Screenshot.CaptureRectangleNative2(windowRect);

                    if (!wfgdi.ActiveWindowGDIFreezeWindow)
                    {
                        form.BackColor = Color.White;
                        Application.DoEvents();

                        white2BGImage = (Bitmap)Screenshot.CaptureRectangleNative2(windowRect);
                    }
                }

                if (wfgdi.ActiveWindowGDIFreezeWindow || whiteBGImage.AreBitmapsEqual(white2BGImage))
                {
                    windowImageGdi = HelpersLib.GraphicsHelper.Core.ComputeOriginal(whiteBGImage, blackBGImage);
                }
                else
                {
                    windowImageGdi = (Image)whiteBGImage.Clone();
                }
            }
            finally
            {
                if (whiteBGImage != null) whiteBGImage.Dispose();
                if (blackBGImage != null) blackBGImage.Dispose();
                if (white2BGImage != null) white2BGImage.Dispose();
            }

            if (windowImageGdi != null)
            {
                Rectangle windowRectCropped = HelpersLib.GraphicsHelper.Core.GetCroppedArea((Bitmap)windowImageGdi);
                windowImageGdi = CaptureHelpers.CropImage(windowImageGdi, windowRectCropped);

                if (wfgdi.DrawCursor)
                {
            #if DEBUG
                    DebugHelper.WriteLine("Fixed cursor position (before): " + windowRect.ToString());
            #endif
                    windowRect.X += windowRectCropped.X;
                    windowRect.Y += windowRectCropped.Y;
            #if DEBUG
                    DebugHelper.WriteLine("Fixed cursor position (after):  " + windowRect.ToString());
            #endif
                }
            }

            return windowImageGdi;
        }
        public static void LoadSettings(string fp = null)
        {
            LoggerTimer timer = EngineLogger.StartTimer("LoadSettings started");

            Thread threadOptions = new Thread(() =>
            {
                Engine.ConfigOptions = ZScreenOptions.Read(OptionsFilePath);
            });

            Thread threadMainFormSettings = new Thread(() =>
            {
                if (string.IsNullOrEmpty(fp))
                {
                    Engine.ConfigUI = XMLSettings.Read();
                }
                else
                {
                    Engine.ConfigUI = XMLSettings.Read(fp);
                }
            });

            Thread threadWorkflow = new Thread(() =>
            {
                Engine.ConfigWorkflow = Workflow.Read(WorkflowConfigPath);
            });

            Thread threadUploadersConfig = new Thread(() =>
            {
                Engine.ConfigUploaders = UploadersConfig.Load(UploadersConfigPath);
            });

            Thread threadGt = new Thread(() =>
            {
                Engine.ConfigGT = GoogleTranslatorConfig.Read(GoogleTranslateConfigPath);
            });

            threadOptions.Start();
            threadMainFormSettings.Start();
            threadGt.Start();
            threadWorkflow.Start();
            threadUploadersConfig.Start();

            threadMainFormSettings.Join();
            threadWorkflow.Join();
            threadUploadersConfig.Join();

            timer.WriteLineTime("LoadSettings finished");

            Engine.InitializeFiles();

            // Use Configuration Wizard Settings if applied
            if (RunConfig)
            {
                Engine.ConfigUI.ConfOutputs          = Engine.ConfigApp.AppOutputs;
                Engine.ConfigUI.ConfClipboardContent = Engine.ConfigApp.ClipboardContent;
                Engine.ConfigUI.MyImageUploaders     = Engine.ConfigApp.ImageUploaders;
                Engine.ConfigUI.MyTextUploaders      = Engine.ConfigApp.TextUploaders;
                Engine.ConfigUI.MyFileUploaders      = Engine.ConfigApp.FileUploaders;
                Engine.ConfigUI.MyURLShorteners      = Engine.ConfigApp.LinkUploaders;
            }

            // Portable then we don't need PreferSystemFolders to be true
            if (IsPortable)
            {
                Engine.ConfigApp.PreferSystemFolders = false;
            }
        }
        public static void SaveJPG(this Image img, Stream stream, Workflow workflow, bool fillBackground)
        {
            if (fillBackground)
            {
                img = FillImageBackground(img, Color.White);
            }

            // Using FreeImage converter.
            FreeImageNETHelper.SaveJpeg(img, stream, workflow.ImageJpegQuality, workflow.ImageJpegSubSampling);
        }
        public static string GetUniqueFileName(Workflow workflow, string fileNameOrPath)
        {
            if (!workflow.ConfigFileNaming.OverwriteFiles)
            {
                string fn = Path.GetFileNameWithoutExtension(fileNameOrPath);
                string ext = Path.GetExtension(fileNameOrPath);

                if (fn.Length > workflow.ConfigFileNaming.MaxNameLength - ext.Length)
                {
                    string nfn = fn.Substring(0, workflow.ConfigFileNaming.MaxNameLength - ext.Length);
                    fileNameOrPath = nfn + ext;
                }

                string fp, fileExt, pattern = @"(^.+\()(\d+)(\)\.\w+$)";
                int num = 1;
                GroupCollection groups = Regex.Match(fileNameOrPath, pattern).Groups;
                if (string.IsNullOrEmpty(groups[2].Value))
                {
                    fp = fileNameOrPath.Substring(0, fileNameOrPath.LastIndexOf('.')) + "(";
                    fileExt = ")" + fileNameOrPath.Remove(0, fileNameOrPath.LastIndexOf('.'));
                }
                else
                {
                    fp = groups[1].Value;
                    fileExt = groups[3].Value;
                    num = Convert.ToInt32(groups[2].Value);
                }
                while (File.Exists(fileNameOrPath))
                {
                    fileNameOrPath = fp + ++num + fileExt;
                }
            }

            return fileNameOrPath;
        }
 protected void StartWorkflow(Workflow p)
 {
     switch (p.Job)
     {
         case WorkerTask.JobLevel2.AutoCapture:
             break;
         case WorkerTask.JobLevel2.CaptureActiveWindow:
             HideFormTemporary(() => CaptureActiveWindow(), 3000);
             break;
         case WorkerTask.JobLevel2.CaptureEntireScreen:
             CaptureEntireScreen();
             break;
     }
 }
 private ListViewItem WorkFlowToListViewItem(int id, Workflow wf)
 {
     ListViewItem lvi = new ListViewItem();
     lvi.Checked = wf.Enabled;
     lvi.Text = wf.Description;
     lvi.SubItems.Add(wf.Job.GetDescription());
     lvi.SubItems.Add(wf.Hotkey.ToString());
     lvi.Tag = id;
     return lvi;
 }
        public WorkerTask(Workflow wf, bool cloneWorkflow = true)
        {
            Info = new TaskInfo();
            UploadResults = new List<UploadResult>();
            Errors = new List<string>();
            States.Add(TaskState.Created);
            MyWorker = new BackgroundWorker { WorkerReportsProgress = true };

            if (cloneWorkflow)
            {
                IClone cm = new CloneManager();
                WorkflowConfig = cm.Clone(wf);
            }
            else
            {
                WorkflowConfig = wf;
            }
        }
        public WorkerTask(BackgroundWorker worker, Workflow wf)
            : this(wf)
        {
            MyWorker = worker;

            if (wf.DestConfig.Outputs.Contains(OutputEnum.Clipboard) &&
                WorkflowConfig.DestConfig.TaskClipboardContent.Count == 0)
            {
                WorkflowConfig.DestConfig.TaskClipboardContent.Add(ClipboardContentEnum.Data);
            }

            StartWork(wf.Job);
        }
        private static string ConvertImageString(long streamLengthPrevious, Workflow workflow, Stream stream)
        {
            StringBuilder sbMsg = new StringBuilder();
            sbMsg.Append(string.Format("Converting {0} KiB {1} to {2} {3} KiB target {4} KiB",
                                                streamLengthPrevious,
                                                workflow.ImageFormat.GetDescription(),
                                                stream.Length / 1024,
                                                workflow.ImageFormat2.GetDescription(),
                                                Engine.ConfigOptions.ConfigImageEffects.ImageSizeLimit));

            if (workflow.ImageFormat2 == EImageFormat.JPEG)
            {
                sbMsg.Append(string.Format(" using setting {0}", workflow.ImageJpegQuality.GetDescription()));
            }

            return sbMsg.ToString();
        }
 public WorkerTask CreateTask(Workflow workflow)
 {
     Engine.ConfigWorkflow = workflow;
     WorkerTask tempTask = new WorkerTask(CreateWorker(), workflow);
     return tempTask;
 }
 /// <summary>
 /// If file exist then adding number end of file name.
 /// Example: directory/fileName(2).exe
 /// </summary>
 /// <returns></returns>
 public static string GetUniqueFilePath(Workflow workflow, string dir, string fileName)
 {
     return Path.Combine(Engine.IsPortable ?
         Path.Combine(Application.StartupPath, dir) : dir,
         GetUniqueFileName(workflow, fileName));
 }
        /// <summary>
        /// Captures Active Window and draws cursor if the option is set in WorkflowConfig
        /// </summary>
        /// <param name="WorkflowConfig">Optios for Active Window</param>
        /// <returns></returns>
        public static Image CaptureWithGDI2(Workflow WorkflowConfig)
        {
            DebugHelper.WriteLine("Capturing with GDI");
            Image tempImage = null;

            Screenshot.DrawCursor = WorkflowConfig.DrawCursor;
            if (WorkflowConfig.ActiveWindowClearBackground)
            {
                tempImage = Screenshot.CaptureActiveWindowTransparent();
            }
            else
            {
                tempImage = Screenshot.CaptureActiveWindow();
            }

            return tempImage;
        }
        public static MemoryStream SaveImage(this Image img, Workflow workflow, EImageFormat imageFormat)
        {
            MemoryStream stream = new MemoryStream();

            switch (imageFormat)
            {
                case EImageFormat.PNG:
                    DebugHelper.WriteLine("Performing PNG {0} {1} interlace", workflow.ImagePngCompression.GetDescription(), workflow.ImagePngInterlaced ? "with" : "without");
                    FreeImageNETHelper.SavePng(img, stream, workflow.ImagePngCompression, workflow.ImagePngInterlaced);
                    break;
                case EImageFormat.JPEG:
                    img.SaveJPG(stream, workflow, true);
                    break;
                case EImageFormat.GIF:
                    // FreeImageNETHelper.SaveGif(img, stream);
                    img.SaveGIF(stream, workflow.ImageGIFQuality);
                    break;
                case EImageFormat.BMP:
                    img.Save(stream, ImageFormat.Bmp);
                    break;
                case EImageFormat.TIFF:
                    DebugHelper.WriteLine("Performing TIFF {0} ", workflow.ImageTiffCompression.GetDescription());
                    FreeImageNETHelper.SaveTiff(img, stream, workflow.ImageTiffCompression);
                    break;
            }

            return stream;
        }
        public static bool TurnOn(EngineOptions options)
        {
            StartTimer = Stopwatch.StartNew();

            DebugHelper.WriteLine("");
            DebugHelper.WriteLine(string.Format("{0} r{1} started", GetProductName(), Adapter.AppRevision));
            DebugHelper.WriteLine("Operating system: " + Environment.OSVersion.VersionString);

            Application.ThreadException += new ThreadExceptionEventHandler(Application_ThreadException);
            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);

            DialogResult startEngine = DialogResult.OK;

            if (IsPortable)
            {
                ConfigApp.PreferSystemFolders = false;
                RootAppFolder = PortableRootFolder;
            }
            else
            {
                if (options.ShowConfigWizard && !File.Exists(AppSettings.AppSettingsFile))
                {
                    if (ConfigWorkflow == null)
                    {
                        ConfigWorkflow = Workflow.Read(Engine.WorkflowConfigPath);
                    }
                    ConfigWizard cw = new ConfigWizard(DocsAppFolder);
                    startEngine = cw.ShowDialog();
                    if (startEngine == DialogResult.OK)
                    {
                        if (!cw.PreferSystemFolders)
                        {
                            Engine.ConfigApp.RootDir = cw.RootFolder;
                        }
                        Engine.ConfigApp.PreferSystemFolders = cw.PreferSystemFolders;
                        Engine.ConfigApp.AppOutputs          = cw.cwOutputs.Cast <int>().ToList();
                        Engine.ConfigApp.ClipboardContent    = cw.cwClipboardContent.Cast <int>().ToList();
                        Engine.ConfigApp.ImageUploaders      = cw.cwImageUploaders;
                        Engine.ConfigApp.FileUploaders       = cw.cwFileUploaders;
                        Engine.ConfigApp.TextUploaders       = cw.cwTextUploaders;
                        Engine.ConfigApp.LinkUploaders       = cw.cwLinkUploaders;

                        ConfigWorkflow.Write(WorkflowConfigPath); // DestSelector in ConfigWizard automatically initializes MyUploadersConfig if null so no errors

                        RunConfig = true;
                    }
                }
            }

            ConfigApp.Write();

            if (!ConfigApp.PreferSystemFolders && Directory.Exists(Engine.ConfigApp.RootDir))
            {
                RootAppFolder = Engine.ConfigApp.RootDir;
            }
            else if (!IsPortable) // issue 613
            {
                RootAppFolder = DocsAppFolder;
            }

            if (startEngine == DialogResult.OK)
            {
                DebugHelper.WriteLine("Core file: " + AppSettings.AppSettingsFile);
                if (!ConfigApp.PreferSystemFolders)
                {
                    DebugHelper.WriteLine(string.Format("Root Folder: {0}", RootAppFolder));
                }
                DebugHelper.WriteLine("Initializing Default folder paths...");
                Engine.InitializeDefaultFolderPaths(); // happens before XMLSettings is readed

                bool bGrantedOwnership;
                try
                {
                    Guid     assemblyGuid    = Guid.Empty;
                    object[] assemblyObjects = System.Reflection.Assembly.GetEntryAssembly().GetCustomAttributes(typeof(System.Runtime.InteropServices.GuidAttribute), true);
                    if (assemblyObjects.Length > 0)
                    {
                        assemblyGuid = new Guid(((System.Runtime.InteropServices.GuidAttribute)assemblyObjects[0]).Value);
                    }
                    Engine.mAppMutex = new Mutex(true, assemblyGuid.ToString(), out bGrantedOwnership);
                }
                catch (UnauthorizedAccessException)
                {
                    bGrantedOwnership = false;
                }

                if (!bGrantedOwnership)
                {
                    IsMultiInstance = true;
                }
            }

            return(startEngine == DialogResult.OK);
        }