public virtual void OnViewOutputting(object sender, ViewOutputCancelEventArgs args)
 {
     args.Cancel = true;
     iApp.Factory.StopBlockingUserInput();
     if (args.View == null)
     {
         return;
     }
     iApp.Session[iFactrActivity.InitKey] = args.View;
     if (!iApp.Session.SafeKeys.Contains(iFactrActivity.InitKey))
     {
         iApp.Session.SafeKeys.Add(iFactrActivity.InitKey);
     }
     if (iApp.Session.ContainsKey(iFactrActivity.InitKey) && _animationFinished)
     {
         StartiFactrActivity();
     }
 }
        /// <summary>
        /// Executes the rendering logic for the view of the specified <see cref="IMXController"/> instance before painting it on the screen.
        /// </summary>
        /// <param name="controller">The controller to output.</param>
        /// <param name="perspective">The perspective that is mapped to the view that will be rendered.</param>
        /// <param name="navigatedUri">A <see cref="String"/> that represents the uri used to navigate to the controller.</param>
        /// <exception cref="ArgumentNullException">Thrown when the <paramref name="controller"/> is <c>null</c>.</exception>
        /// <exception cref="InvalidOperationException">Thrown when there is no view mapped to the <paramref name="perspective"/>.</exception>
        public void OutputController(IMXController controller, string perspective, string navigatedUri)
        {
            if (controller == null)
            {
                throw new ArgumentNullException("controller");
            }

            var     ilayer = controller as iLayer;
            IMXView view   = Views.GetView(controller.ModelType, perspective);

            if (view == null)
            {
                if (ilayer != null)
                {
                    view        = ilayer.GetView();
                    ilayer.View = view;
                }
                else
                {
                    var viewType = Views.GetViewType(controller.ModelType, perspective);
                    if (viewType == null)
                    {
                        object model = controller.GetModel();
                        if (model != null && Device.Reflector.HasAttribute(model.GetType(), typeof(ViewAttribute), false))
                        {
                            view = ReflectiveUIBuilder.GenerateView(model);
                        }
                        else
                        {
                            throw new InvalidOperationException("There is no view or view type mapped to the given perspective.");
                        }
                    }
                    else
                    {
                        view = (IMXView)Activator.CreateInstance(viewType);
                    }
                }
            }

            view.SetModel(controller.GetModel());

            var entry = view as IHistoryEntry;

            if (entry != null)
            {
                entry.OutputPane = PaneManager.Instance.GetPreferredPaneForView(view);
            }

            view.Render();

            {
                var handler = ViewOutputting;
                if (handler != null)
                {
                    var args = new ViewOutputCancelEventArgs(controller, view);
                    handler(this, args);

                    if (args.Cancel)
                    {
                        return;
                    }
                }
            }

            var tabs = view as ITabView;

            if (tabs != null)
            {
                PaneManager.Instance.Tabs = tabs;
            }

            PaneManager.Instance.NavigatedURIs[view] = navigatedUri;
            OnOutputView(view);

            { // Handler scope
                var handler = ViewOutputted;
                if (handler != null)
                {
                    handler(this, new ViewOutputEventArgs(controller, view));
                }
            }

            StopBlockingUserInput();
        }