/// <summary>
        /// 承接段尾合并方法
        /// </summary>
        /// <param name="obj"></param>
        private void DocParagraphMergeMethod(object obj)
        {
            try
            {
                FileMergeModel fileMergeModel = obj as FileMergeModel;
                //实例化Document对象
                Document doc = new Document();
                doc.InsertTextFromFile(fileMergeModel.mergeFileList[0].fileSrc, FileFormat.Auto);

                //遍历进行合并
                for (var i = 1; i < fileMergeModel.mergeFileList.Count; i++)
                {
                    Section lastSection = doc.LastSection;//获取doc的最后一个section

                    Document currDoc = new Document(fileMergeModel.mergeFileList[i].fileSrc);

                    //遍历currDoc的section和段落,将每一个段落添加到doc的最后一个section
                    foreach (Section section in currDoc.Sections)
                    {
                        foreach (Paragraph paragraph in section.Paragraphs)
                        {
                            lastSection.Paragraphs.Add(paragraph.Clone() as Paragraph);
                        }
                    }
                }
                doc.SaveToFile(fileMergeModel.mergeFileSrc, FileFormat.Auto);//保存为新的文档
                ShowMessage.ShowContent(ChangeLanguage.getLanguage("ExecutionCompleted"), showTitle);
            }
            catch (Exception ex)
            {
                ShowMessage.ShowError(ex.Message, showTitle);
            }
        }
 /// <summary>
 /// 获取文件信息
 /// </summary>
 /// <param name="path">文件路径</param>
 private void GetFileInfo(string path)
 {
     System.IO.FileInfo fileInfo = null;
     try
     {
         fileInfo = new System.IO.FileInfo(path);
     }
     catch (Exception ex)
     {
         ShowMessage.ShowError(ex.Message, showTitle);
     }
     // 如果文件存在
     if (fileInfo != null && fileInfo.Exists)
     {
         ListViewItem item = new ListViewItem(path);
         item.SubItems.Add(fileInfo.Name);
         item.SubItems.Add(fileInfo.Extension);
         item.SubItems.Add(fileInfo.Length.ToString());
         lv_File.Items.Add(item);
     }
     else
     {
         ShowMessage.ShowError(ChangeLanguage.getLanguage("FilePathError"), showTitle);
     }
 }
 private void AboutForm_Load(object sender, EventArgs e)
 {
     this.Text           = ChangeLanguage.getLanguage("About");
     lbl_Version.Text    = ChangeLanguage.getLanguage("ToolVersion");
     lbl_VersionAll.Text = ChangeLanguage.getLanguage("VersionAll");
     lbl_CopyRight.Text  = ChangeLanguage.getLanguage("CopyRight");
 }
