Example #1
0
 public Downloader()
 {
     downloadQueueLock      = new object();
     downloadQueueFilePath  = Path.Combine(Environment.AppDataDirectory, DOWNLOAD_LIST_FILE_NAME);
     downloadQueue          = DownloadQueueStorage.LoadDownloadQueue(downloadQueueFilePath);
     eventQueue             = new BlockingCollection <EventArgs>();
     downloadTaskResetEvent = new AutoResetEvent(false);
     localization           = null;
     httpClient             = null;
     downloadSettings       = null;
     isInOfflineMode        = false;
     isShuttingDown         = false;
     StartEventPublisherTask();
     downloadTask = StartDownloadTask();
 }
Example #2
0
 public DownloadManagerTabViewModel(MainModel mainModel, IWindowContext parentWindowContext)
     : base(mainModel, parentWindowContext, mainModel.Localization.CurrentLanguage.DownloadManager.TabTitle)
 {
     localization                        = mainModel.Localization.CurrentLanguage.DownloadManager;
     Downloads                           = new ObservableCollection <DownloadItemViewModel>(mainModel.Downloader.GetDownloadQueueSnapshot().Select(ToDownloadItemViewModel));
     downloadDictionary                  = Downloads.ToDictionary(downloadItem => downloadItem.Id);
     SelectionChangedCommand             = new Command(SelectionChangedHandler);
     DownloaderListBoxDoubleClickCommand = new Command(DownloaderListBoxDoubleClick);
     StartSelectedDownloadsCommand       = new Command(StartSelectedDownloads);
     StopSelectedDownloadsCommand        = new Command(StopSelectedDownloads);
     RemoveSelectedDownloadsCommand      = new Command(RemoveSelectedDownloads);
     StartAllDownloadsCommand            = new Command(StartAllDownloads);
     StopAllDownloadsCommand             = new Command(StopAllDownloads);
     RemoveAllCompletedDownloadsCommand  = new Command(RemoveAllCompletedDownloads);
     CopyDownloadLogCommand              = new Command(CopyDownloadLog);
     Initialize();
     mainModel.Downloader.DownloaderEvent   += DownloaderEvent;
     mainModel.Localization.LanguageChanged += LocalizationLanguageChanged;
 }
Example #3
0
 public void Configure(Language currentLanguage, NetworkSettings networkSettings, DownloadSettings downloadSettings)
 {
     localization          = currentLanguage.DownloadManager;
     this.downloadSettings = downloadSettings;
     if (networkSettings.OfflineMode)
     {
         if (!isInOfflineMode)
         {
             isInOfflineMode = true;
             SwitchToOfflineMode();
         }
     }
     else
     {
         httpClient      = CreateNewHttpClient(networkSettings, downloadSettings);
         isInOfflineMode = false;
         ResumeDownloadTask();
     }
 }
Example #4
0
        public Language(List <Translation> prioritizedTranslationList)
        {
            translations               = prioritizedTranslationList;
            mainWindow                 = null;
            createDatabaseWindow       = null;
            searchTab                  = null;
            nonFictionSearchResultsTab = null;
            fictionSearchResultsTab    = null;
            sciMagSearchResultsTab     = null;
            commonDetailsTab           = null;
            nonFictionDetailsTab       = null;
            fictionDetailsTab          = null;
            sciMagDetailsTab           = null;
            import             = null;
            exportPanel        = null;
            nonFictionExporter = null;
            fictionExporter    = null;
            sciMagExporter     = null;
            synchronization    = null;
            database           = null;
            sqlDebugger        = null;
            downloadManager    = null;
            applicationUpdate  = null;
            settings           = null;
            about       = null;
            messageBox  = null;
            errorWindow = null;
            Translation mainTranslation = prioritizedTranslationList.First();

            Name          = mainTranslation.General?.Name?.Trim() ?? String.Empty;
            LocalizedName = mainTranslation.General?.LocalizedName?.Trim() ?? String.Empty;
            if (!String.IsNullOrEmpty(Name) && !String.IsNullOrEmpty(LocalizedName))
            {
                DisplayName = $"{Name} ({LocalizedName})";
            }
            else
            {
                DisplayName = "Error";
            }
            CultureCode    = mainTranslation.General?.CultureCode?.Trim() ?? String.Empty;
            TranslatorName = mainTranslation.General?.TranslatorName ?? "unknown";
            Formatter      = new LanguageFormatter(prioritizedTranslationList);
        }