MarkItUp.SingleUserBlog.Web/UserControls/PostEditor.ascx.cs

(开头部分) 6KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using System;
using System.IO;
using System.Web.UI;
using System.Xml;
using FreeTextBoxControls.Support.Sgml;
using MarkItUp.SingleUserBlog.Common;
using MarkItUp.SingleUserBlog.Services;
using MarkItUp.SingleUserBlog.UI;
using MarkItUp.SingleUserBlog.Web.Controls;

public delegate void PostAddedEventHandler(PostEditor sender, Post post);
public delegate void PostErrorEventHandler(PostEditor sender, string errorMessage);

public partial class PostEditor : UserControl {
    // This is the index of the toolbar that has all the insert items. If the toolbars are reordered, you nee
    // to change this!
    private const int InsertToolbarIndex = 4;

    public event PostAddedEventHandler PostAdded;
    public event PostErrorEventHandler PostError;
    public event EventHandler PostCancelled;

    protected override void OnInit(EventArgs e) {
        base.OnInit(e);
        lblCategories.Visible = false;
        lblMessage.Text = "";

        // Unfortunately, the property expects this to already be resolved, so we can't set it in the markup.
        ftbPost.ImageGalleryUrl = ResolveUrl("~/Administration/ftb.imagegallery.aspx?rif={0}&cif={0}");

        // MATT: I've had a crash here, where the toolbar collection is empty. Don't know how/why that
        // could happen, but I'll guard against it.
        if (ftbPost.Toolbars.Count >= InsertToolbarIndex)
            ftbPost.Toolbars[InsertToolbarIndex].Items.Add(new InsertCodeButton(ResolveUrl("~/Administration/ftb.insertcode.aspx")));
    }

    public string PostId {
        get { return hdnPostId.Value; }
        set {
            hdnPostId.Value = value;
            LoadPost(PostId);
        }
    }

    void LoadPost(string postId) {
        Post post = DataLayer.Instance.LoadPost(postId);
        if (post != null) {
            txtHeader.Text = post.DisplayName;
            chkApproved.Checked = post.IsApproved;
            ftbPost.Text = post.Description;
            LoadPostCategories(postId);
        }
    }

    void LoadPostCategories(string postId) {
        CategoryCollection categories = DataLayer.Instance.ListCategoriesByPost(postId);
        string[] selectedItems = new string[categories.Count];
        for (int i = 0; i < selectedItems.Length; i++)
            selectedItems[i] = categories[i].Id;

后面还有 129 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明

AI 解读

登录后可用,每次 10 积分,解读结果公开显示在下面。

还没有人解读过这个文件。