PageRenderTime 9ms CodeModel.GetById 2ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 0ms

/BlogEngine/BlogEngine.NET/widgets/Category list/edit.ascx.cs

#
C# | 58 lines | 33 code | 10 blank | 15 comment | 1 complexity | e11ca41901f4937f46e76d4be5d3be9e MD5 | raw file
 1// --------------------------------------------------------------------------------------------------------------------
 2// <summary>
 3//   The widgets categories edit.
 4// </summary>
 5// --------------------------------------------------------------------------------------------------------------------
 6
 7namespace Widgets.CategoryList
 8{
 9    using System;
10
11    using App_Code.Controls;
12
13    /// <summary>
14    /// The widgets categories edit.
15    /// </summary>
16    public partial class WidgetsCategoriesEdit : WidgetEditBase
17    {
18        #region Public Methods
19
20        /// <summary>
21        /// Saves this the basic widget settings such as the Title.
22        /// </summary>
23        public override void Save()
24        {
25            var settings = this.GetSettings();
26            settings["showrssicon"] = this.cbShowRssIcon.Checked.ToString();
27            settings["showpostcount"] = this.cbShowPostCount.Checked.ToString();
28            this.SaveSettings(settings);
29        }
30
31        #endregion
32
33        #region Methods
34
35        /// <summary>
36        /// Raises the <see cref="E:System.Web.UI.Control.Init"/> event.
37        /// </summary>
38        /// <param name="e">An <see cref="T:System.EventArgs"/> object that contains the event data.</param>
39        protected override void OnInit(EventArgs e)
40        {
41            var settings = this.GetSettings();
42            var showRssIcon = true;
43            var showPostCount = true;
44            if (settings.ContainsKey("showrssicon"))
45            {
46                bool.TryParse(settings["showrssicon"], out showRssIcon);
47                bool.TryParse(settings["showpostcount"], out showPostCount);
48            }
49
50            this.cbShowRssIcon.Checked = showRssIcon;
51            this.cbShowPostCount.Checked = showPostCount;
52
53            base.OnInit(e);
54        }
55
56        #endregion
57    }
58}