예제 #1
0
파일: Form1.cs 프로젝트: superkaka/mycsharp
        private void init()
        {

            this.AllowDrop = true;

            this.FormBorderStyle = FormBorderStyle.FixedSingle;
            this.MaximizeBox = false;
            this.MinimizeBox = false;

            CheckForIllegalCrossThreadCalls = false;

            selectedPath = new ArrayList();

            fd = new OpenFileDialog();
            fd.Multiselect = true;
            //fd.Filter = "Excel文件|*.xls;*.xlsx";
            fd.Title = "选择要处理的文件";

            //cb_algorithm.Items.Add("sss");

            cb_algorithm.Items.AddRange(new Object[] { 
                CompressOption.lzma,
                CompressOption.gzip,
                CompressOption.zlib
            });

            fc = new FileCompresser();
            cb_algorithm.SelectedIndex = 0;

        }
예제 #2
0
        static public void exec(Dictionary<String, String> args)
        {

            FileCompresser fc = new FileCompresser();
            fc.setCompressAlgorithm(CompressOption.lzma);

            if (args.ContainsKey("a"))
            {
                switch (args["a"].ToLower())
                {
                    case "lzma":
                        fc.setCompressAlgorithm(CompressOption.lzma);
                        break;

                    case "zlib":
                        fc.setCompressAlgorithm(CompressOption.zlib);
                        break;

                    case "gzip":
                        fc.setCompressAlgorithm(CompressOption.gzip);
                        break;

                    default:
                        MessageBox.Show("无效的参数 -a:" + args["a"]);
                        return;
                }
            }

            CompressProcesser processer = fc.compress;
            if (args.ContainsKey("op"))
            {
                switch (args["op"].ToLower())
                {
                    case "compress":
                    case "c":
                        processer = fc.compress;
                        break;

                    case "uncompress":
                    case "extract":
                    case "e":
                        processer = fc.uncompress;
                        break;

                    default:
                        MessageBox.Show("无效的参数: -op:" + args["op"]);
                        return;
                }
            }

            String tail = "";
            if (args.ContainsKey("tail"))
                tail = args["tail"];

            if (args.ContainsKey("path"))
            {
                String[] pathList = args["path"].Split(',');

                processer(pathList, tail);
            }


        }