public TagsManagerMainView(ITagsManager tagsManager, TagsManagerMainViewModel model, 
            IIdeaManager ideaManager, IRelationManager relationManager, IBlockManager blockManager, IMaterialManager materialManager)
        {
            _relationManager = relationManager;
            _blockManager = blockManager;
            var db = new AllDb()
            {
                RelationManager = _relationManager,
                IdeaManager = ideaManager,
                BlockManager = _blockManager,
                TagsManager = tagsManager,
                MaterialManager = materialManager
            };
            InitializeComponent();
            _tagHelper = new TagTreeHelper(treeList, db);
            _tagHelper.ReloadTree();

            model.NodeAdded += dto =>
            {
                dto.AddNodeToTree(treeList);
                treeList.CurrentItem = dto;
            };

            model.NodeAnnihilated += dto => dto.AnnihilateNode(treeList);

            model.MaterialUpdate += dto => dto.UpdateMaterialInTree(treeList);

            Loaded += (sender, args) =>
            {
                DataContext = model;

                treeList.View.ValidateCell += (o, e) =>
                {
                    var wrong = Path.GetInvalidFileNameChars();
                    if (e.Value.ToString().Any(wrong.Contains))
                        e.IsValid = false;
                };

                treeList.View.PreviewKeyDown += (o, eventArgs) =>
                {
                    if (eventArgs.Key == Key.Enter || eventArgs.Key == Key.Return)
                    {
                        eventArgs.Handled = true;
                        treeList.View.CloseEditor();
                        RenameCurrent();
                    }
                };

                treeList.View.ShownEditor += ViewOnShownEditor;

                model.RenameTag += dto => Dispatcher.Invoke(() =>
                {
                    treeList.View.AllowEditing = true;
                    treeList.View.ShowEditor(true);
                }, DispatcherPriority.Background);

                model.Refresh += () => Dispatcher.Invoke(() => _tagHelper.ReloadTree(),
                    DispatcherPriority.Background);
            };
        }
Exemplo n.º 2
0
		private void AddToRecordRemappers(Relation relation, IRelationManager merger)
		{
			if(_recordRemappers.ContainsKey(relation)) 
				_recordRemappers[relation].Add(merger);
			else
				_recordRemappers.Add(relation,new List<IRelationManager>{merger});
		}
Exemplo n.º 3
0
        public FieldMerger(IEnumerable <Relation> relations, IMassMerge customMerger = null)
        {
            var availableMergers = new IRelationManager[]
            {
                new OneToManyManager(),
                new OneToOneManager()
            };

            foreach (Relation relation in relations)
            {
                bool customMergerFound = false;
                if (customMerger != null)
                {
                    foreach (IRelationManager merger in customMerger.CustomRelationManagers.Where(m => m.CanProcess(relation)))
                    {
                        AddRelationManager(relation, merger);
                        customMergerFound = true;
                    }
                }

                if (!customMergerFound)
                {
                    foreach (IRelationManager merger in availableMergers.Where(m => m.CanProcess(relation)))
                    {
                        AddRelationManager(relation, merger);
                    }
                }
            }
        }
        public TagSelectorView(ITagsManager tagsManager, IIdeaManager ideaManager, 
            IBlockManager blockManager, IRelationManager relationManager, ISettingsService settingsService, IMaterialManager materialManager)
        {
            _settingsService = settingsService;
            var allDb = new AllDb
            {
                RelationManager = relationManager,
                BlockManager = blockManager,
                IdeaManager = ideaManager,
                TagsManager = tagsManager,
                MaterialManager = materialManager
            };

            InitializeComponent();
            Loaded += (sender, args) =>
            {
                var model = RegionContext.GetObservableContext(this).Value as ISelectTagRegionView;

                if (model != null)
                {
                    var selectItem = new DelegateCommand<Guid>(id =>
                    {
                        if (model.TargetType == typeof(Tag))
                            _settingsService.AddRecentTag(id);
                        if (model.TargetType == typeof(Idea))
                            _settingsService.AddRecentIdea(id);
                        if (model.TargetType == typeof(Block))
                            _settingsService.AddRecentBlock(id);
                        if (model.TargetType == typeof(Comment))
                            _settingsService.AddRecentComment(id);
                        if (model.TargetType == typeof(Guidable))
                            _settingsService.AddRecentGuidable(id);

                        model.OkCommand.Execute(id);
                    });
                    var items = model.TargetType == typeof (Tag)
                        ? _settingsService.GetRecentTags()
                        : model.TargetType == typeof (Idea)
                            ? _settingsService.GetRecentIdeas()
                            : model.TargetType == typeof (Block)
                                ? _settingsService.GetRecentBlocks()
                                : model.TargetType == typeof (Guidable)
                                    ? _settingsService.GetRecentGuidables()
                                    : _settingsService.GetRecentComments();

                    var recent = new BarSubItem() {CategoryName = "BuiltInMenus", Content = "Recent"};
                    MainMenu.Items.Add(recent);
                    foreach (var item in items.OrderByDescending(i => i.Order))
                        recent.Items.Add(new BarButtonItem{Content = item.Name,
                            CommandParameter = item.Id, Command = selectItem});
                }
                DataContext = model;
            };
            _tagHelper = new TagTreeHelper(treeList, allDb);
            _tagHelper.ReloadTree();
        }
