📄 property.cs
字号:
namespace PowerEasy.WebSite.Controls.FieldControl
{
using AjaxControlToolkit;
using PowerEasy.Common;
using PowerEasy.Web.UI;
using System;
using System.Collections.Generic;
using System.Text;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
public class Property : BaseFieldControl
{
protected DropDownExtender DDE;
protected Panel DropPanel;
protected Literal LtrProperty;
protected Repeater RptSelectPropertyItem;
protected HtmlTableRow Tab;
protected TextBox TxtProperty;
protected UpdatePanel UpnlSelectProperty;
protected void DelItem_Command(object sender, CommandEventArgs e)
{
if (e.CommandName == "DelPropertyItem")
{
this.DelProperty(e.CommandArgument.ToString());
}
this.RptSelectPropertyItem.DataSource = this.ViewState["PropertyItemList" + base.FieldName] as List<string>;
this.RptSelectPropertyItem.DataBind();
}
private void DelProperty(string delItem)
{
IList<string> propertyList = new List<string>();
if (this.ViewState["PropertyItemList" + base.FieldName] != null)
{
propertyList = this.ViewState["PropertyItemList" + base.FieldName] as List<string>;
}
propertyList.Remove(delItem);
this.SetProperties(propertyList);
}
private IList<string> GetPropertyItemList(string addItem)
{
IList<string> list = new List<string>();
if (this.ViewState["PropertyItemList" + base.FieldName] != null)
{
list = this.ViewState["PropertyItemList" + base.FieldName] as List<string>;
}
bool flag = false;
foreach (string str in list)
{
if (str == addItem)
{
flag = true;
break;
}
}
if (!flag)
{
list.Add(addItem);
}
this.ViewState["PropertyItemList" + base.FieldName] = list;
return list;
}
private void InitializeDropPanel()
{
if (base.Settings.Count > 0)
{
string[] strArray = base.Settings[0].Split(new char[] { '|' });
int num = 0;
foreach (string str in strArray)
{
LinkButton child = new LinkButton();
child.Text = str;
child.ID = "LbtnProperty" + num;
child.CssClass = "ContextMenuItem";
child.CausesValidation = false;
child.Click += new EventHandler(this.OnSelect);
this.DropPanel.Controls.Add(child);
num++;
}
}
}
protected void OnSelect(object sender, EventArgs e)
{
IList<string> propertyItemList = this.GetPropertyItemList(((LinkButton) sender).Text);
this.RptSelectPropertyItem.DataSource = propertyItemList;
this.RptSelectPropertyItem.DataBind();
this.SetProperties(propertyItemList);
}
protected void Page_Load(object sender, EventArgs e)
{
this.InitializeDropPanel();
if (!this.Page.IsPostBack && (BaseUserControl.RequestStringToLower("Action") == "modify"))
{
IList<string> list = new List<string>();
foreach (string str in this.FieldValue.Split(new char[] { '|' }))
{
list.Add(str);
}
this.RptSelectPropertyItem.DataSource = list;
this.RptSelectPropertyItem.DataBind();
this.ViewState["PropertyItemList" + base.FieldName] = list;
this.Properties = this.FieldValue;
this.TxtProperty.Visible = false;
this.RptSelectPropertyItem.Visible = false;
this.LtrProperty.Visible = true;
this.LtrProperty.Text = this.FieldValue;
}
}
private void SetProperties(IList<string> propertyList)
{
StringBuilder sb = new StringBuilder();
foreach (string str in propertyList)
{
StringHelper.AppendString(sb, str, "|");
}
this.Properties = sb.ToString();
}
public string Properties
{
get
{
return (this.ViewState["Properties"] as string);
}
set
{
this.FieldValue = value;
this.ViewState["Properties"] = value;
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -