// parameter: // node char节点 // strLang 语言版本 public TemplateLine(TemplateRoot templateRoot, XmlNode node, string strLang) { this.container = templateRoot; this.m_charNode = node; this.m_strLang = strLang; string strError; // 通过一个Char节点,初始化本行的值 // parameter: // node char节点 // strLang 语言版本 // strError 出错信息 // return: // -1 失败 // 0 成功 int nRet = this.Initial(this.m_charNode, this.m_strLang, out strError); if (nRet == -1) { throw new Exception(strError); } }
// parameter: // node char节点 // strLang 语言版本 public TemplateLine(TemplateRoot templateRoot, XmlNode node, string strLang) { this.container = templateRoot; this.m_charNode = node; this.m_strLang = strLang; string strError; // 通过一个Char节点,初始化本行的值 // parameter: // node char节点 // strLang 语言版本 // strError 出错信息 // return: // -1 失败 // 0 成功 int nRet = this.Initial(this.m_charNode, this.m_strLang, out strError); if (nRet == -1) throw new Exception(strError); }
// 初始化控件 // paramters: // fieldNode Field节点 // strLang 语言版本 // return: // -1 出错 // 0 不是定长字段 // 1 成功 public int Initial(XmlNode node, string strLang, out int nResultWidth, out int nResultHeight, out string strError) { nResultWidth = 0; nResultHeight = 0; strError = ""; this.Lang = strLang; this.Controls.Clear(); this.templateRoot = new TemplateRoot(this); int nRet = this.templateRoot.Initial(node, strLang, out strError); if (nRet == 0) return 0; if (nRet == -1) return -1; for (int i = 0; i < this.templateRoot.Lines.Count; i++) { TemplateLine line = (TemplateLine)this.templateRoot.Lines[i]; /* string strTempValue = line.m_strValue; strTempValue = strTempValue.Replace(' ', 'M'); // ? nValueWidth = GraphicsUtil.GetWidth(//g, this.DefaultValueFont, strTempValue); if (nMaxValueWidth < nValueWidth) nMaxValueWidth = nValueWidth; int nHeight = this.DefaultValueFont.Height; * */ ValueEditBox textBox_value = new ValueEditBox(); textBox_value.Font = this.DefaultValueFont; textBox_value.Name = "value_" + Convert.ToString(i); textBox_value.TabIndex = i; textBox_value.Text = line.m_strValue; textBox_value.MaxLength = line.m_nValueLength; textBox_value.nIndex = i; textBox_value.fixedFieldCtrl = this; this.Controls.Add(textBox_value); line.TextBox_value = textBox_value; textBox_value.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; textBox_value.ForeColor = SystemColors.WindowText; textBox_value.BackColor = SystemColors.Window; textBox_value.TextChanged -= new EventHandler(textBox_value_TextChanged); textBox_value.TextChanged += new EventHandler(textBox_value_TextChanged); Label label_label = new Label(); label_label.Font = this.DefaultInfoFont; label_label.Name = "label_" + Convert.ToString(i); label_label.TabIndex = i; label_label.Text = line.m_strLabel; label_label.TextAlign = ContentAlignment.MiddleRight; // label_label.BorderStyle = BorderStyle.FixedSingle; this.Controls.Add(label_label); line.Label_label = label_label; Label label_name = new Label(); label_name.Font = this.DefaultInfoFont; label_name.Name = "name_" + Convert.ToString(i); label_name.TabIndex = i; label_name.Text = line.m_strName; // label_name.BorderStyle = BorderStyle.Fixed3D; label_name.BorderStyle = BorderStyle.None; // label_name.BackColor = SystemColors.Window; label_name.ForeColor = SystemColors.GrayText; this.Controls.Add(label_name); line.Label_Name = label_name; Label label_state = new Label(); label_state.Font = this.DefaultInfoFont; label_state.Name = "state_" + Convert.ToString(i); label_state.TabIndex = i; label_state.Text = ""; label_state.BorderStyle = BorderStyle.None; label_state.ImageList = this.imageList_lineState; this.Controls.Add(label_state); line.Label_state = label_state; line.LineState = line.LineState; } this.listView_values = new ListView(); this.listView_values.Name = "listView_values"; this.listView_values.TabIndex = 100; this.listView_values.View = View.Details; this.listView_values.Columns.Add("值", 50, HorizontalAlignment.Left); this.listView_values.Columns.Add("说明", 700, HorizontalAlignment.Left); this.listView_values.FullRowSelect = true; this.listView_values.HideSelection = false; this.AutoScroll = true; this.listView_values.DoubleClick += new System.EventHandler(this.ValueList_DoubleClick); // this.listView_values.Anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top | AnchorStyles.Bottom; this.listView_values.Anchor = AnchorStyles.Left | AnchorStyles.Top; this.listView_values.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.Controls.Add(this.listView_values); #if NO this.SuspendLayout(); // Graphics g = Graphics.FromHwnd(this.Handle); int nJianGeWidth = 8; // int nNameWidth = 60; int nNameWidth = GraphicsUtil.GetWidth(this.DefaultInfoFont, "99/99"); int nLabelWidth = this.GetMaxLabelWidth(//g, this.DefaultInfoFont); // +8; int nValueWidth = 0; int nMaxValueWidth = 0; int x = 0; int y = 0; for(int i=0;i<this.templateRoot.Lines.Count;i++) { TemplateLine line = (TemplateLine)this.templateRoot.Lines[i]; string strTempValue = line.m_strValue; // strTempValue = strTempValue.Replace(' ','m'); // ? /* string strTemp = ""; strTempValue = strTemp.PadLeft(strTempValue.Length+1, 'M'); // 2008/7/16 * */ strTempValue = strTempValue.Replace(' ','M'); // ? nValueWidth = GraphicsUtil.GetWidth(//g, this.DefaultValueFont, strTempValue); if (nMaxValueWidth < nValueWidth) nMaxValueWidth = nValueWidth; int nHeight = this.DefaultValueFont.Height; ValueEditBox textBox_value = new ValueEditBox(); // textBox_value.BorderStyle = BorderStyle.None; // ((TextBoxBase)textBox_value).AutoSize = false; textBox_value.Font = this.DefaultValueFont; textBox_value.Location = new System.Drawing.Point(x + nLabelWidth + nJianGeWidth + nNameWidth + nJianGeWidth, 0 + y); textBox_value.Name = "value_" + Convert.ToString(i); textBox_value.TabIndex = i; textBox_value.Text = line.m_strValue; textBox_value.MaxLength = line.m_nValueLength; textBox_value.nIndex = i; textBox_value.fixedFieldCtrl = this; this.Controls.Add(textBox_value); line.TextBox_value = textBox_value; textBox_value.ClientSize = new System.Drawing.Size(nValueWidth, textBox_value.ClientSize.Height); // nHeight); // changed textBox_value.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; textBox_value.ForeColor = SystemColors.WindowText; textBox_value.BackColor = SystemColors.Window; textBox_value.TextChanged -= new EventHandler(textBox_value_TextChanged); textBox_value.TextChanged += new EventHandler(textBox_value_TextChanged); nHeight = textBox_value.Size.Height; Label label_label = new Label(); label_label.Font = this.DefaultInfoFont; label_label.Location = new System.Drawing.Point(x + 0, 0 + y); label_label.Size = new Size(nLabelWidth,nHeight); label_label.Name = "label_" + Convert.ToString(i); label_label.TabIndex = i; label_label.Text = line.m_strLabel; label_label.TextAlign = ContentAlignment.MiddleRight; // label_label.BorderStyle = BorderStyle.FixedSingle; this.Controls.Add(label_label); line.Label_label = label_label; Label label_name = new Label(); label_name.Font = this.DefaultInfoFont; label_name.Location = new System.Drawing.Point(x + nLabelWidth + nJianGeWidth, 0 + y); label_name.Size = new Size(nNameWidth,nHeight); label_name.Name = "name_" + Convert.ToString(i); label_name.TabIndex = i; label_name.Text = line.m_strName; // label_name.BorderStyle = BorderStyle.Fixed3D; label_name.BorderStyle = BorderStyle.None; label_name.BackColor = SystemColors.Window; label_name.ForeColor = SystemColors.GrayText; this.Controls.Add(label_name); line.Label_Name = label_name; y = y + nHeight; } int nListViewOrgX = nLabelWidth + nJianGeWidth + nNameWidth + nJianGeWidth + nMaxValueWidth + 10; int nListViewOrgY = 0; int nListViewWidth = 200; int nListViewHeight = Math.Max(y, 10 * this.DefaultValueFont.Height); // 保证高度不能太小 this.listView_values = new ListView(); this.listView_values.Location = new System.Drawing.Point(nListViewOrgX,nListViewOrgY); this.listView_values.Name = "listView_values"; this.listView_values.TabIndex = 100; //this.listView_values.Size = new Size(nListViewWidth,nListViewHeight); this.listView_values.Size = new Size(nListViewWidth, nListViewHeight); this.listView_values.MinimumSize = new Size(nListViewWidth/2, nListViewHeight); this.listView_values.MaximumSize = new Size(1024, 768); this.listView_values.View = View.Details; this.listView_values.Columns.Add("值", 50, HorizontalAlignment.Left); this.listView_values.Columns.Add("说明",700, HorizontalAlignment.Left); this.listView_values.FullRowSelect = true; this.listView_values.HideSelection = false; this.AutoScroll = true; this.listView_values.DoubleClick += new System.EventHandler(this.ValueList_DoubleClick); this.listView_values.Anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top | AnchorStyles.Bottom; this.Controls.Add(this.listView_values); int nDocumentWith = nListViewOrgX + nListViewWidth; int nDocumentHeight = nListViewHeight; //this.Size = new Size(nDocumentWith, // nDocumentHeight); nResultWidth = nDocumentWith + 100; nResultHeight = nDocumentHeight; // xietao change this.ResumeLayout(false); this.PerformLayout(); #endif this.nodeTemplateDef = node; // 保存定义节点 AdjustTextboxSize( true, out nResultWidth, out nResultHeight); return 1; }