Exemplo n.º 5
0
 public ChatClient(IAuthorizationManager authorizationManager,
                   IUserManager userManager,
                   IMessageManager messageManager,
                   IRelationManager relationManager)
 {
     _authorizationManager = authorizationManager;
     _userManager          = userManager;
     _messageManager       = messageManager;
     _relationManager      = relationManager;
 }
Exemplo n.º 6
0
 public RelationController(IEntityResourceManager iEntityResourceManager, ILayoutManager iILayoutManager, IMetadataManager iMetadataManager, IJsonMessage iJsonMessage,
                           IInitilizeManager initilizeManager,
                           IRelationManager iRelationManager
                           )
 {
     _iEntityResourceManager = iEntityResourceManager;
     _iILayoutManager        = iILayoutManager;
     _iMetadataManager       = iMetadataManager;
     _iJsonMessage           = iJsonMessage;
     _initilizeManager       = initilizeManager;
     _iRelationManager       = iRelationManager;
 }
Exemplo n.º 7
0
		private void AddRelationManager(Relation relation, IRelationManager merger)
		{
			AddToRecordRemappers(relation, merger);

			var mergeRelationPair = new MergerRelationPair {Manager = merger, Relation = relation};

			if (relation.Left != null)
				AddToFieldSetters(relation.Left, mergeRelationPair);

			if (relation.Right != null)
				AddToFieldSetters(relation.Right, mergeRelationPair);
		}
Exemplo n.º 8
0
 private void AddToRecordRemappers(Relation relation, IRelationManager merger)
 {
     if (_recordRemappers.ContainsKey(relation))
     {
         _recordRemappers[relation].Add(merger);
     }
     else
     {
         _recordRemappers.Add(relation, new List <IRelationManager> {
             merger
         });
     }
 }
        public ConspEditorMainViewModel(IIdeaManager ideaManager, IMaterialManager materialManager,
            ITagsManager tagsManager, IParticlesManager particlesManager, IBlockManager blockManager,
            IEventAggregator eventAggregator, IRelationManager relationManager, ICommentManager commentManager)
        {
            _ideaManager = ideaManager;
            _materialManager = materialManager;
            _tagsManager = tagsManager;
            _particlesManager = particlesManager;
            _blockManager = blockManager;
            _eventAggregator = eventAggregator;
            _relationManager = relationManager;
            _commentManager = commentManager;
            Bookmarks = new List<string>();

            _eventAggregator.GetEvent<MaterialUpdatedEvent>().Subscribe(MaterialUpdated);
        }
Exemplo n.º 10
0
        private void AddRelationManager(Relation relation, IRelationManager merger)
        {
            AddToRecordRemappers(relation, merger);

            var mergeRelationPair = new MergerRelationPair {
                Manager = merger, Relation = relation
            };

            if (relation.Left != null)
            {
                AddToFieldSetters(relation.Left, mergeRelationPair);
            }

            if (relation.Right != null)
            {
                AddToFieldSetters(relation.Right, mergeRelationPair);
            }
        }
Exemplo n.º 11
0
 public UserProjectRelationManager(
     IFootChatUserRepository userRepository,
     IAddressBookMobileRepository addressBookMobileRepository,
     IRelationManager relationManager,
     IFootPrintRepository footPrintRepository,
     IUserManager userManager,
     IAddressBookManager addressBookManager,
     IRepository <Data.ClassStuRelation> classStuRelationRepository,
     IRepository <Data.Class> classRepository)
 {
     _RelationManager             = relationManager;
     _UserRepository              = userRepository;
     _FootPrintRepository         = footPrintRepository;
     _UserManager                 = userManager;
     _AddressBookManager          = addressBookManager;
     _AddressBookMobileRepository = addressBookMobileRepository;
     _ClassStuRelationRepository  = classStuRelationRepository;
     _ClassRepository             = classRepository;
 }
