Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            // single instance code taken from
            // http://forge.fenchurch.mc.vanderbilt.edu/scm/viewvc.php/branches/IDPicker-3/Program.cs?revision=431&root=idpicker&view=markup

            var singleInstanceHandler = new SingleInstanceHandler(Application.ExecutablePath)
            {
                Timeout = 200
            };

            singleInstanceHandler.Launching += (sender, e) =>
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                var singleInstanceArgs = e.Args.ToList();
                MainWindow = new MainForm(singleInstanceArgs);
                Application.Run(MainWindow);
            };
            try
            {
                singleInstanceHandler.Connect(args);
            }
            catch (Exception e)
            {
                HandleException(e);
            }
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            // redirect console output to parent process;
            // must be before any calls to Console.WriteLine()
            AttachConsole(ATTACH_PARENT_PROCESS);

            if (!args.Contains("--test-ui-layout"))
            {
                // Add the event handler for handling UI thread exceptions to the event.
                Application.ThreadException += UIThread_UnhandledException;

                // Set the unhandled exception mode to force all Windows Forms errors to go through our handler.
                Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);

                // Add the event handler for handling non-UI thread exceptions to the event.
                AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
            }

            var singleInstanceHandler = new SingleInstanceHandler(Application.ExecutablePath)
            {
                Timeout = 200
            };

            singleInstanceHandler.Launching += (sender, e) =>
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);

                var singleInstanceArgs = e.Args.ToList();
                IsHeadless = singleInstanceArgs.Contains("--headless");
                if (IsHeadless)
                {
                    singleInstanceArgs.RemoveAll(o => o == "--headless");
                }

                // initialize webClient asynchronously
                initializeWebClient();

                checkin();

                automaticCheckForUpdates();

                //HibernatingRhinos.Profiler.Appender.NHibernate.NHibernateProfiler.Initialize();

                MainWindow = new IDPickerForm(singleInstanceArgs);
                Application.Run(MainWindow);
            };

            try
            {
                singleInstanceHandler.Connect(args);
            }
            catch (Exception e)
            {
                HandleException(e);
            }
        }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            if (args.Length == 0)
            {
                InstallerForm installerForm = new InstallerForm();
                Application.Run(installerForm);
                return;
            }

            MainForm form = new MainForm();
            SingleInstanceHandler handler = null;

            string extractTo = ConfigurationManager.AppSettings[AppConfig.ExtractionPath];
            string selectFolder = ConfigurationManager.AppSettings[AppConfig.SelectExtractionFolder];

            try
            {
                if (selectFolder.ToLower() == "true" || !Directory.Exists(extractTo))
                {
                    FolderBrowserDialog folderBrowser = new FolderBrowserDialog();
                    folderBrowser.Description = string.Format("UnpackQueue {0} - Select extraction folder:", GetVersion());
                    folderBrowser.SelectedPath = extractTo;
                    folderBrowser.ShowNewFolderButton = true;
                    DialogResult folderBrowserResult = folderBrowser.ShowDialog();
                    if (folderBrowserResult == DialogResult.OK)
                    {
                        extractTo = folderBrowser.SelectedPath;
                    }
                    else
                    {
                        return;
                    }
                }

                handler = new SingleInstanceHandler(form);
                handler.SendMessage(string.Format("{0}|{1}", 
                    string.Join("|", args.Where(a => !string.IsNullOrEmpty(a.Trim()))),
                    extractTo));
                if (handler.IsMaster)
                {
                    Application.Run(form);
                }
            }
            finally
            {
                if (handler != null)
                {
                    handler.Dispose();
                }
            }
        }
Ejemplo n.º 4
0
        static void Main (string[] args)
        {
            // redirect console output to parent process;
            // must be before any calls to Console.WriteLine()
            AttachConsole(ATTACH_PARENT_PROCESS);

            if (!args.Contains("--test-ui-layout"))
            {
                // Add the event handler for handling UI thread exceptions to the event.
                Application.ThreadException += UIThread_UnhandledException;

                // Set the unhandled exception mode to force all Windows Forms errors to go through our handler.
                Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);

                // Add the event handler for handling non-UI thread exceptions to the event. 
                AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
            }

            var singleInstanceHandler = new SingleInstanceHandler(Application.ExecutablePath) { Timeout = 200 };
            singleInstanceHandler.Launching += (sender, e) =>
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);

                var singleInstanceArgs = e.Args.ToList();
                IsHeadless = singleInstanceArgs.Contains("--headless");
                if (IsHeadless)
                    singleInstanceArgs.RemoveAll(o => o == "--headless");

                // initialize webClient asynchronously
                //initializeWebClient();

                //automaticCheckForUpdates();

                //HibernatingRhinos.Profiler.Appender.NHibernate.NHibernateProfiler.Initialize();

                MainWindow = new IDPickerForm(singleInstanceArgs);
                Application.Run(MainWindow);
            };

            try
            {
                singleInstanceHandler.Connect(args);
            }
            catch (Exception e)
            {
                HandleException(e);
            }
        }
Ejemplo n.º 5
0
        static void Main(string[] args)
        {
            // single instance code taken from
            // http://forge.fenchurch.mc.vanderbilt.edu/scm/viewvc.php/branches/IDPicker-3/Program.cs?revision=431&root=idpicker&view=markup

            var singleInstanceHandler = new SingleInstanceHandler(Application.ExecutablePath) { Timeout = 200 };

            singleInstanceHandler.Launching += (sender, e) =>
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                var singleInstanceArgs = e.Args.ToList();
                MainWindow = new MainForm(singleInstanceArgs);
                Application.Run(MainWindow);
            };
            try
            {
                singleInstanceHandler.Connect(args);
            }
            catch (Exception e)
            {
                HandleException(e);
            }
        }
