Exemple #1
0
        /// <summary>
        /// Called to the main view to display the given items.
        /// </summary>
        /// <param name="items">The items to display.</param>
        public void ShowItems(FileSystemEntry location, IEnumerable <FileSystemEntry> items)
        {
            CurrentLocation = location;
            SuppressEvents  = true;
            Location        = location.FullName;
            SuppressEvents  = false;
            FilenameDisplay = string.Empty;
            bool horizontal = DisplayMode == FileDisplayMode.Large;
            int  itemCount  = PopulateScrollRect(_filesView, _iconItems[(int)DisplayMode], items, _iconSet,
                                                 _iconModeWidths[(int)DisplayMode], horizontal);

            if (_filesView != null)
            {
                FileEntryComponent initialSelection = null;
                // Bind selection events. Can't be done easily in static code.
                for (int i = 0; i < _filesView.content.childCount; ++i)
                {
                    FileEntryComponent itemUI = _filesView.content.GetChild(i).GetComponent <FileEntryComponent>();
                    foreach (Button button in itemUI.GetComponentsInChildren <Button>())
                    {
                        button.onClick.AddListener(delegate() { this.OnSelectFile(itemUI); });
                        if (!string.IsNullOrEmpty(_pendingSelection) &&
                            itemUI.Entry.FullName.CompareTo(_pendingSelection) == 0)
                        {
                            initialSelection = itemUI;
                        }
                    }
                }

                // Make initial selection.
                if (initialSelection)
                {
                    OnSelectFile(initialSelection);
                }
            }

            if (itemCount != 0 && isActiveAndEnabled)
            {
                StartCoroutine(FixSizeAtEndOfFrame(_filesView, _iconItems[(int)DisplayMode], horizontal));
            }

            _pendingSelection = null;
        }
Exemple #2
0
        /// <summary>
        /// Called to update the links view to display the given items.
        /// For example, the <paramref name="locations"/> may specify a list of drives.
        /// </summary>
        /// <param name="locations">The locations items.</param>
        public void ShowLinks(IEnumerable <FileSystemEntry> locations)
        {
            int itemCount = PopulateScrollRect(_locationView, _iconItems[(int)FileDisplayMode.Large], locations, _iconSet,
                                               0, true);

            if (_locationView != null)
            {
                // Bind selection events. Can't be done easily in static code.
                for (int i = 0; i < _locationView.content.childCount; ++i)
                {
                    FileEntryComponent itemUI = _locationView.content.GetChild(i).GetComponent <FileEntryComponent>();
                    foreach (Button button in itemUI.GetComponentsInChildren <Button>())
                    {
                        button.onClick.AddListener(delegate() { this.OnSelectLocation(itemUI); });
                    }
                }
            }

            if (itemCount != 0)
            {
                StartCoroutine(FixSizeAtEndOfFrame(_locationView, _iconItems[(int)FileDisplayMode.Large], true));
            }
        }