Exemplo n.º 1
0
 public ProcessRunner(
     IResultsWriter resultsWriter,
     IResultsParser resultsParser,
     IProgressDisplay progressDisplayBuilder,
     IResultsStatsWriter resultsStatsWriter)
 {
     _resultsWriter          = resultsWriter;
     _resultsParser          = resultsParser;
     _progressDisplayBuilder = progressDisplayBuilder;
     _resultsStatsWriter     = resultsStatsWriter;
 }
Exemplo n.º 2
0
        /// <summary>
        /// Constructor
        /// </summary>
        public static void LoadAllGames(IProgressDisplay pdc)
        {
            // Load all known deck names
            DeckNames = new Dictionary <string, string>();
            if (File.Exists(Constants.GetLocalDeckNamesFilePath()))
            {
                try
                {
                    var json = Utilities.ReadLocalFile(Constants.GetLocalDeckNamesFilePath());
                    Dictionary <string, JsonElement> deckNames = JsonSerializer.Deserialize <Dictionary <string, JsonElement> >(json);
                    DeckNames = deckNames["DeckNames"].ToObject <Dictionary <string, string> >();
                }
                catch
                {
                    if (File.Exists(Constants.GetLocalDeckNamesFilePath() + ".backup"))
                    {
                        try
                        {
                            var json = Utilities.ReadLocalFile(Constants.GetLocalDeckNamesFilePath() + ".backup");
                            Dictionary <string, JsonElement> deckNames = JsonSerializer.Deserialize <Dictionary <string, JsonElement> >(json);
                            DeckNames = deckNames["DeckNames"].ToObject <Dictionary <string, string> >();
                        }
                        catch { }
                    }
                }
            }

            // Load all games
            Games = new List <GameRecord>();
            if (Directory.Exists(Constants.GetLocalGamesPath()))
            {
                DirectoryInfo dirInfo      = new DirectoryInfo(Constants.GetLocalGamesPath());
                FileInfo[]    files        = dirInfo.GetFiles("*.txt");
                var           filesInOrder = files.OrderBy(x => x.CreationTime);
                for (int i = 0; i < filesInOrder.Count(); i++)
                {
                    filesInOrder.Count();
                    try
                    {
                        AddGameRecord(GameRecord.LoadFromFile(filesInOrder.ElementAt(i).FullName));
                    }
                    catch
                    {
                        // Skip bad records
                    }
                    pdc.Update("Loading game records...", 100.0 * (i + 1) / filesInOrder.Count());
                    //Thread.Yield();
                }
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Find all missing sets and download them
        /// </summary>
        /// <param name="progressDisplay"></param>
        /// <returns></returns>
        public bool DownloadAllSets(IProgressDisplay progressDisplay)
        {
            MyProgressDisplay = progressDisplay;

            MissingSets = FindMissingSets();
            if (MissingSets.Count > 0)
            {
                long totalDownloadSize = MissingSets.Sum(x => x.Item2);
                var  result            = MessageBox.Show(
                    string.Format("Card sets have been updated. Download size is {0} MB. Download new sets?", totalDownloadSize / 1024 / 1024),
                    "Sets Out of Date",
                    MessageBoxButtons.YesNo);
                if (result != DialogResult.Yes)
                {
                    return(false);
                }

                // Delete existing outdated sets
                foreach (var set in MissingSets)
                {
                    if (Directory.Exists(Constants.GetSetPath(set.Item1)))
                    {
                        Directory.Delete(Constants.GetSetPath(set.Item1), true);
                    }
                }

                CurrentDownloadIndex = 0;
                CardLibrary.DownloadSet(MissingSets[CurrentDownloadIndex].Item1,
                                        new DownloadProgressChangedEventHandler(OnDownloadProgressChanged),
                                        new AsyncCompletedEventHandler(OnDownloadFileCompleted));
            }
            else
            {
                Callback.OnAllSetsDownloaded();
            }
            return(true);
        }
 public CherryCompositeProgress(string key, IProgressDisplay display)
     : base(key, display)
 {
 }
Exemplo n.º 5
0
 protected CherryProgressBase(string key, IProgressDisplay display)
 {
     _display = display;
     Key = key;
     Display.OnProgressStarted(this);
 }
Exemplo n.º 6
0
 public RegionsOfInterestFinder(ILogger logger, IProgressDisplay progressOverlay)
 {
     _logger          = logger;
     _progressOverlay = progressOverlay;
     _lazyWrapper     = new Lazy <Task <YoloWrapper> >(InitYolo);
 }
 public TesseractOcr(ILogger <TesseractOcr> logger, IProgressDisplay progressOverlay)
 {
     _logger = logger;
     _regionsOfInterestFinder = new RegionsOfInterestFinder(logger, progressOverlay);
 }