Beispiel #1
0
        private static void Main(string[] args)
        {
            Console.WriteLine("Compress or decompress files?");
            string input = Console.ReadLine();

            bool compress = input.StartsWith("c", StringComparison.InvariantCultureIgnoreCase);

            IList <string> paths;

            if (args.Length == 0)
            {
                Console.WriteLine("Enter:");
                Console.WriteLine($"- The path to directory containing all files to be {(compress ? "" : "de")}compressed, OR");
                Console.WriteLine($"- The path to each file to be {(compress ? "" : "de")}compressed, and press enter twice to finish.");
                paths = new List <string>();
                string nextPath;
                while (!string.IsNullOrWhiteSpace(nextPath = Console.ReadLine()))
                {
                    if (Directory.Exists(nextPath))
                    {
                        paths = Directory.GetFiles(nextPath);
                        break;
                    }
                    else
                    {
                        paths.Add(nextPath);
                    }
                }
            }
            else
            {
                paths = args;
            }
            Console.WriteLine("Enter the path of the result folder:");
            string resultFolder = Console.ReadLine();

            Algorithm algorithm = Algorithm.BuiltInAlgorithms[ConsoleChoiceMenu("Enter the number of the algorithm you want to use:", Algorithm.BuiltInAlgorithms.ListSelect(algo => algo.Name))];

            int top   = Console.WindowHeight - 1;
            int width = Console.WindowWidth - "[...%] [".Length - "]".Length;

            var progress = new Progress <float>(p => {
                Console.SetCursorPosition(0, top);
                Console.Write($"[{p,4:P0}] [{new string('#', (int) (p * width)).PadRight(width)}]");
            });

            if (compress)
            {
                ImageSetCompressor.CompressSet(algorithm, new ReadOnlyCollection <string>(paths), resultFolder, progress).GetAwaiter().GetResult();
            }
            else
            {
                ImageSetCompressor.DecompressSet(algorithm, new ReadOnlyCollection <string>(paths), resultFolder, progress).GetAwaiter().GetResult();
            }
        }
Beispiel #2
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            if (Activity.CheckSelfPermission(Manifest.Permission.WriteExternalStorage) == Android.Content.PM.Permission.Denied)
            {
                new AlertDialog.Builder(Activity.ApplicationContext)
                .SetTitle("@string/permission_required")
                .SetMessage("@string/permission_required_write")
                .SetPositiveButton("@string/ok", (o, e) => ((MainActivity)Activity).SwitchFragment <ViewFragment>())
                .Create();

                return(new View(Activity.ApplicationContext));
            }
            else
            {
                var ret = inflater.Inflate(Resource.Layout.fragment_compress, container, false);

                ret.FindViewById <Button>(Resource.Id.compressCompress).Click += (o, e) => AsynchronousOperation("@string/compressing", (progress) =>
                                                                                                                 ImageSetCompressor.CompressSet(Algorithm.Delta, m_SetImages, m_ResultFolder, progress)
                                                                                                                 );

                ret.FindViewById <Button>(Resource.Id.compressDecompress).Click += (o, e) => AsynchronousOperation("@string/decompressing", (progress) =>
                                                                                                                   ImageSetCompressor.DecompressSet(Algorithm.Delta, m_SetImages, m_ResultFolder, progress)
                                                                                                                   );

                ret.FindViewById <Button>(Resource.Id.compressSelectSetImages).Click += (o, e) => OnSelectSetImages();

                return(ret);
            }
        }