private void tb_bundles_TextChanged(object sender, EventArgs e)
        {
            if (!String.IsNullOrEmpty(this.tb_bundles.Text) && !String.IsNullOrWhiteSpace(this.tb_bundles.Text))
            {
                if (!String.IsNullOrEmpty(this.tb_folders.Text) && !String.IsNullOrWhiteSpace(this.tb_folders.Text))
                {
                    this.btn_save.Enabled = true;
                }
                else
                {
                    this.btn_save.Enabled = false;
                }
            }
            else
            {
                this.btn_save.Enabled = false;
            }

            ArrayList al_tmp  = ClassLib_RML.SplitString(this.tb_bundles.Text, "\r\n");
            int       int_cot = 0;

            for (int idx = 0; idx < al_tmp.Count; idx++)
            {
                if (!String.IsNullOrEmpty(al_tmp[idx].ToString()) && !String.IsNullOrWhiteSpace(al_tmp[idx].ToString()))
                {
                    int_cot++;
                }
            }
            this.lab_bundCount.Text = int_cot.ToString() + " item(s)";
        }
Example #2
0
        private void timer_listFiles_Tick(object sender, EventArgs e)
        {
            this.timer_listFiles.Enabled = false;
            List <FileInfo> l_files     = new List <FileInfo>();
            ArrayList       al_fileType = new ArrayList();

            al_fileType = ClassLib_RML.SplitString(str_fileType, ";");
            ClassLib_RML.GetFilesListOfFolder(str_path, true, l_files);

            foreach (FileInfo finfo in l_files)
            {
                for (int index = 0; index < al_fileType.Count; index++)
                {
                    if (finfo.Extension == "." + al_fileType[index])
                    {
                        lfi_fileList.Add(finfo);
                    }
                }
            }

            if (lfi_fileList.Count > 0)
            {
                this.timer_move.Enabled = true;
            }
            else
            {
                MessageBox.Show("Can not find file to move!\r\nPlease check your file type setting.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Example #3
0
 private void btn_check_Click(object sender, EventArgs e)
 {
     str_filepath = this.tb_filePath.Text;
     str_filetype = this.tb_fileType.Text;
     l_filelist.Clear();
     al_filetype.Clear();
     addLabInfo(this.lab_info, "Reading file type......", Color.White);
     al_filetype = ClassLib_RML.SplitString(str_filetype, ";");
     this.grpBox_settings.Enabled = false;
     this.btn_check.Enabled       = false;
     this.timer_listfiles.Enabled = true;
 }
        private void btn_save_Click(object sender, EventArgs e)
        {
            ArrayList al_budTmp = ClassLib_RML.SplitString(this.tb_bundles.Text, "\r\n");
            ArrayList al_fodTmp = ClassLib_RML.SplitString(this.tb_folders.Text, "\r\n");

            if (al_budTmp.Count == al_fodTmp.Count)
            {
                Form_moveBundle.al_Bundles.Clear();
                Form_moveBundle.al_Folders.Clear();
                File.Delete(str_cfgPath);

                for (int idx = 0; idx < al_budTmp.Count; idx++)
                {
                    String str_bTmp = al_budTmp[idx].ToString();
                    String str_fTmp = al_fodTmp[idx].ToString();

                    if (String.IsNullOrEmpty(str_bTmp) || String.IsNullOrWhiteSpace(str_bTmp))
                    {
                        str_bTmp = "N/A";
                    }

                    if (String.IsNullOrEmpty(str_fTmp) || String.IsNullOrWhiteSpace(str_fTmp))
                    {
                        str_fTmp = "N/A";
                    }

                    Form_moveBundle.al_Bundles.Add(str_bTmp);
                    Form_moveBundle.al_Folders.Add(str_fTmp);

                    ClassLib_RML.WriteValueToINI("BUNDLE" + idx.ToString(), "Bundle", str_bTmp, str_cfgPath);
                    ClassLib_RML.WriteValueToINI("BUNDLE" + idx.ToString(), "Folder", str_fTmp, str_cfgPath);
                }
                this.Close();
            }
            else
            {
                MessageBox.Show("The number of bundle is not same with folder's.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
        private void btn_run_Click(object sender, EventArgs e)
        {
            this.panel_proBar.Controls.Clear();
            ProgressBar proBar_steps = new ProgressBar();

            this.panel_proBar.Controls.Add(proBar_steps);
            proBar_steps.Dock = DockStyle.Fill;

            var str_pathIn      = this.tb_path.Text;
            var str_OrigSrcPath = this.tb_OriginalSrc.Text;
            var pathOut         = this.tb_pathOut.Text;

            if (Directory.Exists(str_pathIn) && Directory.Exists(str_OrigSrcPath))
            {
                var str_type     = this.tb_type.Text;
                var al_fileType  = ClassLib_RML.SplitString(str_type, ";");
                var filesIn      = getFilesByTypes(str_pathIn, al_fileType, true);
                var origSrcFiles = getFilesByTypes(str_OrigSrcPath, al_fileType, true);

                if (filesIn.Count < 1 || origSrcFiles.Count < 1)
                {
                    MessageBox.Show("Please enter the directory paths containing the operable files.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    this.tb_path.Text        = "";
                    this.tb_OriginalSrc.Text = "";
                    this.panel_proBar.Controls.Clear();
                }
                else
                {
                    this.grpBox_set.Enabled = false;
                    this.btn_run.Enabled    = false;

                    proBar_steps.Maximum = filesIn.Count;
                    proBar_steps.Minimum = 0;
                    foreach (var fileIn in filesIn)
                    {
                        var nameFileIn = Path.GetFileName(fileIn);
                        var textFileIn = File.ReadAllText(fileIn);
                        var langFileIn = Regex.Match(textFileIn, @"(?<=target-language[ \t]*=[ \t]*"")[^""]+?(?="")").Value;
                        var fileOut    = fileIn.Replace(str_pathIn, pathOut);
                        if (File.Exists(fileOut))
                        {
                            File.Delete(fileOut);
                        }

                        if (!Directory.Exists(Path.GetDirectoryName(fileOut)))
                        {
                            Directory.CreateDirectory(Path.GetDirectoryName(fileOut));
                        }

                        foreach (var origSrcFile in origSrcFiles)
                        {
                            var nameOrigSrc = Path.GetFileName(origSrcFile);
                            var textOrigSrc = File.ReadAllText(origSrcFile);
                            var langOrigSrc = Regex.Match(textOrigSrc, @"(?<=target-language[ \t]*=[ \t]*"")[^""]+?(?="")").Value;
                            if (nameOrigSrc.ToLower() == nameFileIn.ToLower() && langOrigSrc.ToLower() == langFileIn.ToLower())
                            {
                                regularFile(fileIn, origSrcFile, fileOut, b_remnoupd);
                                origSrcFiles.Remove(origSrcFile);
                                proBar_steps.Value++;
                                break;
                            }
                        }
                    }

                    if (proBar_steps.Value == filesIn.Count)
                    {
                        MessageBox.Show("Done!!", "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        this.grpBox_set.Enabled = true;
                        this.btn_run.Enabled    = true;
                    }
                    else
                    {
                        var undo = filesIn.Count - proBar_steps.Value;
                        MessageBox.Show(undo.ToString() + " file(s) did not be processed. \r\nPlease check if they have Original Source for reference.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        this.grpBox_set.Enabled  = true;
                        this.tb_OriginalSrc.Text = "";
                    }
                }
            }
            else
            {
                MessageBox.Show("Please enter the valid directory paths.", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.tb_path.Text        = "";
                this.tb_OriginalSrc.Text = "";
                this.panel_proBar.Controls.Clear();
            }
        }