コード例 #1
0
 private void Initialize(string name)
 {
     Name        = name;
     _settings   = UIPConfiguration.Config.GetNavigationGraphSettings(name);
     ViewManager = CreateViewManager(name);
     _startView  = UIPConfiguration.Config.GetFirstViewSettings(name);
 }
コード例 #2
0
        private ViewSettings CreateNewView(string viewName, Navigator navigator, Guid taskId, TaskArgumentsHolder args)
        {
            //Create a new instance
            ViewSettings viewSettings = UIPConfiguration.Config.GetViewSettingsFromName(viewName);

            if (viewSettings == null)
            {
                throw new UIPException(Resource.ResourceManager.FormatMessage(Resource.Exceptions.RES_ExceptionViewConfigNotFound, viewName));
            }

            IView view = (IView)GenericFactory.Create(viewSettings);

            if (view is WindowsFormView)
            {
                WindowsFormView form = (WindowsFormView)view;
                ActivateForm(form, viewSettings, navigator, taskId, null, args);
            }
            else
            {
                WindowsFormControlView ctrl = (WindowsFormControlView)view;
                AddActiveControl(taskId, viewName, ctrl);
                ctrl.Disposed += new EventHandler(ControlDisposed);
                ActivateControl(ctrl, viewSettings, navigator, taskId, args);
                ctrl.Show();
            }

            return(viewSettings);
        }
コード例 #3
0
        private void ClosePreviousFormIfNecessary(WindowsFormView currentForm, string previousView, Guid taskId, ViewSettings currentViewSettings)
        {
            if (!currentViewSettings.IsFloatable)
            {
                if (null != previousView && 0 != previousView.Length)
                {
                    //Get the current form
                    ViewSettings previousViewSettings = UIPConfiguration.Config.GetViewSettingsFromName(previousView);
                    if (previousViewSettings == null)
                    {
                        throw new UIPException(Resource.ResourceManager.FormatMessage(Resource.Exceptions.RES_ExceptionViewConfigNotFound, previousView));
                    }

                    WindowsFormView previousForm = (WindowsFormView)GetActiveForms(taskId)[previousView];
                    //if we end up staying with same form, we should not close it
                    if (currentForm != null && previousForm != null && previousForm == currentForm)
                    {
                        return;
                    }
                    //if the current one is modal, we don't want to close the preivous view
                    if (currentViewSettings.IsOpenModal && !previousViewSettings.IsOpenModal)
                    {
                        return;
                    }
                    if (previousForm != null && !previousViewSettings.IsStayOpen)
                    {
                        //The current window must be closed
                        previousForm.Close();
                    }
                }
            }
        }
コード例 #4
0
        /// <summary>
        /// Activates a specific view with activation arguments.
        /// </summary>
        /// <param name="previousView">The view currently displayed.</param>
        /// <param name="view">The name of the view to be displayed next.</param>
        /// <param name="navigator">The navigator.</param>
        /// <param name="args">The arguments for the next view.</param>
        public void ActivateView(string previousView, string view, Navigator navigator, TaskArgumentsHolder args)
        {
            Guid taskId = navigator.CurrentState.TaskId;

            InitiailizeFormAndViews(taskId);

            WindowsFormView        winFormView = GetActiveForm(taskId, view);
            WindowsFormControlView controlView = GetActiveControl(taskId, view);

            ViewSettings viewSettings = null;

            if (winFormView != null)
            {
                winFormView.Activate();
                winFormView.Visible = true;
                viewSettings        = UIPConfiguration.Config.GetViewSettingsFromName(winFormView.ViewName);
                ClosePreviousFormIfNecessary(winFormView, previousView, taskId, viewSettings);
            }
            else if (controlView != null)
            {
                ActivateControl(controlView, previousView);
                viewSettings = UIPConfiguration.Config.GetViewSettingsFromName(controlView.ViewName);
            }
            else
            {
                viewSettings = CreateNewView(view, navigator, taskId, args);
                ClosePreviousFormIfNecessary(null, previousView, taskId, viewSettings);
            }
        }
