AspNetEdit.UI.PropertyGrid.Populate C# (CSharp) Méthode

Populate() private méthode

private Populate ( ) : void
Résultat void
        private void Populate()
        {
            bool categorised = PropertySort == System.Windows.Forms.PropertySort.Categorized;

            if (currentObject != null)
            properties = selectedTab.GetProperties (currentObject);
            else
            properties = new PropertyDescriptorCollection (new PropertyDescriptor[0] {});

            //kill existing table
            if (expanderBox != null) {
            expanderBox.Destroy ();
            expanderBox = null;
            }
            Rows.Clear();

            //transcribe browsable properties
            ArrayList sorted = new ArrayList();

            foreach (PropertyDescriptor descriptor in properties)
            if (descriptor.IsBrowsable)
                sorted.Add (descriptor);

            //expands to fill empty space
            EventBox bottomWidget = new EventBox ();
            bottomWidget.ModifyBg (StateType.Normal, new Gdk.Color (0xff, 0xff, 0xff));
            bottomWidget.CanFocus = true;
            bottomWidget.ButtonPressEvent += on_bottomWidget_ButtonPressEvent;
            expanderBox = new VBox ();

            //how are we displaying it?
            if (!categorised) {
            sorted.Sort(new SortByName ());
            table = BuildTable (sorted);
            expanderBox.PackStart (table, false, false, 0);
            }
            else {
            sorted.Sort (new SortByCat ());

            ArrayList tabList = new ArrayList ();
            string oldCat = "";
            int oldIndex = 0;
            Expander catHead = null;

            for (int i = 0; i < sorted.Count; i++) {
                PropertyDescriptor pd = (PropertyDescriptor) sorted[i];

                //Create category header
                if (pd.Category != oldCat) {
                    if (catHead != null) {
                        Table t = BuildTable (sorted.GetRange(oldIndex, i - oldIndex));
                        catHead.Add (t);
                    }

                    catHead = new Expander ("<b>" + pd.Category + "</b>");
                    ((Label) catHead.LabelWidget).UseMarkup = true;
                    catHead.Expanded = true;
                    expanderBox.PackStart (catHead, false, false, 0);

                    oldCat = pd.Category;
                    oldIndex = i;
                }
            }

            if (catHead != null) {
                Table t = BuildTable (sorted.GetRange (oldIndex, sorted.Count - oldIndex));
                catHead.Add (t);
            }

            //TODO: Find better way of getting all tables same size, maybe resizable
            int maxwidth = 1;
            foreach (GridRow pgr in Rows) {
                int width = pgr.propertyNameLabel.SizeRequest ().Width;
                if (width > maxwidth)
                    maxwidth = width;
            }
            foreach (GridRow pgr in Rows)
                pgr.propertyNameLabel.WidthRequest = maxwidth;
            }

            expanderBox.PackStart (bottomWidget, true, true, 1);
            scrolledWindow.AddWithViewport (expanderBox);
            expanderBox.ShowAll ();
        }