Example #1
0
		/// <summary>
		/// Adds the contents of another <see cref="UserPrefCollection">UserPrefCollection</see> to the end of the collection.
		/// </summary>
		/// <param name="value">A <see cref="UserPrefCollection">UserPrefCollection</see> containing the Components to add to the collection. </param>
		public void AddRange(UserPrefCollection value) 
		{
			for (int i = 0;	(i < value.Count); i = (i +	1))	
			{
				if (((UserPref)value.List[i]).DataType != UserPrefDataType.HiddenType)
					this._visibleItemCount++;
				if (((UserPref)value.List[i]).Required)
					this._showRequired = true;
				this.Add((UserPref)value.List[i]);
			}
		}
 /// <summary>
 /// Adds the contents of another <see cref="UserPrefCollection">UserPrefCollection</see> to the end of the collection.
 /// </summary>
 /// <param name="value">A <see cref="UserPrefCollection">UserPrefCollection</see> containing the Components to add to the collection. </param>
 public void AddRange(UserPrefCollection value)
 {
     for (int i = 0; (i < value.Count); i = (i + 1))
     {
         if (((UserPref)value.List[i]).DataType != UserPrefDataType.HiddenType)
         {
             this._visibleItemCount++;
         }
         if (((UserPref)value.List[i]).Required)
         {
             this._showRequired = true;
         }
         this.Add((UserPref)value.List[i]);
     }
 }