コード例 #5
0
        /// <summary>
        /// Looks up the next view based on the incoming graph, view, and navigation values.
        /// </summary>
        /// <param name="navigationGraphName">Name of the navigation graph that is being worked in.</param>
        /// <param name="currentViewName">Name of the current view.</param>
        /// <param name="navigateValue">Navigate value used to determine the next view to be navigated to from the current view.</param>
        public virtual ViewSettings GetNextViewSettings(string navigationGraphName, string currentViewName, string navigateValue)
        {
            //Retrieve a navgraph class based on nav name
            NavigationGraphSettings navigationGraph = GetNavigationGraphSettings(navigationGraphName);
            ViewSettings            nextView        = null;

            //  Get the current view node settings
            NodeSettings node = navigationGraph[currentViewName];

            if (null == node)
            {
                throw new ConfigurationException(Resource.ResourceManager.FormatMessage(Resource.Exceptions.RES_ExceptionCouldNotGetNextViewType, navigationGraphName, currentViewName, navigateValue));
            }

            //  Get the next view name from the navigateTo node
            NavigateToSettings navigateTo = node[navigateValue];

            if (null == navigateTo)
            {
                nextView = GetSharedTransitionView(navigationGraph, navigateValue);
            }
            else
            {
                nextView = GetViewSettingsFromName(navigateTo.View);
            }

            if (nextView == null)
            {
                throw new ConfigurationException(Resource.ResourceManager.FormatMessage(Resource.Exceptions.RES_ExceptionCouldNotGetNextViewType, navigationGraphName, currentViewName, navigateValue));
            }

            return(nextView);
        }
コード例 #6
0
        /// <summary>
        /// Navigates to the next node in the navigation graph.
        /// </summary>
        /// <param name="nextNode">The next node.</param>
        public override void Navigate(string nextNode)
        {
            string previousView = CurrentState.CurrentView;

            CurrentState.NavigateValue = nextNode;

            UIPManager.InvokeEventHandlers(CurrentState);

            ViewSettings nextView = UIPConfiguration.Config.GetNextViewSettings(
                Name,
                CurrentState.CurrentView,
                CurrentState.NavigateValue);

            CurrentState.CurrentView   = nextView.Name;
            CurrentState.NavigateValue = "";
            CurrentState.Save();

            try
            {
                ActivateNextView(previousView, CurrentState.CurrentView);
            }
            catch (System.Threading.ThreadAbortException) {}
            catch (Exception ex)
            {
                throw new UIPException(Resource.ResourceManager.FormatMessage(Resource.Exceptions.RES_ExceptionCantActivateView, nextView.Name) + UIPException.GetFirstExceptionMessage(ex), ex);
            }
        }
コード例 #7
0
        private void LayoutControlsIfRequired(ViewSettings viewSettings, WindowsFormView winFormView)
        {
            ILayoutManager layoutManager = LayoutManagerFactory.Create(viewSettings.Name);

            if (layoutManager != null)
            {
                layoutManager.LayoutControls(winFormView);
            }
        }
コード例 #8
0
 private void SetWinFormControlInternals(WindowsFormControlView control, ViewSettings viewSettings, Navigator navigator)
 {
     if (control != null)
     {
         control.InternalNavigator       = navigator;
         control.InternalNavigationGraph = navigator.Name;
         control.InternalViewName        = viewSettings.Name;
     }
 }
コード例 #9
0
 private void SetWinFormInternals(WindowsFormView view, ViewSettings viewSettings, Navigator navigator)
 {
     if (view != null)
     {
         view.InternalNavigator       = navigator;
         view.InternalNavigationGraph = navigator.Name;
         view.InternalViewName        = viewSettings.Name;
     }
 }
コード例 #10
0
        private void ActivateControl(WindowsFormControlView control, ViewSettings viewSettings, Navigator navigator, Guid taskId, TaskArgumentsHolder args)
        {
            control.InternalViewName = viewSettings.Name;
            control.InternalTaskId   = taskId;
            ControllerBase controller = navigator.GetController(control);

            control.InternalNavigator  = navigator;
            control.InternalController = controller;
            control.Initialize(args, viewSettings);
        }
コード例 #11
0
        /// <summary>
        /// Gets the settings of the controller object used by the specified view.
        /// </summary>
        /// <param name="viewName">The name of the view to retrieve the controller settings for.</param>
        public virtual ObjectTypeSettings GetControllerSettings(string viewName)
        {
            ViewSettings viewSettings = GetViewSettingsFromName(viewName);

            if (viewSettings == null)
            {
                throw new UIPException(Resource.ResourceManager.FormatMessage(Resource.Exceptions.RES_ExceptionViewConfigNotFound, viewName));
            }

            return((ObjectTypeSettings)_controllerCollection[viewSettings.Controller]);
        }
