Ejemplo n.º 1
0
        private void Application_Startup(object sender, StartupEventArgs e)
        {
#if DEBUG
            InstallUtils.RegisterApp();
#else
            SquirrelAwareApp.HandleEvents(
                onAppUpdate: v => InstallUtils.ReregisterApp(),
                onInitialInstall: v => InstallUtils.RegisterApp(),
                onAppUninstall: v => {
                InstallUtils.KillOtherInstances();
                InstallUtils.UnregisterApp();
                Current.Shutdown();
            }
                );
#endif
            websocket    = new WebsocketUtils();
            notification = new NotificationUtils();
            pushHistory  = new List <JObject>();

            contextMenu = new System.Windows.Forms.ContextMenu()
            {
                MenuItems =
                {
                    new System.Windows.Forms.MenuItem("&Settings", (a, b) => {
                        SettingsWindow settings = new SettingsWindow();
                        settings.Logout        += OnLogout;
                        settings.Show();
                    }),
                    new System.Windows.Forms.MenuItem("-"),
                    new System.Windows.Forms.MenuItem("&Exit",     (a, b) => {
                        Current.Shutdown();
                    })
                }
            };

            icon = new System.Windows.Forms.NotifyIcon()
            {
                Visible     = true,
                Text        = ResourceAssembly.GetName().Name,
                Icon        = Notiwin.Properties.Resources.Tray,
                ContextMenu = contextMenu
            };

            websocket.LoginError += OnLoginError;
            websocket.Data       += OnData;

            NotificationActivator.Action += OnAction;
            NotificationActivator.Initialize();

            NetworkUtils.ConnectionChanged += OnNetworkChange;

            OpenLoginWindow(openHidden: true);
            Init();
        }
Ejemplo n.º 2
0
        private void Application_Exit(object sender, ExitEventArgs e)
        {
            CloseLoginWindow();

            if (icon != null)
            {
                icon.Visible = false;
                icon.Dispose();
            }

            if (websocket != null)
            {
                websocket.Data -= OnData;
                websocket.Disconnect();
            }

            NotificationActivator.Uninitialize();
#if DEBUG
            InstallUtils.UnregisterApp();
#endif
        }