Example #1
0
        /// <summary>
        /// Rotate objSrc to objDst with angle nAngle.
        /// </summary>
        /// <returns> Success return true, otherwise return false. </returns>
        private bool RotateScannedFiles(ScanFiles objSrc, ScanFiles objDst, int nAngle)
        {
            bool bSuccess = true;

            string args1 = "\"" + objSrc.m_pathOrig + "\" \"" + objDst.m_pathOrig + "\" \"" + nAngle.ToString();
            string args2 = "\"" + objSrc.m_pathView + "\" \"" + objDst.m_pathView + "\" \"" + nAngle.ToString();
            string args3 = "\"" + objSrc.m_pathThumb + "\" \"" + objDst.m_pathThumb + "\" \"" + nAngle.ToString();

            try
            {
                // Get the ExitCode of VopHelper. 0 success, otherwise fail.
                int nExitCode1 = 0;
                int nExitCode2 = 0;
                int nExitCode3 = 0;

                ProcessStartInfo startInfo = new ProcessStartInfo();
                startInfo.WindowStyle = ProcessWindowStyle.Hidden;
                startInfo.FileName    = App.vopHelperExe;
                Process exeProcess = null;

                startInfo.Arguments = args1;
                exeProcess          = Process.Start(startInfo);
                exeProcess.WaitForExit();
                nExitCode1 = exeProcess.ExitCode;

                startInfo.Arguments = args2;
                exeProcess          = Process.Start(startInfo);
                exeProcess.WaitForExit();
                nExitCode2 = exeProcess.ExitCode;

                startInfo.Arguments = args3;
                exeProcess          = Process.Start(startInfo);
                exeProcess.WaitForExit();
                nExitCode3 = exeProcess.ExitCode;

                bSuccess = (0 == nExitCode1 &&
                            0 == nExitCode2 &&
                            0 == nExitCode3);
            }
            catch
            {
                bSuccess = false;
            }

            return(bSuccess);
        }
Example #2
0
        public void DoScanning()
        {
            string strSuffix = (Environment.TickCount & Int32.MaxValue).ToString("D10");

            if (false == Directory.Exists(App.cacheFolder))
            {
                Directory.CreateDirectory(App.cacheFolder);
            }

            lock ( objLock )
            {
                m_shareObj             = new ScanFiles();
                m_shareObj.m_colorMode = m_color;
                m_shareObj.m_pathOrig  = App.cacheFolder + "\\vopOrig" + strSuffix + ".bmp";
                m_shareObj.m_pathView  = App.cacheFolder + "\\vopView" + strSuffix + ".bmp";
                m_shareObj.m_pathThumb = App.cacheFolder + "\\vopThum" + strSuffix + ".bmp";
            }

            int scanMode   = (int)m_color;
            int resolution = (int)m_scanResln;
            int nWidth     = 0;
            int nHeight    = 0;
            int contrast   = m_contrast;
            int brightness = m_brightness;
            int docutype   = (int)m_docutype;

            common.GetPaperSize(m_paperSize, ref nWidth, ref nHeight);

            int nResult = dll.ScanEx(
                m_MainWin.statusPanelPage.m_selectedPrinter,
                m_shareObj.m_pathOrig,
                m_shareObj.m_pathView,
                m_shareObj.m_pathThumb,
                scanMode,
                resolution,
                nWidth,
                nHeight,
                contrast,
                brightness,
                docutype,
                WM_VOPSCAN_PROGRESS);

            Win32.PostMessage((IntPtr)0xffff, WM_VOPSCAN_COMPLETED, (IntPtr)nResult, IntPtr.Zero);
        }
Example #3
0
        private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            if (0 != m_rotatedAngle)
            {
                VOP.Controls.MessageBoxExResult ret = VOP.Controls.MessageBoxEx.Show(VOP.Controls.MessageBoxExStyle.YesNo_NoIcon, this,
                                                                                     (string)this.TryFindResource("ResStr_Scanning_image_has_been_changed__please_confirm_whether_save_it_or_not_"),
                                                                                     (string)this.TryFindResource("ResStr_Prompt"));

                if (VOP.Controls.MessageBoxExResult.Yes == ret)
                {
                    m_rotatedObj             = new ScanFiles();
                    m_rotatedObj.m_colorMode = m_images.m_colorMode;

                    m_rotatedObj.m_pathOrig  = m_images.m_pathOrig.Insert(m_images.m_pathOrig.Length - 4, m_rotatedAngle.ToString());
                    m_rotatedObj.m_pathView  = m_images.m_pathView.Insert(m_images.m_pathView.Length - 4, m_rotatedAngle.ToString());
                    m_rotatedObj.m_pathThumb = m_images.m_pathThumb.Insert(m_images.m_pathThumb.Length - 4, m_rotatedAngle.ToString());

                    AsyncWorker worker = new AsyncWorker(this);
                    if (false == worker.InvokeRotateScannedFiles(RotateScannedFiles, m_images, m_rotatedObj, m_rotatedAngle))
                    {
                        VOP.Controls.MessageBoxEx.Show(
                            VOP.Controls.MessageBoxExStyle.Simple,
                            this,
                            (string)this.FindResource("ResStr_Operation_cannot_be_carried_out_due_to_insufficient_memory_or_hard_disk_space_Please_try_again_after_freeing_memory_or_hard_disk_space_"),
                            (string)this.FindResource("ResStr_Error")
                            );

                        m_rotatedAngle = 0; // Fixed #0059434.
                    }
                }
                else if (VOP.Controls.MessageBoxExResult.No == ret)
                {
                    m_rotatedAngle = 0;
                }
                else
                {
                    e.Cancel = true;
                    isPrint  = false;
                    FileSelectionPage.IsInitPrintSettingPage = oldValueForPrintSettingPage;
                }
            }
        }