Esempio n. 1
0
        public Bitmap FromNoncontigImage()
        {
            Bitmap bitmap = null;

            m_error = "";
            Exception exc = null;

            string libTiffDir = Project.driveSystem + "Program Files\\GnuWin32";
            string libtiffcp  = Path.Combine(libTiffDir, "bin\\tiffcp.exe");
            string cpArgs     = "-p contig";

            if (!File.Exists(libtiffcp))
            {
                Project.ErrorBox(Project.mainForm, String.Format(libTiffMustInstallMessage, libTiffWin32Url, libTiffDir));
                return(null);
            }

            CmdRunner runner   = new CmdRunner();
            string    tempFile = Path.GetTempFileName();

            Project.filesToDelete.Add(tempFile);

            string outputText = "";

            try
            {
                runner.executeCommand(libtiffcp, cpArgs + " \"" + m_fileName + "\" \"" + tempFile + "\"",
                                      Path.Combine(Project.startupPath, Bindirectory), null, out outputText);
                m_result = runner.OutputString;
                m_error  = runner.ErrorString;
            }
            catch (Exception ee)
            {
                m_error = ee.Message;
                LibSys.StatusBar.Error(ee.Message);
                exc = ee;
            }

            if (runner.exitcode == 0)
            {
                try
                {
                    LibSys.StatusBar.Trace(outputText);
                    bitmap = new Bitmap(tempFile);
                    LibSys.StatusBar.Trace("OK: contig tiff read in");
                }
                catch (Exception ee)
                {
                    m_error = ee.Message;
                    LibSys.StatusBar.Error(ee.Message);
                    exc = ee;
                }
            }

            if (exc != null)
            {
                throw exc;
            }
            return(bitmap);
        }