コード例 #12
0
        private WindowsFormView ActivateForm(WindowsFormView winFormView, ViewSettings viewSettings, Navigator navigator, Guid taskId, string previousView, TaskArgumentsHolder args)
        {
            winFormView.InternalTaskId          = taskId;
            winFormView.InternalNavigationGraph = navigator.Name;
            winFormView.InternalViewName        = viewSettings.Name;
            winFormView.InternalNavigator       = navigator;
            ControllerBase controller = navigator.GetController(winFormView);

            winFormView.InternalController = controller;

            InitializeChildren(winFormView, navigator, taskId);
            winFormView.Initialize(args, viewSettings);

            AddActiveForm(taskId, viewSettings.Name, winFormView);
            AddActiveView(taskId, winFormView, viewSettings.Name);

            LayoutControlsIfRequired(viewSettings, winFormView);

            winFormView.Activated += new EventHandler(Form_Activated);
            winFormView.Closed    += new EventHandler(Form_Closed);

            //Get the parent form
            Form parentForm = (Form)GetProperty(taskId, ParentFormKey);

            if (winFormView.IsMdiContainer || viewSettings.CanHaveFloatingWindows)
            {
                StoreProperty(taskId, ParentFormKey, winFormView);
            }
            else if (parentForm != null)
            {
                if (parentForm.IsMdiContainer)
                {
                    winFormView.MdiParent = parentForm;
                }
                else if (viewSettings.IsFloatable)
                {
                    winFormView.TopLevel = true;
                    parentForm.AddOwnedForm(winFormView);
                    winFormView.Show();
                }
            }

            if (viewSettings.IsOpenModal)
            {
                ShowModal(winFormView, previousView, taskId, parentForm);
            }
            else
            {
                winFormView.Show();
            }

            return(winFormView);
        }
コード例 #13
0
        /// <summary>
        /// Finds the view setting for a specified view type.
        /// </summary>
        /// <param name="viewType">The view type defined in the app.config.</param>
        /// <returns>The settings.</returns>
        public virtual ViewSettings GetViewSettingsFromType(string viewType)
        {
            ViewSettings viewForType = null;

            foreach (ViewSettings view in _viewByNameCollection.Values)
            {
                if (view.Type == viewType)
                {
                    viewForType = view;
                    break;
                }
            }

            return(viewForType);
        }
コード例 #14
0
 private void RedirectToNextView(string previousView, ViewSettings viewSettings)
 {
     try
     {
         if (previousView == null)
         {
             HttpContext.Current.Response.Redirect(HttpContext.Current.Request.ApplicationPath + "/" + viewSettings.Type, true);
         }
         else
         {
             HttpContext.Current.Response.Redirect(HttpContext.Current.Request.ApplicationPath + "/" + viewSettings.Type, false);
         }
     }
     catch (System.Threading.ThreadAbortException) {}
 }
コード例 #15
0
        /// <summary>
        /// A utility method that checks Web requests to ensure that the requested page and current view match.
        ///	If a user bookmarks page D, then proceeds to page F, and then returns to the bookmark, the
        ///	state, when loaded, will have F as the current view.
        /// Any submissions on page D will fail, because the navigation graph may not have appropriate view-navigateResult pairs.
        /// Therefore, you should code defensively against this. Check the current page, check the referring page, andc heck the state object's current view.
        /// </summary>
        /// <param name="view">The next view.</param>
        /// <param name="stateViewName">The view saved in the state.</param>
        /// <returns></returns>
        public bool IsRequestCurrentView(IView view, string stateViewName)
        {
            //  get state currentview; must all match
            ViewSettings viewSettings = UIPConfiguration.Config.GetViewSettingsFromName(stateViewName);

            if (viewSettings == null)
            {
                throw new UIPException(Resource.ResourceManager.FormatMessage(Resource.Exceptions.RES_ExceptionViewConfigNotFound, stateViewName));
            }

            string stateViewType = viewSettings.Type;

            System.Web.UI.Page page     = (System.Web.UI.Page)view;
            string             viewType = page.Request.CurrentExecutionFilePath.Replace(page.Request.ApplicationPath + "/", "");

            return(string.Compare(viewType, stateViewType, true, System.Globalization.CultureInfo.InvariantCulture) == 0);
        }
コード例 #16
0
        private void LoadViews(XmlNode configNode, IFormatProvider formatProvider)
        {
            ObjectTypeSettings typedObject;

            //Get the configured views
            foreach (XmlNode viewNode in configNode.SelectNodes(NodeViewXPath))
            {
                typedObject = new ViewSettings(viewNode, formatProvider);
                if (!_viewByNameCollection.ContainsKey(typedObject.Name))
                {
                    _viewByNameCollection.Add(typedObject.Name, typedObject);
                }
                else
                {
                    throw new UIPException(Resource.ResourceManager.FormatMessage(Resource.Exceptions.RES_ExceptionViewSettingAlreadyConfigured, typedObject.Name));
                }
            }
        }
