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