Пример #1
0
        /// <summary>
        /// Add captions to the attribute list panel
        /// </summary>
        private void CreateLabels()
        {
            int adefidx = 0;

            foreach (XmlNode a in m_definitions.SelectNodes("element"))
            {
                string strCaption;

                if (a.Attributes["caption"] != null)
                {
                    strCaption = a.Attributes["caption"].InnerText;
                }
                else
                {
                    strCaption = TemplateUtil.Instance().InventCaptionForName(a.Attributes["name"].InnerText);
                }

                Label lblName = new Label();
                lblName.Text   = strCaption;
                lblName.Height = m_starttop - 2;

                string strToolTip = "";
                if (a.Attributes["tooltip"] != null)
                {
                    strToolTip = a.Attributes["tooltip"].Value;
                }
                strToolTip += "(" + a.Attributes["name"].Value + ")";
                m_tt.SetToolTip(lblName, strToolTip);

                // Walk all controls created for the attributedefinition
                // and find out the leftmost position and rightmost position.
                // Position label to leftmost, and let it extend to rightmost.
                int leftmost  = int.MaxValue;
                int rightmost = 0;
                if (m_AttributeControls.Count > adefidx)
                {
                    foreach (Control c in (m_AttributeControls[adefidx] as ArrayList))
                    {
                        if (leftmost > c.Left)
                        {
                            leftmost = c.Left;
                        }
                        if (rightmost < c.Left + c.Width)
                        {
                            rightmost = c.Left + c.Width;
                        }
                    }
                }
                if (rightmost > 0)                 // any control found?
                {
                    lblName.Name  = "label_" + a.Attributes["name"].InnerText.Trim();
                    lblName.Left  = leftmost;
                    lblName.Width = rightmost - leftmost;
                    m_panel.Controls.Add(lblName);
                    m_LabelControls.Add(lblName);
                }
                else
                {
                    // make sure that label numbering conforms to definition number.
                    m_LabelControls.Add(null);
                }
                adefidx++;
            }
        }