Exemplo n.º 12
0
		public FieldMerger(IEnumerable<Relation> relations,IMassMerge customMerger = null)
		{
			var availableMergers = new IRelationManager[]
				                       {
					                       new OneToManyManager(),
					                       new OneToOneManager()
				                       };

			foreach (Relation relation in relations)
			{
				bool customMergerFound = false;
				if (customMerger != null)
				foreach (IRelationManager merger in customMerger.CustomRelationManagers.Where(m => m.CanProcess(relation)))
				{
					AddRelationManager(relation, merger);
					customMergerFound = true;
				}

				if(!customMergerFound)
				foreach (IRelationManager merger in availableMergers.Where(m => m.CanProcess(relation)))
					AddRelationManager(relation, merger);
			}
		}
        public TagsManagerMainViewModel(ITagsManager tagsManager, IBlockManager blockManager,
            EventAggregator eventAggregator, IReferenceManager referenceManager, IRelationManager relationManager,
            IIdeaManager ideaManager, ISharedService shared, IMaterialManager materialManager, IParticlesManager particlesManager)
        {
            _eventAggregator = eventAggregator;
            _shared = shared;

            _db = new AllDb()
            {
                TagsManager = tagsManager,
                RelationManager = relationManager,
                IdeaManager = ideaManager,
                BlockManager = blockManager,
                MaterialManager = materialManager,
                ParticlesManager = particlesManager
            };

            _eventAggregator.GetEvent<BlockAddedEvent>().Subscribe(guid =>
            {
                var block = _db.BlockManager.GetBlockById(guid);
                if (block is Idea)
                {
                    var ideaDto = IdeaDto.FromBase(block as Idea, _db);
                    OnNodeAdded(ideaDto);
                }
                if (block is Relation)
                {
                    var relDto = RelationDto.FromBase(block as Relation, _db);
                    OnNodeAdded(relDto);
                }
                if (block is Comment)
                {
                    var commDto = CommentDto.FromBase(block as Comment, _db);
                    OnNodeAdded(commDto);
                }
            });

            _eventAggregator.GetEvent<DatabaseImportedEvent>().Subscribe(s => OnRefresh());

            _eventAggregator.GetEvent<MaterialUpdatedEvent>().Subscribe(guid =>
            {
                var mat = _db.MaterialManager.GetMaterialById(guid);
                var matDto = MaterialDto.FromBase(mat, _db);
                OnMaterialUpdate(matDto as MaterialDto);
            });

            NewTagCommand = new DelegateCommand<TreeItemDto>((dto) =>
            {
                if (dto == null || dto is TagDto)
                {
                    var added = _db.TagsManager.AddTag(dto == null ? null : (Guid?) dto.Id, "New tag");
                    var addedDto = TagDto.FromBase(added, _db);
                    OnNodeAdded(addedDto);
                    OnRenameTag(addedDto);
                }
            });

            NewIdeaCommand = new DelegateCommand<TreeItemDto>(dto =>
            {
                /*var added = _ideaManager.CreateIdea("New idea");
                var addedDto = _map.Map<IdeaDto>(added);
                OnNodeAdded(addedDto);
                OnRenameTag(addedDto);*/
            });

            AddReferenceCommand = new DelegateCommand<TreeItemDto>(dto =>
            {
                if (dto is IdeaDto || dto is RelationDto)
                {
                    var dlgVm = new CreateReferenceDlgViewModel(_db.BlockManager, dto);
                    if (shared.SelectedParticle != Guid.Empty)
                    {
                        var pis = _db.ParticlesManager.GetParticleInplacesForParticle(shared.SelectedParticle);
                        if (pis != null && pis.Any())
                        {
                            var block = _db.BlockManager.GetBlockById(pis.First().BlockId) as Idea;
                            if (block != null)
                                dlgVm.Block2 = new NamedGuid() {Caption = block.Caption, Uid = block.Id};
                        }
                    }

                    var dlg = new CreateReferenceDlg(dlgVm);
                    var res = dlg.ShowDialog();
                    if (res.HasValue && res.Value)
                    {
                        if (dlgVm.IsTo || dlgVm.IsBoth)
                        {
                            var refer = referenceManager.CreateReference(dlgVm.Block1.Uid, dlgVm.Block2.Uid);
                            OnNodeAdded(ReferenceDto.FromBase(refer, _db));
                        }
                        if (dlgVm.IsFrom || dlgVm.IsBoth)
                        {
                            var refer = referenceManager.CreateReference(dlgVm.Block2.Uid, dlgVm.Block1.Uid);
                            OnNodeAdded(ReferenceDto.FromBase(refer, _db));
                        }
                    }
                }
            });

            ClearCommand = new DelegateCommand(() =>
            {
                tagsManager.DeleteAllTAgs();
                OnRefresh();
            });

            OpenIdeaCommand = new DelegateCommand<TreeItemDto>(dto =>
            {
                if (dto is IdeaDto)
                    Interfaces.CompositeCommands.OpenBlockCommand.Execute(dto.Id);
                if (dto is MaterialDto)
                    Interfaces.CompositeCommands.OpenSourceCommand.Execute(dto.Id);
            });

            RenameCommand = new DelegateCommand<TreeItemDto>(OnRenameTag);

            AddCurrentMaterialCommand = new DelegateCommand<TagDto>(dto =>
            {
                if (_shared.CurrentMaterial.HasValue)
                {
                    _db.TagsManager.ApplyTagToMaterial(_shared.CurrentMaterial.Value, dto.Id);
                    var m = _db.MaterialManager.GetMaterialById(_shared.CurrentMaterial.Value);
                    var addedDto = MaterialDto.FromBase(m, _db);
                    OnNodeAdded(addedDto);
                }
            });

            DeleteCommand = new DelegateCommand<TreeItemDto>(dto =>
            {
                if (dto is IdeaDto)
                {
                    _db.IdeaManager.DeleteIdea((dto as IdeaDto).Id);
                    NodeAnnihilated(dto);
                }
            });
        }
        public CreateRelationDlgViewModel(IParticlesManager particlesManager, IIdeaManager ideaManager,
            IRelationManager relationManager, IBlockManager blockManager, IEventAggregator eventAggregator)
        {
            _particlesManager = particlesManager;
            _ideaManager = ideaManager;
            _relationManager = relationManager;
            _blockManager = blockManager;
            _eventAggregator = eventAggregator;
            AddParticleVm = new AddParticleViewViewModel(_particlesManager);

            SelectIdea1Command = new DelegateCommand(() =>
            {
                var dlg = new SelectTagDlg(typeof (Idea));
                var res = dlg.ShowDialog();
                if (res.HasValue && res.Value && dlg.Id.HasValue)
                {
                    _idea1 = _ideaManager.GetIdeaById(dlg.Id.Value);
                    Idea1Caption = _idea1.Caption;
                    OnPropertyChanged("Idea1Caption");
                }
                OkCommand.RaiseCanExecuteChanged();
            });

            SelectIdea2Command = new DelegateCommand(() =>
            {
                var dlg = new SelectTagDlg(typeof (Idea));
                var res = dlg.ShowDialog();
                if (res.HasValue && res.Value && dlg.Id.HasValue)
                {
                    _idea2 = _ideaManager.GetIdeaById(dlg.Id.Value);
                    Idea2Caption = _idea2.Caption;
                    OnPropertyChanged("Idea2Caption");
                }
                OkCommand.RaiseCanExecuteChanged();
            });

            AddRelationTypeCommand = new DelegateCommand<RoutedEventArgs>(e =>
            {
                var text = ((ButtonEdit) e.Source).Text;
                var rt = _relationManager.AddRelationType(text);
                var relationDto = new RelationTypeDto() {Id = rt.Id, Name = text};
                Relations.Add(relationDto);
                Relation = relationDto;
            });

            OkCommand = new DelegateCommand<Window>(wnd =>
            {
                var relation = _relationManager.CreateRelation(Relation.Id, _idea1.Id, _idea2.Id);

                if (AddParticleVm.AddParticle)
                    if (AddParticleVm.UseNewParticle)
                    {
                        var particle = _particlesManager.CreateParticle(AddParticleVm.NewParticle.Material,
                            AddParticleVm.NewParticle.Begin, AddParticleVm.NewParticle.End);
                        _blockManager.AddParticleToBlock(relation, particle);
                    }
                    else if (AddParticleVm.UseExistParticle && AddParticleVm.ExistParticle.HasValue)
                    {
                        var particle = _particlesManager.GetParticleById(AddParticleVm.ExistParticle.Value);
                        _blockManager.AddParticleToBlock(relation, particle);
                    }

                _eventAggregator.GetEvent<BlockAddedEvent>().Publish(relation.Id);
                wnd.DialogResult = true;
                wnd.Close();
            }, wnd => Relation != null && _idea1 != null && _idea2 != null);

            Relations =
                new ObservableCollection<RelationTypeDto>(
                    _relationManager.GetRelationTypes()
                        .Select(rt => new RelationTypeDto() {Id = rt.Id, Name = rt.Caption}));
        }