コード例 #17
0
        /// <summary>
        /// Activates a specific view.
        /// </summary>
        /// <param name="previousView">The view actually displayed.</param>
        /// <param name="taskId">An existing task identifier (a GUID associated with the task).</param>
        /// <param name="navGraph">A configured navigation graph name.</param>
        /// <param name="view">The name of the view to be displayed.</param>
        public void ActivateView(string previousView, Guid taskId, string navGraph, string view)
        {
            //  create a session moniker
            SessionMoniker sessionMoniker = new SessionMoniker(navGraph, view, taskId);

            // store the moniker into the session, so the next view can get the task information
            sessionMoniker.StoreInSession();

            ViewSettings viewSettings = UIPConfiguration.Config.GetViewSettingsFromName(view);

            if (viewSettings == null)
            {
                throw new UIPException(Resource.ResourceManager.FormatMessage(Resource.Exceptions.RES_ExceptionViewConfigNotFound, view));
            }

            HttpContext.Current.Session[WebFormView.CurrentTaskKey] = taskId.ToString();

            RedirectToNextView(previousView, viewSettings);
        }
コード例 #18
0
        private ViewSettings GetSharedTransitionView(NavigationGraphSettings navigationGraph, string navigateValue)
        {
            SharedTransitionSettings sharedTransition = null;
            ViewSettings             sharedView       = null;

            sharedTransition = navigationGraph.GetSharedTransitionSettings(navigateValue);

            if (null == sharedTransition)
            {
                sharedTransition = this.GetSharedTransitionSettings(navigateValue);
            }

            if (sharedTransition != null)
            {
                sharedView = GetViewSettingsFromName(sharedTransition.View);
            }

            return(sharedView);
        }
コード例 #19
0
        private void ShowModal(WindowsFormView winFormView, string previousView, Guid taskId, object parentForm)
        {
            if (previousView != null)
            {
                //Get the current form
                ViewSettings previousViewSettings = UIPConfiguration.Config.GetViewSettingsFromName(previousView);
                if (previousViewSettings == null)
                {
                    throw new UIPException(Resource.ResourceManager.FormatMessage(Resource.Exceptions.RES_ExceptionViewConfigNotFound, previousView));
                }

                WindowsFormView previousForm = GetActiveForm(taskId, previousView);
                winFormView.ShowDialog((IWin32Window)previousForm);
            }
            else
            {
                //the previous view is unknown, so the first view of the navgraph is modal,
                // as a last resort we try to get the parentForm from our _properties.
                winFormView.ShowDialog((IWin32Window)parentForm);
            }
        }
コード例 #20
0
        /// <summary>
        /// Overloaded. Starts open navigation beginning with the first view.
        /// </summary>
        /// <param name="firstView">The name of the first view.</param>
        /// <param name="args">Additional navigation arguments.</param>
        public void StartTask(string firstView, TaskArgumentsHolder args)
        {
            string startViewName = null;

            if (CurrentState.CurrentView != null && CurrentState.CurrentView.Length > 0)
            {
                startViewName = CurrentState.CurrentView;
                _startView    = UIPConfiguration.Config.GetViewSettingsFromName(CurrentState.CurrentView);
            }
            else if (firstView != null && firstView.Length > 0)
            {
                startViewName = firstView;
                _startView    = UIPConfiguration.Config.GetViewSettingsFromName(firstView);
            }
            if (_startView == null)
            {
                throw new UIPException(Resource.ResourceManager.FormatMessage(Resource.Exceptions.RES_ExceptionViewConfigNotFound, startViewName));
            }

            StartTask(args);
        }
コード例 #21
0
        private IView[] CreateViews(Navigator navigator)
        {
            IView[] results = new IView[_nodeSettings.Length];
            int     i       = 0;

            foreach (NodeSettings node in _nodeSettings)
            {
                ViewSettings viewSettings = UIPConfiguration.Config.GetViewSettingsFromName(node.View);

                if (viewSettings == null)
                {
                    throw new UIPException(Resource.ResourceManager.FormatMessage(Resource.Exceptions.RES_ExceptionViewConfigNotFound, node.View));
                }

                IView view = (IView)GenericFactory.Create(viewSettings);
                SetWinFormControlInternals(view as WindowsFormControlView, viewSettings, navigator);
                SetWinFormInternals(view as WindowsFormView, viewSettings, navigator);
                results[i++] = view;
            }
            return(results);
        }
