PageRenderTime 16ms CodeModel.GetById 8ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 0ms

/BlogEngine/BlogEngine.NET/widgets/Most comments/edit.ascx.cs

#
C# | 83 lines | 52 code | 14 blank | 17 comment | 5 complexity | 7d8c28f4acc2fea3b8222ca1b4d8f981 MD5 | raw file
 1// --------------------------------------------------------------------------------------------------------------------
 2// <summary>
 3//   Edit widget.
 4// </summary>
 5// --------------------------------------------------------------------------------------------------------------------
 6
 7namespace Widgets.ModeComments
 8{
 9    using System;
10
11    using App_Code.Controls;
12    using BlogEngine.Core;
13
14    /// <summary>
15    /// Edit widget.
16    /// </summary>
17    public partial class Edit : WidgetEditBase
18    {
19        #region Public Methods
20
21        /// <summary>
22        /// Saves this the basic widget settings such as the Title.
23        /// </summary>
24        public override void Save()
25        {
26            var settings = this.GetSettings();
27            settings["avatarsize"] = this.txtSize.Text;
28            settings["numberofvisitors"] = this.txtNumber.Text;
29            settings["days"] = this.txtDays.Text;
30            settings["showcomments"] = this.cbShowComments.Checked.ToString();
31            this.SaveSettings(settings);
32
33            Blog.CurrentInstance.Cache.Remove("most_comments");
34        }
35
36        #endregion
37
38        #region Methods
39
40        /// <summary>
41        /// Raises the <see cref="E:System.Web.UI.Control.PreRender"/> event.
42        /// </summary>
43        /// <param name="e">
44        /// An <see cref="T:System.EventArgs"/> object that contains the event data.
45        /// </param>
46        protected override void OnPreRender(EventArgs e)
47        {
48            if (this.Page.IsPostBack)
49            {
50                return;
51            }
52
53            this.txtNumber.Text = @"3";
54            this.txtSize.Text = @"50";
55            this.txtDays.Text = @"60";
56            this.cbShowComments.Checked = true;
57
58            var settings = this.GetSettings();
59            if (settings.ContainsKey("avatarsize"))
60            {
61                this.txtSize.Text = settings["avatarsize"];
62            }
63
64            if (settings.ContainsKey("numberofvisitors"))
65            {
66                this.txtNumber.Text = settings["numberofvisitors"];
67            }
68
69            if (settings.ContainsKey("days"))
70            {
71                this.txtDays.Text = settings["days"];
72            }
73
74            if (settings.ContainsKey("showcomments"))
75            {
76                this.cbShowComments.Checked = settings["showcomments"].Equals(
77                    "true", StringComparison.OrdinalIgnoreCase);
78            }
79        }
80
81        #endregion
82    }
83}