Exemple #1
0
        private void InitializeFields()
        {
            RegisterField(PropertyType.Page, labelPageOrder, textPageOrder,
                          opts => opts.SupportsPageOrder,
                          post => textPageOrder.Text = post.PageOrder,
                          post => post.PageOrder     = textPageOrder.Text);

            RegisterField2(PropertyType.Page, labelPageParent, comboPageParent,
                           opts => opts.SupportsPageParent,
                           (ctx, opts) =>
            {
                PostIdAndNameField none     = new PostIdAndNameField(Res.Get(StringId.PropertiesNoPageParent));
                PostIdAndNameField parent   = ctx.BlogPost.PageParent;
                BlogPageFetcher pageFetcher = new BlogPageFetcher(_blogId, 10000);
                if (!parent.Equals(PostIdAndNameField.Empty))
                {
                    comboPageParent.Initialize(new object[] { none, parent }, parent, pageFetcher);
                }
                else
                {
                    comboPageParent.Initialize(none, pageFetcher);
                }
            },
                           post => post.PageParent = comboPageParent.SelectedItem as PostIdAndNameField);

            RegisterField(PropertyType.Post, labelCategory, categoryDropDown,
                          opts => opts.SupportsCategories,
                          post => { },
                          post => { });

            RegisterField2(PropertyType.Post, labelTags, textTags,
                           opts => opts.SupportsKeywords,
                           (ctx, opts) => textTags.Text = ctx.BlogPost.Keywords,
                           post => post.Keywords        = textTags.TextValue);

            RegisterField(PropertyType.Post, labelPublishDate, datePublishDate,
                          opts => opts.SupportsCustomDate,
                          post =>
            {
                if (post.HasDatePublishedOverride)
                {
                    DatePublishedOverride    = post.DatePublishedOverride;
                    HasDatePublishedOverride = true;
                }
                else
                {
                    HasDatePublishedOverride = false;
                }
            },
                          post => post.DatePublishedOverride = HasDatePublishedOverride ? DatePublishedOverride : DateTime.MinValue);
        }
 private void SetAuthor(PostIdAndNameField author)
 {
     if (author != null)
     {
         BlogAuthorFetcher authorFetcher = new BlogAuthorFetcher(_blogId, 10000);
         if (!author.IsEmpty)
         {
             comboAuthor.Initialize(new object[] { new PostIdAndNameField(Res.Get(StringId.PropertiesDefault)), author }, author, authorFetcher);
         }
         else
         {
             comboAuthor.Initialize(new PostIdAndNameField(Res.Get(StringId.PropertiesDefault)), authorFetcher);
         }
     }
 }
        protected override void OnDrawItem(DrawItemEventArgs e)
        {
            if (e.Index != -1)
            {
                // calculate text to paint
                PostIdAndNameField comboItem = Items[e.Index] as PostIdAndNameField;
                string             text      = comboItem.ToString();
                if (comboItem is ParentPageComboItem)
                {
                    if (e.Bounds.Width >= Width)
                    {
                        text = new String(' ', (comboItem as ParentPageComboItem).IndentLevel * 3) + text;
                    }
                }

                e.DrawBackground();

                using (Brush brush = new SolidBrush(e.ForeColor))
                    e.Graphics.DrawString(text, e.Font, brush, e.Bounds.X, e.Bounds.Y + 1);

                e.DrawFocusRectangle();
            }
        }