Example #1
0
        private void okbtn_Click(object sender, EventArgs e)
        {
            String key = contentlist.SelectedItems[0].Name;

            if (catagorylist.SelectedItems[0].Index >= 2)
            {
                //设置当前的Catagory
                catagory = OpenCatagory.Blog;

                String key1 = catagorylist.SelectedItems[0].Name;

                int idx1 = int.Parse(key1.Trim());

                //设置当前的Account
                curinfo = infolist[idx1];

                int idx = int.Parse(key.Trim());

                postinfo = new PostInfo();
                postinfo.title = posts.ElementAt(idx).Title;

                JoeBlogs.Post p = blog.getPostById(posts.ElementAt(idx).PostID );

                postinfo.text = p.Body;
                postinfo.postid = posts.ElementAt(idx).PostID;
                postinfo.status = BlogStatus.Old;
            }
            else if (catagorylist.SelectedItems[0].Index == 1)
            {
                catagory = OpenCatagory.Recently;

                int idx = int.Parse(key.Trim());

                RecentInfo recent = recentlist[idx];

                //设置account
                curinfo = DataMgr.getAccountById(recent.accountid);

                //设置当前的PostInfo
                postinfo = new PostInfo();
                postinfo.title = recent.title;

                blog = BlogFactory.createBlogger(curinfo.provider);

                JoeBlogs.Post p = blog.getPostById(recent.postid);

                postinfo.text = p.Body;
                postinfo.postid = recent.postid;
                postinfo.status = BlogStatus.Old;
            }
            else
            {
                catagory = OpenCatagory.Draft;

                int idx = int.Parse(key.Trim());

                DraftInfo draft = draftlist[idx];

                postinfo = new PostInfo();
                postinfo.title = draft.title;
                postinfo.text = draft.text;
                postinfo.status = BlogStatus.New;

                curinfo = DataMgr.getAccountById(draft.accountid);
            }

            this.DialogResult = DialogResult.OK;

            this.Close();
        }
Example #2
0
        private void openbtn_Click(object sender, EventArgs e)
        {
            List<AccountInfo> infolist = DataMgr.getAllAccount();
            List<DraftInfo> draftlist = DataMgr.getAllDraft();
            List<RecentInfo> recentlist = DataMgr.getAllRecent();

            if ((infolist == null) || (infolist.Count == 0))
                MessageBox.Show("请先在博客设置中添加博客账户");
            else
            {
                OpenBlogDlg openDlg = new OpenBlogDlg(infolist, draftlist, recentlist);

                if (openDlg.ShowDialog() == DialogResult.OK)
                {
                    if (openDlg.Catagory == OpenCatagory.Blog)
                    {
                        //修改当前的IBlog 和 账户
                        blog = openDlg.Blog;
                        curinfo = openDlg.Account;

                        titlelabel.Text = curinfo.blogname;

                        postinfo = openDlg.Post;

                        titlebox.Text = postinfo.title;
                        editor.HtmlText = postinfo.text;
                        status = postinfo.status;
                    }
                }
            }
        }