Exemplo n.º 1
0
 public void HandleLogonEvent(object authenticatedUser)
 {
     DoLogin((AppUser)authenticatedUser);
     var deactivate = new ScreenEventArgs { Event = ScreenEventType.Deactivate, RegionName = RegionName.Body };
     EventManager.Screen_Event(deactivate);
 }
Exemplo n.º 2
0
        private void DoLogout()
        {
            // make sure the contexts are cleared
            //            var lookupContext = Container.Instance.Resolve<LookupContext>();

            // if this is NOT an automatic logout, make sure there are no context changes;
            // this is a safeguard; the user should not be able to logout when there are changes anyway.
            //if (_LogoutTimer != null)
               // if (_coreContext.HasChanges || lookupContext.HasChanges || employmentContext.HasChanges) return;

            StopActivityMonitor();

            // all good; clear everything
            //_coreContext.Addresses.Clear();

            AllowedActions = null;
            Entity = null;
            Instance = null;

            //_authContext.LogoutQuery();

            // take down screens
            var closeMainRegion = new ScreenEventArgs {Event = ScreenEventType.CloseInactiveScreens, RegionName = RegionName.Body};
            EventManager.Screen_Event(closeMainRegion);

            var closeOverlayActiveScreen = new ScreenEventArgs { Event = ScreenEventType.Deactivate, RegionName = RegionName.Overlay };
            EventManager.Screen_Event(closeOverlayActiveScreen);

            var closeOverlayRegionInactive = new ScreenEventArgs { Event = ScreenEventType.CloseInactiveScreens, RegionName = RegionName.Overlay };
            EventManager.Screen_Event(closeOverlayRegionInactive);

               EventManager.Screen_Activate("EntryScreen");
        }
Exemplo n.º 3
0
 private void SwitchScreens(IScreen oldScreen, ScreenEventArgs newScreenArgs)
 {
     if (oldScreen != null && Region.Views.Contains(oldScreen.View))
     {
         oldScreen.Leaving();
         Region.Deactivate(oldScreen.View);
         Region.Remove(oldScreen.View);
     }
     PrepareScreen(newScreenArgs.ScreenName,newScreenArgs.ScreenSubject);
     ShowScreen(newScreenArgs.ScreenName, newScreenArgs.UseAnimation);
 }
Exemplo n.º 4
0
 private void HandleScreenEventRetry(ScreenEventArgs args)
 {
     Log("HandleScreenEventRetry(); screenName="+args.ScreenName);
     // create a dispatcherTimer to call activate screen
     if (_jobQueue == null) _jobQueue = new List<ScreenEventArgs>();
     _jobQueue.Add(args);
     if (_timer == null)
     {
         _timer = new DispatcherTimer {Interval = TimeSpan.FromSeconds(2)};
         _timer.Tick += TimerDing;
         _timer.Start();
     }
 }
Exemplo n.º 5
0
        private void ActivateScreen(ScreenEventArgs args)
        {
            Log("ActivateScreen(); " + args.ScreenName);
            // check if there is no such registered screen type.
            if (!this.ScreenFactoryRegistry.HasFactory(args.ScreenName))
            {
                // the most likely reason is that the screen's module is not loaded.
                // check again in 2 seconds
                Log(string.Format("Requested screen '{0}' is not available. Verify it is registered.", args.ScreenName));
                HandleScreenEventRetry(args);
                return;
            }

            // Check if an active screen exists.
            if (this.ScreenCollection.ContainsKey(this._activeScreenName))
            {
                // Get the currently active screen
                IScreen activeScreen = this.ScreenCollection[this._activeScreenName];
                // Check if we can leave
                if (activeScreen.CanLeave())
                {
                    IScreen screen = this.ScreenCollection[this._activeScreenName];
                    if (args.UseAnimation)
                        VisibilityService.LeaveViewAnimation(screen.View, () => SwitchScreens(screen, args));
                    else
                        SwitchScreens(screen, args);
                }
                else
                    activeScreen.LeaveCanceled();
            }
            else
            {
                Log("call PrepareScreen()");
                // no active screen exists
                PrepareScreen(args.ScreenName, args.ScreenSubject);
                ShowScreen(args.ScreenName, args.UseAnimation);
            }
        }
Exemplo n.º 6
0
 protected bool IsNotificationRelevant(ScreenEventArgs args)
 {
     return true;
 }
Exemplo n.º 7
0
 protected virtual void HandleScreenEvent(ScreenEventArgs args)
 {
     // check the event type for deactivate, because
     // check the screen's region.  If it is not "my" region, then ignore the request
     if (args.RegionName != MyRegionName) return;
     Log("HandleScreenEvent; handling screen=" + args.ScreenName + ",  event="+args.Event);
     if (args.Event == ScreenEventType.Activate)
         ActivateScreen(args);
     else if (args.Event == ScreenEventType.Deactivate)
         DeactivateScreen(args.ScreenName);
     else if (args.Event == ScreenEventType.CloseInactiveScreens)
         CloseInactiveScreens();
 }