Example #1
0
        /// <summary>
        /// Creates a Binding List of <see cref="SortedMapItem"/> objects representing all the Value
        /// in T enum. The List is Sorted Based upon <see cref="SortedMapItem.SortOrder"/>
        /// </summary>
        /// <param name="ExcludeRules">
        /// If any rule matches the exclude then the matched item will not be
        /// outputted in the bind list.
        /// </param>
        /// <returns>
        /// Binding list of <see cref="SortedMapItem"/>
        /// </returns>
        /// <remarks>
        /// <see cref="SortedMapItem.Parent"/> is set to the Binding List.
        /// </remarks>
        public virtual BindingList <SortedMapItem> ToBindingList(EnumRule <T> ExcludeRules)
        {
            BindingList <SortedMapItem> bl = new BindingList <SortedMapItem>();

            if (this.Item == null)
            {
                return(bl);
            }
            List <SortedMapItem> SortList = new List <SortedMapItem>();

            foreach (var map in this.Item)
            {
                SortedMapItem newMap = new SortedMapItem();
                if (ExcludeRules[map.Key])
                {
                    // exclude rule continue
                    continue;
                }
                newMap.Key       = map.Key;
                newMap.Value     = map.Value;
                newMap.SortOrder = map.SortOrder;
                SortList.Add(newMap);
            }
            // Sort the list based upon sort values for display.
            // This comes into play when the binding list is bound to a list control
            // such as a drop down list.
            SortList.Sort((value1, value2) => value1.SortOrder.CompareTo(value2.SortOrder));

            // Now that the list is sorted add the values to the binding list.
            foreach (var map in SortList)
            {
                map.Parent = bl;
                bl.Add(map);
            }
            SortList.Clear();
            return(bl);
        }
 /// <summary>
 /// Creates a new instance specifying the exclude rules
 /// </summary>
 /// <param name="Exclude"></param>
 public SelectedOptionRule(EnumRule <T> Exclude)
     : this()
 {
     this.m_ExcludeRules = Exclude;
 }
Example #3
0
        /// <summary>
        /// Creates a List of <see cref="SortedMapItem"/> objects representing all the Value
        /// in T enum. The List is Sorted Based upon <see cref="SortedMapItem.SortOrder"/>
        /// </summary>
        /// <param name="SelectedValues">
        /// Instance of <see cref="SelectedOptions{T}"/>. Each value in SelectedValues will set the
        /// corresponding <see cref="SortedMapItem.Selected"/> to true;
        /// </param>
        /// <param name="ExcludeRules">
        /// If any rule matches the exclude then the matched item will not be
        /// outputted in the list.
        /// </param>
        /// <returns>
        /// List of <see cref="SortedMapItem"/>
        /// </returns>
        /// <remarks>
        /// <see cref="SortedMapItem.Parent"/> is set to the List.
        /// </remarks>
        public virtual List <SortedMapItem> ToList(SelectedOptions <T> SelectedValues, EnumRule <T> ExcludeRules)
        {
            List <SortedMapItem> SortList = new List <SortedMapItem>();

            if (this.Item == null)
            {
                return(SortList);
            }

            foreach (var map in this.Item)
            {
                SortedMapItem newMap = new SortedMapItem();
                if (ExcludeRules[map.Key])
                {
                    // exclude rule continue
                    continue;
                }
                newMap.Key       = map.Key;
                newMap.Value     = map.Value;
                newMap.SortOrder = map.SortOrder;
                if (SelectedValues.HasKey[map.Key])
                {
                    newMap.Selected = true;
                }
                newMap.Parent = SortList;
                SortList.Add(newMap);
            }
            // Sort the list based upon sort values for display.
            // This comes into play when the binding list is bound to a list control
            // such as a drop down list.
            SortList.Sort((value1, value2) => value1.SortOrder.CompareTo(value2.SortOrder));
            return(SortList);
        }
Example #4
0
        /// <summary>
        /// Creates a List of <see cref="AhkKeyMapAhkMapValue"/> objects representing all the Value
        /// in T enum. The List is Sorted Based upon <see cref="AhkKeyMapAhkMapValue.Sort"/>
        /// </summary>
        /// <param name="SelectedValues">
        /// Instance of <see cref="SelectedOptions{T}"/>. Each value in SelectedValues will set the
        /// corresponding <see cref="AhkKeyMapAhkMapValue.Selected"/> to true;
        /// </param>
        /// <param name="ExcludeRules">
        /// If any rule matches the exclude then the matched item will not be
        /// outputted in the list.
        /// </param>
        /// <returns>
        /// List of <see cref="AhkKeyMapAhkMapValue"/>
        /// </returns>
        /// <remarks>
        /// <see cref="AhkKeyMapAhkMapValue.Parent"/> is set to the List.
        /// </remarks>
        public virtual List <AhkKeyMapAhkMapValue> ToList(SelectedOptions <T> SelectedValues, EnumRule <T> ExcludeRules)
        {
            List <AhkKeyMapAhkMapValue> SortList = new List <AhkKeyMapAhkMapValue>();

            if (this.AhkMapValue == null)
            {
                return(SortList);
            }

            foreach (var map in this.AhkMapValue)
            {
                AhkKeyMapAhkMapValue newMap = new AhkKeyMapAhkMapValue();
                if (ExcludeRules[map.Key])
                {
                    // exclude rule continue
                    continue;
                }
                // newMap.Parent = bl;
                newMap.AutoHotKeyValue = map.AutoHotKeyValue;
                newMap.DisplayValue    = map.DisplayValue;
                newMap.Key             = map.Key;
                newMap.Sort            = map.Sort;
                if (SelectedValues.HasKey[map.Key])
                {
                    newMap.Selected = true;
                }
                newMap.Parent = SortList;
                SortList.Add(newMap);
            }
            // Sort the list based upon sort values for display.
            // This comes into play when the binding list is bound to a list control
            // such as a drop down list.
            SortList.Sort((value1, value2) => value1.Sort.CompareTo(value2.Sort));
            return(SortList);
        }