Ejemplo n.º 6
0
        public static int Main(string[] args)
        {
            // redirect console output to parent process;
            // must be before any calls to Console.WriteLine()
            AttachConsole(ATTACH_PARENT_PROCESS);

            /*MSAnalysisClass a = new MSAnalysisClass();
             * a.Open( @"C:\test\100 fmol BSA\0_B4\1\1SRef" );
             * MSSpectrumCollection c = a.MSSpectrumCollection;
             * MSSpectrum s = c[1];
             * MSSpectrumParameterCollection sp = s.MSSpectrumParameterCollection;
             * MSSpectrumParameter p = sp[1];*/
            /*IAnalysisFactory factory = new AnalysisFactory();
             * IAnalysis a = factory.Open( @"C:\test\MM48pos_20uM_1-A,8_01_9111.d" );
             * ITraceDeclaration[] tdList = a.GetTraceDeclarations();
             * List<ITraceDataCollection> tdcList = new List<ITraceDataCollection>();
             * foreach( ITraceDeclaration td in tdList )
             *  tdcList.Add( a.GetTraceDataCollection( td.TraceId ) );
             * ISpectrumSourceDeclaration[] ssdList = a.GetSpectrumSourceDeclarations();
             * List<ISpectrumCollection> scList = new List<ISpectrumCollection>();
             * foreach( ISpectrumSourceDeclaration ssd in ssdList )
             *  scList.Add( a.GetSpectrumCollection( ssd.SpectrumCollectionId ) );*/

            // Add the event handler for handling UI thread exceptions to the event.
            Application.ThreadException += UIThread_UnhandledException;

            // Set the unhandled exception mode to force all Windows Forms errors to go through
            // our handler.
            Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            // Add the event handler for handling non-UI thread exceptions to the event.
            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;


            var singleInstanceHandler = new SingleInstanceHandler(Application.ExecutablePath)
            {
                Timeout = 200
            };

            singleInstanceHandler.Launching += (sender, e) =>
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);

                var singleInstanceArgs = e.Args.ToArray();

                MainForm = new seemsForm();
                MainForm.ParseArgs(singleInstanceArgs);
                if (!MainForm.IsDisposed)
                {
                    Application.Run(MainForm);
                }
                e.ExitCode = Environment.ExitCode;
            };

            try
            {
                TestMode = args.Contains("--test");
                return(singleInstanceHandler.Connect(args));
            }
            catch (Exception e)
            {
                HandleException("Error connecting to single instance", e);
                return(1);
            }
        }
Ejemplo n.º 7
0
        public static void Main(string[] args)
        {
            // redirect console output to parent process;
            // must be before any calls to Console.WriteLine()
            AttachConsole(ATTACH_PARENT_PROCESS);

            /*MSAnalysisClass a = new MSAnalysisClass();
             * a.Open( @"C:\test\100 fmol BSA\0_B4\1\1SRef" );
             * MSSpectrumCollection c = a.MSSpectrumCollection;
             * MSSpectrum s = c[1];
             * MSSpectrumParameterCollection sp = s.MSSpectrumParameterCollection;
             * MSSpectrumParameter p = sp[1];*/
            /*IAnalysisFactory factory = new AnalysisFactory();
             * IAnalysis a = factory.Open( @"C:\test\MM48pos_20uM_1-A,8_01_9111.d" );
             * ITraceDeclaration[] tdList = a.GetTraceDeclarations();
             * List<ITraceDataCollection> tdcList = new List<ITraceDataCollection>();
             * foreach( ITraceDeclaration td in tdList )
             *  tdcList.Add( a.GetTraceDataCollection( td.TraceId ) );
             * ISpectrumSourceDeclaration[] ssdList = a.GetSpectrumSourceDeclarations();
             * List<ISpectrumCollection> scList = new List<ISpectrumCollection>();
             * foreach( ISpectrumSourceDeclaration ssd in ssdList )
             *  scList.Add( a.GetSpectrumCollection( ssd.SpectrumCollectionId ) );*/

            // Add the event handler for handling UI thread exceptions to the event.
            Application.ThreadException += new ThreadExceptionEventHandler(UIThread_UnhandledException);

            // Set the unhandled exception mode to force all Windows Forms errors to go through
            // our handler.
            Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            // Add the event handler for handling non-UI thread exceptions to the event.
            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);


            var singleInstanceHandler = new SingleInstanceHandler(Application.ExecutablePath)
            {
                Timeout = 200
            };

            singleInstanceHandler.Launching += (sender, e) =>
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);

                var singleInstanceArgs = e.Args.ToArray();

                MainForm = new seemsForm();
                MainForm.ParseArgs(singleInstanceArgs);
                if (!MainForm.IsDisposed)
                {
                    Application.Run(MainForm);
                }
            };

            try
            {
                singleInstanceHandler.Connect(args);
            }
            catch (Exception e)
            {
                string message = e.ToString();
                if (e.InnerException != null)
                {
                    message += "\n\nAdditional information: " + e.InnerException.ToString();
                }
                MessageBox.Show(message,
                                "Unhandled Exception",
                                MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1,
                                0, false);
            }
        }