コード例 #1
0
 /// <summary>
 /// Return true, if node corresponding to given category need subnodes to edit subentries.
 /// </summary>
 protected bool NeedSubNodes(string category)
 {
     foreach (KeyValuePair <string, string> entry in ParameterDict.Current.SortedEntries)
     {
         string parameterName = entry.Key;
         if (parameterName.StartsWith(category) && ParameterDict.HasControl(parameterName) && parameterName != category)
         {
             string tempName = parameterName.Substring(category.Length + 1);
             if (!tempName.Contains("."))
             {
                 return(true);
             }
             System.Diagnostics.Debug.WriteLine(parameterName);
         }
     }
     return(false);
 }
コード例 #2
0
        /// <summary>
        /// Control ist filled with all entries which corresponds to the given category.
        /// </summary>
        public void Create(string category)
        {
            this.Dock = DockStyle.Fill;

            _category      = category;
            _nodeHash      = ParameterDict.Current.GetHashOfName(category);
            _nodeValueHash = ParameterDict.Current.GetHash(category);

            // Contain the edit entries before adding to the control
            List <DataViewElement> oldElements = new List <DataViewElement>();

            this.SuspendLayout();
            _computedHeight = 0;
            bool elementAdded = false;

            {
                DataViewElement helement = DataViewElementFactory.Create(category.Replace(".", " "), "", "Headline", "", false);
                oldElements.Add(helement);
                _computedHeight += DataViewElementFactory.DefaultHeight;
            }


            foreach (KeyValuePair <string, string> entry in ParameterDict.Current.SortedEntries)
            {
                string parameterName = entry.Key;
                if (parameterName.StartsWith(category + ".") && ParameterDict.HasControl(parameterName))
                {
                    if (parameterName.Length > category.Length)
                    {
                        string tempName = parameterName.Substring(category.Length + 1);
                        if (!tempName.Contains("."))
                        {
                            DataViewElement dElement = DataViewElementFactory.Create(parameterName, entry.Value, ParameterDict.Current.GetDatatype(parameterName),
                                                                                     ParameterDict.Current.GetDescription(parameterName), true);
                            dElement.ElementChanged += new ElementChangedDelegate(_parent.dElement_ElementChanged);
                            oldElements.Add(dElement);
                            dElement.TabIndex = oldElements.Count;
                            _computedHeight  += DataViewElementFactory.DefaultHeight;
                            elementAdded      = true;
                        }
                    }
                }
            }

            // Wenn kein direktes Unterelement existiert, werden alle Unterelemente eingefügt.
            string currentCategory = "";
            string oldCategory     = "";

            if (!elementAdded)
            {
                // Header:


                foreach (KeyValuePair <string, string> entry in ParameterDict.Current.SortedEntries)
                {
                    string parameterName = entry.Key;
                    if (parameterName.StartsWith(category) && ParameterDict.HasControl(parameterName) && !ParameterDict.IsAdditionalInfo(parameterName))
                    {
                        string[] paraSplit = parameterName.Split('.');
                        if (paraSplit.Length > 1)
                        {
                            currentCategory = paraSplit[paraSplit.Length - 2];
                            if (currentCategory != oldCategory)
                            {
                                /*
                                 * //DataViewElement helement = DataViewElementFactory.Create(currentCategory, "", "Headline", "", false);
                                 * DataViewElement helement = DataViewElementFactory.Create("", "", "Headline", "", false);
                                 * oldElements.Add(helement);
                                 */

                                oldCategory      = currentCategory;
                                _computedHeight += DataViewElementFactory.DefaultHeight;
                            }
                        }
                        DataViewElement dElement = DataViewElementFactory.Create(parameterName, entry.Value, ParameterDict.Current.GetDatatype(parameterName), ParameterDict.Current.GetDescription(parameterName), true);
                        dElement.ElementChanged += new ElementChangedDelegate(_parent.dElement_ElementChanged);
                        oldElements.Add(dElement);
                        dElement.TabIndex = oldElements.Count;
                        _computedHeight  += DataViewElementFactory.DefaultHeight;
                    }
                }
            }
            for (int i = oldElements.Count - 1; i >= 0; i--)
            {
                DataViewElement dElement = oldElements[i];
                Controls.Add(dElement);
            }
            this.ResumeLayout(true);
        }