Example #4
0
    void GenerateIconPlacements()
    {
        float   angle        = 360f / (float)selectedVeggies.Count;
        Vector3 targetVector = Vector3.up;

        for (int i = 0; i < selectedVeggies.Count; i++)
        {
            targetVector = Quaternion.Euler(0, 0, angle) * targetVector;

            GameObject go;

            if (findWordToMatchImage)
            {
                go = Instantiate(textObject, transform);
                ClickMethodContainer cmc = go.GetComponent <ClickMethodContainer> ();
                go.GetComponent <Text> ().text = (isCurrentlyDanish ? selectedVeggies [i].danishName : selectedVeggies [i].englishName);
                go.GetComponent <Button> ().onClick.AddListener(cmc.OnClick);
                cmc.danish  = selectedVeggies [i].danishName;
                cmc.english = selectedVeggies [i].englishName;

                ChangeToLanguage += cmc.UpdateLanguage;
            }
            else
            {
                go = Instantiate(imageObject, transform);
                ClickMethodContainer cmc = go.GetComponent <ClickMethodContainer> ();
                go.GetComponent <Image> ().sprite = selectedVeggies [i].vegetableImage;
                go.GetComponent <Button> ().onClick.AddListener(cmc.OnClick);
            }

            go.transform.localPosition = Camera.main.ViewportToScreenPoint(targetVector) * 0.3f;
        }
    }
 /// <summary>
 /// 必填项验证
 /// </summary>
 /// <returns></returns>
 private bool RequiredVerification()
 {
     if (string.IsNullOrWhiteSpace(txt_SelectFile.Text))
     {
         ShowMessage.ShowContent(ChangeLanguage.getLanguage("SelectFile"), showTitle);
         return(false);
     }
     if (string.IsNullOrWhiteSpace(txt_Src.Text))
     {
         ShowMessage.ShowContent(ChangeLanguage.getLanguage("SelectFileSavePath"), showTitle);
         return(false);
     }
     if (string.IsNullOrWhiteSpace(txt_FileName.Text))
     {
         ShowMessage.ShowContent(ChangeLanguage.getLanguage("EnterFileName"), showTitle);
         return(false);
     }
     if (cb_WaterMark.Checked)
     {
         if (string.IsNullOrWhiteSpace(txt_WaterMark.Text))
         {
             ShowMessage.ShowContent(ChangeLanguage.getLanguage("EnterCustomContent"), showTitle);
             return(false);
         }
     }
     return(true);
 }
        private void Inits()
        {
            gb_Main.Text        = ChangeLanguage.getLanguage("FilesMerged");
            gb_fileList.Text    = ChangeLanguage.getLanguage("FileList");
            gb_Operating.Text   = ChangeLanguage.getLanguage("Operating");
            btn_AddFile.Text    = ChangeLanguage.getLanguage("Add");
            btn_RemoveFile.Text = ChangeLanguage.getLanguage("Remove");
            btn_Clean.Text      = ChangeLanguage.getLanguage("Clear");
            btn_UpFile.Text     = ChangeLanguage.getLanguage("MoveUp");
            btn_DownFile.Text   = ChangeLanguage.getLanguage("MoveDown");

            lbl_FileName.Text  = ChangeLanguage.getLanguage("FileName") + ":";
            lbl_FilePath.Text  = ChangeLanguage.getLanguage("FilePath") + ":";
            btn_SelectSrc.Text = ChangeLanguage.getLanguage("Browse");
            btn_Merge.Text     = ChangeLanguage.getLanguage("Merge");

            rbtn_WorkBook.Text  = ChangeLanguage.getLanguage("MultipleWorkbookMerges");
            rbtn_WorkSheet.Text = ChangeLanguage.getLanguage("MultipleWorksheetsMerges");

            lv_File.GridLines     = true;
            lv_File.View          = View.Details;                   //显示列名称
            lv_File.FullRowSelect = true;
            lv_File.HeaderStyle   = ColumnHeaderStyle.Nonclickable; //隐藏列标题
            lv_File.Columns.Add(ChangeLanguage.getLanguage("FilePath"), 350, System.Windows.Forms.HorizontalAlignment.Center);
            lv_File.Columns.Add(ChangeLanguage.getLanguage("FileName"), 150, System.Windows.Forms.HorizontalAlignment.Center);
            lv_File.Columns.Add(ChangeLanguage.getLanguage("FileType"), 150, System.Windows.Forms.HorizontalAlignment.Center);
            lv_File.Columns.Add(ChangeLanguage.getLanguage("FileSize"), 200, System.Windows.Forms.HorizontalAlignment.Center);
        }
 void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
 }
        private void btn_DownFile_Click(object sender, EventArgs e)
        {
            if (lv_File.SelectedItems.Count == 0)
            {
                ShowMessage.ShowContent(ChangeLanguage.getLanguage("SelectItemToMove"), showTitle);
                return;
            }
            if (lv_File.SelectedItems[lv_File.SelectedItems.Count - 1].Index == (lv_File.Items.Count - 1))
            {
                ShowMessage.ShowContent(ChangeLanguage.getLanguage("LastItemCannotMove"), showTitle);
                return;
            }

            lv_File.BeginUpdate();
            int count = lv_File.SelectedItems.Count;

            foreach (ListViewItem file in lv_File.SelectedItems)
            {
                ListViewItem item  = file;
                int          index = file.Index;
                lv_File.Items.RemoveAt(index);
                lv_File.Items.Insert(index + count, item);
            }
            lv_File.EndUpdate();
        }
Example #9
0
        private void Inits()
        {
            try
            {
                #region 源语言
                List <ComboBoxModel> formList = new List <ComboBoxModel>();
                for (int i = 0; i < 14; i++)
                {
                    ComboBoxModel cbBox = new ComboBoxModel()
                    {
                        text = ChangeLanguage.getLanguage("lang_" + (i + 1).ToString()), value = i.ToString()
                    };
                    formList.Add(cbBox);
                }

                if (cbBox_Form.Items.Count > 0)
                {
                    cbBox_Form.DataSource = null;
                    cbBox_Form.Items.Clear();
                }
                cbBox_Form.DataSource    = formList;
                cbBox_Form.DisplayMember = "text";
                cbBox_Form.ValueMember   = "value";
                cbBox_Form.SelectedValue = "0";
                #endregion

                #region 翻译语言
                List <ComboBoxModel> toList = new List <ComboBoxModel>();
                for (int i = 0; i < 13; i++)
                {
                    ComboBoxModel toCbBox = new ComboBoxModel()
                    {
                        text = ChangeLanguage.getLanguage("lang_" + (i + 2).ToString()), value = i.ToString()
                    };
                    toList.Add(toCbBox);
                }

                if (cbBox_To.Items.Count > 0)
                {
                    cbBox_To.DataSource = null;
                    cbBox_To.Items.Clear();
                }
                cbBox_To.DataSource    = toList;
                cbBox_To.DisplayMember = "text";
                cbBox_To.ValueMember   = "value";
                cbBox_To.SelectedValue = "0";
                #endregion

                gb_Translation.Text  = ChangeLanguage.getLanguage("Translation");
                btn_Translation.Text = ChangeLanguage.getLanguage("Translation");
                this.Text            = ChangeLanguage.getLanguage("TranslationTool");
                lbl_Note.Text        = ChangeLanguage.getLanguage("TranslationNote");
            }
            catch (Exception ex)
            {
                ShowMessage.ShowError(ex.Message, showTitle);
            }
        }
