public AncestryDnaDownloadingViewModel(Action <string> continueInClusterTab)
        {
            // Ancestry's security works by setting some cookies in the browser when someone signs in.
            // The CookieContainer captures those cookies when they are set, and adds them to subsequent requests.
            var cookies = new CookieContainer();
            var handler = new HttpClientHandler {
                CookieContainer = cookies
            };
            var ancestryClient = new HttpClient(handler)
            {
                BaseAddress = new Uri("https://www.ancestry.com"), Timeout = TimeSpan.FromMinutes(5)
            };

            _loginHelper      = new AncestryLoginHelper(ancestryClient, cookies);
            _testsRetriever   = new AncestryTestsRetriever(ancestryClient);
            _matchesRetriever = new AncestryMatchesRetriever(ancestryClient);

            SignInCommand               = new RelayCommand <PasswordBox>(async password => await SignInAsync(password));
            GetDnaMatchesCommand        = new RelayCommand(async() => await GetDnaMatchesAsync());
            ContinueInClusterTabCommand = new RelayCommand(() => continueInClusterTab(LastFileDownloaded));

            AncestryUserName          = Settings.Default.AncestryUserName;
            MinCentimorgansToRetrieve = Settings.Default.MinCentimorgansToRetrieve;
            MinSharedMatchesCentimorgansToRetrieve = Settings.Default.MinSharedMatchesCentimorgansToRetrieve;
            ShowAdvancedDownloadOptions            = Settings.Default.ShowAdvancedDownloadOptions;
            DownloadTypeFast     = Settings.Default.DownloadTypeFast;
            DownloadTypeComplete = Settings.Default.DownloadTypeComplete;
            DownloadTypeEndogamy = Settings.Default.DownloadTypeEndogamy;
            LastFileDownloaded   = Settings.Default.LastFileDownloaded;
        }
Esempio n. 2
0
        public AncestryDnaSignInViewModel(AncestryLoginHelper loginHelper, AncestryTestsRetriever testsRetriever)
        {
            _loginHelper    = loginHelper;
            _testsRetriever = testsRetriever;

            SignInCommand = new RelayCommand <PasswordBox>(async password => await SignInAsync(password));

            AncestryUserName = Settings.Default.AncestryUserName;
        }
        public AncestryDnaToolsViewModel()
        {
            // Ancestry's security works by setting some cookies in the browser when someone signs in.
            // The CookieContainer captures those cookies when they are set, and adds them to subsequent requests.
            var cookies = new CookieContainer();
            var handler = new HttpClientHandler {
                CookieContainer = cookies
            };
            var ancestryClient = new HttpClient(handler)
            {
                BaseAddress = new Uri("https://www.ancestry.com"), Timeout = TimeSpan.FromMinutes(5)
            };

            var loginHelper      = new AncestryLoginHelper(ancestryClient, cookies);
            var testsRetriever   = new AncestryTestsRetriever(ancestryClient);
            var matchesRetriever = new AncestryMatchesRetriever(ancestryClient);
            var endogamyProber   = new EndogamyProber(matchesRetriever);

            var serializedMatchesReaders = new List <ISerializedMatchesReader>
            {
                new DnaGedcomAncestryMatchesReader(),
                new DnaGedcomFtdnaMatchesReader(),
                new SharedClusteringMatchesReader(),
                new AutoClusterCsvMatchesReader(),
                new AutoClusterExcelMatchesReader(),
            };

            var matchesLoader = new MatchesLoader(serializedMatchesReaders);

            var signInViewModel = new AncestryDnaSignInViewModel(loginHelper, testsRetriever);

            // Extendable list of tabs to display.
            var clusteringTab = new AncestryDnaHierarchicalClusteringViewModel(matchesLoader);

            Tabs = new List <object>
            {
                new IntroductionViewModel(),
                new AncestryDnaDownloadingViewModel(signInViewModel, matchesRetriever, endogamyProber, OpenInClusterTab),
                new AncestryDnaHierarchicalClusteringViewModel(matchesLoader),
                new AncestryDnaSimilarityViewModel(matchesLoader),
                new AncestryDnaExportViewModel(matchesLoader),
                new AncestryDnaUploadNotesViewModel(signInViewModel, new AncestryNotesUpdater(matchesRetriever)),
            };
            SelectedTabIndex = Settings.Default.SelectedTabIndex;
        }