示例#1
0
        private void OnCurrentSampleBackdoorChanged(DependencyObject sender, DependencyProperty dp)
        {
            var backdoorParts = _shell.CurrentSampleBackdoor.Split("-");
            var title         = backdoorParts.FirstOrDefault();
            var designName    = backdoorParts.Length > 1 ? backdoorParts[1] : string.Empty;

            var sample = GetSamples()
                         .FirstOrDefault(x => string.Equals(x.Title, title, StringComparison.OrdinalIgnoreCase));

            if (sample == null)
            {
                this.Log().Warn($"No SampleAttribute found with a Title that matches: {_shell.CurrentSampleBackdoor}");
                return;
            }

            if (Enum.TryParse <Design>(designName, out var design))
            {
                SamplePageLayout.SetPreferredDesign(design);
            }

            ShellNavigateTo <OverviewPage>();
            ShellNavigateTo(sample);
        }
示例#2
0
        /// <summary>
        /// This method is invoked from JavaScript within the branch.js file.
        /// </summary>
        /// <param name="title"></param>
        /// <param name="design"></param>
        public static void TryNavigateToLaunchSample(string title, string design)
        {
            const string UndefinedValue = "undefined";

            if (!HasValue(title))
            {
                return;
            }

            var sample = GetSamples().FirstOrDefault(s => s.ViewType.Name.ToLowerInvariant() == title.ToLowerInvariant());

            if (sample != null)
            {
                if (HasValue(design) && Enum.TryParse <Design>(design, out var designType))
                {
                    SamplePageLayout.SetPreferredDesign(designType);
                }

                (Application.Current as App)?.ShellNavigateTo(sample);
            }

            bool HasValue(string val) =>
            !string.IsNullOrWhiteSpace(val) && !string.Equals(UndefinedValue, val, StringComparison.OrdinalIgnoreCase);
        }