async void FtrExecuteBtnClick(object sender, EventArgs e) { if (FileRadio.Checked && File.Exists(FilePathTxb.Text)) { WdTools = WdTools ?? new WordTools(); int result = await WdTools.InsertFooter(FilePathTxb.Text, footerContentTxb.Text, footerFont); Console.WriteLine("Done."); } else { if (!FileRadio.Checked && Directory.Exists(FilePathTxb.Text)) { //TODO implement Program.GetFiles(string dir, string pattern, ref List<string> files) string[] Files; Files = RecursiveChkb.Checked ? Directory.GetFiles(FilePathTxb.Text, "*.docx", SearchOption.AllDirectories) : Directory.GetFiles(FilePathTxb.Text, "*.docx"); foreach (string FileName in Files) { WdTools = WdTools ?? new WordTools(); int result = await WdTools.InsertFooter(FileName, footerContentTxb.Text, footerFont); } Console.WriteLine("Done."); } } }
private async void WdExecuteBtnClick(object sender, EventArgs e) { string Action = ""; if (this.XpathFragmRadio.Checked) { Action = "XpathReplaceFragment"; } if (this.XpathExactRadio.Checked) { Action = "XpathReplaceExact"; } if (this.TextReplRadio.Checked) { Action = "TextReplace"; } WdTools = WdTools ?? new WordTools(); if (FileRadio.Checked && File.Exists(FilePathTxb.Text)) { var result = (System.Threading.Tasks.Task <int>)WdTools.GetType().GetMethod(Action).Invoke(WdTools, new object[] { FilePathTxb.Text, wdOldTextb.Text, wdNewTextb.Text }); await result; Console.WriteLine("Done."); } else { if (!FileRadio.Checked && Directory.Exists(FilePathTxb.Text)) { string[] Files; Files = RecursiveChkb.Checked ? Directory.GetFiles(FilePathTxb.Text, "*.docx", SearchOption.AllDirectories) : Directory.GetFiles(FilePathTxb.Text, "*.docx"); foreach (string FileName in Files) { var result = (System.Threading.Tasks.Task <int>)WdTools.GetType().GetMethod(Action).Invoke(WdTools, new object[] { FileName, wdOldTextb.Text, wdNewTextb.Text }); await result; } Console.WriteLine("Done."); } } }
private async void StatsExecuteBtnClick(object sender, EventArgs e) { if (FileRadio.Checked && File.Exists(FilePathTxb.Text)) { WdTools = WdTools ?? new WordTools(); int result = await WdTools.PrintDocxStats(FilePathTxb.Text, this.statsXpathChkb.Checked, this.statsSectionsChkb.Checked, this.statsFooterHeadersChkb.Checked); } else { if (!FileRadio.Checked && Directory.Exists(FilePathTxb.Text)) { //TODO implement Program.GetFiles(string dir, string pattern, ref List<string> files) string[] Files; Files = RecursiveChkb.Checked ? Directory.GetFiles(FilePathTxb.Text, "*.docx", SearchOption.AllDirectories) : Directory.GetFiles(FilePathTxb.Text, "*.docx"); foreach (string FileName in Files) { WdTools = WdTools ?? new WordTools(); int result = await WdTools.PrintDocxStats(FileName, this.statsXpathChkb.Checked, this.statsSectionsChkb.Checked, this.statsFooterHeadersChkb.Checked); } } } Console.WriteLine("Done."); }