Example #10
0
 private void ContactForm_Load(object sender, EventArgs e)
 {
     this.Text           = ChangeLanguage.getLanguage("Contact");
     btn_CopyQQ.Text     = ChangeLanguage.getLanguage("CopyToClipboard");
     btn_CopyWechat.Text = ChangeLanguage.getLanguage("CopyToClipboard");
     btn_CopyEmail.Text  = ChangeLanguage.getLanguage("CopyToClipboard");
     btn_CopyPhone.Text  = ChangeLanguage.getLanguage("CopyToClipboard");
     lklbl_Note.Text     = ChangeLanguage.getLanguage("ContactNote");
 }
        /// <summary>
        /// 分割方法
        /// </summary>
        /// <param name="obj"></param>
        private void SplitFileThread(object obj)
        {
            FileSplitModel fileSplitModel = obj as FileSplitModel;

            //文件判断
            string outFile = @fileSplitModel.fileSrc;

            if (File.Exists(outFile))
            {
                File.Delete(outFile);
            }
            if (!System.IO.File.Exists(outFile))
            {
                FileStream fs;
                fs = File.Create(outFile);
                fs.Close();
            }

            //新建文件流按照指定的块数分割文件
            using (FileStream newFileStream = new FileStream(outFile, FileMode.OpenOrCreate, FileAccess.Write))
            {
                int fileData     = 0;
                int bufferLength = Convert.ToInt32(fileSplitModel.fileLength);


                //指定byte数组大小
                byte[] buffer = new byte[bufferLength];

                //读取指定大小的流
                if ((fileData = fileStream.Read(buffer, fileSplitModel.fileStreamReadOffset, buffer.Length)) > 0)
                {
                    //转换为默认编码的流
                    BinaryWriter bw = new BinaryWriter(newFileStream, Encoding.UTF8);

                    if (cb_CustomContent.Checked && !string.IsNullOrWhiteSpace(txt_CustomContent.Text))
                    {
                        bw.Write(txt_CustomContent.Text.Trim());
                    }

                    //将字节数组写入流
                    bw.Write(buffer, 0, fileData);
                    bw.Flush();
                    bw.Dispose();
                    bw.Close();
                }
                else
                {
                    ShowMessage.ShowError(string.Format(ChangeLanguage.getLanguage("SplitPrompt"), outFile), showTitle);
                    return;
                }
                if (fileSplitModel.fileIndex == -1)
                {
                    ShowMessage.ShowContent(ChangeLanguage.getLanguage("ExecutionCompleted"), showTitle);
                }
            }
        }
        /// <summary>
        /// 合并文件方法
        /// </summary>
        /// <param name="obj"></param>
        private void MergeFileThread(object obj)
        {
            FileMergeModel    fileMergeModel = obj as FileMergeModel;
            List <MergeModel> list           = new List <MergeModel>();

            list = fileMergeModel.mergeFileList;
            //文件判断
            string outFile = fileMergeModel.mergeFileSrc;

            if (File.Exists(outFile))
            {
                File.Delete(outFile);
            }
            using (FileStream fileOut = new FileStream(fileMergeModel.mergeFileSrc, FileMode.Create, FileAccess.ReadWrite))
            {
                //转换为默认编码的流
                BinaryWriter bw = new BinaryWriter(fileOut, Encoding.UTF8);
                foreach (MergeModel item in list)
                {
                    try
                    {
                        //创建文件
                        FileStream fileStream = new FileStream(item.fileSrc, FileMode.Open, FileAccess.Read, FileShare.Read);
                        //设置当前流的位置,即开始位置
                        fileStream.Seek(0, SeekOrigin.Begin);

                        int fileData = 0;
                        //指定byte数组大小
                        byte[] buffer = new byte[fileStream.Length];
                        //读取指定大小的流
                        if ((fileData = fileStream.Read(buffer, 0, buffer.Length)) > 0)
                        {
                            //将字节数组写入流
                            bw.Write(buffer, 0, fileData);
                        }
                        if (item.fileIndex == -1)
                        {
                            ShowMessage.ShowContent(ChangeLanguage.getLanguage("ExecutionCompleted"), showTitle);
                            bw.Flush();
                            bw.Dispose();
                            bw.Close();
                            fileOut.Close();
                        }
                    }
                    catch (System.Exception ex)
                    {
                        ShowMessage.ShowError(ex.Message, showTitle);
                        fileOut.Close();
                        return;
                    }
                    finally
                    { }
                }
            }
        }
