Esempio n. 1
0
 public ProcessIcon(IRacesIndexRepository racesRepository, BrowserOpener browserOpener)
 {
     this.racesRepository              = racesRepository;
     this.browserOpener                = browserOpener;
     this.notifyIcon                   = new NotifyIcon();
     this.notifyIcon.MouseDoubleClick += (sender, e) => browserOpener.OpenHomepage();
     this.menu          = new ContextMenuStrip();
     this.menu.Opening += ContextMenuStrip_Opening;
 }
Esempio n. 2
0
        static void Main()
        {
            try
            {
                var baseWebUiUri  = ConfigurationManager.AppSettings["web:ui"];
                var baseWebApiUri = ConfigurationManager.AppSettings["web:api"];
                var adminToken    = ConfigurationManager.AppSettings["authentication:admin"];
                var startOptions  = new StartOptions();
                var createdNew    = false;
                var appName       = "FreediveComp";
                var browserOpener = new BrowserOpener(baseWebUiUri, adminToken);
                startOptions.Urls.Add(baseWebApiUri);

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

                using (var mutex = new Mutex(true, appName, out createdNew))
                {
                    if (createdNew)
                    {
                        using (var web = WebApp.Start <Startup>(startOptions))
                            using (var icon = new ProcessIcon(Startup.Container.Resolve <IRacesIndexRepository>(), browserOpener))
                            {
                                icon.Display();
                                browserOpener.OpenHomepage();
                                Application.Run();
                            }
                    }
                    else
                    {
                        browserOpener.OpenHomepage();
                    }
                }
            }
            catch (Exception e)
            {
                while (e.InnerException != null)
                {
                    e = e.InnerException;
                }
                var message = GetErrorMessage(e);
                MessageBox.Show(message, "Failed to start", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }