void LoadTemplates() { if (this.m_bTempaltesChanged == true) { DialogResult result = MessageBox.Show(this, "当前模板列表中有改动尚未保存。如此时强行刷新列表,新增和改动的内容会丢失。\r\n\r\n确实要刷新列表? ", "PrintOptionDlg", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2); if (result != DialogResult.Yes) { return; } RemoveNewCreatedTemplateFiles(); } this.listView_templates.Items.Clear(); this.textBox_templates_content.Text = ""; this.textBox_templates_content.Enabled = false; this.m_nCurrentTemplateIndex = -1; this.m_bTemplateFileContentChanged = false; if (this.PrintOption == null) { return; } if (this.PrintOption.TemplatePages == null) { return; } for (int i = 0; i < this.PrintOption.TemplatePages.Count; i++) { TemplatePageParam param = this.PrintOption.TemplatePages[i]; ListViewItem item = new ListViewItem(); item.Text = param.Caption; item.SubItems.Add(param.FilePath); this.listView_templates.Items.Add(item); } this.m_bTempaltesChanged = false; }
// 获得模板页文件 // parameters: // strCaption 模板名称。大小写不敏感 public string GetTemplatePageFilePath(string strCaption) { if (this.TemplatePages == null) { return(null); } for (int i = 0; i < this.TemplatePages.Count; i++) { TemplatePageParam param = this.TemplatePages[i]; if (param.Caption.ToLower() == strCaption.ToLower()) { Debug.Assert(param.FilePath.IndexOf("%") == -1, "去除宏以后的路径字符串里面不能有%符号"); return(param.FilePath); } } return(null); // not found }
void SaveTemplatesChanges() { // 保存模板列表 if (this.m_bTempaltesChanged == true) { PrintOption.TemplatePages.Clear(); for (int i = 0; i < this.listView_templates.Items.Count; i++) { ListViewItem item = this.listView_templates.Items[i]; TemplatePageParam param = new TemplatePageParam(); param.Caption = item.Text; param.FilePath = ListViewUtil.GetItemText(item, 1); PrintOption.TemplatePages.Add(param); } this.m_bTempaltesChanged = false; } this.m_newCreateTemplateFiles.Clear(); // 避免后面Closing()处理中不小心删除刚刚创建的文件 }
public List <TemplatePageParam> TemplatePages = new List <TemplatePageParam>(); // 定制的页面 // 从Application对象中装载数据 public virtual void LoadData(ApplicationInfo ai, string strPath) { this.PageHeader = ai.GetString(strPath, "PageHeader", this.PageHeaderDefault); // "%date% 册移交清单 - %barcodefilename% - (共 %pagecount% 页)"); this.PageFooter = ai.GetString(strPath, "PageFooter", this.PageFooterDefault); // "%pageno%/%pagecount%"); this.TableTitle = ai.GetString(strPath, "TableTitle", this.TableTitleDefault); // "%date% 册移交清单"); this.LinesPerPage = ai.GetInt(strPath, "LinesPerPage", this.LinesPerPageDefault); // 20); int nCount = ai.GetInt(strPath, "ColumnsCount", 0); if (nCount != 0) // 只有当外部存储中有配置信息时,才清除构造函数创建的缺省信息 { Columns.Clear(); for (int i = 0; i < nCount; i++) { string strColumnName = ai.GetString(strPath, "ColumnName_" + i.ToString(), ""); if (String.IsNullOrEmpty(strColumnName) == true) { break; } string strColumnCaption = ai.GetString(strPath, "ColumnCaption_" + i.ToString(), ""); int nMaxChars = ai.GetInt(strPath, "ColumnMaxChars_" + i.ToString(), -1); int nWidthChars = ai.GetInt(strPath, "ColumnWidthChars_" + i.ToString(), -1); string strEvalue = ai.GetString(strPath, "ColumnEvalue_" + i.ToString(), ""); Column column = new Column(); column.Name = strColumnName; column.Caption = strColumnCaption; column.WidthChars = nWidthChars; column.MaxChars = nMaxChars; column.Evalue = strEvalue; this.Columns.Add(column); } } nCount = ai.GetInt(strPath, "TemplatePagesCount", 0); if (nCount != 0) // 只有当外部存储中有配置信息时,才清除构造函数创建的缺省信息 { this.TemplatePages.Clear(); for (int i = 0; i < nCount; i++) { TemplatePageParam param = new TemplatePageParam(); param.Caption = ai.GetString(strPath, "TemplateCaption_" + i.ToString(), ""); param.FilePath = ai.GetString(strPath, "TemplateFilePath_" + i.ToString(), ""); Debug.Assert(String.IsNullOrEmpty(this.DataDir) == false, ""); // 把带有宏的路径兑现为实际路径。这里要用到 this.DataDir param.FilePath = UnMacroPath(param.FilePath); Debug.Assert(param.FilePath.IndexOf("%") == -1, "去除宏以后的路径字符串里面不能有%符号"); this.TemplatePages.Add(param); } } }
public List<TemplatePageParam> TemplatePages = new List<TemplatePageParam>(); // 定制的页面 // 从Application对象中装载数据 public virtual void LoadData(ApplicationInfo ai, string strPath) { this.PageHeader = ai.GetString(strPath, "PageHeader", this.PageHeaderDefault); // "%date% 册移交清单 - %barcodefilename% - (共 %pagecount% 页)"); this.PageFooter = ai.GetString(strPath, "PageFooter", this.PageFooterDefault); // "%pageno%/%pagecount%"); this.TableTitle = ai.GetString(strPath, "TableTitle", this.TableTitleDefault); // "%date% 册移交清单"); this.LinesPerPage = ai.GetInt(strPath, "LinesPerPage", this.LinesPerPageDefault); // 20); int nCount = ai.GetInt(strPath, "ColumnsCount", 0); if (nCount != 0) // 只有当外部存储中有配置信息时,才清除构造函数创建的缺省信息 { Columns.Clear(); for (int i = 0; i < nCount; i++) { string strColumnName = ai.GetString(strPath, "ColumnName_" + i.ToString(), ""); if (String.IsNullOrEmpty(strColumnName) == true) break; string strColumnCaption = ai.GetString(strPath, "ColumnCaption_" + i.ToString(), ""); int nMaxChars = ai.GetInt(strPath, "ColumnMaxChars_" + i.ToString(), -1); int nWidthChars = ai.GetInt(strPath, "ColumnWidthChars_" + i.ToString(), -1); string strEvalue = ai.GetString(strPath, "ColumnEvalue_" + i.ToString(), ""); Column column = new Column(); column.Name = strColumnName; column.Caption = strColumnCaption; column.WidthChars = nWidthChars; column.MaxChars = nMaxChars; column.Evalue = strEvalue; this.Columns.Add(column); } } nCount = ai.GetInt(strPath, "TemplatePagesCount", 0); if (nCount != 0) // 只有当外部存储中有配置信息时,才清除构造函数创建的缺省信息 { this.TemplatePages.Clear(); for (int i = 0; i < nCount; i++) { TemplatePageParam param = new TemplatePageParam(); param.Caption = ai.GetString(strPath, "TemplateCaption_" + i.ToString(), ""); param.FilePath = ai.GetString(strPath, "TemplateFilePath_" + i.ToString(), ""); Debug.Assert(String.IsNullOrEmpty(this.DataDir) == false, ""); param.FilePath = UnMacroPath(param.FilePath); Debug.Assert(param.FilePath.IndexOf("%") == -1, "去除宏以后的路径字符串里面不能有%符号"); this.TemplatePages.Add(param); } } }