defaultcs.aspx.cs
来自「Telerik是很大的第三方软件制造商」· CS 代码 · 共 210 行
CS
210 行
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using Telerik.QuickStart;
using Telerik.WebControls;
namespace Telerik.CallbackExamplesCSharp.Controls.ImageButton
{
/// <summary>
/// Summary description for _Default.
/// </summary>
public class DefaultCS: XhtmlPage
{
protected System.Web.UI.WebControls.TextBox TextBox1;
protected System.Web.UI.WebControls.Label Label1;
protected System.Web.UI.WebControls.Label Label2;
protected System.Web.UI.WebControls.Label label11;
protected System.Web.UI.WebControls.Label statusLabel;
protected Telerik.WebControls.LoadingPanel LoadingPanel1;
protected System.Web.UI.HtmlControls.HtmlImage Img1;
protected Telerik.WebControls.CallbackImageButton CallbackImageButton1;
private void Page_Load(object sender, System.EventArgs e)
{
if (!Page.IsPostBack)
{
Rows = 0;
}
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.CallbackImageButton1.Activate += new System.EventHandler(this.CallbackImageButton1_Activate);
this.CallbackImageButton1.Deactivate += new System.EventHandler(this.CallbackImageButton1_Deactivate);
this.CallbackImageButton1.MouseOut += new Telerik.WebControls.CallbackControls.MouseEventHandler(this.CallbackImageButton1_MouseOut);
this.CallbackImageButton1.Click += new System.Web.UI.ImageClickEventHandler(this.CallbackImageButton1_Click);
this.CallbackImageButton1.ContextMenuRequest += new Telerik.WebControls.CallbackControls.MouseEventHandler(this.CallbackImageButton1_ContextMenuRequest);
this.CallbackImageButton1.MouseWheel += new Telerik.WebControls.CallbackControls.MouseEventHandler(this.CallbackImageButton1_MouseWheel);
this.CallbackImageButton1.GetFocus += new System.EventHandler(this.CallbackImageButton1_GetFocus);
this.CallbackImageButton1.LoseFocus += new System.EventHandler(this.CallbackImageButton1_LoseFocus);
this.CallbackImageButton1.MouseOver += new Telerik.WebControls.CallbackControls.MouseEventHandler(this.CallbackImageButton1_MouseOver);
this.CallbackImageButton1.MouseDblClick += new Telerik.WebControls.CallbackControls.MouseEventHandler(this.CallbackImageButton1_MouseDblClick);
this.CallbackImageButton1.KeyPress += new Telerik.WebControls.CallbackControls.KeyPressEventHandler(this.CallbackImageButton1_KeyPress);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private int Rows
{
get
{
return (int) ViewState["Rows"];
}
set
{
ViewState["Rows"] = value;
}
}
private void AddText(string s)
{
Rows++;
if (Rows > 18)
{
CallbackImageButton1.ResponseScript += string.Format("updateTextBox('{0}', true);", s);
Rows = 0;
}
else
{
CallbackImageButton1.ResponseScript += string.Format("updateTextBox('{0}', false);", s);
}
}
private static string[] town = new string[4] { "Andora", "Monaco", "San Marino", "Vatikana"};
private static string[] descr = new string[4] {
"The site of Andorra la Vella (literally, \"Andorra the Old\") has been settled since prior to the Christian era, and it has been as the principal city of Andorra since 1278 when the French and the Episcopal co-princes agreed to joint suzerainty. In 1993, the country's first constitution established a parliamentary democracy with executive, legislative, and judicial branches located in Andorra la Vella.",
"Monaco derives its name from the nearby Greek colony, Monoikos, founded in the 6th century BC by the Phoceans. According to an ancient myth, Hercules passed through the Monaco area. A temple was constructed there by Phoceans, the temple of Hercules Monoikos (Monoikos means single house or single temple).",
"San Marino claims to be the world's oldest republic still in existence, being founded in A.D. 301 by a skilled builder referred to as St. Marinus. Its written constitution was adopted on October 8, 1600. The tiny nation was recognized by Napoleon's France in 1797, and by the other European nations at the 1815 Congress of Vienna.",
"The city takes its name from Mons Vaticanus, also known as Vatican Hill. Mons Vaticanus and the adjacent Vatican Fields upon which St. Peter's Basilica and its Sistine Chapel, Apostolic Palace and museums were built, predates Christendom."
};
private static Rectangle[] Regions = new Rectangle[4] { Rectangle.FromLTRB(3, 75, 49, 116),
Rectangle.FromLTRB(108, 47, 156, 78),
Rectangle.FromLTRB(200, 28, 250, 68),
Rectangle.FromLTRB(206, 79, 260, 119)
};
private int GetRectIndex(Point p)
{
int index = 0;
foreach (Rectangle rect in Regions)
{
if (rect.Contains(p))
{
return index;
}
index++;
}
return -1;
}
private void CallbackImageButton1_Click(object sender, System.Web.UI.ImageClickEventArgs e)
{
Point p = new Point(e.X, e.Y);
AddText("Image button is clicked on " + e.X.ToString() + ", " + e.Y.ToString());
int rectIndex = GetRectIndex(p);
if (rectIndex > -1)
{
Label2.Text = town[rectIndex] + " - " + descr[rectIndex];
}
else
{
Label2.Text = "";
}
}
private void CallbackImageButton1_Activate(object sender, System.EventArgs e)
{
AddText("Activated.");
}
private void CallbackImageButton1_ContextMenuRequest(object sender, Telerik.WebControls.CallbackControls.MouseEventArgs args)
{
AddText("ContextMenuRequeted.");
}
private void CallbackImageButton1_Deactivate(object sender, System.EventArgs e)
{
AddText("Deactivated.");
}
private void CallbackImageButton1_GetFocus(object sender, System.EventArgs e)
{
AddText("Got focus.");
}
private void CallbackImageButton1_HelpRequest(object sender, System.EventArgs e)
{
AddText("Help requested.");
}
private void CallbackImageButton1_KeyPress(object sender, Telerik.WebControls.CallbackControls.KeyEventArgs args)
{
AddText("Key press.");
}
private void CallbackImageButton1_LoseFocus(object sender, System.EventArgs e)
{
AddText("Focus lost.");
}
private void CallbackImageButton1_MouseDblClick(object sender, Telerik.WebControls.CallbackControls.MouseEventArgs args)
{
AddText("Mouse double click.");
}
private void CallbackImageButton1_MouseDown(object sender, Telerik.WebControls.CallbackControls.MouseEventArgs args)
{
AddText("Mouse down.");
}
private void CallbackImageButton1_MouseOut(object sender, Telerik.WebControls.CallbackControls.MouseEventArgs args)
{
AddText("Mouse out.");
}
private void CallbackImageButton1_MouseOver(object sender, Telerik.WebControls.CallbackControls.MouseEventArgs args)
{
AddText("Mouse over.");
}
private void CallbackImageButton1_MouseUp(object sender, Telerik.WebControls.CallbackControls.MouseEventArgs args)
{
AddText("Mouse up.");
}
private void CallbackImageButton1_MouseWheel(object sender, Telerik.WebControls.CallbackControls.MouseEventArgs args)
{
AddText("Mouse wheel.");
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?