//Open SinglePost form and populate fields with the correct data. protected void excerpt_ReadLinkClick(object sender, EventArgs e) { ctlPostExcerpt excerpt = sender as ctlPostExcerpt; frmSinglePost mySinglePost = new frmSinglePost(); mySinglePost.labelPostTitle.Text = excerpt.TitleText; mySinglePost.richTextBoxPostContent.Text = excerpt.FullContent; mySinglePost.labelPostDate.Text = excerpt.DateText; mySinglePost.ActiveControl = null; mySinglePost.ShowDialog(); }
//Open the post editor form and prepopulate the editor. protected void excerpt_EditLinkClick(object sender, EventArgs e) { ctlPostExcerpt excerpt = sender as ctlPostExcerpt; frmPostEditor myPostEditor = new frmPostEditor(); myPostEditor.textBoxTitle.Text = excerpt.TitleText; myPostEditor.richTextBoxContent.Text = excerpt.FullContent; myPostEditor.dateTimePicker1.Value = Convert.ToDateTime(excerpt.DateText); myPostEditor.fileName = excerpt.PostFileName; myPostEditor.ActiveControl = null; myPostEditor.ShowDialog(); }
//These actions will occur every time this form takes the Active state, keeping the list of posts fresh. protected void frmHome_Activated(object sender, EventArgs e) { flowLayoutPanelPostExcerpts.Controls.Clear(); string tFont, tSize, cFont, cSize, shDate; string[] postFileNames; postFileNames = GetPostFileList(); currentPostList = GetPostObjects(postFileNames); currentPostList.Reverse(); listCount = currentPostList.Count; //This loop adds the composite control 'ctlPostExcerpt' to the FlowLayoutPanel, 3 at a time. for (x = pointer; x < currentPostList.Count && x < (pointer + 3); x++) { ctlPostExcerpt excerpt = new ctlPostExcerpt(); excerpt.TitleText = currentPostList[x].PostTitle; excerpt.DateText = currentPostList[x].PostDate; excerpt.ContentText = currentPostList[x].PostExcerpt; excerpt.FullContent = currentPostList[x].PostContent; excerpt.PostFileName = currentPostList[x].PostFileName; //Apply settings to each post excerpt. GetSettings(out tFont, out tSize, out cFont, out cSize, out shDate); excerpt.TitleFontSize = Convert.ToSingle(tSize); excerpt.TitleFont = tFont; excerpt.DateFontSize = 8; excerpt.DateFont = "Century Gothic"; excerpt.ContentFontSize = Convert.ToSingle(cSize); excerpt.ContentFont = cFont; excerpt.DateVisible = Convert.ToBoolean(shDate); excerpt.ReadLinkClick += new EventHandler(excerpt_ReadLinkClick); excerpt.EditLinkClick += new EventHandler(excerpt_EditLinkClick); flowLayoutPanelPostExcerpts.Controls.Add(excerpt); } }