示例#1
0
        public HelpDialog()
        {
            InitializeComponent();
            var massivNedlastingVersjon = new MassivNedlastingVersion(new GitHubReleaseInfoReader());
            var currentVersion          = MassivNedlastingVersion.Current;

            if (massivNedlastingVersjon.UpdateIsAvailable())
            {
                versionStatusMessage.Visibility = Visibility.Visible;
                versionStatusMessage.Text       = "Ny versjon tilgjengelig!";
            }
            else
            {
                versionStatusMessage.Visibility = Visibility.Collapsed;
            }
            txtVersion.Text = currentVersion;
        }
        public MainWindow()
        {
            Log.Logger = new LoggerConfiguration()
                         .MinimumLevel.Information()
                         .WriteTo.File("log-.txt",
                                       rollOnFileSizeLimit: true,
                                       shared: true,
                                       flushToDiskInterval: TimeSpan.FromSeconds(1))
                         .CreateLogger();

            Log.Information("Start application");

            InitializeComponent();


            BtnSelectAll.Visibility = Visibility.Hidden;
            BtnSelectAll.IsChecked  = false;
            ToggleSubscribeSelectedDatasetFiles.Visibility = Visibility.Hidden;
            MenuSubscribe.Visibility = Visibility.Hidden;

            var massivNedlastingVersjon = new MassivNedlastingVersion(new GitHubReleaseInfoReader());

            _currentVersion = MassivNedlastingVersion.Current;
            if (massivNedlastingVersjon.UpdateIsAvailable())
            {
                versionStatusMessage.Visibility = Visibility.Visible;
                versionStatusMessage.Text       = "Ny versjon tilgjengelig!";
            }
            else
            {
                versionStatusMessage.Visibility = Visibility.Collapsed;
            }

            _appSettings        = ApplicationService.GetAppSettings();
            _datasetService     = new DatasetService(_appSettings.LastOpendConfigFile);
            _selectedConfigFile = _appSettings.LastOpendConfigFile;
            _datasetService.UpdateProjections();
            _datasetService.ConvertDownloadToDefaultConfigFileIfExists();


            try
            {
                LbDatasets.ItemsSource = _datasetService.GetDatasets();
                fylker.ItemsSource     = _datasetService.GetCounties();
            }
            catch (Exception)
            {
                MessageBox.Show("Klarer ikke hente datasett... Sjekk internett tilkoblingen din");
            }


            _selectedFilesForDownload = _datasetService.GetSelectedFilesToDownloadAsViewModel();
            _selectedDatasetFiles     = new List <DatasetFileViewModel>();

            var viewDatasets = (CollectionView)CollectionViewSource.GetDefaultView(LbDatasets.ItemsSource);

            if (viewDatasets != null)
            {
                viewDatasets.Filter = UserDatasetFilter;
            }

            LbSelectedFilesForDownload.ItemsSource = _selectedFilesForDownload;

            cmbConfigFiles.ItemsSource  = ApplicationService.NameConfigFiles();
            cmbConfigFiles.SelectedItem = _selectedConfigFile.Name;

            SetDownloadUsage();

            RunWatch();
        }