144 lines
5.0 KiB
C#
144 lines
5.0 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Reflection;
|
|
using System.Text;
|
|
using System.Windows.Forms;
|
|
|
|
namespace dccdc.Report
|
|
{
|
|
public partial class PrinterSetting : Form
|
|
{
|
|
public PrinterSetting()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
private void btn_ok_Click(object sender, EventArgs e)
|
|
{
|
|
//Assembly.GetExecutingAssembly().Location
|
|
System.Configuration.Configuration congf = Main.Config;
|
|
//MessageBox.Show(Assembly.GetExecutingAssembly().Location);
|
|
|
|
if ((congf.AppSettings.Settings.AllKeys as ICollection<string>).Contains("tm_dyj"))
|
|
{
|
|
congf.AppSettings.Settings["tm_dyj"].Value = cbb_tm.SelectedValue.ToString();
|
|
}
|
|
else
|
|
{
|
|
congf.AppSettings.Settings.Add("tm_dyj", cbb_tm.SelectedValue.ToString());
|
|
}
|
|
if ((congf.AppSettings.Settings.AllKeys as ICollection<string>).Contains("zj_dyj"))
|
|
{
|
|
congf.AppSettings.Settings["zj_dyj"].Value = cbb_zj.SelectedValue.ToString();
|
|
}
|
|
else
|
|
{
|
|
congf.AppSettings.Settings.Add("zj_dyj", cbb_zj.SelectedValue.ToString());
|
|
}
|
|
if ((congf.AppSettings.Settings.AllKeys as ICollection<string>).Contains("bg_dyj"))
|
|
{
|
|
congf.AppSettings.Settings["bg_dyj"].Value = cbb_bg.SelectedValue.ToString();
|
|
}
|
|
else
|
|
{
|
|
congf.AppSettings.Settings.Add("bg_dyj", cbb_bg.SelectedValue.ToString());
|
|
}
|
|
if ((congf.AppSettings.Settings.AllKeys as ICollection<string>).Contains("xp_dyj"))
|
|
{
|
|
congf.AppSettings.Settings["xp_dyj"].Value = ccb_xp.SelectedValue.ToString();
|
|
}
|
|
else
|
|
{
|
|
congf.AppSettings.Settings.Add("xp_dyj", ccb_xp.SelectedValue.ToString());
|
|
}
|
|
congf.Save();
|
|
|
|
MessageBox.Show("保持成功!");
|
|
DialogResult = DialogResult.OK;
|
|
}
|
|
|
|
private void PrinterSetting_Load(object sender, EventArgs e)
|
|
{
|
|
myinit();
|
|
System.Configuration.Configuration congf = Main.Config;
|
|
string tm_dyj = "";
|
|
if ((congf.AppSettings.Settings.AllKeys as ICollection<string>).Contains("tm_dyj"))
|
|
{
|
|
tm_dyj = congf.AppSettings.Settings["tm_dyj"].Value;
|
|
}
|
|
string zj_dyj = "";
|
|
if ((congf.AppSettings.Settings.AllKeys as ICollection<string>).Contains("zj_dyj"))
|
|
{
|
|
zj_dyj = congf.AppSettings.Settings["zj_dyj"].Value;
|
|
}
|
|
string bg_dyj = "";
|
|
if ((congf.AppSettings.Settings.AllKeys as ICollection<string>).Contains("bg_dyj"))
|
|
{
|
|
bg_dyj = congf.AppSettings.Settings["bg_dyj"].Value;
|
|
}
|
|
string xp_dyj = "";
|
|
if ((congf.AppSettings.Settings.AllKeys as ICollection<string>).Contains("xp_dyj"))
|
|
{
|
|
xp_dyj = congf.AppSettings.Settings["xp_dyj"].Value;
|
|
}
|
|
foreach (var v in ps)
|
|
{
|
|
if(v.value==tm_dyj)
|
|
{
|
|
cbb_tm.SelectedValue = tm_dyj;
|
|
}
|
|
if (v.value == zj_dyj)
|
|
{
|
|
cbb_zj.SelectedValue = zj_dyj;
|
|
}
|
|
if (v.value == bg_dyj)
|
|
{
|
|
cbb_bg.SelectedValue = bg_dyj;
|
|
}
|
|
if (v.value == xp_dyj)
|
|
{
|
|
ccb_xp.SelectedValue = xp_dyj;
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
List<zprint> ps = new List<zprint>();
|
|
List<zprint> ps1 = new List<zprint>();
|
|
List<zprint> ps2 = new List<zprint>();
|
|
List<zprint> ps3 = new List<zprint>();
|
|
private void myinit()
|
|
{
|
|
//throw new NotImplementedException();
|
|
|
|
ps.Add(new zprint { name = "默认打印机", value = "" });
|
|
ps1.Add(new zprint { name = "默认打印机", value = "" });
|
|
ps2.Add(new zprint { name = "默认打印机", value = "" });
|
|
ps3.Add(new zprint { name = "默认打印机", value = "" });
|
|
foreach (string p in System.Drawing.Printing.PrinterSettings.InstalledPrinters)
|
|
{
|
|
ps.Add(new zprint { name = p, value = p });
|
|
ps1.Add(new zprint { name = p, value = p });
|
|
ps2.Add(new zprint { name = p, value = p });
|
|
ps3.Add(new zprint { name = p, value = p });
|
|
}
|
|
cbb_tm.DataSource = ps;
|
|
cbb_zj.DataSource = ps1;
|
|
cbb_bg.DataSource = ps2;
|
|
ccb_xp.DataSource = ps3;
|
|
}
|
|
|
|
class zprint
|
|
{
|
|
public string name { get; set; }
|
|
public string value { get; set; }
|
|
}
|
|
|
|
}
|
|
}
|