Split VAR.WebForms.Common to a class library.
This commit is contained in:
@@ -1,12 +0,0 @@
|
||||
using System.Web.UI.WebControls;
|
||||
|
||||
namespace VAR.Focus.Web.Controls
|
||||
{
|
||||
public class CButton : Button
|
||||
{
|
||||
public CButton()
|
||||
{
|
||||
CssClass = "button";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
|
||||
namespace VAR.Focus.Web.Controls
|
||||
{
|
||||
public class CLabel : Label
|
||||
{
|
||||
#region Declarations
|
||||
|
||||
private string _tagName = "span";
|
||||
|
||||
#endregion Declarations
|
||||
|
||||
#region Properties
|
||||
|
||||
public string Tag
|
||||
{
|
||||
get { return _tagName; }
|
||||
set { _tagName = value; }
|
||||
}
|
||||
|
||||
#endregion Properties
|
||||
|
||||
#region Life cycle
|
||||
|
||||
public override void RenderBeginTag(HtmlTextWriter writer)
|
||||
{
|
||||
if (string.IsNullOrEmpty(_tagName) == false)
|
||||
{
|
||||
this.AddAttributesToRender(writer);
|
||||
writer.RenderBeginTag(_tagName);
|
||||
}
|
||||
else
|
||||
{
|
||||
base.RenderBeginTag(writer);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Life cycle
|
||||
}
|
||||
}
|
||||
@@ -1,210 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
using VAR.Json;
|
||||
|
||||
namespace VAR.Focus.Web.Controls
|
||||
{
|
||||
public class CTextBox : Control, INamingContainer, IValidableControl
|
||||
{
|
||||
#region Declarations
|
||||
|
||||
private TextBox _txtContent = new TextBox();
|
||||
|
||||
private HiddenField _hidSize = null;
|
||||
|
||||
private const string CssClassBase = "textbox";
|
||||
private string _cssClassExtra = "";
|
||||
|
||||
private bool _allowEmpty = true;
|
||||
|
||||
private string _placeHolder = string.Empty;
|
||||
|
||||
private bool _markedInvalid = false;
|
||||
|
||||
private Control _nextFocusOnEnter = null;
|
||||
|
||||
private bool _keepSize = false;
|
||||
|
||||
#endregion Declarations
|
||||
|
||||
#region Properties
|
||||
|
||||
public string CssClassExtra
|
||||
{
|
||||
get { return _cssClassExtra; }
|
||||
set { _cssClassExtra = value; }
|
||||
}
|
||||
|
||||
public bool AllowEmpty
|
||||
{
|
||||
get { return _allowEmpty; }
|
||||
set { _allowEmpty = value; }
|
||||
}
|
||||
|
||||
public string PlaceHolder
|
||||
{
|
||||
get { return _placeHolder; }
|
||||
set { _placeHolder = value; }
|
||||
}
|
||||
|
||||
public bool MarkedInvalid
|
||||
{
|
||||
get { return _markedInvalid; }
|
||||
set { _markedInvalid = value; }
|
||||
}
|
||||
|
||||
public Control NextFocusOnEnter
|
||||
{
|
||||
get { return _nextFocusOnEnter; }
|
||||
set { _nextFocusOnEnter = value; }
|
||||
}
|
||||
|
||||
public bool KeepSize
|
||||
{
|
||||
get { return _keepSize; }
|
||||
set { _keepSize = value; }
|
||||
}
|
||||
|
||||
public string Text
|
||||
{
|
||||
get { return _txtContent.Text; }
|
||||
set { _txtContent.Text = value; }
|
||||
}
|
||||
|
||||
public TextBoxMode TextMode
|
||||
{
|
||||
get { return _txtContent.TextMode; }
|
||||
set { _txtContent.TextMode = value; }
|
||||
}
|
||||
|
||||
#endregion Properties
|
||||
|
||||
#region Control life cycle
|
||||
|
||||
public CTextBox()
|
||||
{
|
||||
Init += CTextBox_Init;
|
||||
PreRender += CTextbox_PreRender;
|
||||
}
|
||||
|
||||
private void CTextBox_Init(object sender, EventArgs e)
|
||||
{
|
||||
Controls.Add(_txtContent);
|
||||
|
||||
if (TextMode == TextBoxMode.MultiLine)
|
||||
{
|
||||
if (_keepSize)
|
||||
{
|
||||
_hidSize = new HiddenField();
|
||||
Controls.Add(_hidSize);
|
||||
}
|
||||
|
||||
string strCfgName = string.Format("{0}_cfg", this.ClientID);
|
||||
Dictionary<string, object> cfg = new Dictionary<string, object>
|
||||
{
|
||||
{"txtContent", _txtContent.ClientID},
|
||||
{"hidSize", _hidSize.ClientID},
|
||||
{"keepSize", _keepSize },
|
||||
};
|
||||
JsonWriter jsonWriter = new JsonWriter();
|
||||
StringBuilder sbCfg = new StringBuilder();
|
||||
sbCfg.AppendFormat("<script>\n");
|
||||
sbCfg.AppendFormat("var {0} = {1};\n", strCfgName, jsonWriter.Write(cfg));
|
||||
sbCfg.AppendFormat("CTextBox_Multiline_Init({0});\n", strCfgName);
|
||||
sbCfg.AppendFormat("</script>\n");
|
||||
LiteralControl liScript = new LiteralControl(sbCfg.ToString());
|
||||
Controls.Add(liScript);
|
||||
}
|
||||
}
|
||||
|
||||
private void CTextbox_PreRender(object sender, EventArgs e)
|
||||
{
|
||||
_txtContent.CssClass = CssClassBase;
|
||||
if (string.IsNullOrEmpty(_cssClassExtra) == false)
|
||||
{
|
||||
_txtContent.CssClass = string.Format("{0} {1}", CssClassBase, _cssClassExtra);
|
||||
}
|
||||
if (Page.IsPostBack && (_allowEmpty == false && IsEmpty()) || _markedInvalid)
|
||||
{
|
||||
_txtContent.CssClass += " textboxInvalid";
|
||||
}
|
||||
_txtContent.Attributes.Add("onchange", "ElementRemoveClass(this, 'textboxInvalid');");
|
||||
|
||||
if (string.IsNullOrEmpty(_placeHolder) == false)
|
||||
{
|
||||
_txtContent.Attributes.Add("placeholder", _placeHolder);
|
||||
}
|
||||
|
||||
if (_nextFocusOnEnter != null)
|
||||
{
|
||||
_txtContent.Attributes.Add("onkeydown", string.Format(
|
||||
"if(event.keyCode==13){{document.getElementById('{0}').focus(); return false;}}",
|
||||
_nextFocusOnEnter.ClientID));
|
||||
}
|
||||
|
||||
// FIX: The framework deletes textbox values on password mode
|
||||
if (_txtContent.TextMode == TextBoxMode.Password)
|
||||
{
|
||||
_txtContent.Attributes["value"] = _txtContent.Text;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Control life cycle
|
||||
|
||||
#region Public methods
|
||||
|
||||
public bool IsEmpty()
|
||||
{
|
||||
return string.IsNullOrEmpty(_txtContent.Text);
|
||||
}
|
||||
|
||||
public bool IsValid()
|
||||
{
|
||||
return _allowEmpty || (string.IsNullOrEmpty(_txtContent.Text) == false);
|
||||
}
|
||||
|
||||
public int? GetClientsideHeight()
|
||||
{
|
||||
if (string.IsNullOrEmpty(_hidSize.Value))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
JsonParser jsonParser = new JsonParser();
|
||||
Dictionary<string, object> sizeObj = jsonParser.Parse(_hidSize.Value) as Dictionary<string, object>;
|
||||
if (sizeObj == null) { return null; }
|
||||
|
||||
if (sizeObj.ContainsKey("height") == false) { return null; }
|
||||
return (int)sizeObj["height"];
|
||||
}
|
||||
|
||||
public void SetClientsideHeight(int? height)
|
||||
{
|
||||
if(height == null)
|
||||
{
|
||||
_hidSize.Value = string.Empty;
|
||||
return;
|
||||
}
|
||||
Dictionary<string, object> sizeObj = null;
|
||||
if (string.IsNullOrEmpty(_hidSize.Value) == false)
|
||||
{
|
||||
JsonParser jsonParser = new JsonParser();
|
||||
sizeObj = jsonParser.Parse(_hidSize.Value) as Dictionary<string, object>;
|
||||
}
|
||||
else
|
||||
{
|
||||
sizeObj = new Dictionary<string, object> {
|
||||
{ "height", height },
|
||||
{ "width", null },
|
||||
{ "scrollTop", null },
|
||||
};
|
||||
}
|
||||
JsonWriter jsonWriter = new JsonWriter();
|
||||
_hidSize.Value = jsonWriter.Write(sizeObj);
|
||||
}
|
||||
|
||||
#endregion Public methods
|
||||
}
|
||||
}
|
||||
@@ -3,9 +3,9 @@ using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
using VAR.Focus.Web.Code;
|
||||
using VAR.Focus.Web.Pages;
|
||||
using VAR.Json;
|
||||
using VAR.WebForms.Common.Code;
|
||||
|
||||
namespace VAR.Focus.Web.Controls
|
||||
{
|
||||
@@ -146,7 +146,7 @@ namespace VAR.Focus.Web.Controls
|
||||
{"DefaultRegionWidth", _defaultRegionWidth},
|
||||
{"DefaultRegionHeight", _defaultRegionHeight},
|
||||
{"Texts", new Dictionary<string, object> {
|
||||
{"Toolbox",MultiLang.GetLiteral( "Toolbox")},
|
||||
{"Toolbox", MultiLang.GetLiteral( "Toolbox")},
|
||||
{"AddCard", MultiLang.GetLiteral("AddCard")},
|
||||
{"AddRegion", MultiLang.GetLiteral("AddRegion")},
|
||||
{"EditBoard", MultiLang.GetLiteral("Config")},
|
||||
|
||||
@@ -3,8 +3,9 @@ using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
using VAR.Focus.Web.Code;
|
||||
using VAR.Json;
|
||||
using VAR.WebForms.Common.Code;
|
||||
using VAR.WebForms.Common.Controls;
|
||||
|
||||
namespace VAR.Focus.Web.Controls
|
||||
{
|
||||
|
||||
@@ -6,6 +6,7 @@ using VAR.Focus.BusinessLogic;
|
||||
using VAR.Focus.BusinessLogic.Entities;
|
||||
using VAR.Focus.BusinessLogic.Persistence;
|
||||
using VAR.Focus.Web.Code;
|
||||
using VAR.WebForms.Common.Code;
|
||||
|
||||
namespace VAR.Focus.Web.Controls
|
||||
{
|
||||
|
||||
@@ -6,6 +6,7 @@ using VAR.Focus.BusinessLogic;
|
||||
using VAR.Focus.BusinessLogic.Entities;
|
||||
using VAR.Focus.BusinessLogic.Persistence;
|
||||
using VAR.Focus.Web.Code;
|
||||
using VAR.WebForms.Common.Code;
|
||||
|
||||
namespace VAR.Focus.Web.Controls
|
||||
{
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
namespace VAR.Focus.Web.Controls
|
||||
{
|
||||
public interface IValidableControl
|
||||
{
|
||||
bool IsValid();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user