您目前尚未登陆,请选择【登陆】或【注册
首页->博客论坛->SpaceBuilder v1.0正式版源码>>BlogControls/Views/WeblogCalendar.cs>>源码在线查看
温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:SpaceBuilder v1.0正式版源码
当前文件:文件类型 SpaceBuiderV10Source/BlogControls/Views/WeblogCalendar.cs打开代码结构图
普通视图
		            
1//------------------------------------------------------------------------------ 2// <copyright company="Tunynet"> 3// Copyright (c) Tunynet Network Technology Co., Ltd. All rights reserved. 4// </copyright> 5//------------------------------------------------------------------------------ 6 7using System; 8using System.Web.UI; 9using System.Web.UI.WebControls; 10using System.Collections; 11using System.Globalization; 12using System.Threading; 13 14using SpaceBuilder.Blogs.Components; 15using SpaceBuilder.Components; 16using SpaceBuilder.Configuration; 17using SpaceBuilder.Utils; 18using System.Collections.Generic; 19using TunyNet.Utils; 20 21namespace SpaceBuilder.Blogs.Controls 22{ 23 /// <summary> 24 /// 博客日历 25 /// </summary> 26 public class WeblogCalendar : WeblogThemedControl 27 { 28 protected override void OnLoad(EventArgs e) 29 { 30 base.OnLoad(e); 31 this.EnsureChildControls(); 32 Bind(); 33 } 34 35 public void Bind() 36 { 37 新增日历格式 52 53 int month = ValueHelper.SafeInt(Context.Request.QueryString["M"], -1); 54 int year = ValueHelper.SafeInt(Context.Request.QueryString["Y"], -1); 55 int day = ValueHelper.SafeInt(Context.Request.QueryString["D"], -1); 56 57 if (month != -1 && year != -1) 58 { 59 CurrentDate = new DateTime(year, month, day != -1 ? day : 1); 60 postCalendar.VisibleDate = CurrentDate; 61 } 62 } 63 64 private ArchiveDataItem DataItem(int day) 65 { 66 if (days == null) 67 { 68 days = BlogPosts.GetPostsByMonth(this.CurrentWeblog.SectionID, CurrentDate); 69 postCalendar.VisibleDate = CurrentDate; 70 } 71 72 if (days.ContainsKey(day)) 73 return days[day]; 74 else 75 return null; 76 } 77 78 79 private System.Web.UI.WebControls.Calendar postCalendar = null; 80 private DateTime CurrentDate = DateTime.Now; 81 private Dictionary<int, ArchiveDataItem> days = null; 82 83 protected override void AttachChildControls() 84 { 85 postCalendar = FindControl("PostCalendar") as System.Web.UI.WebControls.Calendar; 86 postCalendar.DayRender += new DayRenderEventHandler(postCalendar_DayRender); 87 postCalendar.VisibleMonthChanged += new MonthChangedEventHandler(postCalendar_VisibleMonthChanged); 88 } 89 90 private void postCalendar_DayRender(object sender, DayRenderEventArgs e) 91 { 92 e.Cell.Controls.Clear(); 93 int day = e.Day.Date.Day; 94 95 ArchiveDataItem item = DataItem(day); 96 if (!e.Day.IsOtherMonth && item != null) 97 { 98 HyperLink hl = new HyperLink(); 99 hl.NavigateUrl = BlogUrls.Instance().ShowBlogPostByDay(this.CurrentWeblog.ApplicationKey, item.Date); 100 hl.Text = e.Day.DayNumberText; 101 if (item.Count > 1) 102 hl.ToolTip = item.Count + " 篇文章"; 103 else 104 hl.ToolTip = item.Count + " 篇文章"; 105 106 e.Cell.Controls.Add(hl); 107 } 108 else 109 { 110 e.Cell.Controls.Add(new LiteralControl(e.Day.DayNumberText)); 111 } 112 113 } 114 115 private void postCalendar_VisibleMonthChanged(object sender, MonthChangedEventArgs e) 116 { 117 CurrentDate = e.NewDate; 118 } 119 } 120} 121
还没有找到您心仪的内容?请用.net源码大搜捕
代码片断 打包下载该项目完整源码:SpaceBuilder v1.0正式版源码