#region Using
using System;
using System.IO;
using System.Web;
using System.Web.UI;
using System.Web.Hosting;
using System.Threading;
using System.Xml;
using System.Text;
using BlogEngine.Core;
using BlogEngine.Core.DataStore;
using System.Xml.Serialization;
using System.Collections.Specialized;
#endregion
///
/// Summary description for WidgetBase
///
public abstract class WidgetBase : UserControl
{
#region Properties
private string _Title;
///
/// Gets or sets the title of the widget. It is mandatory for all widgets to set the Title.
///
/// The title of the widget.
public string Title
{
get { return _Title; }
set { _Title = value; }
}
private bool _ShowTitle;
///
/// Gets or sets a value indicating whether [show title].
///
/// true if [show title]; otherwise, false.
public bool ShowTitle
{
get { return _ShowTitle; }
set { _ShowTitle = value; }
}
///
/// Gets the name. It must be exactly the same as the folder that contains the widget.
///
public abstract string Name { get; }
private string _Zone;
///
/// Gets the name of the containing WidgetZone
///
public string Zone
{
get { return _Zone; }
set { _Zone = value; }
}
///
/// Gets wether or not the widget can be edited.
///
/// The only way a widget can be editable is by adding a edit.ascx file to the widget folder.
///
///
public abstract bool IsEditable { get; }
private Guid _WidgetID;
///
/// Gets the widget ID.
///
/// The widget ID.
public Guid WidgetID
{
get { return _WidgetID; }
set { _WidgetID = value; }
}
///
/// Gets a value indicating if the header is visible. This only takes effect if the widgets isn't editable.
///
/// true if the header is visible; otherwise, false.
public virtual bool DisplayHeader
{
get { return true; }
}
#endregion
///
/// This method works as a substitute for Page_Load. You should use this method for
/// data binding etc. instead of Page_Load.
///
public abstract void LoadWidget();
#region Settings
///
/// Get settings from data store
///
/// Settings
public StringDictionary GetSettings()
{
string cacheId = "be_widget_" + WidgetID;
if (Cache[cacheId] == null)
{
WidgetSettings ws = new WidgetSettings(WidgetID.ToString());
Cache[cacheId] = (StringDictionary)ws.GetSettings();
}
return (StringDictionary)Cache[cacheId];
}
#endregion
///
/// Sends server control content to a provided
/// object, which writes the content to be rendered on the client.
///
/// The object that receives the server control content.
protected override void Render(HtmlTextWriter writer)
{
if (string.IsNullOrEmpty(Name))
throw new NullReferenceException("Name must be set on a widget");
StringBuilder sb = new StringBuilder();
sb.Append("
");
}
}