Exemple #1
0
        public async void Save()
        {
            await Task.Run(async() =>
            {
                var config = new Core.Configuration()
                {
                    RtspPort         = _rtspPort,
                    HttpPort         = _httpPort,
                    MinimumNeighbors = _minNeighbors,
                    ScaleFactor      = _scaleFactor,
                    SerenityAddress  = _serenityIp,
                    SerenityUser     = _serenityUser,
                    SerenityPassword = _serenityPass
                };

                config.SelectedDatasources.AddRange(SelectedDataSources.Select(ds =>
                {
                    return(new DataSourceEntry()
                    {
                        Name = ds.Name, Id = ds.Id
                    });
                }));

                if (await _datasourcesMgr.ReInit(_serenityIp, _serenityUser, _serenityPass))
                {
                    InitDatasources(new List <DataSourceEntry>());
                }

                if (!_serializer.Save(config))
                {
                    LOG.Error("Failed to apply(save) configuration file");
                }
            });
        }
Exemple #2
0
        public MainUserControlViewModel(Core.Configuration config, IDataSourcesManager dsMgr)
        {
            _rtspPort       = config.RtspPort;
            _httpPort       = config.HttpPort;
            _scaleFactor    = config.ScaleFactor;
            _minNeighbors   = config.MinimumNeighbors;
            _serenityIp     = config.SerenityAddress;
            _serenityUser   = config.SerenityUser;
            _serenityPass   = config.SerenityPassword;
            _serializer     = new ConfigurationFileSerializer();
            _datasourcesMgr = dsMgr;

            SelectedDataSources      = new ObservableCollection <DataSource>();
            AvailableDataSources     = new ObservableCollection <DataSource>();
            SaveCommand              = new DelegateCommand(Save);
            AddDataSourcesCommand    = new DelegateCommand <IList>(selected => AddDataSources(selected));
            RemoveDataSourcesCommand = new DelegateCommand <IList>(selected => RemoveDataSources(selected));

            InitDatasources(config.SelectedDatasources);
        }