Пример #1
0
        private void AddItemFilterBlockViewModels(IEnumerable <IItemFilterBlockBase> itemFilterBlocks, int addAtIndex)
        {
            var firstNewViewModel = true;

            foreach (var itemFilterBlock in itemFilterBlocks)
            {
                var vm = _itemFilterBlockBaseViewModelFactory.Create(itemFilterBlock);
                vm.Initialise(itemFilterBlock, this);
                vm.BlockBecameDirty += OnBlockBecameDirty;

                if (addAtIndex == -1)
                {
                    ItemFilterBlockViewModels.Add(vm);
                }
                else
                {
                    ItemFilterBlockViewModels.Insert(addAtIndex, vm);
                }

                if (firstNewViewModel)
                {
                    SelectedBlockViewModel = vm;
                    firstNewViewModel      = false;
                }
            }
        }
        public void AddSection(IItemFilterBlockViewModel targetBlockViewModel)
        {
            var vm         = _itemFilterBlockViewModelFactory.Create();
            var newSection = new ItemFilterSection {
                Description = "New Section"
            };

            vm.Initialise(newSection, this);

            Script.ItemFilterBlocks.Insert(Script.ItemFilterBlocks.IndexOf(targetBlockViewModel.Block), newSection);
            ItemFilterBlockViewModels.Insert(ItemFilterBlockViewModels.IndexOf(targetBlockViewModel), vm);
            IsDirty = true;
            SelectedBlockViewModel = vm;
            RaisePropertyChanged("ItemFilterSectionViewModels");
        }
        public void AddSection(IItemFilterBlockViewModel targetBlockViewModel)
        {
            var vm         = _itemFilterBlockViewModelFactory.Create();
            var newSection = new ItemFilterSection {
                Description = "New Section"
            };

            vm.Initialise(newSection, this);

            Script.ItemFilterBlocks.Insert(Script.ItemFilterBlocks.IndexOf(targetBlockViewModel.Block), newSection);
            ItemFilterBlockViewModels.Insert(ItemFilterBlockViewModels.IndexOf(targetBlockViewModel), vm);
            IsDirty = true;
            SelectedBlockViewModel = vm;
            RaisePropertyChanged(nameof(ItemFilterSectionViewModels));
            Messenger.Default.Send(new NotificationMessage("SectionsChanged"));
        }
Пример #4
0
        public void PasteBlock(IItemFilterBlockViewModel targetBlockViewModel)
        {
            try
            {
                var clipboardText = _clipboardService.GetClipboardText();
                if (string.IsNullOrEmpty(clipboardText))
                {
                    return;
                }
                _blockGroupHierarchyBuilder.Initialise(Script.ItemFilterBlockGroups.First());

                var translatedBlock = _blockTranslator.TranslateStringToItemFilterBlock(clipboardText, Script.ThemeComponents);
                if (translatedBlock == null)
                {
                    return;
                }

                var vm = _itemFilterBlockViewModelFactory.Create();
                vm.Initialise(translatedBlock, this);

                if (ItemFilterBlockViewModels.Count > 0)
                {
                    Script.ItemFilterBlocks.Insert(Script.ItemFilterBlocks.IndexOf(targetBlockViewModel.Block) + 1,
                                                   translatedBlock);
                    ItemFilterBlockViewModels.Insert(ItemFilterBlockViewModels.IndexOf(targetBlockViewModel) + 1, vm);
                }
                else
                {
                    Script.ItemFilterBlocks.Add(translatedBlock);
                    ItemFilterBlockViewModels.Add(vm);
                }

                SelectedBlockViewModel = vm;
                IsDirty = true;
            }
            catch (Exception e)
            {
                _logger.Error(e);
                var innerException = e.InnerException != null
                    ? e.InnerException.Message
                    : string.Empty;

                _messageBoxService.Show("Paste Error",
                                        e.Message + Environment.NewLine + innerException, MessageBoxButton.OK,
                                        MessageBoxImage.Error);
            }
        }
Пример #5
0
        public void AddBlock(IItemFilterBlockViewModel targetBlockViewModel)
        {
            var vm       = _itemFilterBlockViewModelFactory.Create();
            var newBlock = new ItemFilterBlock();

            vm.Initialise(newBlock, this);

            if (targetBlockViewModel != null)
            {
                Script.ItemFilterBlocks.Insert(Script.ItemFilterBlocks.IndexOf(targetBlockViewModel.Block) + 1, newBlock);
                ItemFilterBlockViewModels.Insert(ItemFilterBlockViewModels.IndexOf(targetBlockViewModel) + 1, vm);
            }
            else
            {
                Script.ItemFilterBlocks.Add(newBlock);
                ItemFilterBlockViewModels.Add(vm);
            }

            SelectedBlockViewModel = vm;
            vm.IsExpanded          = true;
            IsDirty = true;
        }