Ejemplo n.º 1
0
        public DownloadUsageDialog()
        {
            InitializeComponent();

            _appSettings    = ApplicationService.GetAppSettings();
            _datasetService = new DatasetService(_appSettings.LastOpendConfigFile);
            _config         = _appSettings.TempConfigFile ?? _appSettings.LastOpendConfigFile;

            try
            {
                _downloadUsageGroup = _datasetService.FetchDownloadUsageGroups();
            }
            catch (Exception e)
            {
                _downloadUsageGroup = _datasetService.ReadFromDownloadUsageGroup();
            }

            try
            {
                _downloadUsagePurposes = _datasetService.FetchDownloadUsagePurposes();
            }
            catch (Exception e)
            {
                _downloadUsagePurposes = _datasetService.ReadFromDownloadUsagePurposes();
            }


            if (_config.DownloadUsageIsSet())
            {
                Group   = _config.DownloadUsage.Group;
                Purpose = _config.DownloadUsage.Purpose;
            }

            _downloadUsagePurposesViewModel = new List <PurposeViewModel>();
            foreach (var item in _downloadUsagePurposes)
            {
                _downloadUsagePurposesViewModel.Add(new PurposeViewModel(item, Purpose));
            }

            cmbDownloadUsageGroups.ItemsSource  = _downloadUsageGroup;
            cmbDownloadUsageGroups.SelectedItem = Group;
            lbPurposes.ItemsSource = _downloadUsagePurposesViewModel;
            //lbPurposes.SelectedValue = Purpose;
        }