コード例 #1
0
        private bool ReselectPresetOnExpanded(PresetFolderViewModel presetFolderViewModel)
        {
            if (!presetFolderViewModel.IsExpanded)
            {
                return(false);
            }

            if (presetFolderViewModel.Items.Items.Contains(this.presetsService.SelectedPreset))
            {
                this.presetsService.SelectedPreset.IsSelected = true;
                return(true);
            }

            foreach (var subFolder in presetFolderViewModel.SubFolders.Items)
            {
                if (this.ReselectPresetOnExpanded(subFolder))
                {
                    return(true);
                }
            }

            return(false);
        }
コード例 #2
0
        public void AddSubfolder(PresetFolderViewModel subfolderViewModel)
        {
            this.SubFolders.Add(subfolderViewModel);
            subfolderViewModel.Parent = this;

            int insertionIndex;

            // Add in the right place.
            for (insertionIndex = 0; insertionIndex <= this.AllItems.Count; insertionIndex++)
            {
                // If at the end, add there.
                if (insertionIndex == this.AllItems.Count)
                {
                    break;
                }

                // If we made it to the presets, add there at end of folder list.
                object item   = this.AllItems.Items.ElementAt(insertionIndex);
                var    preset = item as PresetViewModel;
                if (preset != null)
                {
                    break;
                }

                // If the name compares to less than this folder name, (and we are not built-in) add here.
                var folder = (PresetFolderViewModel)item;
                if (!this.IsBuiltIn && string.Compare(subfolderViewModel.Name, folder.Name, StringComparison.CurrentCultureIgnoreCase) < 0)
                {
                    break;
                }
            }

            this.AllItems.Insert(insertionIndex, subfolderViewModel);

            this.IsExpanded = true;
        }
コード例 #3
0
 public void RemoveSubfolder(PresetFolderViewModel subFolderViewModel)
 {
     this.SubFolders.Remove(subFolderViewModel);
     this.AllItems.Remove(subFolderViewModel);
 }