Exemplo n.º 1
0
        public void NextLineIfNeed()
        {
            if (this.SelectionStart >= this.MaxLength)
            {
                if (this.nIndex < fixedFieldCtrl.LineCount - 1)
                {
                    ValueEditBox target = fixedFieldCtrl.SwitchFocus(this.nIndex + 1,
                                                                     CaretPosition.FirstChar);

                    if (target != null)
                    {
                        // 2011/3/20
                        // 刷新值列表
                        fixedFieldCtrl.ShowValueList(target.SelectionStart,
                                                     target.MaxLength,
                                                     target.Text);
                    }
                }
            }
        }
Exemplo n.º 2
0
        ValueEditBox m_currentTextBox = null;   // 当前处于焦点的TextBox

        public void ChangeFocusDisplay(ValueEditBox textbox)
        {
            if (this.m_currentTextBox != null)
            {
                this.m_currentTextBox.Font = this.DefaultValueFont;
                this.m_currentTextBox.ForeColor = SystemColors.WindowText;
                this.m_currentTextBox.BackColor = SystemColors.Window;
            }

            this.m_currentTextBox = textbox;
            this.m_currentTextBox.Font = new Font(this.DefaultValueFont, FontStyle.Bold);
            this.m_currentTextBox.BackColor = Color.LightYellow;
            this.m_currentTextBox.ForeColor = Color.DarkRed;
        }
Exemplo n.º 3
0
        TemplateLine GetLine(ValueEditBox textbox)
        {
            foreach (TemplateLine line in this.templateRoot.Lines)
            {
                if (line.TextBox_value == textbox)
                {
                    return line;
                }
            }

            return null;
        }
Exemplo n.º 4
0
		// 初始化控件
		// 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;
		}