Esempio n. 1
0
        public Sheet(int id, IUndoService undoService, Factories.IBlockSymbolFactory blockSymbolFactory,
                     Factories.IConnectionFactory connectionFactory,
                     Factories.IConnectorFactory connectorFactory)
        {
            Id                  = id;
            _undoService        = undoService;
            _blockSymbolFactory = blockSymbolFactory;
            _connectionFactory  = connectionFactory;
            _connectorFactory   = connectorFactory;

            _undoService.ActiveStateChanged += UndoServiceOnActiveStateChanged;
        }
Esempio n. 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="projectManagerService">Gets projects from some source i.e. DB</param>
        /// <param name="aplayProjectsCache">A cache of transformed projects. Contains Aplay-Projects. These projects must be the same over all ProjectManagers.</param>
        /// <param name="undoService">A service for undo/redo. Same for all clients.</param>
        /// <param name="undoManagerCache"></param>
        /// <param name="connectionFactory"></param>
        /// <param name="connectorFactory"></param>
        /// <param name="blockSymbolFactory"></param>
        /// <param name="sheetFactory"></param>
        public ProjectManager(IProjectManagerService projectManagerService,
                              IAplayProjectsCache aplayProjectsCache, IUndoService undoService,
                              IUndoManagerCache undoManagerCache,
                              Factories.IConnectionFactory connectionFactory, //Todo: A ProjectFactory is needed here instead of creating projects here directly.
                              Factories.IConnectorFactory connectorFactory,
                              Factories.IBlockSymbolFactory blockSymbolFactory,
                              Factories.ISheetFactory sheetFactory)
        {
            _projectManagerService = projectManagerService;
            _aplayProjectsCache    = aplayProjectsCache;
            _undoService           = undoService;
            _undoManagerCache      = undoManagerCache;
            _connectionFactory     = connectionFactory;
            _connectorFactory      = connectorFactory;
            _blockSymbolFactory    = blockSymbolFactory;
            _sheetFactory          = sheetFactory;


            //Subscribe for newly added, deleted projects from the service.
            var serviceUpdates = _projectManagerService.ProjectsDelta.Connect()
                                 .Filter(project => Filter(_searchString, project))
                                 .Transform(GetAplayProject)
                                 .Subscribe(changeSet =>
            {
                foreach (var change in changeSet)
                {
                    if (change.Reason == ChangeReason.Add)
                    {
                        Projects.Add(change.Current);
                    }
                    if (change.Reason == ChangeReason.Remove)
                    {
                        Projects.Remove(change.Current);
                    }
                }

                UpdateStates();
            });

            _cleanUp.Add(serviceUpdates);

            UpdateStates();
        }