Exemple #1
0
        protected async override void OnStartup(StartupEventArgs e)
        {
            if (HasAnotherInstanceRunning())
            {
                Current.Shutdown();
            }

            InitLog();

            base.OnStartup(e);

            this.DispatcherUnhandledException += App_DispatcherUnhandledException;

            var config = DataCache.Load<UserConfig>();
            if (config == null)
            {
                config = new UserConfig();
                config.FirstRun = false;
                StartupRegistration.IsRegisteredForStartup = true;
                DataCache.Save(config);
            }
            if (!StartupRegistration.IsRegisteredForStartMenu)
            {
                StartupRegistration.RegisterForStartMenu();
            }

            user = GetUser();

            if (user == null)
            {
                Current.ShutdownMode = ShutdownMode.OnExplicitShutdown;
                var editUser = new EditUser();
                editUser.ShowDialog();
                user = new User()
                {
                    EmailAddress = editUser.FirstName + "." + editUser.LastName + "@placeholder",
                    FullName = editUser.FirstName + " " + editUser.LastName,
                    UserName = editUser.FirstName + "~" + editUser.LastName
                };
                DataCache.Save(user);
                Current.ShutdownMode = ShutdownMode.OnMainWindowClose;
            }

            hub = new Hub(user, Dispatcher);
            groupsCache = new GroupsCache();            
            queueUpdater = new QueueUpdater(hub, user, groupsCache);

            hub.QueueMembershipChanged += QueueMembershipChanged;
            hub.QueueCreated += QueueCreated;
            hub.QueueStatusChanged += QueueStatusChanged;
            hub.QueueMessageReceived += QueueMessageReceived;
            hub.QueueNagged += QueueNagged;

            hub.PropertyChanged += HubPropertyChanged;

            if (hub.ConnectionState == ConnectionState.Connected)
            {
                await queueUpdater.RefreshALl();
            }
        }
Exemple #2
0
        protected async override void OnStartup(StartupEventArgs e)
        {
            if (HasAnotherInstanceRunning())
            {
                Current.Shutdown();
            }

            InitLog();

            base.OnStartup(e);

            this.DispatcherUnhandledException += App_DispatcherUnhandledException;

            var config = DataCache.Load <UserConfig>();

            if (config == null)
            {
                config          = new UserConfig();
                config.FirstRun = false;
                StartupRegistration.IsRegisteredForStartup = true;
                DataCache.Save(config);
            }

            user = GetUser();

            if (user == null)
            {
                Current.ShutdownMode = ShutdownMode.OnExplicitShutdown;
                var editUser = new EditUser();
                editUser.ShowDialog();
                user = new User()
                {
                    EmailAddress = editUser.FirstName + "." + editUser.LastName + "@placeholder",
                    FullName     = editUser.FirstName + " " + editUser.LastName,
                    UserName     = editUser.FirstName + "~" + editUser.LastName
                };
                DataCache.Save(user);
                Current.ShutdownMode = ShutdownMode.OnMainWindowClose;
            }

            hub          = new Hub(user, Dispatcher);
            groupsCache  = new GroupsCache();
            queueUpdater = new QueueUpdater(hub, user, groupsCache);

            hub.QueueMembershipChanged += QueueMembershipChanged;
            hub.QueueCreated           += QueueCreated;
            hub.QueueStatusChanged     += QueueStatusChanged;
            hub.QueueMessageReceived   += QueueMessageReceived;
            hub.QueueNagged            += QueueNagged;

            hub.PropertyChanged += HubPropertyChanged;

            if (hub.ConnectionState == ConnectionState.Connected)
            {
                await queueUpdater.RefreshALl();
            }
        }