コード例 #1
0
        void Synchronize()
        {
            DisposeEditors();
            while (Element.Rows.Length != 0)
            {
                Element.RemoveChild(Element.Rows[0]);
            }

            if (contentType != null && listItem != null)
            {
                for (int i = 0; i < contentType.Fields.Count; i++)
                {
                    Field field = contentType.Fields[i];
                    if ((listItem.IsNew ? field.ShowInNewForm : field.ShowInEditForm) &&
                        !field.ReadOnly &&
                        field.ID != BuiltInFields.ContentType.ID)
                    {
                        AddEditor(field);
                    }
                }

                if (listItem.FileSystemObjectType == FileSystemObjectType.File && listItem.ParentList.EnableAttachments)
                {
                    Field         field   = listItem.ParentList.Detail.Value.Fields.TryGetFieldById(BuiltInFields.Attachments.ID);
                    HtmlTableCell cell    = AddEditor(field).Cells[0];
                    HtmlElement   element = cell.AppendChild(cell.OwnerDocument.CreateElement("SPAN"));
                    element.TabIndex = 1;
                    addFiles         = new AddFilesButton <ImageTextButton>()
                    {
                        Element = element,
                        AllowMultipleSelection = true,
                        Button =
                        {
                            ImageClass = ListStyles.AddAttachments
                        },
                    };

                    Action <HtmlCollection <File> > addAttachments = (files) => listItem.Attachments.Value.Add(files);
                    disposable = listItem.Attachments.Advise(delegate()
                    {
                        addFiles.Execute = listItem.Attachments.Value != null ? addAttachments : null;
                    });

                    if (listItem.Attachments.Value != null)
                    {
                        addFiles.Execute = addAttachments;
                    }
                }
            }
        }