Exemple #1
0
        private void SetupEditor()
        {
            FastTrackPage page = GetPage();

            if (page != null)
            {
                object obj  = page.SelectedObject;
                Type   type = page.SelectedType;
                if (obj != null)
                {
                    type = obj.GetType();
                }

                PropertyInfo property = type.GetProperty(propertyName);
                if (property != null)
                {
                    Control editor = EditorFactory.GetPropertyValueEditor(page, type, property);

                    if (editor != null)
                    {
                        Label nameLabel = new Label();
                        nameLabel.Text = property.Name;

                        TableRow row   = null;
                        Table    table = this.table;

                        if (table == null)
                        {
                            table = this.Parent as Table;
                        }

                        if (table != null)
                        {
                            row = new TableRow();
                            table.Rows.Add(row);
                        }

                        if (row == null)
                        {
                            row = this.Parent as TableRow;
                        }

                        if (row != null)
                        {
                            TableCell nameCell   = new TableCell();
                            TableCell editorCell = new TableCell();

                            nameCell.VerticalAlign     = VerticalAlign.Top;
                            nameCell.HorizontalAlign   = HorizontalAlign.Left;
                            editorCell.VerticalAlign   = VerticalAlign.Top;
                            editorCell.HorizontalAlign = HorizontalAlign.Left;
                            editorCell.Wrap            = false;

                            nameCell.Controls.Add(nameLabel);
                            editorCell.Controls.Add(editor);

                            row.Cells.Add(nameCell);
                            row.Cells.Add(editorCell);

                            if (page.IsNullableProperty(type, propertyName))
                            {
                                NullValueEditor nullEditor = new NullValueEditor(propertyName);

                                Label nullLabel = new Label();
                                nullLabel.Text = "Null";

                                editorCell.Controls.Add(nullEditor);
                                editorCell.Controls.Add(nullLabel);
                            }
                        }
                        else
                        {
                            this.Controls.Add(nameLabel);
                            this.Controls.Add(editor);
                        }

                        ((IValueEditor)editor).Initialize();
                    }
                }
            }
        }