Example #3
0
 public void AddRange(UserPrefCollection <T> value)
 {
     for (int i = 0; i < value.Count; i++)
     {
         T t = value[i];
         if (t.DataType != UserPrefDataType.HiddenType)
         {
             this._visibleItemCount++;
         }
         T t2 = value[i];
         if (t2.Required)
         {
             this._showRequired = true;
         }
         base.Add(value[i]);
     }
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="UserPrefCollectionEnumerator">UserPrefCollectionEnumerator</see> class referencing the specified <see cref="UserPrefCollection">UserPrefCollection</see> object.
 /// </summary>
 /// <param name="mappings">The <see cref="UserPrefCollection">UserPrefCollection</see> to enumerate.</param>
 public UserPrefCollectionEnumerator(UserPrefCollection mappings)
 {
     _temp       = ((IEnumerable)(mappings));
     _enumerator = _temp.GetEnumerator();
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="UserPrefCollection">UserPrefCollection</see> class containing the elements of the specified source collection.
 /// </summary>
 /// <param name="value">A <see cref="UserPrefCollection">UserPrefCollection</see> with which to initialize the collection.</param>
 public UserPrefCollection(UserPrefCollection value)
 {
     this.AddRange(value);
 }
Example #6
0
		/// <summary>
		/// Initializes a new instance of the <see cref="UserPrefCollection">UserPrefCollection</see> class containing the elements of the specified source collection.
		/// </summary>
		/// <param name="value">A <see cref="UserPrefCollection">UserPrefCollection</see> with which to initialize the collection.</param>
		public UserPrefCollection(UserPrefCollection value)	
		{
			this.AddRange(value);
		}
Example #7
0
			/// <summary>
			/// Initializes a new instance of the <see cref="UserPrefCollectionEnumerator">UserPrefCollectionEnumerator</see> class referencing the specified <see cref="UserPrefCollection">UserPrefCollection</see> object.
			/// </summary>
			/// <param name="mappings">The <see cref="UserPrefCollection">UserPrefCollection</see> to enumerate.</param>
			public UserPrefCollectionEnumerator(UserPrefCollection mappings)
			{
				_temp =	((IEnumerable)(mappings));
				_enumerator = _temp.GetEnumerator();
			}
Example #8
0
		/// <summary>
		/// 将UserPrefs组织成Table表现形式
		/// </summary>
		/// <param name="defaultUserPrefs">默认设置</param>
		/// <param name="personalUserPrefs">用户的个性化设置</param>
		/// <returns></returns>
        public static string GetUserPrefsTable(UserPrefCollection<UserPref> defaultUserPrefs, UserPrefsSaved personalUserPrefs)
		{
			StringBuilder sb = new StringBuilder("<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"95%\" align=\"center\">");
			
			bool scriptAdded = false;

			for (int i = 0; i < defaultUserPrefs.Count; i++)
			{
				string value = personalUserPrefs.GetValueByName(defaultUserPrefs[i].Name);

				//此处不需要进行判断value的差异是因为当value为string.empty时ToHtml方法会自动按默认值输出
				sb.Append(defaultUserPrefs[i].ToHtml(value).Replace("__ITEM_INDEX__", i.ToString()));

				if (!scriptAdded && defaultUserPrefs[i].DataType == UserPrefDataType.ListType)
				{
					scriptAdded = true;
					sb.Insert(0,"<script>var listcontrol___MODULE_ID__ = new Array();function checklist___MODULE_ID__() {for (var i = 0; i < listcontrol___MODULE_ID__.length; i ++) {var inputFld = listcontrol___MODULE_ID__[i][0];var checkFunc = listcontrol___MODULE_ID__[i][1];if (inputFld.value &&inputFld.value.length > 0) {if(!checkFunc || checkFunc()) {inputFld.listApp.add();} else {inputFld.focus();inputFld.select();return false;}}}return true;};var checklist_submit___MODULE_ID__ = function(event) {if (!checklist___MODULE_ID__()) {return false;}return this.prev_submit(event);};var reset_list___MODULE_ID__ = function() {this.prev_reset();for (var i = 0; i < this.elements.length; i ++) {if (this.elements[i].listApp) {this.elements[i].listApp.reset();}}};_gel(\"m___MODULE_ID___form\").prev_reset = _gel(\"m___MODULE_ID___form\").reset;_gel(\"m___MODULE_ID___form\").reset = reset_list___MODULE_ID__;if (!_gel(\"m___MODULE_ID___form\").prev_submit) {_gel(\"m___MODULE_ID___form\").prev_submit = _gel(\"m___MODULE_ID___form\").onsubmit;_gel(\"m___MODULE_ID___form\").onsubmit = checklist_submit___MODULE_ID__;}</script>");
				}

			}
			if (defaultUserPrefs.ShowRequired)
				sb.Append("<tr><td colspan=\"3\" align=\"left\"><font color=\"red\">* 为必填项</font></td></tr>");
			sb.Append("</table>");
			return sb.ToString();
		}
Example #9
0
		/// <summary>
		/// 返回指定文件中的UserPref集合
		/// </summary>
		/// <param name="filename">文件名</param>
		/// <returns></returns>
        public static UserPrefCollection<UserPref> LoadUserPrefs(string filename)
    	{
			XmlDocument xmlfile = LoadXmlFile(filename);

			if (xmlfile == null)
				return null;
			XmlNodeList xmlnodelist = xmlfile.SelectNodes("/Module/UserPref");

			if (xmlnodelist == null)
				return null;

            UserPrefCollection<UserPref> upc = new UserPrefCollection<UserPref>();

			foreach (XmlNode xmlnode in xmlnodelist)
			{
				UserPref up = new UserPref();
				up.Name = xmlnode.Attributes["name"] == null ? "" : xmlnode.Attributes["name"].Value;
				up.DisplayName = xmlnode.Attributes["display_name"] == null ? "" : xmlnode.Attributes["display_name"].Value;
				up.UrlParam = xmlnode.Attributes["urlparam"] == null ? "" : xmlnode.Attributes["urlparam"].Value;
				up.DataType = xmlnode.Attributes["datatype"] == null ? UserPrefDataType.StringType : ParseUserPrefDataType(xmlnode.Attributes["datatype"].Value);

				if (up.DataType == UserPrefDataType.EnumType)
				{
                    up.EnumValues = new Discuz.Common.Generic.List<EnumValue>();
					XmlNodeList enumlist = xmlnode.SelectNodes("EnumValue");
					foreach(XmlNode enumnode in enumlist)
					{
						EnumValue ev = new EnumValue();
						ev.Value = enumnode.Attributes["value"] == null ? "" : enumnode.Attributes["value"].Value;
						ev.DisplayValue = enumnode.Attributes["display_value"] == null ? "" : enumnode.Attributes["display_value"].Value;
						up.EnumValues.Add(ev);
					}
				}

				up.Required = xmlnode.Attributes["required"] == null ? false : Utils.StrToBool(xmlnode.Attributes["required"].Value, false);
				up.DefaultValue = xmlnode.Attributes["default_value"] == null ? "" : xmlnode.Attributes["default_value"].Value;
				upc.Add(up);
			}
			return upc;
		}