Ejemplo n.º 1
0
 public override void DataBind()
 {
     base.DataBind();
     RightListBox.DataTextField  = this.DataTextField;
     RightListBox.DataValueField = this.DataValueField;
     RightListBox.DataBind();
     BaseItems.Clear();
     for (int index = 0; index < RightListBox.Items.Count; index++)
     {
         this.Items.Remove(this.Items.FindByValue(RightListBox.Items[index].Value));
         if (!BaseItems.ContainsKey(RightListBox.Items[index].Value.Trim()))
         {
             BaseItems.Add(RightListBox.Items[index].Value.Trim(), RightListBox.Items[index].Text.Trim());
         }
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Creates new instance with "Default" as group name.
 /// </summary>
 /// <param name="fileNames">File path enumeration.</param>
 /// <param name="maximumCount">Maximum number of items to load or save.</param>
 /// <exception cref="ArgumentOutOfRangeException">Maximum count must be between 1 and 99.</exception>
 public RecentlyUsed(IEnumerable <string> fileNames, int maximumCount)
 {
     if ((maximumCount < 1) || (maximumCount > 99))
     {
         throw new ArgumentOutOfRangeException(nameof(maximumCount), "Maximum count must be between 1 and 99.");
     }
     MaximumCount = maximumCount;
     if (fileNames != null)
     {
         foreach (var fileName in fileNames)
         {
             BaseItems.Add(new RecentlyUsedFile(fileName));
             if (BaseItems.Count >= MaximumCount)
             {
                 break;
             }
         }
     }
 }
Ejemplo n.º 3
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            if (!Page.IsPostBack)
            {
                for (int index = 0; index < RightListBox.Items.Count; index++)
                {
                    this.Items.Remove(this.Items.FindByValue(RightListBox.Items[index].Value));
                    if (!BaseItems.ContainsKey(RightListBox.Items[index].Value.Trim()))
                    {
                        BaseItems.Add(RightListBox.Items[index].Value.Trim(), RightListBox.Items[index].Text.Trim());
                    }
                }
            }
            if (AddedBox.Value != null && AddedBox.Value != "")
            {
                string   AddedString = AddedBox.Value.Substring(0, AddedBox.Value.Length - 1);
                string[] adds        = AddedString.Split(";".ToCharArray());
                //List<ListItem> LeftClears = new List<ListItem>();
                RightListBox.Items.Clear();
                for (int index = 0; index < adds.Length; index++)
                {
                    string[] item = adds[index].Trim().Split(",".ToCharArray());
                    RightListBox.Items.Add(new ListItem(item[1], item[0]));
                    //this.Items.Remove(this.Items.FindByValue(item[1]));
                }
                AddedBox.Value = "";
            }
            //if (DeletedBox.Value != null && DeletedBox.Value != "")
            //{
            //    string DeletedString = DeletedBox.Value.Substring(0, DeletedBox.Value.Length - 1);
            //    string[] dels = DeletedString.Split(";".ToCharArray());
            //    List<ListItem> RightClears = new List<ListItem>();
            //    for (int index = 0; index < dels.Length; index++)
            //    {
            //        string[] item = dels[index].Trim().Split(",".ToCharArray());
            //        this.Items.Add(new ListItem(item[0], item[1]));
            //        RightListBox.Items.Remove(RightListBox.Items.FindByValue(item[1]));
            //    }
            //    DeletedBox.Value = "";
            //}

            if (!Page.ClientScript.IsClientScriptBlockRegistered("MoveListBox"))
            {
                string clientscript = "function Add(Obj,Active,IsAll)                                                                              " +
                                      "{                                                                                                           " +
                                      "    var row=Obj.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode;                          " +
                                      "    var addedHidden=Obj.parentNode.parentNode.parentNode.parentNode.rows[4].cells[0].childNodes[0];         " +
                                      "    var deletedHidden=Obj.parentNode.parentNode.parentNode.parentNode.rows[4].cells[0].childNodes[1];       " +
                                      "    var FromSelect,ToSelect;                                                                                " +
                                      "    if(Active=='toRight')                                                                                   " +
                                      "    {FromSelect=row.cells[0].childNodes[0];ToSelect=row.cells[2].childNodes[0];}                            " +
                                      "    else                                                                                                    " +
                                      "    {FromSelect=row.cells[2].childNodes[0];ToSelect=row.cells[0].childNodes[0];}                            " +
                                      "    var sss=new Array(),l=0;                                                                                " +
                                      "    if(IsAll)                                                                                               " +
                                      "    {                                                                                                       " +
                                      "        for(var i=0;i<FromSelect.options.length;i++){sss[l]=FromSelect.options[i];l++;}                     " +
                                      "    }                                                                                                       " +
                                      "    else                                                                                                    " +
                                      "    {                                                                                                       " +
                                      "        for(var i=0;i<FromSelect.options.length;i++)                                                        " +
                                      "	 {                                                                                                   " +
                                      "	 	if(FromSelect.options[i].selected)                                                           "+
                                      "	 	{                                                                                            "+
                                      "	 		sss[l]=FromSelect.options[i];l++;                                                    "+
                                      "	 	}                                                                                            "+
                                      "	 }                                                                                                   " +
                                      "    }                                                                                                       " +
                                      "                                                                                                            " +
                                      "    for(var i=0;i<sss.length;i++)                                                                           " +
                                      "    {                                                                                                       " +
                                      "       if(Active=='toRight')                                                                                " +
                                      "       {                                                                                                    " +
                                      "		   if(!IsRightExist(sss[i].value,ToSelect))                                                  "+
                                      "		   {                                                                                         "+
                                      "              var oOption = document.createElement('OPTION');                                                  " +
                                      "			   ToSelect.options.add(oOption);                                                    "+
                                      "			   oOption.innerText=sss[i].innerText;                                               "+
                                      "			   oOption.value =sss[i].value;                                                      "+
                                      "		   }                                                                                         "+
                                      "       }                                                                                                    " +
                                      "       else                                                                                                 " +
                                      "       {                                                                                                    " +
                                      "			FromSelect.removeChild(sss[i]);                                                      "+
                                      "       }                                                                                                    " +
                                      "    }                                                                                                       " +
                                      "    addedHidden.value = '';                                                                                 " +
                                      "    if(Active!='toRight')                                                                                   " +
                                      "    {                                                                                                       " +
                                      "          for(var i=0;i<FromSelect.options.length;i++)                                                      " +
                                      "          {                                                                                                 " +
                                      "              addedHidden.value += FromSelect.options[i].value+','+ FromSelect.options[i].innerText+';';    " +
                                      "          }                                                                                                 " +
                                      "    }                                                                                                       " +
                                      "    else                                                                                                    " +
                                      "    {                                                                                                       " +
                                      "          for(var i=0;i<ToSelect.options.length;i++)                                                        " +
                                      "          {                                                                                                 " +
                                      "              addedHidden.value += ToSelect.options[i].value+','+ ToSelect.options[i].innerText+';';        " +
                                      "          }	                                                                                             "+
                                      "    }                                                                                                       " +
                                      "    SetButton(Obj,'button');                                                                                " +
                                      "}                                                                                                           " +
                                      "function IsRightExist(option,right)                                                                         " +
                                      "{                                                                                                           " +
                                      "      for(var i=0;i<right.options.length;i++)                                                               " +
                                      "	  {                                                                                                  " +
                                      "		  if(right.options[i].value == option)                                                       "+
                                      "		      return true;                                                                           "+
                                      "	  }                                                                                                  " +
                                      "	  return false;                                                                                      " +
                                      "}                                                                                                           " +
                                      "function SetButton(Obj,ctrlType)                                                                            " +
                                      "{                                                                                                           " +
                                      "	var LeftSelect,RightSelect,ToRightAdd,ToLeftAdd,ToLeftAll,ToRightAll,row,table;                      " +
                                      "	if(ctrlType=='button')                                                                               " +
                                      "	{                                                                                                    " +
                                      "		table=Obj.parentNode.parentNode.parentNode.parentNode;row=table.parentNode.parentNode;       "+
                                      "	}                                                                                                    " +
                                      "	else                                                                                                 " +
                                      "	{                                                                                                    " +
                                      "		row=Obj.parentNode.parentNode.parentNode.parentNode;table=row.rows[0].cells[1].childNodes[0];"+
                                      "	}                                                                                                    " +
                                      "	LeftSelect=row.cells[0].childNodes[0];RightSelect=row.cells[2].childNodes[0];                        " +
                                      "	ToRightAdd=table.rows[0].cells[0].childNodes[0];ToLeftAdd=table.rows[1].cells[0].childNodes[0];      " +
                                      "	ToRightAll=table.rows[2].cells[0].childNodes[0];ToLeftAll=table.rows[3].cells[0].childNodes[0];      " +
                                      "	if(LeftSelect.options.length<=0)                                                                     " +
                                      "	{                                                                                                    " +
                                      "		ToRightAdd.disabled='disabled';ToRightAll.disabled='disabled';                               "+
                                      "	}                                                                                                    " +
                                      "	else                                                                                                 " +
                                      "	{                                                                                                    " +
                                      "		ToRightAll.disabled='';var ToRightAdddisabled='disabled';                                    "+
                                      "		for(var i=0;i<LeftSelect.options.length;i++)                                                 "+
                                      "		{                                                                                            "+
                                      "			if(LeftSelect.options[i].selected)                                                   "+
                                      "			{                                                                                    "+
                                      "				ToRightAdddisabled='';                                                       "+
                                      "				break;                                                                       "+
                                      "			}                                                                                    "+
                                      "		}                                                                                            "+
                                      "		ToRightAdd.disabled=ToRightAdddisabled;                                                      "+
                                      "	}                                                                                                    " +
                                      "	if(RightSelect.options.length<=0)                                                                    " +
                                      "	{                                                                                                    " +
                                      "		ToLeftAdd.disabled='disabled';ToLeftAll.disabled='disabled';                                 "+
                                      "	}                                                                                                    " +
                                      "	else                                                                                                 " +
                                      "	{                                                                                                    " +
                                      "		ToLeftAll.disabled='';var ToLeftAdddisabled='disabled';                                      "+
                                      "		for(var i=0;i<RightSelect.options.length;i++)                                                "+
                                      "		{                                                                                            "+
                                      "			if(RightSelect.options[i].selected)                                                  "+
                                      "			{                                                                                    "+
                                      "				ToLeftAdddisabled='';                                                        "+
                                      "				break;                                                                       "+
                                      "			}                                                                                    "+
                                      "		}                                                                                            "+
                                      "		ToLeftAdd.disabled=ToLeftAdddisabled;                                                        "+
                                      "	}                                                                                                    " +
                                      "}                                                                                                           ";
                Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "MoveListBox", clientscript, true);
            }
        }
