Exemplo n.º 1
0
        /// <summary>
        /// Display the page that corresponds to the history token
        /// If there is a valid history token, then navigate to the corresponding page
        /// otherwise open the home page
        /// </summary>
        /// <param name="token"></param>
        protected void OnOpenPage(object param)
        {
            NavigationToken token = (NavigationToken)param;
            Controllable    page  = null;

            try
            {
                string functionality = token.Functionality;
                if (functionality == FunctionalitiesCode.HELP_ABOUT)
                {
                    OpenAboutDialog(); return;
                }
                if (functionality == FunctionalitiesCode.LOAD_TABLES_AND_GRIDS)
                {
                    StartRunAllAllocation(); return;
                }
                if (functionality == FunctionalitiesCode.LOAD_CLEAR_TABLES_AND_GRIDS)
                {
                    StartClearAllAllocation(); return;
                }
                if (functionality == FunctionalitiesCode.LOAD_LOG)
                {
                    StartAllocationLog(); return;
                }
                if (functionality == FunctionalitiesCode.MULTIPLE_FILES_UPLOAD)
                {
                    UploadMultipleFiles(); return;
                }
                if (functionality == FunctionalitiesCode.PROPERTIES_FUNCTIONALITY)
                {
                    createProperties(); return;
                }
                if (functionality == FunctionalitiesCode.TRANSFORMATION_TREE_LOAD)
                {
                    LoadTransformationTrees(false); return;
                }
                if (functionality == FunctionalitiesCode.TRANSFORMATION_TREE_CLEAR)
                {
                    LoadTransformationTrees(true); return;
                }
                if (functionality == FunctionalitiesCode.FILE_SAVE)
                {
                    token.currentActiveFunctionality = ActivePage.FunctionalityCode;
                }
                if (functionality == FunctionalitiesCode.FILE_SAVE_AS)
                {
                    SaveFileAs(token); return;
                }
                if (functionality == FunctionalitiesCode.BACKUP_SIMPLE_FUNCTIONALITY || functionality == FunctionalitiesCode.BACKUP_AUTOMATIC_FUNCTIONALITY)
                {
                    bool isSimpleBackup = functionality == FunctionalitiesCode.BACKUP_SIMPLE_FUNCTIONALITY;
                    loadBackup(functionality, isSimpleBackup); return;
                }

                string            tag = token.GetTag();
                FunctionalityType functionalityType = token.FunctionalityType;
                ViewType          viewType          = token.ViewType;

                bool isMainFonctionality = functionalityType == FunctionalityType.MAIN_FONCTIONALITY;

                OperationState state = OperationState.CONTINUE;
                if (isMainFonctionality && !(ActivePage != null && ActivePage is FileController))
                {
                    string activefunctionality = ActivePage != null ? ActivePage.FunctionalityCode : null;
                    page = searchInOpenedPages(activefunctionality);
                    bool tryToSaveActivePage = page != null && activefunctionality != null && !activefunctionality.Equals(functionality);
                    state = tryToSaveActivePage ? page.Close() : OperationState.CONTINUE;

                    if (page != null && state == OperationState.CONTINUE)
                    {
                        OpenedPages.Remove(page);
                    }
                }
                else
                {
                }

                if (state == OperationState.CONTINUE)
                {
                    ApplicationManager.MainWindow.SetPogressBar1Visible(false);
                    ApplicationManager.MainWindow.SetPogressBar2Visible(false);
                    if (viewType == ViewType.LOGOUT)
                    {
                        tryToCloseApplication(); return;
                    }
                    else if (viewType == ViewType.EDITION)
                    {
                        this.openEditionPage(token);
                        if (!String.IsNullOrEmpty(InternalErrorMessage))
                        {
                            MessageDisplayer.DisplayError("Error", InternalErrorMessage);
                            InternalErrorMessage = null;
                        }
                    }
                    else
                    {
                        openSearchPage(token);
                    }
                }
            }
            catch (Exception e)
            {
                MessageDisplayer.DisplayError("Error", e.Message);
                return;
            }
            return;
        }