Example #13
0
 // Use this for initialization
 void Start()
 {
     changeLanguage = GetComponent <ChangeLanguage>();
     gm             = GameObject.Find("GameManager").GetComponent <AudioSource>();
     music.value    = gm.volume * 100;
     //manageVolume(); print("music.value == "+music.value);
     language          = GameObject.Find("GameManager").GetComponent <LangageLoader>().language;
     ressourceGameMode = GameObject.Find("RessourceRaceControl");
     _maxResources     = GameObject.Find("GameManager").GetComponent <GameManager>()._maxResources;
     nbrResources.text = Convert.ToString(GameObject.Find("GameManager").GetComponent <GameManager>()._maxResources);
 }
        private void Inits()
        {
            try
            {
                #region 初始化转换类型
                List <ComboBoxModel> list = new List <ComboBoxModel>();
                for (int i = 0; i < 13; i++)
                {
                    ComboBoxModel cbBoxModel = new ComboBoxModel();
                    cbBoxModel.text  = ChangeLanguage.getLanguage("FormatType" + i.ToString());
                    cbBoxModel.value = i.ToString();
                    list.Add(cbBoxModel);
                }
                if (cbBox_ConvertType.Items.Count > 0)
                {
                    cbBox_ConvertType.DataSource = null;
                    cbBox_ConvertType.Items.Clear();
                }
                cbBox_ConvertType.DataSource    = list;
                cbBox_ConvertType.DisplayMember = "text";
                cbBox_ConvertType.ValueMember   = "value";
                cbBox_ConvertType.SelectedIndex = 0;
                #endregion

                #region 初始化文件列表
                lv_File.GridLines     = true;
                lv_File.View          = View.Details;                   //显示列名称
                lv_File.FullRowSelect = true;
                lv_File.HeaderStyle   = ColumnHeaderStyle.Nonclickable; //隐藏列标题
                lv_File.Columns.Add(ChangeLanguage.getLanguage("FilePath"), 350, System.Windows.Forms.HorizontalAlignment.Center);
                lv_File.Columns.Add(ChangeLanguage.getLanguage("FileName"), 150, System.Windows.Forms.HorizontalAlignment.Center);
                lv_File.Columns.Add(ChangeLanguage.getLanguage("FileType"), 150, System.Windows.Forms.HorizontalAlignment.Center);
                lv_File.Columns.Add(ChangeLanguage.getLanguage("FileSize"), 200, System.Windows.Forms.HorizontalAlignment.Center);
                #endregion

                btn_SaveSrc.Text     = ChangeLanguage.getLanguage("Browse");
                lbl_Number.Text      = "+ " + ChangeLanguage.getLanguage("SerialNumber");
                btn_AddFile.Text     = ChangeLanguage.getLanguage("Add");
                btn_RemoveFile.Text  = ChangeLanguage.getLanguage("Remove");
                btn_Clean.Text       = ChangeLanguage.getLanguage("Clear");
                gb_fileList.Text     = ChangeLanguage.getLanguage("FileList");
                gb_Main.Text         = ChangeLanguage.getLanguage("FilesConvert");
                gb_Operating.Text    = ChangeLanguage.getLanguage("Operating");
                btn_Convert.Text     = ChangeLanguage.getLanguage("Convert");
                lbl_FileName.Text    = ChangeLanguage.getLanguage("FileName") + ":";
                lbl_FilePath.Text    = ChangeLanguage.getLanguage("FilePath") + ":";
                lbl_ConvertType.Text = ChangeLanguage.getLanguage("ConvertType") + ":";
                this.Text            = ChangeLanguage.getLanguage("FileFormatConversionTool");
            }
            catch (Exception ex)
            {
                ShowMessage.ShowError(ex.Message, showTitle);
            }
        }
Example #15
0
 private void btn_CopyPhone_Click(object sender, EventArgs e)
 {
     try
     {
         Clipboard.SetDataObject(lbl_Phone.Text.Split(':')[1]);
         ShowMessage.ShowContent(ChangeLanguage.getLanguage("CopyPhoneNumber"), showTitle);
     }
     catch (Exception ex)
     {
         ShowMessage.ShowError(ex.Message, showTitle);
     }
 }
 private void btn_RemoveFile_Click(object sender, EventArgs e)
 {
     if (lv_File.SelectedItems.Count == 0)
     {
         ShowMessage.ShowContent(ChangeLanguage.getLanguage("SelectItemToRemove"), showTitle);
         return;
     }
     foreach (ListViewItem item in lv_File.SelectedItems)
     {
         item.Remove();//删除方法
     }
 }
        private void btn_Merge_Click(object sender, EventArgs e)
        {
            if (!RequiredVerification())
            {
                return;
            }
            if (ShowMessage.ShowConfirm(ChangeLanguage.getLanguage("ConfirmExecution"), showTitle) == DialogResult.OK)
            {
                double            totalSize      = 0;
                FileMergeModel    fileMergeModel = new FileMergeModel();
                List <MergeModel> list           = new List <MergeModel>();
                foreach (ListViewItem item in lv_File.Items)
                {
                    MergeModel model = new MergeModel();
                    model.fileSrc       = item.SubItems[0].Text;
                    model.fileName      = item.SubItems[1].Text;
                    model.fileExtension = item.SubItems[2].Text;
                    model.fileLength    = item.SubItems[3].Text;
                    if (item.Index == lv_File.Items.Count - 1)
                    {
                        model.fileIndex = -1;
                    }
                    else
                    {
                        model.fileIndex = item.Index;
                    }
                    totalSize += double.Parse(model.fileLength);
                    list.Add(model);
                }
                fileMergeModel.mergeFileList      = list;
                fileMergeModel.mergeFilePath      = txt_FilePath.Text;
                fileMergeModel.mergeFileName      = txt_FileName.Text.Trim();
                fileMergeModel.mergeFileExtension = lv_File.Items[0].SubItems[2].Text;
                fileMergeModel.mergeFileSrc       = fileMergeModel.mergeFilePath + @"\" + fileMergeModel.mergeFileName + fileMergeModel.mergeFileExtension;
                if (totalSize > 21474836480)
                {
                    ShowMessage.ShowContent(ChangeLanguage.getLanguage("MergeFileSizeLimit"), showTitle);
                    return;
                }

                if (rbtn_WorkBook.Checked)
                {
                    WorkBookMergeMethodInvoker mergeWorkBookMethod = new WorkBookMergeMethodInvoker(WorkBookMergeMethod);
                    this.BeginInvoke(mergeWorkBookMethod, new object[] { fileMergeModel });
                }
                else if (rbtn_WorkSheet.Checked)
                {
                    WorkSheetMergeMethodInvoker mergeWorkSheetMethod = new WorkSheetMergeMethodInvoker(WorkSheetMergeMethod);
                    this.BeginInvoke(mergeWorkSheetMethod, new object[] { fileMergeModel });
                }
            }
        }
