Example #1
0
        public static void TestPaletteCommands()
        {
            var commands = new List<IPaletteCommand>();

            var block1 = new PaletteInsertBlock("1", @"c:\temp\1.dwg", "Блок 1", null, "Вставка блока 1");
            commands.Add(block1);
            PaletteSetCommands.InitPalette(commands, "");
        }
Example #2
0
        public DesignTimePalette()
        {
            var commands = new List <IPaletteCommand>();
            var block1   = new PaletteInsertBlock("1", @"c:\temp\1.dwg", "Блок 1", null, "Вставка блока 1");

            commands.Add(block1);

            PaletteCommands = new ObservableCollection <IPaletteCommand>(commands);
        }
Example #3
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);
        }