Exemplo n.º 1
0
        public override RibbonItemData GetItem()
        {
            var item = new RibbonInsertBlock();

            FillItem(item);
            return(item);
        }
Exemplo n.º 2
0
 public RibbonInsertBlockVM(RibbonInsertBlock item, List <BlockFile> blockFiles)
     : base(item)
 {
     File       = blockFiles.FirstOrDefault(f => f.FileName.EqualsIgnoreCase(item.File));
     Layer      = item.Layer;
     Explode    = item.Explode;
     BlockName  = item.BlockName;
     Properties = new ObservableCollection <Property>(item.Properties ?? new List <Property>());
 }
Exemplo n.º 3
0
        public RibbonInsertBlockVM(RibbonInsertBlock item, List <BlockFile> blockFiles)
            : base(item)
        {
            File    = blockFiles.FirstOrDefault(f => f.FileName.EqualsIgnoreCase(item.File));
            Layer   = item.Layer;
            Explode = item.Explode;
            Block   = new BlockItem {
                Name = item.BlockName
            };
            Properties = new ObservableCollection <Property>(item.Properties ?? new List <Property>());

            this.WhenAnyValue(v => v.Block).Skip(1)
            .Throttle(TimeSpan.FromMilliseconds(150))
            .ObserveOnDispatcher()
            .Subscribe(s =>
            {
                if (Block?.Image != null)
                {
                    Image = Block.Image;
                }
            });
        }
Exemplo n.º 4
0
        private RibbonItemData GetItem(IPaletteCommand com)
        {
            RibbonItemData item;

            switch (com)
            {
            case PaletteInsertBlock paletteInsertBlock:
                item = new RibbonInsertBlock
                {
                    Name       = paletteInsertBlock.blName,
                    File       = GetBlockFile(paletteInsertBlock.file),
                    Explode    = paletteInsertBlock.explode,
                    Layer      = paletteInsertBlock.Layer?.Name,
                    BlockName  = paletteInsertBlock.blName,
                    Properties = paletteInsertBlock.props
                };
                break;

            case PaletteVisualInsertBlocks paletteVisualInsertBlocks:
                item = new RibbonVisualInsertBlock
                {
                    Name    = paletteVisualInsertBlocks.Name ?? paletteVisualInsertBlocks.CommandName,
                    File    = GetBlockFile(paletteVisualInsertBlocks.file),
                    Explode = paletteVisualInsertBlocks.explode,
                    Layer   = paletteVisualInsertBlocks.Layer?.Name,
                };
                break;

            case SplitCommand splitCommand:
                item = new RibbonSplit
                {
                    Items = splitCommand.Commands?.Select(GetItem).ToList()
                };
                break;

            case ToggleButton toggleButton:
                item = new RibbonToggle
                {
                    Name      = toggleButton.Name ?? toggleButton.CommandName,
                    IsChecked = toggleButton.IsChecked,
                    Command   = toggleButton.CommandName
                };
                break;

            case PaletteCommand paletteCommand:
                item = new RibbonCommand
                {
                    Name    = paletteCommand.Name ?? paletteCommand.CommandName,
                    Command = paletteCommand.CommandName,
                };
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(com));
            }

            item.Name        = com.Name;
            item.Access      = com.Access;
            item.Description = com.Description;
            item.IsTest      = com.IsTest;
            SaveImage(com);
            return(item);
        }