Exemple #1
0
        public PaletteModel([NotNull] IEnumerable <IPaletteCommand> commands)
        {
            PaletteCommands = new ObservableCollection <IPaletteCommand>();
            foreach (var item in commands)
            {
                if (RibbonBuilder.IsAccess(item.Access))
                {
                    PaletteCommands.Add(item);
                }
            }

            ChangeContent(Settings.Default.PaletteStyle);
        }
Exemple #2
0
        private static IPaletteCommand GetCommand(RibbonItemData item, string panel, string userGroup)
        {
            if (!RibbonBuilder.IsAccess(item.Access))
            {
                return(null);
            }
            IPaletteCommand com = null;

            switch (item)
            {
            case RibbonBreakPanel ribbonBreakPanel:
                break;

            case RibbonToggle ribbonToggle:
                var toggle = new ToggleButton();
                toggle.IsChecked   = ribbonToggle.IsChecked;
                toggle.CommandName = ribbonToggle.Command;
                com = toggle;
                break;

            case RibbonCommand ribbonCommand:
                var c = new PaletteCommand();
                c.CommandName = ribbonCommand.Command;
                com           = c;
                break;

            case RibbonVisualGroupInsertBlock ribbonVisualGroupInsertBlock:
                break;

            case RibbonVisualInsertBlock ribbonVisualInsertBlock:
                var vb = new PaletteVisualInsertBlocks();
                vb.file    = ribbonVisualInsertBlock.File;
                vb.filter  = s => Regex.IsMatch(s, ribbonVisualInsertBlock.Filter);
                vb.explode = ribbonVisualInsertBlock.Explode;
                vb.Layer   = new LayerInfo(ribbonVisualInsertBlock.Layer);
                com        = vb;
                break;

            case RibbonInsertBlock ribbonInsertBlock:
                var ib = new PaletteInsertBlock();
                ib.file    = ribbonInsertBlock.File;
                ib.blName  = ribbonInsertBlock.BlockName;
                ib.explode = ribbonInsertBlock.Explode;
                ib.Layer   = new LayerInfo(ribbonInsertBlock.Layer);
                ib.props   = ribbonInsertBlock.Properties;
                com        = ib;
                break;

            case RibbonSplit ribbonSplit:
                var coms = ribbonSplit.Items.Select(s => GetCommand(s, panel, userGroup))
                           .Where(w => w != null).ToList();
                var split = new SplitCommand(coms);
                com = split;
                break;
            }

            if (com != null)
            {
                com.Name        = item.Name;
                com.Description = item.Description;
                com.Image       = RibbonBuilder.GetImage(item, userGroup);
                com.Access      = item.Access;
                com.Command     = item.GetCommand();
                com.IsTest      = item.IsTest;
                com.Group       = panel;
            }

            return(com);
        }