Exemplo n.º 1
0
        private void AddYearRowIfDoesNotExist(ComicStrip strip)
        {
            lock (_yearRows)
            {
                if (!_yearRows.ContainsKey(strip.Year))
                {
                    var endDate = new DateTime(strip.Year + 1, 1, 1);
                    if (endDate > DateTime.Today)
                    {
                        endDate = DateTime.Today;
                    }

                    var timeSpan = endDate - strip.Date;
                    _yearRows.Add(strip.Year, DataTable.Rows.Add(strip.Year, timeSpan.TotalDays, 0));
                }
            }
        }
Exemplo n.º 2
0
        private static void ProcessStrip(ComicStrip strip, string folder)
        {
            // Check if local year directory exists and create if it doesn't
            var localDirectory = Path.Combine(folder, strip.Year.ToString());
            if (!Directory.Exists(localDirectory))
            {
                Directory.CreateDirectory(localDirectory);
            }

            // Initialize file pathes for GIF and PNG format
            var gifPath = Path.Combine(localDirectory, strip.GetFilename("gif"));
            var pngPath = Path.Combine(localDirectory, strip.GetFilename("png"));

            // Check if PNG already exists
            if (File.Exists(pngPath))
            {
                var length = new FileInfo(pngPath).Length;
                if (length > 0)
                {
                    File.Delete(gifPath);
                    return;
                }
            }

            // Download image on computer
            if (!File.Exists(gifPath))
            {
                strip.Download(gifPath);
            }

            // Convert to PNG
            ComicStrip.ConvertToPng(gifPath);

            // When successfully converted to PNG, remove GIF image
            if (File.Exists(pngPath))
            {
                File.Delete(gifPath);
            }
        }