private void AddDirFile_Click(object sender, RoutedEventArgs e) { string dir = FileUtils.SelectDir(); if (!Utils.IsStrNull(dir)) { model.Dir = dir; DirClass dirClass = new DirClass(dir); if (model.IsDiGuiChaZhao) { AddFile(dirClass.FindFileAll()); } else { AddFile(dirClass.Files); } } }
/// <summary> /// 执行打印 /// </summary> /// <param name="print"></param> /// <param name="path"></param> /// <param name="horizontal"></param> private static void Print(PrintDocument print, string path, int Copies = 1, Duplex horizontal = Duplex.Simplex, string range = null) { print.DocumentName = Path.GetFileName(path); PrinterSettings settings = print.PrinterSettings; settings.Copies = (short)Copies; if (settings.CanDuplex) { settings.Duplex = horizontal; } else { settings.Duplex = Duplex.Simplex; } if (!Utils.IsStrNull(range)) { if (range.Contains("-")) { string[] array = range.Split('-'); int[] pageArray = new int[array.Length]; for (int a = 0; a < array.Length; a++) { if (Utils.IsInt(array[a])) { pageArray[a] = int.Parse(array[a]); } else { MessageBox.Show("你的输入有不是数字"); return; } } settings.FromPage = pageArray[0]; settings.ToPage = pageArray[1]; print.PrinterSettings.PrintRange = PrintRange.SomePages; print.Print(); } if (range.Contains("、")) { string[] array = range.Split('、'); int[] pageArray = new int[array.Length]; for (int a = 0; a < array.Length; a++) { if (Utils.IsInt(array[a])) { pageArray[a] = int.Parse(array[a]); } else { MessageBox.Show("你的输入有不是数字"); return; } } foreach (int pageInt in pageArray) { settings.FromPage = pageInt; settings.ToPage = pageInt + 1; print.PrinterSettings.PrintRange = PrintRange.SomePages; print.Print(); } } } else { print.Print(); } }