예제 #1
0
        public MemoryStream UncompressToMemoryStream(string inputFile, FolderComicsInfo info, String DirectoryPath)
        {
            SevenZipExtractor temp = null;

            try
            {
                temp = GetExtractor(inputFile);
                List <ArchiveFileInfo> list        = temp.ArchiveFileData.OrderBy(f => f.FileName).ToList();
                ArchiveFileInfo        filenamepng =
                    list.Where(f => (f.FileName.EndsWith(".jpg") || f.FileName.EndsWith(".png")) &&
                               (f.FileName.Contains("MACOSX") == false) &&
                               (f.Size > 0) &&
                               (f.IsDirectory == false)).FirstOrDefault();
                MemoryStream ms = new MemoryStream();
                temp.ExtractFile(filenamepng.Index, ms);
                ms.Position = 0;
                ms.Seek(0, SeekOrigin.Begin);
                return(ms);
            }
            catch (Exception err)
            {
                MemoryStream ms = new MemoryStream();
                return(ms);
            }
            finally
            {
                ReleaseExtractor(temp);
            }
        }
예제 #2
0
        /// <summary>
        /// Definition of routing urls
        /// </summary>
        public MainModule()
        {
            Get("/", x => {
                return(View["index.html", Program.ViewModel.Items]);
            });

            //View detail
            Get("/views/{uri*}", x => {
                String id             = x.uri.ToString().Replace(".html", "");
                FolderComicsInfo info = Program.ViewModel.GetFolderComicInfoById(id);
                return(View["detail.html", info]);
            });

            Get("/Search/{term*}", x => {
                String searchby = x.term.ToString().Replace(".html", "");
                var result      = Program.ViewModel.Items.Where(f => f.FolderName.Contains(searchby)).ToList();
                return(View["index.html", result]);
            });

            //Download File
            Get("/comics/{uri*}", p =>
            {
                dynamic cbrPath = p.uri.ToString();
                bool e          = System.IO.File.Exists(cbrPath);

                var file                = new FileStream(cbrPath, FileMode.Open);
                String fileName         = System.IO.Path.GetFileName(cbrPath);
                StreamResponse response = new StreamResponse(() => file, MimeTypes.GetMimeType(fileName));
                return(response.AsAttachment(fileName));
            });
        }
예제 #3
0
        /// <summary>
        /// self uncompress a content to BitmapImage
        /// </summary>
        /// <param name="inputFile"></param>
        /// <returns></returns>
        public BitmapImage UncompressToBitmapImage(string inputFile, FolderComicsInfo info, String DirectoryPath)
        {
            SevenZipExtractor temp = null;

            try
            {
                temp = GetExtractor(inputFile);
                BitmapImage            bitmap      = null;
                List <ArchiveFileInfo> list        = temp.ArchiveFileData.OrderBy(f => f.FileName).ToList();
                ArchiveFileInfo        filenamepng =
                    list.Where(f => (f.FileName.EndsWith(".jpg") || f.FileName.EndsWith(".png")) &&
                               (f.FileName.Contains("MACOSX") == false) &&
                               (f.Size > 0) &&
                               (f.IsDirectory == false)).FirstOrDefault();
                using (MemoryStream ms = new MemoryStream())
                {
                    temp.ExtractFile(filenamepng.Index, ms);
                    bitmap = new BitmapImage();
                    bitmap.BeginInit();
                    ms.Position = 0;
                    ms.Seek(0, SeekOrigin.Begin);
                    bitmap.DecodePixelHeight = 384;
                    bitmap.DecodePixelWidth  = 256;
                    bitmap.CacheOption       = BitmapCacheOption.OnLoad;
                    bitmap.StreamSource      = ms;
                    bitmap.EndInit();
                    bitmap.Freeze();

                    //Save image for test
                    //String path = DirectoryPath +  "\\snap"+System.IO.Path.GetExtension(filenamepng);
                    //Save(bitmap,path);

                    return(bitmap);
                }
                return(bitmap);
            }
            catch (Exception err)
            {
                var bmp = new BitmapImage();
                return(bmp);
            }
            finally
            {
                ReleaseExtractor(temp);
            }
        }
예제 #4
0
        /// <summary>
        /// Search changue combo
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void comboSearch_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            FolderComicsInfo item = (FolderComicsInfo)comboSearch.SelectedItem;

            App.ViewModel.SelectedFolder = item;
        }