private void backgroundWorker_import_DoWork(object sender, DoWorkEventArgs e)
        {
            if (!Directory.Exists(_base_dicpath))
            {
                Directory.CreateDirectory(_base_dicpath);
            }

            var factory = new TXTFactory();
            var list = factory.ReadTXT(this.textBox_filepath.Text);
            var listlist = factory.PrepareDics(list);

            List<string> index = new List<string>(listlist.Keys);
            for (int i = 0; i < listlist.Count; i++)
            {
                factory.WriteTXT(Path.Combine(_base_dicpath, index[i]), listlist[index[i]], false);
                backgroundWorker_import.ReportProgress(100 * i / listlist.Count);
            }
        }
Beispiel #2
0
        private void backgroundWorker_import_DoWork(object sender, DoWorkEventArgs e)
        {
            if (!Directory.Exists(_base_dicpath))
            {
                Directory.CreateDirectory(_base_dicpath);
            }

            var factory  = new TXTFactory();
            var list     = factory.ReadTXT(this.textBox_filepath.Text);
            var listlist = factory.PrepareDics(list);

            List <string> index = new List <string>(listlist.Keys);

            for (int i = 0; i < listlist.Count; i++)
            {
                factory.WriteTXT(Path.Combine(_base_dicpath, index[i]), listlist[index[i]], false);
                backgroundWorker_import.ReportProgress(100 * i / listlist.Count);
            }
        }
Beispiel #3
0
        private void backgroundWorker_scan_DoWork(object sender, DoWorkEventArgs e)
        {
            ///准备字典
            try
            {
                var file = this.getType();
                if (file == string.Empty)
                {
                    throw new ArgumentNullException("请勾选一个类型");
                }
                else if (file != "all")
                {
                    FileInfo info = new FileInfo(this._base_dicpath + "\\" + file);
                    var cgipath = Application.StartupPath + "\\" + _dicname;
                    if (System.IO.File.Exists(cgipath))
                    {
                        System.IO.File.Delete(cgipath);
                    }
                    info.CopyTo(cgipath);
                }
                else
                {
                    var factory = new TXTFactory();
                    var newcgilist = new List<string>();
                    var files = Directory.GetFiles(_base_dicpath);
                    foreach (var item in files)
                    {
                        var dic = factory.ReadTXT(item);
                        if (dic.Count > 0)
                        {
                            newcgilist.AddRange(dic);
                        }
                    }
                    factory.WriteTXT(_dicname, newcgilist, true);
                }

            }
            catch (ArgumentNullException ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Beispiel #4
0
 private void backgroundWorker_scan_DoWork(object sender, DoWorkEventArgs e)
 {
     ///准备字典
     try
     {
         var file = this.getType();
         if (file == string.Empty)
         {
             throw new ArgumentNullException("请勾选一个类型");
         }
         else if (file != "all")
         {
             FileInfo info    = new FileInfo(this._base_dicpath + "\\" + file);
             var      cgipath = Application.StartupPath + "\\" + _dicname;
             if (System.IO.File.Exists(cgipath))
             {
                 System.IO.File.Delete(cgipath);
             }
             info.CopyTo(cgipath);
         }
         else
         {
             var factory    = new TXTFactory();
             var newcgilist = new List <string>();
             var files      = Directory.GetFiles(_base_dicpath);
             foreach (var item in files)
             {
                 var dic = factory.ReadTXT(item);
                 if (dic.Count > 0)
                 {
                     newcgilist.AddRange(dic);
                 }
             }
             factory.WriteTXT(_dicname, newcgilist, true);
         }
     }
     catch (ArgumentNullException ex)
     {
         MessageBox.Show(ex.Message);
     }
 }