|
|
@ -36,6 +36,10 @@ namespace formula_manage.Windows |
|
|
WindowStartupLocation = WindowStartupLocation.CenterScreen; |
|
|
WindowStartupLocation = WindowStartupLocation.CenterScreen; |
|
|
InitializeComponent(); |
|
|
InitializeComponent(); |
|
|
cbxPrinter.ItemsSource = this.GetLocalPrinters(); //打印机搜索
|
|
|
cbxPrinter.ItemsSource = this.GetLocalPrinters(); //打印机搜索
|
|
|
|
|
|
cbxPrinter2.ItemsSource = this.GetLocalPrinters(); |
|
|
|
|
|
cbxPrinter3.ItemsSource = this.GetLocalPrinters(); |
|
|
|
|
|
cbxPrinter4.ItemsSource = this.GetLocalPrinters(); |
|
|
|
|
|
cbxPrinter5.ItemsSource = this.GetLocalPrinters(); |
|
|
this.Closing += Window_Closing; //添加窗口关闭事件
|
|
|
this.Closing += Window_Closing; //添加窗口关闭事件
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -45,6 +49,10 @@ namespace formula_manage.Windows |
|
|
string Log_time = "[" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "]:"; |
|
|
string Log_time = "[" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "]:"; |
|
|
|
|
|
|
|
|
bool Printer; |
|
|
bool Printer; |
|
|
|
|
|
bool Printer2; |
|
|
|
|
|
bool Printer3; |
|
|
|
|
|
bool Printer4; |
|
|
|
|
|
bool Printer5; |
|
|
|
|
|
|
|
|
private void Window_Print(object sender, RoutedEventArgs e) |
|
|
private void Window_Print(object sender, RoutedEventArgs e) |
|
|
{ |
|
|
{ |
|
|
@ -52,9 +60,31 @@ namespace formula_manage.Windows |
|
|
|
|
|
|
|
|
Printer = Boolean.Parse(Configini.IniReadvalue("PRINTER", "P1")); |
|
|
Printer = Boolean.Parse(Configini.IniReadvalue("PRINTER", "P1")); |
|
|
cbxPrinter.SelectedValue = Configini.IniReadvalue("PRINTER", "P2"); //读配置文件
|
|
|
cbxPrinter.SelectedValue = Configini.IniReadvalue("PRINTER", "P2"); //读配置文件
|
|
|
|
|
|
Print_path.Text = Configini.IniReadvalue("PRINTER", "P3"); |
|
|
|
|
|
Printer2 = Boolean.Parse(Configini.IniReadvalue("PRINTER", "P4")); |
|
|
|
|
|
Printer3 = Boolean.Parse(Configini.IniReadvalue("PRINTER", "P5")); |
|
|
|
|
|
Printer4 = Boolean.Parse(Configini.IniReadvalue("PRINTER", "P6")); |
|
|
|
|
|
Printer5 = Boolean.Parse(Configini.IniReadvalue("PRINTER", "P7")); |
|
|
|
|
|
cbxPrinter2.SelectedValue = Configini.IniReadvalue("PRINTER", "P8"); //读配置文件
|
|
|
|
|
|
cbxPrinter3.SelectedValue = Configini.IniReadvalue("PRINTER", "P9"); //读配置文件
|
|
|
|
|
|
cbxPrinter4.SelectedValue = Configini.IniReadvalue("PRINTER", "P10"); //读配置文件
|
|
|
|
|
|
cbxPrinter5.SelectedValue = Configini.IniReadvalue("PRINTER", "P11"); //读配置文件
|
|
|
|
|
|
Print_path2.Text = Configini.IniReadvalue("PRINTER", "P12"); |
|
|
|
|
|
|
|
|
TEXT_Print.IsChecked = Printer; |
|
|
TEXT_Print.IsChecked = Printer; |
|
|
cbxPrinter.IsEnabled = Printer; |
|
|
cbxPrinter.IsEnabled = Printer; |
|
|
|
|
|
|
|
|
|
|
|
TEXT_Print2.IsChecked = Printer2; |
|
|
|
|
|
cbxPrinter2.IsEnabled = Printer2; |
|
|
|
|
|
|
|
|
|
|
|
TEXT_Print3.IsChecked = Printer3; |
|
|
|
|
|
cbxPrinter3.IsEnabled = Printer3; |
|
|
|
|
|
|
|
|
|
|
|
TEXT_Print4.IsChecked = Printer4; |
|
|
|
|
|
cbxPrinter4.IsEnabled = Printer4; |
|
|
|
|
|
|
|
|
|
|
|
TEXT_Print5.IsChecked = Printer5; |
|
|
|
|
|
cbxPrinter5.IsEnabled = Printer5; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) //窗口关闭事件
|
|
|
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) //窗口关闭事件
|
|
|
@ -64,6 +94,16 @@ namespace formula_manage.Windows |
|
|
UserClass.IniFile.IniFiles Configini = new UserClass.IniFile.IniFiles(INIPath); |
|
|
UserClass.IniFile.IniFiles Configini = new UserClass.IniFile.IniFiles(INIPath); |
|
|
Configini.IniWritevalue("PRINTER", " P1", Printer.ToString()); |
|
|
Configini.IniWritevalue("PRINTER", " P1", Printer.ToString()); |
|
|
Configini.IniWritevalue("PRINTER", " P2", cbxPrinter.SelectedValue.ToString()); |
|
|
Configini.IniWritevalue("PRINTER", " P2", cbxPrinter.SelectedValue.ToString()); |
|
|
|
|
|
Configini.IniWritevalue("PRINTER", " P3", Print_path.Text.ToString()); |
|
|
|
|
|
Configini.IniWritevalue("PRINTER", " P4", Printer2.ToString()); |
|
|
|
|
|
Configini.IniWritevalue("PRINTER", " P5", Printer3.ToString()); |
|
|
|
|
|
Configini.IniWritevalue("PRINTER", " P6", Printer4.ToString()); |
|
|
|
|
|
Configini.IniWritevalue("PRINTER", " P7", Printer5.ToString()); |
|
|
|
|
|
Configini.IniWritevalue("PRINTER", " P8", cbxPrinter2.SelectedValue.ToString()); |
|
|
|
|
|
Configini.IniWritevalue("PRINTER", " P9", cbxPrinter3.SelectedValue.ToString()); |
|
|
|
|
|
Configini.IniWritevalue("PRINTER", " P10", cbxPrinter4.SelectedValue.ToString()); |
|
|
|
|
|
Configini.IniWritevalue("PRINTER", " P11", cbxPrinter5.SelectedValue.ToString()); |
|
|
|
|
|
Configini.IniWritevalue("PRINTER", " P12", Print_path2.Text.ToString()); |
|
|
|
|
|
|
|
|
System.IO.DirectoryInfo log = new System.IO.DirectoryInfo(@logpath);//生成日志文件目录
|
|
|
System.IO.DirectoryInfo log = new System.IO.DirectoryInfo(@logpath);//生成日志文件目录
|
|
|
FileStream fs = new FileStream(logPath, FileMode.Append, FileAccess.Write); |
|
|
FileStream fs = new FileStream(logPath, FileMode.Append, FileAccess.Write); |
|
|
@ -83,6 +123,18 @@ namespace formula_manage.Windows |
|
|
Print_path.Text = Dilog.SelectedPath; //返回选择的字符串
|
|
|
Print_path.Text = Dilog.SelectedPath; //返回选择的字符串
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
private void Button_Click1(object sender, RoutedEventArgs e) //路径选择按钮
|
|
|
|
|
|
{ |
|
|
|
|
|
FolderBrowserDialog Dilog = new FolderBrowserDialog(); |
|
|
|
|
|
Dilog.SelectedPath = Print_path2.Text; //打开目录
|
|
|
|
|
|
Dilog.ShowNewFolderButton = false; //不显示新建文件夹按钮
|
|
|
|
|
|
//
|
|
|
|
|
|
if (Dilog.ShowDialog() == System.Windows.Forms.DialogResult.OK) |
|
|
|
|
|
{ |
|
|
|
|
|
Print_path2.Text = Dilog.SelectedPath; //返回选择的字符串
|
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
private void Button_Click_1(object sender, RoutedEventArgs e) //编辑模板
|
|
|
private void Button_Click_1(object sender, RoutedEventArgs e) //编辑模板
|
|
|
{ |
|
|
{ |
|
|
/* if (string.IsNullOrEmpty(Print_path.Text)) |
|
|
/* if (string.IsNullOrEmpty(Print_path.Text)) |
|
|
@ -103,15 +155,39 @@ namespace formula_manage.Windows |
|
|
System.Windows.MessageBox.Show($"打开设计器失败:{tuple.Item2}"); |
|
|
System.Windows.MessageBox.Show($"打开设计器失败:{tuple.Item2}"); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
private void Button_Click_12(object sender, RoutedEventArgs e) //编辑模板
|
|
|
|
|
|
{ |
|
|
|
|
|
/* if (string.IsNullOrEmpty(Print_path.Text)) |
|
|
|
|
|
{ |
|
|
|
|
|
System.Windows.MessageBox.Show("模板不能为空"); |
|
|
|
|
|
return; |
|
|
|
|
|
}*/ |
|
|
|
|
|
var data = this.CreateBillData(); |
|
|
|
|
|
if (!data.Item1) |
|
|
|
|
|
{ |
|
|
|
|
|
System.Windows.MessageBox.Show("模拟数据生成错误"); |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var tuple = PrintHelper.Design(Print_path2.Text, data.Item2, data.Item3); |
|
|
|
|
|
if (!tuple.Item1) |
|
|
|
|
|
{ |
|
|
|
|
|
System.Windows.MessageBox.Show($"打开设计器失败:{tuple.Item2}"); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
private void Button_Click_2(object sender, RoutedEventArgs e) //预览模板
|
|
|
private void Button_Click_2(object sender, RoutedEventArgs e) //预览模板
|
|
|
{ |
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
private void Button_Click_22(object sender, RoutedEventArgs e) //预览模板
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private Tuple<bool, Dictionary<string, object>, DataSet> CreateBillData() |
|
|
private Tuple<bool, Dictionary<string, object>, DataSet> CreateBillData() |
|
|
{ |
|
|
{ |
|
|
//注意事项
|
|
|
//注意事项
|
|
|
//小票打印和门票一样,主要的区别是小票动态数据会变化,小票的长度也会动态改变
|
|
|
//小票动态数据会变化,小票的长度也会动态改变
|
|
|
//这里主要演示下 动态数据源 为了动态拉伸,除了传入数据源,在模板上面code部分需要加代码
|
|
|
//这里主要演示下 动态数据源 为了动态拉伸,除了传入数据源,在模板上面code部分需要加代码
|
|
|
Dictionary<string, object> dic = new Dictionary<string, object>(); |
|
|
Dictionary<string, object> dic = new Dictionary<string, object>(); |
|
|
dic.Add("billNo", "2018111100002222"); |
|
|
dic.Add("billNo", "2018111100002222"); |
|
|
@ -143,6 +219,26 @@ namespace formula_manage.Windows |
|
|
Printer = TEXT_Print.IsChecked.GetValueOrDefault(); //打印机是否生效
|
|
|
Printer = TEXT_Print.IsChecked.GetValueOrDefault(); //打印机是否生效
|
|
|
cbxPrinter.IsEnabled = Printer; //
|
|
|
cbxPrinter.IsEnabled = Printer; //
|
|
|
} |
|
|
} |
|
|
|
|
|
private void Print_Checked2(object sender, RoutedEventArgs e) //打印机是否生效
|
|
|
|
|
|
{ |
|
|
|
|
|
Printer2 = TEXT_Print2.IsChecked.GetValueOrDefault(); //打印机是否生效
|
|
|
|
|
|
cbxPrinter2.IsEnabled = Printer2; //
|
|
|
|
|
|
} |
|
|
|
|
|
private void Print_Checked3(object sender, RoutedEventArgs e) //打印机是否生效
|
|
|
|
|
|
{ |
|
|
|
|
|
Printer3 = TEXT_Print3.IsChecked.GetValueOrDefault(); //打印机是否生效
|
|
|
|
|
|
cbxPrinter3.IsEnabled = Printer3; //
|
|
|
|
|
|
} |
|
|
|
|
|
private void Print_Checked4(object sender, RoutedEventArgs e) //打印机是否生效
|
|
|
|
|
|
{ |
|
|
|
|
|
Printer4 = TEXT_Print4.IsChecked.GetValueOrDefault(); //打印机是否生效
|
|
|
|
|
|
cbxPrinter4.IsEnabled = Printer4; //
|
|
|
|
|
|
} |
|
|
|
|
|
private void Print_Checked5(object sender, RoutedEventArgs e) //打印机是否生效
|
|
|
|
|
|
{ |
|
|
|
|
|
Printer5 = TEXT_Print5.IsChecked.GetValueOrDefault(); //打印机是否生效
|
|
|
|
|
|
cbxPrinter5.IsEnabled = Printer5; //
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
private List<XElement> GetLocalPrinters() //查找打印机
|
|
|
private List<XElement> GetLocalPrinters() //查找打印机
|
|
|
{ |
|
|
{ |
|
|
|