Beispiel #1
0
        private CustomToolbarInfo LoadUserToolbar()
        {
            bool isReadOnly;
            var  toolbarInfo = m_ToolbarConfProvider.GetToolbar(out isReadOnly,
                                                                ToolbarSpecificationFile);

            if (toolbarInfo?.Groups != null)
            {
                foreach (var grp in toolbarInfo.Groups
                         .Where(g => g.Commands?.Any(c => c.Triggers.HasFlag(Triggers_e.Button)) == true))
                {
                    var cmdGrp = new CommandGroupInfoSpec(grp);

                    m_Logger.Log($"Adding command group: {cmdGrp.Title} [{cmdGrp.Id}]. Commands: {string.Join(", ", cmdGrp.Commands.Select(c => $"{c.Title} [{c.UserId}]").ToArray())}");

                    var cmdGrpCad = m_AddIn.CommandManager.AddCommandGroup(cmdGrp);

                    cmdGrpCad.CommandClick        += OnCommandClick;
                    cmdGrpCad.CommandStateResolve += OnCommandStateResolve;
                }

                LoadToggleStateResolvers(
                    toolbarInfo.Groups.SelectMany(
                        g => g.Commands ?? Enumerable.Empty <CommandMacroInfo>())
                    .Where(m => m.Triggers.HasFlag(Triggers_e.ToggleButton) && m.ToggleButtonStateCodeType != ToggleButtonStateCode_e.None));
            }

            return(toolbarInfo);
        }
Beispiel #2
0
        private void LoadCommands()
        {
            bool isReadOnly;

            try
            {
                ToolbarInfo = m_ConfsProvider.GetToolbar(out isReadOnly, ToolbarSpecificationPath);
            }
            catch
            {
                isReadOnly = true;
                m_MsgService.ShowMessage("Failed to load the toolbar from the specification file. Make sure that you have access to the specification file",
                                         MessageType_e.Error);
            }

            IsEditable = !isReadOnly;

            if (Groups != null)
            {
                Groups.CommandsChanged   -= OnGroupsCollectionChanged;
                Groups.NewCommandCreated -= OnNewCommandCreated;
            }

            Groups = new CommandsCollection <CommandGroupVM>(
                (ToolbarInfo.Groups ?? new CommandGroupInfo[0])
                .Select(g => new CommandGroupVM(g)));

            HandleCommandGroupCommandCreation(Groups.Commands);

            Groups.NewCommandCreated += OnNewCommandCreated;
            Groups.CommandsChanged   += OnGroupsCollectionChanged;
        }
Beispiel #3
0
        private CustomToolbarInfo LoadUserToolbar()
        {
            bool isReadOnly;
            var  toolbarInfo = m_ToolbarConfProvider.GetToolbar(out isReadOnly,
                                                                ToolbarSpecificationFile);

            if (toolbarInfo?.Groups != null)
            {
                foreach (var grp in toolbarInfo.Groups
                         .Where(g => g.Commands?.Any(c => c.Triggers.HasFlag(Triggers_e.Button)) == true))
                {
                    var cmdGrp = new CommandGroupInfoSpec(grp, m_App);
                    cmdGrp.MacroCommandClick += OnMacroCommandClick;

                    m_Logger.Log($"Adding command group: {cmdGrp.Title} [{cmdGrp.Id}]. Commands: {string.Join(", ", cmdGrp.Commands.Select(c => $"{c.Title} [{c.UserId}]").ToArray())}");

                    m_AddIn.AddCommandGroup(cmdGrp);
                }
            }

            return(toolbarInfo);
        }