Example #18
0
 void Clear()
 {
     foreach (Transform t in transform.GetComponentsInChildren <Transform>())
     {
         if (t != transform && t != correct && t != wrong)
         {
             if (t.GetComponent <ClickMethodContainer> () != null)
             {
                 ChangeToLanguage -= t.GetComponent <ClickMethodContainer> ().UpdateLanguage;
             }
             Destroy(t.gameObject);
         }
     }
 }
        private void Inits()
        {
            gb_BaseInfo.Text       = ChangeLanguage.getLanguage("BasicInformation");
            lbl_File.Text          = ChangeLanguage.getLanguage("SplitFile") + ":";
            lbl_FilePath.Text      = ChangeLanguage.getLanguage("FilePath") + ":";
            lbl_FileName.Text      = ChangeLanguage.getLanguage("FileName") + ":";
            lbl_FileSize.Text      = ChangeLanguage.getLanguage("FileLength") + ":";
            gb_SplitType.Text      = ChangeLanguage.getLanguage("SplitMethod");
            rbtn_PageBreak.Text    = ChangeLanguage.getLanguage("FileLength") + ":";
            rbtn_SectionBreak.Text = ChangeLanguage.getLanguage("FileCount") + ":";
            btn_Split.Text         = ChangeLanguage.getLanguage("Split");
            btn_SelectFile.Text    = ChangeLanguage.getLanguage("Browse");
            btn_SelectSrc.Text     = ChangeLanguage.getLanguage("Browse");
            lbl_Number.Text        = "+ " + ChangeLanguage.getLanguage("SerialNumber");
            rbtn_PageBreak.Text    = ChangeLanguage.getLanguage("PageBreakSplit");
            rbtn_SectionBreak.Text = ChangeLanguage.getLanguage("SectionBreakSplit");
            cb_WaterMark.Text      = ChangeLanguage.getLanguage("AddTextWatermark");
            lbl_Layout.Text        = ChangeLanguage.getLanguage("LayoutMethod") + ":";
            lbl_Color.Text         = ChangeLanguage.getLanguage("WatermarkColor") + ":";
            lbl_FontSize.Text      = ChangeLanguage.getLanguage("FontSize") + ":";
            btn_Color.Text         = ChangeLanguage.getLanguage("ChooseColor");
            btn_FontSize.Text      = ChangeLanguage.getLanguage("ChooseFontSize");

            #region 水印排列方式
            try
            {
                IList <ComboBoxModel> comboxList = new List <ComboBoxModel>();
                ComboBoxModel         box1       = new ComboBoxModel()
                {
                    value = "0", text = ChangeLanguage.getLanguage("WatermarkLayoutDiagonal")
                };
                ComboBoxModel box2 = new ComboBoxModel()
                {
                    value = "1", text = ChangeLanguage.getLanguage("WatermarkLayoutHorizontal")
                };
                comboxList.Add(box1);
                comboxList.Add(box2);
                cbBox_Layout.Items.Clear();
                cbBox_Layout.DataSource    = comboxList;
                cbBox_Layout.ValueMember   = "value";
                cbBox_Layout.DisplayMember = "text";
            }
            catch (Exception ex)
            {
                ShowMessage.ShowError(ex.Message, showTitle);
            }
            #endregion
        }
 private void btn_Split_Click(object sender, EventArgs e)
 {
     if (!RequiredVerification())
     {
         return;
     }
     if (ShowMessage.ShowConfirm(ChangeLanguage.getLanguage("ConfirmExecution"), showTitle) == DialogResult.OK)
     {
         FileSplitModel splitModel = new FileSplitModel();
         splitModel.filePath      = txt_SelectFile.Text.Trim();
         splitModel.fileOutPath   = txt_Src.Text.Trim();
         splitModel.fileName      = txt_FileName.Text.Trim();
         splitModel.fileExtension = splitModel.filePath.Substring(splitModel.filePath.LastIndexOf('.'));
         if (cb_WaterMark.Checked)
         {
             WaterMarkModel waterModel = new WaterMarkModel();
             waterModel.waterMarkContent  = txt_WaterMark.Text.Trim();
             waterModel.waterMarkColor    = txt_Color.Text.Trim();
             waterModel.waterMarkFontSize = float.Parse(txt_FontSize.Text.Trim());
             waterModel.waterMarkLayout   = int.Parse(cbBox_Layout.SelectedValue.ToString());
             splitModel.fileWaterMark     = waterModel;
         }
         if (rbtn_SectionBreak.Checked)//分节符
         {
             try
             {
                 SplitSectionMethodInvoker splitSectionMethod = new SplitSectionMethodInvoker(SplitSectionBreak);
                 this.BeginInvoke(splitSectionMethod, new object[] { splitModel });
             }
             catch (Exception ex)
             {
                 ShowMessage.ShowError(ex.Message, showTitle);
             }
         }
         else if (rbtn_PageBreak.Checked)//分页符
         {
             try
             {
                 SplitPageMethodInvoker splitPageMethod = new SplitPageMethodInvoker(SplitPageBreak);
                 this.BeginInvoke(splitPageMethod, new object[] { splitModel });
             }
             catch (Exception ex)
             {
                 ShowMessage.ShowError(ex.Message, showTitle);
             }
         }
     }
 }
 /// <summary>
 /// 必填项验证
 /// </summary>
 /// <returns></returns>
 private bool RequiredVerification()
 {
     if (string.IsNullOrWhiteSpace(txt_SelectFile.Text))
     {
         ShowMessage.ShowContent(ChangeLanguage.getLanguage("SelectFile"), showTitle);
         return(false);
     }
     if (string.IsNullOrWhiteSpace(txt_Src.Text))
     {
         ShowMessage.ShowContent(ChangeLanguage.getLanguage("SelectFileSavePath"), showTitle);
         return(false);
     }
     if (string.IsNullOrWhiteSpace(txt_FileName.Text))
     {
         ShowMessage.ShowContent(ChangeLanguage.getLanguage("EnterFileName"), showTitle);
         return(false);
     }
     if (rbtn_FixedRows.Checked)
     {
         Regex regex  = new Regex(@"^[1-9]\d*$");
         Regex regexs = new Regex(@"^[0-9]\d*$");
         if (string.IsNullOrWhiteSpace(txt_FixedRowsBegin.Text))
         {
             ShowMessage.ShowContent(ChangeLanguage.getLanguage("RowsCannotBeEmpty"), showTitle);
             return(false);
         }
         if (string.IsNullOrWhiteSpace(txt_FixedRowsEnd.Text))
         {
             ShowMessage.ShowContent(ChangeLanguage.getLanguage("RowsCannotBeEmpty"), showTitle);
             return(false);
         }
         if (!regex.IsMatch(txt_FixedRowsBegin.Text) || !regexs.IsMatch(txt_FixedRowsEnd.Text))
         {
             ShowMessage.ShowContent(ChangeLanguage.getLanguage("RowsWrongFormat"), showTitle);
             return(false);
         }
         if (rbtn_FixedRowsDesignation.Checked)
         {
             if (cbBox_FixedRowsWorkSheet.SelectedItem == null)
             {
                 ShowMessage.ShowContent(ChangeLanguage.getLanguage("ChooseWorksheet"), showTitle);
                 return(false);
             }
         }
     }
     return(true);
 }
 private void Inits()
 {
     gb_BaseInfo.Text      = ChangeLanguage.getLanguage("BasicInformation");
     lbl_File.Text         = ChangeLanguage.getLanguage("SplitFile") + ":";
     lbl_FilePath.Text     = ChangeLanguage.getLanguage("FilePath") + ":";
     lbl_FileName.Text     = ChangeLanguage.getLanguage("FileName") + ":";
     lbl_FileSize.Text     = ChangeLanguage.getLanguage("FileLength") + ":";
     gb_SplitType.Text     = ChangeLanguage.getLanguage("SplitMethod");
     rbtn_Size.Text        = ChangeLanguage.getLanguage("FileLength") + ":";
     lbl_FileCount.Text    = ChangeLanguage.getLanguage("FileCount") + ":";
     rbtn_Total.Text       = ChangeLanguage.getLanguage("FileCount") + ":";
     lbl_FileLength.Text   = ChangeLanguage.getLanguage("FileLength") + ":";
     cb_CustomContent.Text = ChangeLanguage.getLanguage("SplitCustomOptions");
     btn_Split.Text        = ChangeLanguage.getLanguage("Split");
     btn_SelectFile.Text   = ChangeLanguage.getLanguage("Browse");
     btn_SelectSrc.Text    = ChangeLanguage.getLanguage("Browse");
     lbl_Number.Text       = "+ " + ChangeLanguage.getLanguage("SerialNumber");
 }
        private void btn_SelectSrc_Click(object sender, EventArgs e)
        {
            FolderBrowserDialog folderDialog = new FolderBrowserDialog();

            folderDialog.Description = ChangeLanguage.getLanguage("SelectFileSavePath");
            try
            {
                if (folderDialog.ShowDialog() == DialogResult.OK)
                {
                    string folderSrc = folderDialog.SelectedPath;
                    txt_FilePath.Text = folderSrc;
                }
            }
            catch (Exception ex)
            {
                ShowMessage.ShowError(ex.Message, showTitle);
            }
        }
 /// <summary>
 /// 必填项验证
 /// </summary>
 /// <returns></returns>
 private bool RequiredVerification()
 {
     if (string.IsNullOrWhiteSpace(txt_SelectFile.Text))
     {
         ShowMessage.ShowContent(ChangeLanguage.getLanguage("SelectFile"), showTitle);
         return(false);
     }
     if (string.IsNullOrWhiteSpace(txt_Src.Text))
     {
         ShowMessage.ShowContent(ChangeLanguage.getLanguage("SelectFileSavePath"), showTitle);
         return(false);
     }
     if (string.IsNullOrWhiteSpace(txt_FileName.Text))
     {
         ShowMessage.ShowContent(ChangeLanguage.getLanguage("EnterFileName"), showTitle);
         return(false);
     }
     if (rbtn_Size.Checked)
     {
         if (string.IsNullOrWhiteSpace(txt_FixedSize.Text))
         {
             ShowMessage.ShowContent(ChangeLanguage.getLanguage("EnterFileSize"), showTitle);
             return(false);
         }
     }
     else if (rbtn_Total.Checked)
     {
         if (string.IsNullOrWhiteSpace(txt_FixedTotal.Text))
         {
             ShowMessage.ShowContent(ChangeLanguage.getLanguage("EnterFileCount"), showTitle);
             return(false);
         }
     }
     if (cb_CustomContent.Checked)
     {
         if (string.IsNullOrWhiteSpace(txt_CustomContent.Text))
         {
             ShowMessage.ShowContent(ChangeLanguage.getLanguage("EnterCustomContent"), showTitle);
             return(false);
         }
     }
     return(true);
 }
 /// <summary>
 /// 必填项验证
 /// </summary>
 /// <returns></returns>
 private bool RequiredVerification()
 {
     if (string.IsNullOrWhiteSpace(txt_FileName.Text))
     {
         ShowMessage.ShowContent(ChangeLanguage.getLanguage("EnterFileName"), showTitle);
         return(false);
     }
     if (string.IsNullOrWhiteSpace(txt_FilePath.Text))
     {
         ShowMessage.ShowContent(ChangeLanguage.getLanguage("SelectFileSavePath"), showTitle);
         return(false);
     }
     if (lv_File.Items.Count == 0)
     {
         ShowMessage.ShowContent(ChangeLanguage.getLanguage("AddFileToMerge"), showTitle);
         return(false);
     }
     return(true);
 }
        /// <summary>
        /// 根据分节符进行分割方法
        /// </summary>
        /// <param name="obj"></param>
        private void SplitSectionBreak(object obj)
        {
            try
            {
                FileSplitModel splitModel = obj as FileSplitModel;
                //实例化Document对象
                Document doc = new Document();
                //载入待拆分的Word文档
                doc.LoadFromFile(splitModel.filePath);
                Document newWord;
                int      index = 0;
                foreach (Section item in doc.Sections)
                {
                    newWord = new Document();           //每有一个section就创建一个新的文档
                    newWord.Sections.Add(item.Clone()); //复制section内容到新文档
                    if (splitModel.fileWaterMark != null)
                    {
                        TextWatermark txtWatermark = new TextWatermark();//新建一个TextWatermark对象,设置文本水印字样
                        txtWatermark.Text = splitModel.fileWaterMark.waterMarkContent;
                        //设置文本水印字体大小、颜色和文本排列方式
                        txtWatermark.FontSize = splitModel.fileWaterMark.waterMarkFontSize;
                        txtWatermark.Color    = Color.FromName(splitModel.fileWaterMark.waterMarkColor);
                        if (splitModel.fileWaterMark.waterMarkLayout == 0)
                        {
                            txtWatermark.Layout = WatermarkLayout.Diagonal;
                        }
                        else
                        {
                            txtWatermark.Layout = WatermarkLayout.Horizontal;
                        }

                        newWord.Watermark = txtWatermark;                                                                                        //将文本应用到Word文档水印
                    }
                    newWord.SaveToFile(splitModel.fileOutPath + @"\" + splitModel.fileName + index + splitModel.fileExtension, FileFormat.Auto); //保存文档
                    index++;
                }
                ShowMessage.ShowInfomation(ChangeLanguage.getLanguage("ExecutionCompleted"), showTitle);
            }
            catch (Exception ex)
            {
                ShowMessage.ShowError(ex.Message, showTitle);
            }
        }
        private void btn_Split_Click(object sender, EventArgs e)
        {
            if (!RequiredVerification())
            {
                return;
            }
            if (ShowMessage.ShowConfirm(ChangeLanguage.getLanguage("ConfirmExecution"), showTitle) == DialogResult.OK)
            {
                FileSplitModel fileSplitModel = new FileSplitModel();
                fileSplitModel.filePath      = txt_SelectFile.Text.Trim();
                fileSplitModel.fileOutPath   = txt_Src.Text.Trim();
                fileSplitModel.fileName      = txt_FileName.Text.Trim();
                fileSplitModel.fileExtension = fileSplitModel.filePath.Substring(fileSplitModel.filePath.LastIndexOf('.'));
                ExcelSplitModel excelModel = new ExcelSplitModel();
                if (rbtn_AllWorkBook.Checked)
                {
                    excelModel.splitType = 1;
                }
                else if (rbtn_FixedRows.Checked)
                {
                    excelModel.splitType = 2;
                    excelModel.sheetName = "";
                    excelModel.beginRow  = int.Parse(txt_FixedRowsBegin.Text.Trim());
                    excelModel.endRow    = int.Parse(txt_FixedRowsEnd.Text.Trim());
                    if (rbtn_FixedRowsDesignation.Checked)
                    {
                        ComboBoxModel model = cbBox_FixedRowsWorkSheet.SelectedItem as ComboBoxModel;
                        if (model == null)
                        {
                            ShowMessage.ShowError(ChangeLanguage.getLanguage("SpecifiedWorksheetCannotBeEmpty"), showTitle);
                            return;
                        }
                        excelModel.sheetName = model.text;
                    }
                }

                fileSplitModel.fileExcel = excelModel;

                SplitMethodInvoker splitAllMethod = new SplitMethodInvoker(SplitSheetMethod);
                this.BeginInvoke(splitAllMethod, new object[] { fileSplitModel });
            }
        }
        /// <summary>
        /// 添加新页合并方法
        /// </summary>
        /// <param name="obj"></param>
        private void DocPageMergeMethod(object obj)
        {
            try
            {
                FileMergeModel fileMergeModel = obj as FileMergeModel;
                //实例化Document对象
                Document doc = new Document();
                foreach (var mergeFile in fileMergeModel.mergeFileList)
                {
                    //使用InsertTextFromFile方法将文档合并到已创建的文档对象中
                    doc.InsertTextFromFile(mergeFile.fileSrc, FileFormat.Auto);
                }
                doc.SaveToFile(fileMergeModel.mergeFileSrc, FileFormat.Auto); //保存文档

                ShowMessage.ShowContent(ChangeLanguage.getLanguage("ExecutionCompleted"), showTitle);
            }
            catch (Exception ex)
            {
                ShowMessage.ShowError(ex.Message, showTitle);
            }
        }
 private void Inits()
 {
     gb_BaseInfo.Text                  = ChangeLanguage.getLanguage("BasicInformation");
     lbl_File.Text                     = ChangeLanguage.getLanguage("SplitFile") + ":";
     lbl_FilePath.Text                 = ChangeLanguage.getLanguage("FilePath") + ":";
     lbl_FileName.Text                 = ChangeLanguage.getLanguage("FileName") + ":";
     lbl_FileSize.Text                 = ChangeLanguage.getLanguage("FileLength") + ":";
     gb_SplitType.Text                 = ChangeLanguage.getLanguage("SplitMethod");
     btn_Split.Text                    = ChangeLanguage.getLanguage("Split");
     btn_SelectFile.Text               = ChangeLanguage.getLanguage("Browse");
     btn_SelectSrc.Text                = ChangeLanguage.getLanguage("Browse");
     lbl_Number.Text                   = "+ " + ChangeLanguage.getLanguage("SerialNumber");
     gb_SplitWay.Text                  = ChangeLanguage.getLanguage("SplitType");
     rbtn_AllWorkBook.Text             = ChangeLanguage.getLanguage("SplitAllWorksheetsIntoWorkbooks");
     rbtn_FixedRows.Text               = ChangeLanguage.getLanguage("SplitWorksheetIntoFixedRows");
     gb_FixedRows.Text                 = ChangeLanguage.getLanguage("SplitWorksheetIntoFixedRows");
     rbtn_FixedRowsAll.Text            = ChangeLanguage.getLanguage("AllWorksheets");
     rbtn_FixedRowsDesignation.Text    = ChangeLanguage.getLanguage("DesignatedWorksheet");
     lbl_FixedRows.Text                = ChangeLanguage.getLanguage("Rows") + ":";
     lbl_FixedRowsChooseWorkSheet.Text = ChangeLanguage.getLanguage("WorkSheet") + ":";
 }
        /// <summary>
        /// 工作簿合并
        /// </summary>
        /// <param name="obj"></param>
        private void WorkBookMergeMethod(object obj)
        {
            FileMergeModel fileMergeModel = obj as FileMergeModel;
            Workbook       workBook       = new Workbook();

            try
            {
                workBook.CreateEmptySheets(1);
                if (fileMergeModel != null && fileMergeModel.mergeFileList != null)
                {
                    foreach (var mergeFile in fileMergeModel.mergeFileList)
                    {
                        Workbook subWorkBook = new Workbook();
                        subWorkBook.LoadFromFile(mergeFile.fileSrc);
                        workBook.Worksheets.AddCopy(subWorkBook.Worksheets);
                        subWorkBook.Dispose();
                    }
                }
                workBook.Worksheets.RemoveAt(0);
                if (fileMergeModel.mergeFileExtension == ".xls")
                {
                    workBook.SaveToFile(fileMergeModel.mergeFileSrc, ExcelVersion.Version97to2003);
                }
                else
                {
                    workBook.SaveToFile(fileMergeModel.mergeFileSrc, ExcelVersion.Version2007);
                }
                workBook.Dispose();
                ShowMessage.ShowContent(ChangeLanguage.getLanguage("ExecutionCompleted"), showTitle);
            }
            catch (Exception ex)
            {
                workBook.Dispose();
                ShowMessage.ShowError(ex.Message, showTitle);
            }
        }