private void LoadCategories(bool doRtlFixup)
        {
            Controls.Clear();
            int y = DockPadding.Top;
            List <BlogPostCategory> categories = new List <BlogPostCategory>(ctx.Categories);

            if (categories.Count == 0)
            {
                return;
            }

            categories.Add(new BlogPostCategoryNone());
            categories.Sort();

            BlogPostCategory[] selected = ctx.SelectedCategories;

            foreach (BlogPostCategory cat in categories)
            {
                RadioButton radio = new RadioButton();
                Controls.Add(radio);
                radio.Text           = HtmlUtils.UnEscapeEntities(cat.Name, HtmlUtils.UnEscapeMode.Default);
                radio.AccessibleName = cat.Name;
                radio.UseMnemonic    = false;
                radio.Tag            = cat;
                radio.AutoSize       = true;
                radio.Location       = new Point(DockPadding.Left, y);
                y = radio.Bottom;

                if (BlogPostCategoryNone.IsCategoryNone(cat))
                {
                    radio.Checked = selected.Length == 0;
                }
                else
                {
                    radio.Checked = Array.IndexOf(selected, cat) >= 0;
                }

                radio.CheckedChanged += radio_CheckedChanged;
            }

            if (doRtlFixup)
            {
                BidiHelper.RtlLayoutFixup(this, true);
            }
        }
Пример #2
0
        private void UpdateSelectedCategories(BlogPostCategory[] selectedCategories)
        {
            bool focused = false;

            foreach (ICategorySelectorControl sc in _categoryControls)
            {
                if (!focused)
                {
                    sc.Control.Focus();
                    focused = true;
                }
                sc.Selected = false;
            }

            if (selectedCategories.Length > 0)
            {
                foreach (BlogPostCategory c in selectedCategories)
                {
                    foreach (ICategorySelectorControl sc in _categoryControls)
                    {
                        if (c.Id.ToLower(CultureInfo.CurrentCulture) == sc.Category.Id.ToLower(CultureInfo.CurrentCulture) ||
                            c.Name.ToLower(CultureInfo.CurrentCulture) == sc.Category.Name.ToLower(CultureInfo.CurrentCulture))
                        {
                            sc.Selected = true;
                            break;
                        }
                    }
                }
            }
            else
            {
                // scan for special "None" category and select it
                foreach (ICategorySelectorControl sc in _categoryControls)
                {
                    if (BlogPostCategoryNone.IsCategoryNone((sc.Category)))
                    {
                        sc.Selected = true;
                        break;
                    }
                }
            }
        }
Пример #3
0
        private BlogPostCategory GetParentCategory()
        {
            ParentCategoryComboItem parentComboItem = comboBoxParent.SelectedItem as ParentCategoryComboItem;

            if (parentComboItem != null)
            {
                if (!BlogPostCategoryNone.IsCategoryNone(parentComboItem.Category))
                {
                    return(parentComboItem.Category);
                }
                else
                {
                    return(null);
                }
            }
            else
            {
                return(null);
            }
        }
Пример #4
0
        private BlogPostCategory[] GetCurrentlySelectedCategories()
        {
            ArrayList selectedCategories = new ArrayList();

            foreach (ICategorySelectorControl sc in _categoryControls)
            {
                if (sc.Selected)
                {
                    if (BlogPostCategoryNone.IsCategoryNone(sc.Category))
                    {
                        selectedCategories.Clear();
                        break;
                    }
                    else
                    {
                        selectedCategories.Add(sc.Category);
                    }
                }
            }
            return((BlogPostCategory[])selectedCategories.ToArray(typeof(BlogPostCategory)));
        }
Пример #5
0
        private void CommitSelection()
        {
            ArrayList selectedCategories = new ArrayList();

            foreach (ICategorySelectorControl categoryControl in _categoryControls)
            {
                if (categoryControl.Selected)
                {
                    if (BlogPostCategoryNone.IsCategoryNone(categoryControl.Category))
                    {
                        selectedCategories.Clear();
                        break;
                    }
                    else
                    {
                        selectedCategories.Add(categoryControl.Category);
                    }
                }
            }
            _categoryContext.SelectedCategories = (BlogPostCategory[])selectedCategories.ToArray(typeof(BlogPostCategory));
        }
Пример #6
0
        /// <summary>
        /// Take the blog post data and put it into the XML node.
        /// </summary>
        protected virtual void Populate(BlogPost post, Uri documentUri, XmlElement node, bool publish)
        {
            AtomEntry atomEntry = new AtomEntry(_atomVer, _atomNS, CategoryScheme, _nsMgr, documentUri, node);

            if (post.IsNew)
            {
                atomEntry.GenerateId();
            }
            atomEntry.Title = post.Title;
            if (Options.SupportsExcerpt && post.Excerpt != null && post.Excerpt.Length > 0)
            {
                atomEntry.Excerpt = post.Excerpt;
            }
            // extra space is to work around AOL Journals XML parsing bug
            atomEntry.ContentHtml = post.Contents + " ";
            if (Options.SupportsCustomDate && post.HasDatePublishedOverride)
            {
                atomEntry.PublishDate = post.DatePublishedOverride;
            }

            if (Options.SupportsCategories)
            {
                atomEntry.ClearCategories();

                foreach (BlogPostCategory cat in post.Categories)
                {
                    if (!BlogPostCategoryNone.IsCategoryNone(cat))
                    {
                        atomEntry.AddCategory(cat);
                    }
                }

                if (Options.SupportsNewCategories)
                {
                    foreach (BlogPostCategory cat in post.NewCategories)
                    {
                        if (!BlogPostCategoryNone.IsCategoryNone(cat))
                        {
                            atomEntry.AddCategory(cat);
                        }
                    }
                }
            }

            if (Options.SupportsPostAsDraft)
            {
                // remove existing draft nodes
                while (true)
                {
                    XmlNode draftNode = node.SelectSingleNode(@"app:control/app:draft", _nsMgr);
                    if (draftNode == null)
                    {
                        break;
                    }
                    draftNode.ParentNode.RemoveChild(draftNode);
                }

                if (!publish)
                {
                    // ensure control node exists
                    XmlNode controlNode = node.SelectSingleNode(@"app:control", _nsMgr);
                    if (controlNode == null)
                    {
                        controlNode = node.OwnerDocument.CreateElement(_pubNS.Prefix, "control", _pubNS.Uri);
                        node.AppendChild(controlNode);
                    }
                    // create new draft node
                    XmlElement newDraftNode = node.OwnerDocument.CreateElement(_pubNS.Prefix, "draft", _pubNS.Uri);
                    newDraftNode.InnerText = "yes";
                    controlNode.AppendChild(newDraftNode);
                }
            }

            //post.Categories;
            //post.CommentPolicy;
            //post.CopyFrom;
            //post.Excerpt;
            //post.HasDatePublishedOverride;
            //post.Id;
            //post.IsNew;
            //post.IsTemporary;
            //post.Keywords;
            //post.Link;
            //post.Permalink;
            //post.PingUrls;
            //post.ResetToNewPost;
            //post.TrackbackPolicy;
        }