Files
yavsc/WebControls/ResultPages.cs
Paul Schneider b7fa996dbc * yavsc.js:
* yavsc.circles.js: js refactoring

* Credits.aspx: A credit about to add

* CircleBase.cs: The Circle base

* NpgsqlCircleProvider.cs: * refactoring
* updates the circle

* InputCircle.cs: using the new CircleBase class

* ResultPages.cs: Using a new "None" attribute

* CircleController.cs: refactoring : drops the NewCircle class The
  `List` method now resterns collection of circlebase

* style.css: * a new `dirty` css class, could be used to tag data to
  validate ala ajax
* removed quite all of the `float` usages

* AccountController.cs: xml doc

* BlogsController.cs: Avatar method moved to the Account controller

* YavscHelpers.cs: An avatar url

* App.master: Login div moved up

* Circles.aspx: a new `private` filed in the `Circle` object, in order
  to keep circle names from being published as user's information,
should be true by default

* Profile.aspx: removed the tables

* Index.aspx: Un message plus explicite

* Web.config: nothing to view

* Web.csproj: * new page : Credit
* new script: yavsc.circle.js

* instdbws.sql: circles are uniques for a given user against a given
  app

* Circle.cs: Now inherits CircleBase to implement a member list

* CircleProvider.cs: implements a circle update method

* LocalizedText.resx:
* LocalizedText.Designer.cs: no content!!!

* LocalizedText.fr.resx:
* LocalizedText.fr.Designer.cs: pas content

* YavscModel.csproj: a new CircleBAse class
2015-09-10 00:55:19 +02:00

161 lines
3.4 KiB
C#

using System;
using System.Web;
using System.Security.Permissions;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.ComponentModel;
namespace Yavsc.WebControls
{
/// <summary>
/// Result pages.
/// </summary>
[
AspNetHostingPermission (SecurityAction.Demand,
Level = AspNetHostingPermissionLevel.Minimal),
AspNetHostingPermission (SecurityAction.InheritanceDemand,
Level = AspNetHostingPermissionLevel.Minimal),
ParseChildren (true),
ToolboxData ("<{0}:ResultPages runat=\"server\"> </{0}:ResultPages>")
]
public class ResultPages: WebControl
{
/// <summary>
/// Initializes a new instance of the <see cref="Yavsc.WebControls.ResultPages"/> class.
/// </summary>
public ResultPages ()
{
}
/// <summary>
/// Gets or sets the results per page.
/// </summary>
/// <value>The results per page.</value>
[Bindable (true)]
[DefaultValue(10)]
public int ResultsPerPage {
get {
return (int)( ViewState["ResultsPerPage"]==null?10:ViewState["ResultsPerPage"]);
}
set {
ViewState["ResultsPerPage"]=value;
}
}
/// <summary>
/// Gets or sets the result count.
/// </summary>
/// <value>The result count.</value>
[Bindable (true)]
[DefaultValue(0)]
public int ResultCount {
get {
return (int)( ViewState["ResultCount"]==null?0:ViewState["ResultCount"]);
}
set {
ViewState["ResultCount"] = value;
}
}
/// <summary>
/// Gets or sets the text.
/// </summary>
/// <value>The text.</value>
[Bindable (true)]
[DefaultValue("Pages:")]
[Localizable(true)]
public string Text {
get {
string s = (string)ViewState["Text"];
return (s == null) ? "Pages:" : s;
}
set {
ViewState["Text"] = value;
}
}
/// <summary>
/// Gets or sets the action.
/// </summary>
/// <value>The action.</value>
[Bindable (true)]
[DefaultValue("")]
public string Action {
get {
string s = (string)ViewState["Action"];
return (s == null) ? String.Empty : s;
}
set {
ViewState["Action"] = value;
}
}
[Bindable (true)]
[DefaultValue("none")]
public string None {
get {
string s = (string) ViewState["None"];
return (s == null) ? String.Empty : s;
}
set {
ViewState["None"] = value;
}
}
/// <summary>
/// Gets or sets the current page.
/// </summary>
/// <value>The current page.</value>
[Bindable (true)]
[DefaultValue(0)]
public int CurrentPage {
get {
int i = (int)(ViewState["CurrentPage"]==null?0:ViewState["CurrentPage"]);
return i;
}
set {
ViewState["CurrentPage"] = value;
}
}
/// <summary>
/// Renders the contents as the list of links to pages of results.
/// </summary>
/// <param name="writer">Writer.</param>
protected override void RenderContents (HtmlTextWriter writer)
{
if (ResultCount > 0 && ResultCount > ResultsPerPage ) {
writer.WriteEncodedText (Text);
int pageCount = ((ResultCount-1) / ResultsPerPage) + 1;
for (int pi = (CurrentPage < 5) ? 0 : CurrentPage - 5; pi < pageCount && pi < CurrentPage + 5; pi++) {
if (CurrentPage == pi)
writer.RenderBeginTag ("b");
else {
writer.AddAttribute (HtmlTextWriterAttribute.Href,
string.Format (Action, pi));
writer.RenderBeginTag ("a");
}
writer.Write (pi+1);
writer.RenderEndTag ();
writer.Write ("&nbsp;");
}
}
if (ResultCount == 0) {
writer.Write ("(");
writer.Write (None);
writer.Write (")");
}
}
}
}