Esempio n. 2
0
        /// <summary>
        /// Execute the listgeo command, parse it's output filling this object's properties.
        /// </summary>
        public void init()
        {
            m_error = "";
            Exception exc = null;

            CmdRunner runner = new CmdRunner();

            string outputText = "";

            try
            {
                runner.executeCommand(Path.Combine(Project.startupPath, Executable), Args + " \"" + m_fileName + "\"",
                                      Path.Combine(Project.startupPath, Bindirectory), null, out outputText);
                m_result = runner.OutputString;
                m_error  = runner.ErrorString;
            }
            catch (Exception ee)
            {
                m_error = ee.Message;
                LibSys.StatusBar.Error(ee.Message);
                exc = ee;
            }

            if (runner.exitcode == 0)
            {
                try
                {
                    parseListgeo(outputText);
                    LibSys.StatusBar.Trace(outputText);
                }
                catch (Exception ee)
                {
                    m_error = ee.Message;
                    LibSys.StatusBar.Error(ee.Message);
                    exc = ee;
                }
            }

            if (exc != null)
            {
                throw exc;
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Execute the listgeo command, parse it's output filling this object's properties.
        /// </summary>
        public void init()
        {
            m_error = "";
            Exception exc = null;

            CmdRunner runner = new CmdRunner();

            string outputText = "";
            try
            {
                runner.executeCommand(Path.Combine(Project.startupPath, Executable), Args + " \"" + m_fileName + "\"",
                                        Path.Combine(Project.startupPath, Bindirectory), null, out outputText);
                m_result = runner.OutputString;
                m_error = runner.ErrorString;
            }
            catch (Exception ee)
            {
                m_error = ee.Message;
                LibSys.StatusBar.Error(ee.Message);
                exc = ee;
            }

            if(runner.exitcode == 0)
            {
                try
                {
                    parseListgeo(outputText);
                    LibSys.StatusBar.Trace(outputText);
                }
                catch (Exception ee)
                {
                    m_error = ee.Message;
                    LibSys.StatusBar.Error(ee.Message);
                    exc = ee;
                }
            }

            if(exc != null)
            {
                throw exc;
            }
        }
Esempio n. 4
0
        public Bitmap FromNoncontigImage()
        {
            Bitmap bitmap = null;
            m_error = "";
            Exception exc = null;

            string libTiffDir = Project.driveSystem + "Program Files\\GnuWin32";
            string libtiffcp = Path.Combine(libTiffDir, "bin\\tiffcp.exe");
            string cpArgs = "-p contig";

            if(!File.Exists(libtiffcp))
            {
                Project.ErrorBox(Project.mainForm, String.Format(libTiffMustInstallMessage, libTiffWin32Url, libTiffDir));
                return null;
            }

            CmdRunner runner = new CmdRunner();
            string tempFile = Path.GetTempFileName();
            Project.filesToDelete.Add(tempFile);

            string outputText = "";
            try
            {
                runner.executeCommand(libtiffcp, cpArgs + " \"" + m_fileName + "\" \"" + tempFile + "\"",
                    Path.Combine(Project.startupPath, Bindirectory), null, out outputText);
                m_result = runner.OutputString;
                m_error = runner.ErrorString;
            }
            catch (Exception ee)
            {
                m_error = ee.Message;
                LibSys.StatusBar.Error(ee.Message);
                exc = ee;
            }

            if(runner.exitcode == 0)
            {
                try
                {
                    LibSys.StatusBar.Trace(outputText);
                    bitmap = new Bitmap(tempFile);
                    LibSys.StatusBar.Trace("OK: contig tiff read in");
                }
                catch (Exception ee)
                {
                    m_error = ee.Message;
                    LibSys.StatusBar.Error(ee.Message);
                    exc = ee;
                }
            }

            if(exc != null)
            {
                throw exc;
            }
            return bitmap;
        }
Esempio n. 5
0
        /// <summary>
        /// Execute the GpsBabel command defined by all parameters/options/properties.
        /// 
        /// <p/>Raise a GpsBabelException whenever an error occurs.
        /// </summary>
        /// <param name="inputText"></param>
        /// <param name="outputText"></param>
        public void Execute(string args)
        {
            string tempFileInput = null;
            string tempFileOutput = null;
            bool quakeMapOutput = false;
            Exception exc = null;

            if(args != null && args.IndexOf("-i QuakeMap") != -1)
            {
                tempFileInput = GetTempFileName();
                args = args.Replace("-i QuakeMap", "-i gpx -f \"" + tempFileInput + "\"");

                // run QuakeMap to dump required info into tempFileInput
                try
                {
                    QMApiLib qmApiLib = new QMApiLib();

                    qmApiLib.exportToFile(tempFileInput);
                }
                catch (Exception ee)
                {
                    LibSys.StatusBar.Error(ee.Message);
                    try
                    {
                        File.Delete(tempFileInput);
                    }
                    catch {}
                    throw(ee);
                }
            }

            if(args != null && args.IndexOf("-o QuakeMap") != -1)
            {
                quakeMapOutput = true;
                tempFileOutput = GetTempFileName();
                args = args.Replace("-o QuakeMap", "-o gpx -F \"" + tempFileOutput + "\"");
            }

            CmdRunner runner = new CmdRunner();

            string outputText;
            runner.executeCommand(Executable, args == null ? Args : args, Bindirectory, null, out outputText);
            m_result = runner.OutputString;
            m_error = runner.ErrorString;

            if(runner.exitcode == 0 && quakeMapOutput)
            {
                try
                {
                    QMApiLib qmApiLib = new QMApiLib();

                    qmApiLib.resetZoom();		// prepare for a zoom into the file
                    switch(MapType)
                    {
                        case MapType.Aerial:
                            qmApiLib.CommandMappingEngine("/map=aerial");
                            break;
                        case MapType.ColorAerial:
                            qmApiLib.CommandMappingEngine("/map=color");
                            break;
                        case MapType.Topo:
                            qmApiLib.CommandMappingEngine("/map=topo");
                            break;
                        case MapType.None:
                            qmApiLib.CommandMappingEngine("/map=none");
                            break;
                    }
                    qmApiLib.CommandMappingEngine(tempFileOutput);
                }
                catch (Exception ee)
                {
                    LibSys.StatusBar.Error(ee.Message);
                    exc = ee;
                }
            }

            try
            {
                File.Delete(tempFileInput);
            }
            catch {}

            try
            {
                File.Delete(tempFileOutput);
            }
            catch {}

            if(exc != null)
            {
                throw exc;
            }
        }