public CreateReferenceDlgViewModel(IBlockManager blockManager, TreeItemDto first)
        {
            _blockManager = blockManager;

            Block1 = new NamedGuid() {Caption = first.Caption, Uid = first.Id};
            IsTo = true;

            SelectBlockCommand = new DelegateCommand(() =>
            {
                var dlg = new SelectTagDlg(typeof(Block));
                var res = dlg.ShowDialog();
                if (res.HasValue && res.Value && dlg.Id.HasValue)
                {
                    var block = _blockManager.GetBlockById(dlg.Id.Value);

                    Block2 = new NamedGuid() {Caption = block.Caption, Uid = block.Id};
                    OnPropertyChanged("Block2");
                    OkCommand.RaiseCanExecuteChanged();
                }
            });

            OkCommand = new DelegateCommand<Window>(window =>
            {
                window.DialogResult = true;
                window.Close();
            }, window => Block2 != null);
        }
        public AddParticleDlgViewModel(IParticlesManager particleManager, Type targetType, IBlockManager blockManager)
        {
            _particleManager = particleManager;
            _blockManager = blockManager;
            AddParticleVm = new AddParticleViewViewModel(_particleManager, Visibility.Collapsed);
            OkCommand = new DelegateCommand<Window>((wnd) =>
            {
                if (AddParticleVm.UseNewParticle)
                {
                    var particle = _particleManager.CreateParticle(AddParticleVm.NewParticle.Material,
                        AddParticleVm.NewParticle.Begin, AddParticleVm.NewParticle.End);
                    _blockManager.AddParticleToBlock(_block, particle);
                }
                else if (AddParticleVm.UseExistParticle && AddParticleVm.ExistParticle.HasValue)
                {
                    var particle = _particleManager.GetParticleById(AddParticleVm.ExistParticle.Value);
                    _blockManager.AddParticleToBlock(_block, particle);
                }

                wnd.DialogResult = true;
                wnd.Close();
            }, wnd => _block != null && (AddParticleVm.UseNewParticle || AddParticleVm.UseExistParticle));

            SelectIdeaCommand = new DelegateCommand(() =>
            {
                var dlg = new SelectTagDlg(targetType);
                var res = dlg.ShowDialog();
                if (res.HasValue && res.Value && dlg.Id.HasValue)
                {
                    _block = _blockManager.GetBlockById(dlg.Id.Value);
                    BlockCaption = _block.Caption;
                    OkCommand.RaiseCanExecuteChanged();
                }
            });
        }