Пример #1
0
        private void btnChgNmExecute_Click(object sender, EventArgs e)
        {
            new System.Threading.Thread(() =>
            {
                try
                {
                    UIInProcess(true);

                    FileBatchChangeName fileBatchChangeName = ConstructFileBatchChangeName();
                    fileBatchChangeName.ExecuteChangeName();

                    SaveConfig();
                }
                catch (Exception ex)
                {
                    CommFunction.WriteMessage(ex.Message);
                }
                finally
                {
                    UIInProcess(false);
                }

                GC.Collect();
            }
                                        ).Start();
        }
Пример #2
0
        private void btnChgNmViewChgFileNameList_Click(object sender, EventArgs e)
        {
            try
            {
                UIInProcess(true);
                FileBatchChangeName fileBatchChangeName = ConstructFileBatchChangeName();
                List <string>       targetNameList      = fileBatchChangeName.GetTargetNameList();
                UIInProcess(false);

                if (targetNameList.Count > 0)
                {
                    string nameAll = targetNameList.Aggregate("", (current, name) => current + name + Environment.NewLine).TrimEnd(Environment.NewLine.ToCharArray());

                    using (formTextMessage frmMessage = new formTextMessage("更名列表预览", nameAll, true))
                    {
                        frmMessage.ShowDialog(this);
                    }
                }
            }
            catch (Exception ex)
            {
                CommFunction.WriteMessage(ex.Message);
            }
            finally
            {
                UIInProcess(false);
            }
        }
Пример #3
0
        private FileBatchChangeName ConstructFileBatchChangeName()
        {
            FileBatchChangeName retVal = new FileBatchChangeName();

            retVal.SetFileSelectParm(this.GetFormFileSelParm());

            FileChangeRule fileChangeBy = FileChangeRule.FixedString;

            if (rdoChgNmRulFixedStr.Checked)
            {
                fileChangeBy = FileChangeRule.FixedString;
            }
            else if (rdoChgNmRulWildcard.Checked)
            {
                fileChangeBy = FileChangeRule.Wildcard;
            }
            else if (rdoChgNmRulSpecList.Checked)
            {
                fileChangeBy = FileChangeRule.SpecList;
            }

            switch (fileChangeBy)
            {
            case FileChangeRule.FixedString:
                retVal.SetFunctionRule(fileChangeBy, txtChgNmFixedStr.Text, chkChgNmIsRegex.Checked);
                break;

            case FileChangeRule.Wildcard:
                retVal.SetFunctionRule(fileChangeBy,
                                       perfixStr: txtChgNmPerfixStr.Text,
                                       suffixStr: txtChgNmSuffixStr.Text,
                                       startNum: (int)numChgNmStartNum.Value,
                                       wildcardLen: (int)numChgNmWildcardLen.Value,
                                       onlyFixStr: chkChgNmOnlyFixStr.Checked);
                break;

            case FileChangeRule.SpecList:
                retVal.SetFunctionRule(fileChangeBy, specChgList: _fileChangeNameChangeList);
                break;
            }

            return(retVal);
        }
Пример #4
0
        private FileBatchChangeName ConstructFileBatchChangeName()
        {
            FileBatchChangeName retVal = new FileBatchChangeName();
            retVal.SetFileSelectParm(this.GetFormFileSelParm());

            FileChangeRule fileChangeBy = FileChangeRule.FixedString;
            if (rdoChgNmRulFixedStr.Checked)
                fileChangeBy = FileChangeRule.FixedString;
            else if (rdoChgNmRulWildcard.Checked)
                fileChangeBy = FileChangeRule.Wildcard;
            else if (rdoChgNmRulSpecList.Checked)
                fileChangeBy = FileChangeRule.SpecList;

            switch (fileChangeBy) {
                case FileChangeRule.FixedString:
                    retVal.SetFunctionRule(fileChangeBy, txtChgNmFixedStr.Text, chkChgNmIsRegex.Checked);
                    break;
                case FileChangeRule.Wildcard:
                    retVal.SetFunctionRule(fileChangeBy,
                                           perfixStr: txtChgNmPerfixStr.Text,
                                           suffixStr: txtChgNmSuffixStr.Text,
                                           startNum: (int)numChgNmStartNum.Value,
                                           wildcardLen: (int)numChgNmWildcardLen.Value,
                                           onlyFixStr: chkChgNmOnlyFixStr.Checked);
                    break;
                case FileChangeRule.SpecList:
                    retVal.SetFunctionRule(fileChangeBy, specChgList: _fileChangeNameChangeList);
                    break;
            }

            return retVal;
        }