Ejemplo n.º 4
0
 protected new static void Add(IneligibleReasonEnum item)
 {
     item.IndexNum = _itemCount++;
     BaseItems.Add(item);
 }
Ejemplo n.º 5
0
        public void Add(T item)
        {
            var lvi = CreateListViewItem(item);

            BaseItems.Add(lvi);
        }
Ejemplo n.º 6
0
        protected override void OnLoad(EventArgs e)
        {
            RightListBox.SelectionMode = ListSelectionMode.Multiple;
            this.SelectionMode         = ListSelectionMode.Multiple;

            base.OnLoad(e);
            if (!Page.IsPostBack)
            {
                for (int index = 0; index < RightListBox.Items.Count; index++)
                {
                    this.Items.Remove(this.Items.FindByValue(RightListBox.Items[index].Value));
                    if (!BaseItems.ContainsKey(RightListBox.Items[index].Value.Trim()))
                    {
                        BaseItems.Add(RightListBox.Items[index].Value.Trim(), RightListBox.Items[index].Text.Trim());
                    }
                }
            }
            if (AddedBox.Value != null && AddedBox.Value != "")
            {
                string          AddedString  = AddedBox.Value.Substring(0, AddedBox.Value.Length - 1);
                string[]        adds         = AddedString.Split(";".ToCharArray());
                List <ListItem> LeftClears   = new List <ListItem>();
                string[]        strSplitList = new string[] { this.SplitChar };
                for (int index = 0; index < adds.Length; index++)
                {
                    string[] item = adds[index].Trim().Split(strSplitList, StringSplitOptions.None);
                    RightListBox.Items.Add(new ListItem(item[0], item[1]));
                    this.Items.Remove(this.Items.FindByValue(item[1]));
                }
                AddedBox.Value = "";
            }
            if (DeletedBox.Value != null && DeletedBox.Value != "")
            {
                string          DeletedString = DeletedBox.Value.Substring(0, DeletedBox.Value.Length - 1);
                string[]        dels          = DeletedString.Split(";".ToCharArray());
                List <ListItem> RightClears   = new List <ListItem>();
                string[]        strSplitList  = new string[] { this.SplitChar };
                for (int index = 0; index < dels.Length; index++)
                {
                    string[] item = dels[index].Trim().Split(strSplitList, StringSplitOptions.None);
                    this.Items.Add(new ListItem(item[0], item[1]));
                    RightListBox.Items.Remove(RightListBox.Items.FindByValue(item[1]));
                }
                DeletedBox.Value = "";
            }

            if (!Page.ClientScript.IsClientScriptBlockRegistered("MoveListBox"))
            {
                StringBuilder scriptBuilder = new StringBuilder();
                scriptBuilder.AppendLine("<script language=\"javascript\" type=\"text/javascript\">");
                scriptBuilder.AppendLine("function Add(Obj,Active,IsAll)");
                scriptBuilder.AppendLine("{");
                scriptBuilder.AppendLine("var row = $(Obj).parent().parent().parent().parent().parent().parent();");
                scriptBuilder.AppendLine("var addedHidden = $(row).find('input')[0];");
                scriptBuilder.AppendLine("var deletedHidden = $(row).find('input')[1];");
                scriptBuilder.AppendLine("var FromSelect,ToSelect;");
                scriptBuilder.AppendLine("if(Active=='toRight'){ FromSelect = $(row).find('select')[0]; ToSelect = $(row).find('select')[1];}");
                scriptBuilder.AppendLine("else{ FromSelect = $(row).find('select')[1]; ToSelect = $(row).find('select')[0];}");
                scriptBuilder.AppendLine("var sss=new Array(),l=0;");
                scriptBuilder.AppendLine("if(IsAll){for(var i=0;i<FromSelect.options.length;i++){sss[l]=FromSelect.options[i];l++;}}");
                scriptBuilder.AppendLine("else{for(var i=0;i<FromSelect.options.length;i++){if(FromSelect.options[i].selected){sss[l]=FromSelect.options[i];l++;}}}");
                scriptBuilder.AppendLine("for(var i=0;i<sss.length;i++)");
                scriptBuilder.AppendLine("{");
                scriptBuilder.AppendLine("var oOption = document.createElement('OPTION');ToSelect.options.add(oOption);oOption.innerText=sss[i].innerText;");
                scriptBuilder.AppendLine("oOption.value =sss[i].value;FromSelect.removeChild(sss[i]);var itemCode=sss[i].innerText+'" + this.SplitChar + "'+sss[i].value;");
                scriptBuilder.AppendLine("if(Active=='toRight')");
                scriptBuilder.AppendLine("{");
                scriptBuilder.AppendLine("if(deletedHidden.value!='')");
                scriptBuilder.AppendLine("{");
                scriptBuilder.AppendLine("var itemCodes=deletedHidden.value.split(';');var CanAdd=true;");
                scriptBuilder.AppendLine("for(var j=0;j<itemCodes.length;j++){if(itemCodes[j]==itemCode){deletedHidden.value=deletedHidden.value.replace(itemCode+';','');CanAdd=false;}}");
                scriptBuilder.AppendLine("if(CanAdd){addedHidden.value+=itemCode+';';}");
                scriptBuilder.AppendLine("}");
                scriptBuilder.AppendLine("else{addedHidden.value+=itemCode+';';}");
                scriptBuilder.AppendLine("}");
                scriptBuilder.AppendLine("else");
                scriptBuilder.AppendLine("{");
                scriptBuilder.AppendLine("if(addedHidden.value!='')");
                scriptBuilder.AppendLine("{");
                scriptBuilder.AppendLine("var itemCodes=addedHidden.value.split(';');var CanAdd=true;");
                scriptBuilder.AppendLine("for(var j=0;j<itemCodes.length;j++){if(itemCodes[j]==itemCode){addedHidden.value=addedHidden.value.replace(itemCode+';','');CanAdd=false;}}");
                scriptBuilder.AppendLine("if(CanAdd){deletedHidden.value+=itemCode+';';}");
                scriptBuilder.AppendLine("}");
                scriptBuilder.AppendLine("else{deletedHidden.value+=itemCode+';';}");
                scriptBuilder.AppendLine("}");
                scriptBuilder.AppendLine("}");
                scriptBuilder.AppendLine("SetButton(Obj,'button');");
                scriptBuilder.AppendLine("}");
                scriptBuilder.AppendLine("function SetButton(Obj,ctrlType)");
                scriptBuilder.AppendLine("{");
                scriptBuilder.AppendLine("var LeftSelect,RightSelect,ToRightAdd,ToLeftAdd,ToLeftAll,ToRightAll,row,table;");
                scriptBuilder.AppendLine("if(ctrlType=='button'){ table = $(Obj).parent().parent().parent().parent().parent().parent();}");
                scriptBuilder.AppendLine("else{table = $(Obj).parent().parent();}");
                scriptBuilder.AppendLine(" LeftSelect = $(table).find('select')[0]; RightSelect = $(table).find('select')[1];");
                scriptBuilder.AppendLine(" ToRightAdd = $(table).find('img')[0]; ToLeftAdd = $(table).find('img')[1];");
                scriptBuilder.AppendLine("ToRightAll = $(table).find('img')[2]; ToLeftAll = $(table).find('img')[3];");
                scriptBuilder.AppendLine("if(LeftSelect.options.length<=0){ToRightAdd.disabled='disabled';ToRightAll.disabled='disabled';}");
                scriptBuilder.AppendLine("else");
                scriptBuilder.AppendLine("{");
                scriptBuilder.AppendLine("ToRightAll.disabled='';var ToRightAdddisabled='disabled';");
                scriptBuilder.AppendLine("for(var i=0;i<LeftSelect.options.length;i++){if(LeftSelect.options[i].selected){ToRightAdddisabled='';break;}}");
                scriptBuilder.AppendLine("ToRightAdd.disabled=ToRightAdddisabled;");
                scriptBuilder.AppendLine("}");
                scriptBuilder.AppendLine("if(RightSelect.options.length<=0){ToLeftAdd.disabled='disabled';ToLeftAll.disabled='disabled';}");
                scriptBuilder.AppendLine("else");
                scriptBuilder.AppendLine("{");
                scriptBuilder.AppendLine("ToLeftAll.disabled='';var ToLeftAdddisabled='disabled';");
                scriptBuilder.AppendLine("for(var i=0;i<RightSelect.options.length;i++){if(RightSelect.options[i].selected){ToLeftAdddisabled='';break;}}");
                scriptBuilder.AppendLine("ToLeftAdd.disabled=ToLeftAdddisabled;");
                scriptBuilder.AppendLine("}");
                scriptBuilder.AppendLine("}");
                scriptBuilder.AppendLine("</script>");
                Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "MoveListBox", scriptBuilder.ToString());
            }
        }
Ejemplo n.º 7
0
 protected override object BuildItemForRow(object row)
 {
     return(BaseItems.Add(row));
 }