Exemplo n.º 1
0
        private static void Main(string[] args)
        {
            if (args == null ||
                args.Count() < 3)
            {
                Console.WriteLine("Usage: GZipTest.exe compress/decompress [source file] [destination file]");
                return;
            }
            if (!new FileInfo(args[1]).Exists)
            {
                Console.WriteLine($"File '{args[1]}' not exist");
                return;
            }
            var converter = new ByteLengthConverter();
            var archiver  = new GZipWrapper(bytesPerWorker: _bytesPerWorker, converter: converter);

            switch (args[0])
            {
            case null:
            default:
                return;

            case "compress":
                Console.Write($"Bytes after compression: {archiver.Compress(args[1], args[2])}");
                return;

            case "decompress":
                Console.Write($"Bytes after compression: {archiver.Decompress(args[1], args[2])}");
                return;
            }
        }
Exemplo n.º 2
0
        public void Test6()
        {
            var result = ByteLengthConverter.FormatBytes(1024 * 1024 + 1);

            Trace.WriteLine(result);
            Assert.AreEqual(result, "1 MB");
        }
Exemplo n.º 3
0
        private void DisplayMultimedia(MultimediaLinkViewModel selected)
        {
            if (selected != null)
            {
                JobExecutor.QueueJob(() => {
                    BitmapSource image = null;
                    try {
                        string filename       = _tempFileManager.GetContentFileName(selected.MultimediaID, selected.Extension);
                        selected.TempFilename = filename;
                        image = GraphicsUtils.LoadImageFromFile(filename);
                        if (image != null)
                        {
                            imgPreview.InvokeIfRequired(() => {
                                imgPreview.Stretch          = Stretch.Uniform;
                                imgPreview.StretchDirection = StretchDirection.DownOnly;
                                imgPreview.Source           = image;
                                gridInfo.DataContext        = image;
                                FileInfo f = new FileInfo(filename);

                                if (f.Length != selected.SizeInBytes)
                                {
                                    selected.SuspendChangeMonitoring = true;
                                    selected.SizeInBytes             = (int)f.Length;
                                    selected.SuspendChangeMonitoring = false;
                                }

                                lblImageInfo.Content = string.Format("{0}x{1}  {2} DPI  {3}", image.PixelWidth, image.PixelHeight, image.DpiX, ByteLengthConverter.FormatBytes(f.Length));
                                lblFilename.Content  = string.Format("Filename: {0}", filename);
                            });
                        }
                    } finally {
                        if (image == null)
                        {
                            imgPreview.InvokeIfRequired(() => {
                                imgPreview.Source    = null;
                                lblImageInfo.Content = "No image";
                                lblFilename.Content  = "";
                            });
                        }
                    }
                });
            }
            else
            {
                imgPreview.Source    = null;
                lblFilename.Content  = "";
                lblImageInfo.Content = "";
            }
        }
 public DuplicateItemOptions(Multimedia duplicate, int sizeInBytes, Boolean managerMode = false)
 {
     InitializeComponent();
     this.DuplicateItem     = duplicate;
     lblDescription.Content = "There already exists a multimedia item with the name and size ('" + duplicate.Name + "', " + ByteLengthConverter.FormatBytes(sizeInBytes) + ").";
     if (managerMode)
     {
         optContinue.IsChecked       = true;
         optLinkToExisting.IsEnabled = false;
         optLinkToExisting.IsChecked = false;
     }
 }
Exemplo n.º 5
0
        public void Test5()
        {
            var result = ByteLengthConverter.FormatBytes(1024 * 1024);

            Assert.AreEqual(result, "1024 KB");
        }
Exemplo n.º 6
0
        public void Test4()
        {
            var result = ByteLengthConverter.FormatBytes(2048);

            Assert.AreEqual(result, "2 KB");
        }
Exemplo n.º 7
0
        public void Test3()
        {
            var result = ByteLengthConverter.FormatBytes(512);

            Assert.AreEqual(result, "512 Bytes");
        }
 private void DisplayMultimedia(MultimediaLinkViewModel selected)
 {
     if (selected != null)
     {
         JobExecutor.QueueJob(() => {
             string filename = _tempFileManager.GetContentFileName(selected.MultimediaID, selected.Extension);
             var image       = GraphicsUtils.LoadImageFromFile(filename);
             imgPreview.InvokeIfRequired(() => {
                 imgPreview.Stretch          = Stretch.Uniform;
                 imgPreview.StretchDirection = StretchDirection.DownOnly;
                 imgPreview.Source           = image;
                 gridInfo.DataContext        = image;
                 FileInfo f           = new FileInfo(filename);
                 lblImageInfo.Content = string.Format("{0}x{1}  {2} DPI  {3}", image.PixelWidth, image.PixelHeight, image.DpiX, ByteLengthConverter.FormatBytes(f.Length));
             });
         });
     }
     else
     {
         imgPreview.Source    = null;
         lblImageInfo.Content = "";
     }
 }