private void SavePaper() { //从注册表寻找pmp文件的位置 string keyPath = @"Software\Autodesk\AutoCAD\R22.0\ACAD-1001:804"; string keyName = "RoamableRootFolder"; object FindPC3_Path = RegistryHelpers.GetRegistryValue(keyPath, keyName); string pmp_path = (string)FindPC3_Path + "Plotters\\PMP Files\\"; PrinterSetting paper = new PrinterSetting(); DB.BLL.PAPER_SIZE papers = new DB.BLL.PAPER_SIZE(); DataSet papers_list = papers.GetList("1=1"); DataTable row = papers_list.Tables[0]; foreach (DataGridViewRow r in dgv_PaperSizeList.Rows) { paper.PaperX = Convert.ToDouble(r.Cells[2].Value) * 10; paper.PaperY = Convert.ToDouble(r.Cells[3].Value) * 10; paper.userdef_name = (string)r.Cells[1].Value; //三个打印机,添加三次 paper.AddPrinter(pmp_path + "DWG To PDF.pmp"); paper.AddPrinter(pmp_path + "PublishToWeb JPG.pmp"); paper.AddPrinter(pmp_path + "PublishToWeb PNG.pmp"); } }
/// <summary> /// 初始化纸张列表,纸张信息来自数据库 /// </summary> private void Init_PaperSizeList_FromDB() { comboBox_PaperSizeList.Items.Clear(); DB.BLL.PAPER_SIZE bll = new DB.BLL.PAPER_SIZE(); DataSet papers_list = bll.GetList("1=1"); DataTable a = papers_list.Tables[0]; foreach (DataRow m in a.Rows) { comboBox_PaperSizeList.Items.Add(m.ItemArray[1]); } if (0 != comboBox_PaperSizeList.Items.Count) { comboBox_PaperSizeList.SelectedIndex = 0; } }
/// <summary> /// 初始化DataGridView,数据来自数据库 /// </summary> private void Init_dgv_PaperSizeList() { DB.BLL.PAPER_SIZE papers = new DB.BLL.PAPER_SIZE(); DataSet papers_list = papers.GetList("1=1"); dgv_PaperSizeList.DataSource = papers_list.Tables[0]; dgv_PaperSizeList.RowHeadersVisible = false; dgv_PaperSizeList.Columns[0].Visible = false; dgv_PaperSizeList.Columns[1].HeaderCell.Value = "纸张名称"; dgv_PaperSizeList.Columns[2].HeaderCell.Value = "纸张长度/厘米"; dgv_PaperSizeList.Columns[3].HeaderCell.Value = "纸张宽度/厘米"; dgv_PaperSizeList.Columns[4].HeaderCell.Value = "纸张长度/像素"; dgv_PaperSizeList.Columns[5].HeaderCell.Value = "纸张宽度/像素"; dgv_PaperSizeList.Columns[1].Width = dgv_PaperSizeList.Width / 5; dgv_PaperSizeList.Columns[2].Width = dgv_PaperSizeList.Width / 5; dgv_PaperSizeList.Columns[3].Width = dgv_PaperSizeList.Width / 5; dgv_PaperSizeList.Columns[4].Width = dgv_PaperSizeList.Width / 5; dgv_PaperSizeList.Columns[5].Width = dgv_PaperSizeList.Width / 5; }