Exemplo n.º 1
0
        static void Main()
        {
            using (Mutex mutex = new Mutex(false, "Global\\" + appGUID))
            {
                if (!mutex.WaitOne(0, false))
                {
                    MessageBox.Show("Another copy of Toggl Desktop is already running." +
                                    Environment.NewLine + "This copy will now quit.");
                    return;
                }

                bugsnag = new Bugsnag.Library.BugSnag()
                {
                    apiKey    = "2a46aa1157256f759053289f2d687c2f",
                    OSVersion = Environment.OSVersion.ToString()
                };

                Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);
                AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
                Application.ApplicationExit += new EventHandler(onApplicationExit);
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new MainWindowController());
            }
        }
Exemplo n.º 2
0
        static void Main()
        {
            Bugsnag.Library.BugSnag bs = new Bugsnag.Library.BugSnag()
            {
                apiKey = "2a46aa1157256f759053289f2d687c2f"
            };

            Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);
            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
            Application.ApplicationExit += new EventHandler(onApplicationExit);
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new MainWindowController());
        }
Exemplo n.º 3
0
        void DisplayError(string errmsg, bool user_error)
        {
            if (InvokeRequired)
            {
                Invoke((MethodInvoker) delegate { DisplayError(errmsg, user_error); });
                return;
            }
            errorLabel.Text    = errmsg;
            troubleBox.Visible = true;

            if (!user_error)
            {
                Bugsnag.Library.BugSnag bs = new Bugsnag.Library.BugSnag();
                bs.Notify(new Exception(errmsg));
            }
        }
Exemplo n.º 4
0
        void DisplayError(string errmsg, bool user_error)
        {
            if (InvokeRequired)
            {
                Invoke((MethodInvoker)delegate { DisplayError(errmsg, user_error); });
                return;
            }
            errorLabel.Text = errmsg;
            troubleBox.Visible = true;

            if (!user_error)
            {
                Bugsnag.Library.BugSnag bs = new Bugsnag.Library.BugSnag();
                bs.Notify(new Exception(errmsg));
            }
        }
Exemplo n.º 5
0
        static void Main()
        {
            AttachConsole(ATTACH_PARENT_PROCESS);

            using (Mutex mutex = new Mutex(false, "Global\\" + Environment.UserName + "_" + appGUID))
            {
                if (!mutex.WaitOne(0, false))
                {
                    // See if we get hold of the other process.
                    // If we do, activate it's window and exit.
                    Process   current   = Process.GetCurrentProcess();
                    Process[] instances = Process.GetProcessesByName(current.ProcessName);
                    foreach (Process p in instances)
                    {
                        if (p.Id != current.Id)
                        {
                            // gotcha
                            IntPtr hWnd = p.MainWindowHandle;
                            if (hWnd == IntPtr.Zero)
                            {
                                hWnd = SearchForWindow(current.ProcessName, "Toggl Desktop");
                            }
                            ShowWindow(hWnd, SW_RESTORE);
                            SetForegroundWindow(hWnd);
                            return;
                        }
                    }

                    // If not, print an error message and exit.
                    MessageBox.Show("Another copy of Toggl Desktop is already running." +
                                    Environment.NewLine + "This copy will now quit.");
                    return;
                }

                bugsnag = new Bugsnag.Library.BugSnag()
                {
                    apiKey             = "2a46aa1157256f759053289f2d687c2f",
                    OSVersion          = Environment.OSVersion.ToString(),
                    applicationVersion = Version()
                };

                Toggl.OnLogin += delegate(bool open, UInt64 user_id)
                {
                    uid = user_id;
                };

                Toggl.OnError += delegate(string errmsg, bool user_error)
                {
                    Console.WriteLine(errmsg);
                    try
                    {
                        if (!user_error && Properties.Settings.Default.Environment != "development")
                        {
                            notifyBugsnag(new Exception(errmsg));
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine("Could not check if can notify bugsnag: ", ex);
                    }
                };

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

                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);

                mainWindowController = new MainWindowController();
                Application.Run(mainWindowController);
            }
        }
        void OnError(string errmsg, bool user_error)
        {
            if (InvokeRequired)
            {
                Invoke((MethodInvoker)delegate { OnError(errmsg, user_error); });
                return;
            }

            isNetworkError = false;

            errorLabel.Text = errmsg;
            troubleBox.Visible = true;
            contentPanel.Location = errorContentPosition;

            if (!user_error && Properties.Settings.Default.Environment != "development")
            {
                Bugsnag.Library.BugSnag bs = new Bugsnag.Library.BugSnag();
                bs.Notify(new Exception(errmsg));
            }
        }
Exemplo n.º 7
0
 static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e)
 {
     Bugsnag.Library.BugSnag bs = new Bugsnag.Library.BugSnag();
     bs.Notify(e.Exception);
 }
Exemplo n.º 8
0
 static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
 {
     Bugsnag.Library.BugSnag bs = new Bugsnag.Library.BugSnag();
     bs.Notify(e.ExceptionObject as Exception);
 }
Exemplo n.º 9
0
        static void Main()
        {
            using (Mutex mutex = new Mutex(false, "Global\\" + appGUID))
            {
                if (!mutex.WaitOne(0, false))
                {
                    MessageBox.Show("Another copy of Toggl Desktop is already running." +
                        Environment.NewLine + "This copy will now quit.");
                    return;
                }

                bugsnag = new Bugsnag.Library.BugSnag()
                {
                    apiKey = "2a46aa1157256f759053289f2d687c2f",
                    OSVersion = Environment.OSVersion.ToString()
                };

                Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);
                AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
                Application.ApplicationExit += new EventHandler(onApplicationExit);
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new MainWindowController());
            }
        }
Exemplo n.º 10
0
        static void Main()
        {
            using (Mutex mutex = new Mutex(false, "Global\\" + appGUID))
            {
                if (!mutex.WaitOne(0, false))
                {
                    // See if we get hold of the other process.
                    // If we do, activate it's window and exit.
                    Process current = Process.GetCurrentProcess();
                    Process[] instances = Process.GetProcessesByName(current.ProcessName);
                    foreach (Process p in instances)
                    {
                        if (p.Id != current.Id)
                        {
                            // gotcha
                            IntPtr hWnd = p.MainWindowHandle;
                            if (hWnd == IntPtr.Zero)
                            {
                                hWnd = SearchForWindow(current.ProcessName, "Toggl Desktop");
                            }
                            ShowWindow(hWnd, SW_RESTORE);
                            SetForegroundWindow(hWnd);
                            return;
                        }
                    }

                    // If not, print an error message and exit.
                    MessageBox.Show("Another copy of Toggl Desktop is already running." +
                        Environment.NewLine + "This copy will now quit.");
                    return;
                }

                 if (Environment.OSVersion.Version.Major >= 6) SetProcessDPIAware();

                bugsnag = new Bugsnag.Library.BugSnag()
                {
                    apiKey = "2a46aa1157256f759053289f2d687c2f",
                    OSVersion = Environment.OSVersion.ToString()
                };

                Toggl.OnLogin += delegate(bool open, UInt64 user_id)
                {
                    uid = user_id;
                };

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

                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);

                mainWindowController = new MainWindowController();
                Application.Run(mainWindowController);
            }
        }