예제 #1
0
        /// <summary>
        /// Initialisation des sous menus
        /// </summary>
        protected override void initChildren()
        {
            this.Code   = ApplicationMenu.FILE_MENU_CODE;
            this.Header = "File";
            newFile     = BuildMenu(FunctionalitiesCode.PROJECT, "New Project", NavigationToken.GetCreateViewToken(FunctionalitiesCode.PROJECT_EDIT));
            openFile    = BuildMenu(FunctionalitiesCode.PROJECT, "Open Project", NavigationToken.GetSearchViewToken(FunctionalitiesCode.PROJECT_OPEN));
            recentFiles = BuildMenu(FunctionalitiesCode.PROJECT, "Open Recent Project", FunctionalitiesCode.PROJECT_RECENTS);
            BuildRecentOpenedFiles();
            BuildSaveAsMenu();
            NavigationToken token = NavigationToken.GetCreateViewToken(FunctionalitiesCode.FILE_SAVE);

            token.FunctionalityType = FunctionalityType.SUB_FONCTIONALITY;
            saveFile             = BuildMenu(FunctionalitiesCode.PROJECT, "Save Project", token);
            saveFile.IsEnabled   = false;
            saveAsFile.IsEnabled = false;

            backupMenu = BuildMenu(FunctionalitiesCode.PROJECT, FunctionalitiesLabel.BACKUP_LABEL, FunctionalitiesCode.BACKUP_FUNCTIONALITY);
            //backupMenu.IsEnabled = false;
            backupSimpleMenu    = BuildMenu(FunctionalitiesCode.PROJECT, FunctionalitiesLabel.BACKUP_SIMPLE_LABEL, NavigationToken.GetCreateViewToken(FunctionalitiesCode.BACKUP_SIMPLE_FUNCTIONALITY));
            backupAutomaticMenu = BuildMenu(FunctionalitiesCode.PROJECT, FunctionalitiesLabel.BACKUP_AUTOMATIC_LABEL, NavigationToken.GetCreateViewToken(FunctionalitiesCode.BACKUP_AUTOMATIC_FUNCTIONALITY));


            quitApplication = BuildMenu(FunctionalitiesCode.PROJECT, "Close B-Cephal", new NavigationToken(FunctionalitiesCode.FILE_QUIT, ViewType.LOGOUT));
        }
예제 #2
0
        public virtual ApplicationMenu customize(PrivilegeObserver observer)
        {
            if (observer.user == null || !observer.user.active.Value)
            {
                return(null);
            }
            if (observer.user.IsAdmin())
            {
                return(this);
            }
            if (observer.user.profil == null || !observer.user.profil.active)
            {
                return(null);
            }
            String    code      = this.GetFunctionalityCode();
            RightType?rightType = this.RightType;

            if (!string.IsNullOrWhiteSpace(code))
            {
                if (rightType.HasValue)
                {
                    if (observer.hasPrivilege(code, rightType.Value))
                    {
                        return(this);
                    }
                }
                else if (observer.hasPrivilege(code))
                {
                    return(this);
                }
            }

            List <String> list = new List <String>(0);

            list.Add(FunctionalitiesCode.FILE_QUIT);
            list.Add(FunctionalitiesCode.FILE_SAVE);
            list.Add(FunctionalitiesCode.FILE_SAVE_AS);
            list.Add(FunctionalitiesCode.HELP);
            if (!string.IsNullOrWhiteSpace(code) && list.Contains(code))
            {
                return(this);
            }

            int           added    = 0;
            List <Object> controls = new List <Object>(0);

            foreach (Control control in Items)
            {
                if (control is ApplicationMenu)
                {
                    ApplicationMenu menu  = (ApplicationMenu)control;
                    ApplicationMenu other = menu.customize(observer);
                    if (other != null)
                    {
                        added++;
                    }
                    else
                    {
                        controls.Add(menu);
                    }
                }
            }
            foreach (Control control in controls)
            {
                Items.Remove(control);
            }
            if (added <= 0)
            {
                return(null);
            }
            return(this);
        }
예제 #3
0
        public void  BuildSaveAsMenu()
        {
            NavigationToken token = NavigationToken.GetModifyViewToken(FunctionalitiesCode.FILE_SAVE_AS, lastFilePath);

            this.saveAsFile = BuildMenu(FunctionalitiesCode.PROJECT, "Save As", token);
        }