コード例 #1
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);
        }
コード例 #2
0
 private void CleanUpChildWindows(WindowsFormView parent)
 {
     foreach (Form form in parent.OwnedForms)
     {
         form.Close();
     }
 }
コード例 #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
        private void LayoutControlsIfRequired(ViewSettings viewSettings, WindowsFormView winFormView)
        {
            ILayoutManager layoutManager = LayoutManagerFactory.Create(viewSettings.Name);

            if (layoutManager != null)
            {
                layoutManager.LayoutControls(winFormView);
            }
        }
コード例 #6
0
 private void SetWinFormInternals(WindowsFormView view, ViewSettings viewSettings, Navigator navigator)
 {
     if (view != null)
     {
         view.InternalNavigator       = navigator;
         view.InternalNavigationGraph = navigator.Name;
         view.InternalViewName        = viewSettings.Name;
     }
 }
コード例 #7
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);
        }
コード例 #8
0
        /// <summary>
        /// Updates the current view.
        /// </summary>
        private void Form_Activated(object source, EventArgs e)
        {
            WindowsFormView winFormView = (WindowsFormView)source;
            State           state       = winFormView.Controller.State;

            //Get the views related to the current task
            Hashtable taskActiveViews = (Hashtable)_activeViews[state.TaskId];

            //Get the view related to the form that fires this event
            string currentView = (string)taskActiveViews[source];

            //Update the state current view
            if (currentView != null)
            {
                state.CurrentView = currentView;
            }
        }
コード例 #9
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);
            }
        }
コード例 #10
0
 private void AddActiveView(Guid taskId, WindowsFormView view, string viewName)
 {
     GetActiveViews(taskId)[view] = viewName;
 }
コード例 #11
0
 private void AddActiveForm(Guid taskId, string viewName, WindowsFormView view)
 {
     GetActiveForms(taskId)[viewName] = view;
 }