예제 #1
0
 protected virtual Task Refresh()
 {
     return(Windows.Invoke(() =>
     {
         this.Pages.Clear();
         foreach (var section in this.Configuration.Sections.OrderBy(section => section.Id))
         {
             if (section.Flags.HasFlag(ConfigurationSectionFlags.System))
             {
                 //System config should not be presented to the user.
                 continue;
             }
             var sectionMatches = this.MatchesFilter(section);
             var elements = default(IEnumerable <ConfigurationElement>);
             if (sectionMatches)
             {
                 elements = section.Elements;
             }
             else if (!this.MatchesFilter(section.Elements, out elements))
             {
                 continue;
             }
             var page = new ComponentSettingsPage(section.Name, elements);
             page.InitializeComponent(this.Core);
             this.Pages.Add(page);
         }
         this.SelectedPage = this.Pages.FirstOrDefault();
     }));
 }
예제 #2
0
        protected virtual Task Refresh()
        {
            if (this.Configuration == null)
            {
#if NET40
                return(TaskEx.FromResult(false));
#else
                return(Task.CompletedTask);
#endif
            }
            return(Windows.Invoke(() =>
            {
                this.Pages.Clear();
                foreach (var section in this.Configuration.Sections.OrderBy(section => section.Id))
                {
                    if (section.Flags.HasFlag(ConfigurationSectionFlags.System))
                    {
                        //System config should not be presented to the user.
                        continue;
                    }
                    if (this.Sections != null)
                    {
                        if (!this.Sections.Contains(section.Id, StringComparer.OrdinalIgnoreCase))
                        {
                            //Does not match section filter.
                            continue;
                        }
                    }
                    var sectionMatches = this.MatchesFilter(section);
                    var elements = default(IEnumerable <ConfigurationElement>);
                    if (sectionMatches)
                    {
                        elements = section.Elements;
                    }
                    else if (!this.MatchesFilter(section.Elements, out elements))
                    {
                        continue;
                    }
                    var page = new ComponentSettingsPage(section.Name, elements);
                    page.InitializeComponent(this.Core);
                    this.Pages.Add(page);
                }
                this.SelectedPage = this.Pages.FirstOrDefault();
            }));
        }
예제 #3
0
        protected virtual ComponentSettingsPage GetOrAddPage(string path)
        {
            var page     = default(ComponentSettingsPage);
            var pages    = this.Children;
            var segments = path.Split(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar);

            foreach (var segment in segments)
            {
                page = pages.FirstOrDefault(
                    _page => string.Equals(_page.Name, segment, StringComparison.OrdinalIgnoreCase)
                    );
                if (page == null)
                {
                    page = new ComponentSettingsPage(segment);
                    pages.Add(page);
                }
                pages = page.Children;
            }
            return(page);
        }