Ejemplo n.º 1
0
 /// <summary>
 /// This sets up the AllPossibleOptions and the InitialSelection list
 /// This must be done before handed to MVC for display (or redisplay on error)
 /// </summary>
 /// <param name="allPossibleOptions"></param>
 /// <param name="initialSelectionValues">the Ids of the initial selected values</param>
 public void SetupMultiSelectList(IEnumerable <KeyValuePair <string, int> > allPossibleOptions,
                                  IEnumerable <KeyValuePair <string, int> > initialSelectionValues)
 {
     AllPossibleOptions = allPossibleOptions.ToList();           //we take copies of the collections
     InitialSelection   = initialSelectionValues.ToList();
     FinalSelection     = InitialSelection.Select(x => x.Value.ToString("D")).ToArray();
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Selects an item in the ListItemCollection where the date specified is in the date format.
        /// </summary>
        /// <param name="listItems">the ListItemCollection in which to perform selection</param>
        /// <param name="dateString">The date string</param>
        /// <param name="displayDateFormat">The display format of the list item dates.</param>
        /// <returns>
        /// The number of items selected. This is either 0 or 1.
        /// </returns>
        private int PerformInitialSelectionForDate(ListItemCollection listItems, string dateString,
                                                   string displayDateFormat)
        {
            //Throw error if InitialSelection is empty string and list contains some items.
            if (InitialSelection.Trim().Equals(String.Empty) && listItems.Count > 0)
            {
                throw new InitialSelectionInvalidDataException("InitialSelection can not be an empty string.");
            }

            //Try each list item for each date
            foreach (ListItem item in listItems)
            {
                DateTime itemDate, selectDate;
                try
                {
                    itemDate   = DateTime.ParseExact(item.Value, displayDateFormat, CultureInfo.InvariantCulture);
                    selectDate = DateTime.ParseExact(dateString.Trim(), DateFormat, CultureInfo.InvariantCulture);
                }
                catch (Exception e)
                {
                    throw new InitialSelectionInvalidDataException("Could not convert date string to date.", e);
                }

                //Item must not be selected from before
                if (!item.Selected && itemDate == selectDate)
                {
                    item.Selected = true;
                    return(1);
                }
            }

            return(0);
        }
Ejemplo n.º 3
0
 internal void SelectInitialButton()
 {
     if (InitialSelection != null && Displayed)
     {
         InitialSelection.Select();
         CurrentEventSystem.SetSelectedGameObject(InitialSelection.gameObject);
     }
 }
Ejemplo n.º 4
0
        public PathWithFilters(string path, DirectoryDepth depth, InitialSelection initialSelection, SortBindList <StringMatchPathFilterM> stringMatchFilters, SortBindList <RegexPathFilterM> regexFilters)
        {
            Path               = path;
            Depth              = depth;
            InitialSelection   = initialSelection;
            StringMatchFilters = stringMatchFilters ?? new SortBindList <StringMatchPathFilterM>(); //Per far trovare al dataGrid la lista altrimenti non si possono aggiugere righe nella view
            RegexFilters       = regexFilters ?? new SortBindList <RegexPathFilterM>();             //Per far trovare al dataGrid la lista altrimenti non si possono aggiugere righe nella view

            this.stringMatchFilters.ItemNumberChanged      += StringMatchFiltersChanged;
            this.stringMatchFilters.ObjectTPropertyChanged += StringMatchFiltersChanged;
            this.regexFilters.ItemNumberChanged            += RegexFiltersChanged;
            this.regexFilters.ObjectTPropertyChanged       += RegexFiltersChanged;
        }
Ejemplo n.º 5
0
        protected override Task OnInitializedAsync()
        {
            Group.Tabs.Add(this);
            if (Group.Selected == null || InitialSelection.GetValueOrDefault())
            {
                Group.Selected = this;
            }

            if (!String.IsNullOrEmpty(Group?.ReturnId))
            {
                if (Group.ReturnId == Id)
                {
                    Group.Selected = this;
                }
            }
            return(base.OnInitializedAsync());
        }
Ejemplo n.º 6
0
        /// <summary>
        /// <para>Selects the item(s) of the provided ListItemCollection in accordance with the currently set initial
        /// selection properties (selection rule).</para>
        /// </summary>
        /// <param name="listItems">
        /// an instance of the ListItemCollection, which contains the items of the internal list of this control. One
        /// (or several) item will be selected in accordance with the selection rule set to this class. The argument can
        /// not be null. No collection  element can be null. The collection can be empty.
        /// </param>
        /// <param name="allowMultipleSelection">
        /// the control flag, which allows multiple/single selection modes. true value means that the multiple selection
        /// is allowed for the listItems, false - only single selection is allowed.
        /// </param>
        /// <param name="displayDateFormat">The display format of the list item dates.</param>
        /// <returns>
        /// the number of the selected elements from the internal items list of this control. Can be positive number
        /// (including 0).
        /// </returns>
        /// <exception cref="ArgumentNullException">if listItems is null</exception>
        /// <exception cref="ArgumentException">if listItems contains empty elements.</exception>
        /// <exception cref="InitialSelectionInvalidDataException">
        /// if the current set of initial selection properties is invalid
        /// (absent data for requried properties, invalid rule, etc.).
        /// </exception>
        public int SelectItems(ListItemCollection listItems, bool allowMultipleSelection, string displayDateFormat)
        {
            Helper.ValidateNotNull(listItems, "listItems");

            //Return if some item is already selected
            foreach (ListItem item in listItems)
            {
                if (item == null)
                {
                    throw new ArgumentException("ListCollection must not contain null elements.", "listItems");
                }

                if (item.Selected)
                {
                    return(0);
                }
            }

            int selectionsMade = 0;

            string[] initialSelections = InitialSelection.Split(';');

            //For each ';' delimited part of the InitialSelection string
            foreach (string initialSelection in initialSelections)
            {
                switch (initialSelection)
                {
                case SelectFirstListItem:
                {
                    //atleast 1 items in the list must be present
                    if (listItems.Count != 0)
                    {
                        listItems[0].Selected = true;
                        selectionsMade++;
                    }
                    break;
                }

                case SelectLastListItem:
                {
                    //atleast 1 items in the list must be present
                    if (listItems.Count != 0)
                    {
                        listItems[listItems.Count - 1].Selected = true;
                        selectionsMade++;
                    }
                    break;
                }

                case SelectClosestToday:
                {
                    selectionsMade += PerformInitialSelectionForRule(listItems, FilterNone, false,
                                                                     displayDateFormat);
                    break;
                }

                case SelectClosestNotAfterToday:
                {
                    selectionsMade += PerformInitialSelectionForRule(listItems, FilterNotAfter, false,
                                                                     displayDateFormat);
                    break;
                }

                case SelectClosestNotBeforeToday:
                {
                    selectionsMade += PerformInitialSelectionForRule(listItems, FilterNotBefore, false,
                                                                     displayDateFormat);
                    break;
                }

                case SelectClosestNotAfterTimeStamp:
                {
                    selectionsMade += PerformInitialSelectionForRule(listItems, FilterNotAfter, true,
                                                                     displayDateFormat);
                    break;
                }

                case SelectClosestNotBeforeTimeStamp:
                {
                    selectionsMade += PerformInitialSelectionForRule(listItems, FilterNotBefore, true,
                                                                     displayDateFormat);
                    break;
                }

                default:
                {
                    selectionsMade += PerformInitialSelectionForDate(listItems, initialSelection,
                                                                     displayDateFormat);
                    break;
                }
                }

                //Break if multiple selections are not allowed.
                if (!allowMultipleSelection && selectionsMade == 1)
                {
                    return(1);
                }
            }

            return(selectionsMade);
        }