コード例 #22
0
        private void StartTask(TaskArgumentsHolder args)
        {
            FormSettings hostSettings      = _settings[_settings.StartFormName];
            ViewSettings startFormSettings = UIPConfiguration.Config.GetViewSettingsFromName(hostSettings.Name);

            CurrentState.CurrentView = startFormSettings.Name;

            try
            {
                ViewManager.ActivateView(null, startFormSettings.Name, this, args);
            }
            catch (System.Threading.ThreadAbortException) {}
            catch (Exception ex)
            {
                throw new UIPException(Resource.ResourceManager.FormatMessage(Resource.Exceptions.RES_ExceptionCantActivateView, startFormSettings.Name) + UIPException.GetFirstExceptionMessage(ex), ex);
            }
            CurrentState.Save();
            if (hostSettings.InitialView != null)
            {
                Navigate(hostSettings.InitialView);
            }
        }
コード例 #23
0
        /// <summary>
        /// Gets the settings of the layout manager used by the specified view.
        /// </summary>
        /// <param name="viewName">The name of the view to retrieve layout manager settings for.</param>
        public virtual ObjectTypeSettings GetLayoutManagerSettings(string viewName)
        {
            ObjectTypeSettings layoutManagerSettings = null;

            ViewSettings viewSettings = GetViewSettingsFromName(viewName);

            if (viewSettings == null)
            {
                throw new UIPException(Resource.ResourceManager.FormatMessage(Resource.Exceptions.RES_ExceptionViewConfigNotFound, viewName));
            }

            if (ViewExpectsLayoutManager(viewSettings))
            {
                layoutManagerSettings = (ObjectTypeSettings)_iLayoutManagerCollection[viewSettings.LayoutManager];

                if (layoutManagerSettings == null)
                {
                    throw new UIPException(Resource.ResourceManager.FormatMessage(Resource.Exceptions.RES_ExceptionLayoutManagerNotFound, viewSettings.LayoutManager));
                }
            }

            return(layoutManagerSettings);
        }
コード例 #24
0
        private void InitializeChildren(Control container, Navigator navigator, Guid taskId)
        {
            foreach (Control control in container.Controls)
            {
                if (control is WindowsFormControlView)
                {
                    WindowsFormControlView child = (WindowsFormControlView)control;
                    child.InternalNavigator = navigator;
                    child.InternalTaskId    = taskId;
                    string viewName = navigator.GetViewNameFromNodeName(child.Name);
                    child.InternalViewName = viewName;
                    ViewSettings viewSettings = UIPConfiguration.Config.GetViewSettingsFromName(viewName);
                    AddActiveControl(taskId, child.Name, child);
                    child.InternalController = navigator.GetController(child);
                    child.Initialize(null, viewSettings);
                }

                if (control.Controls.Count > 0)
                {
                    InitializeChildren(control, navigator, taskId);
                }
            }
        }
コード例 #25
0
        private void StartTask(TaskArgumentsHolder holder)
        {
            CurrentState.NavigationGraph = Name;
            if (CurrentState.CurrentView != null && CurrentState.CurrentView.Length > 0)
            {
                _startView = UIPConfiguration.Config.GetViewSettingsFromName(CurrentState.CurrentView);
            }
            ControllerBase firstController = ControllerFactory.Create(StartView.Name, this);

            firstController.EnterTask(holder);
            CurrentState.CurrentView   = StartView.Name;
            CurrentState.NavigateValue = "";
            CurrentState.Save();

            try
            {
                ViewManager.ActivateView(null, StartView.Name, this);
            }
            catch (System.Threading.ThreadAbortException) {}
            catch (Exception ex)
            {
                throw new UIPException(Resource.ResourceManager.FormatMessage(Resource.Exceptions.RES_ExceptionCantActivateView, StartView.Name) + UIPException.GetFirstExceptionMessage(ex), ex);
            }
        }
コード例 #26
0
 /// <summary>
 /// Returns true if a layout manager is expected. Returns false if no layout manager was specified for a particular view.
 /// </summary>
 /// <param name="viewSettings">The configuration of a specific view.</param>
 /// <returns></returns>
 private bool ViewExpectsLayoutManager(ViewSettings viewSettings)
 {
     return(viewSettings.LayoutManager != null && viewSettings.LayoutManager.Length > 0);
 }
コード例 #27
0
 /// <summary>
 /// Initializes the WinFormControlView.
 /// </summary>
 /// <param name="args">The initialization arguments.</param>
 /// <param name="settings">The settings for the view.</param>
 public virtual void Initialize(TaskArgumentsHolder args, ViewSettings settings)
 {
 }