Example #1
0
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);
            NavigationFrame.Navigating += NavigationFrame_Navigating;
            NavigationFrame.Navigated  += NavigationFrameOnNavigated;
            SystemNavigationManager.GetForCurrentView().BackRequested += OnBackRequested;

            // Get list of samples
            var sampleCategories = (await Samples.GetCategoriesAsync()).ToList();

            HamburgerMenu.ItemsSource = sampleCategories;

            // Options
            HamburgerMenu.OptionsItemsSource = new[]
            {
                new Option {
                    Glyph = "\xE10F", Name = "About", PageType = typeof(About)
                }
            };

            HideInfoArea();
            NavigationFrame.Navigate(typeof(About));

            if (!string.IsNullOrWhiteSpace(e?.Parameter?.ToString()))
            {
                var parser       = DeepLinkParser.Create(e.Parameter.ToString());
                var targetSample = await Sample.FindAsync(parser.Root, parser["sample"]);

                if (targetSample != null)
                {
                    NavigateToSample(targetSample);
                }
            }
        }
Example #2
0
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            NavigationFrame.Navigated += NavigationFrameOnNavigated;
            NavView.BackRequested     += NavView_BackRequested;

            // Get list of samples
            var sampleCategories = await Samples.GetCategoriesAsync();

            NavView.MenuItemsSource = sampleCategories;

            SetAppTitle(string.Empty);
            NavigateToSample(null);

            if (!string.IsNullOrWhiteSpace(e?.Parameter?.ToString()))
            {
                var parser       = DeepLinkParser.Create(e.Parameter.ToString());
                var targetSample = await Sample.FindAsync(parser.Root, parser["sample"]);

                if (targetSample != null)
                {
                    NavigateToSample(targetSample);
                }
            }

            // NavView goes into a weird size on load unless the window size changes
            // Needs a gentle push to update layout
            NavView.Loaded += (s, args) => NavView.InvalidateMeasure();
        }
Example #3
0
        private async void ShowSamplePicker(Sample[] samples = null, bool group = false)
        {
            if (samples == null && _currentSample != null)
            {
                var category = await Samples.GetCategoryBySample(_currentSample);

                if (category != null)
                {
                    samples = category.Samples;
                }
            }

            if (samples == null)
            {
                samples = (await Samples.GetCategoriesAsync()).FirstOrDefault()?.Samples;
            }

            if (samples == null)
            {
                return;
            }

            if (SamplePickerGrid.Visibility == Windows.UI.Xaml.Visibility.Visible &&
                SamplePickerGridView.ItemsSource is Sample[] currentSamples &&
                currentSamples.Count() == samples.Count() &&
                currentSamples.Except(samples).Count() == 0)
            {
                return;
            }


            SamplePickerGridView.ItemsSource = samples;

            var groups = samples.GroupBy(sample => sample.Subcategory);

            if (group && groups.Count() > 1)
            {
                SampleView.IsSourceGrouped = true;
                SampleView.Source          = groups.OrderBy(g => g.Key);
            }
            else
            {
                SampleView.IsSourceGrouped = false;
                SampleView.Source          = samples;
            }

            SamplePickerGridView.ItemsSource = SampleView.View;

            if (_currentSample != null && samples.Contains(_currentSample))
            {
                SamplePickerGridView.SelectedItem = _currentSample;
            }
            else
            {
                SamplePickerGridView.SelectedItem = null;
            }

            SamplePickerGrid.Visibility = Windows.UI.Xaml.Visibility.Visible;
        }
Example #4
0
        internal static async Task <Sample> FindAsync(string category, string name)
        {
            var categories = await Samples.GetCategoriesAsync();

            return(categories?
                   .FirstOrDefault(c => c.Name.Equals(category, StringComparison.OrdinalIgnoreCase))?
                   .Samples
                   .FirstOrDefault(s => s.Name.Equals(name, StringComparison.OrdinalIgnoreCase)));
        }
Example #5
0
        internal static async Task <Sample> FindAsync(string category, string name)
        {
            var categories = await Samples.GetCategoriesAsync();

            // Replace any spaces in the category name as it's used for the host part of the URI in deep links and that can't have spaces.
            return(categories?
                   .FirstOrDefault(c => c.Name.Replace(" ", string.Empty).Equals(category, StringComparison.OrdinalIgnoreCase))?
                   .Samples
                   .FirstOrDefault(s => s.Name.Equals(name, StringComparison.OrdinalIgnoreCase)));
        }
Example #6
0
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);
            NavigationFrame.Navigate(typeof(About));

            // Get list of samples
            var sampleCategories = (await Samples.GetCategoriesAsync()).ToList();

            HamburgerMenu.ItemsSource = sampleCategories;

            // Options
            HamburgerMenu.OptionsItemsSource = new[]
            {
                new Option {
                    Glyph = "\xE10F", Name = "About", PageType = typeof(About)
                }
            };

            HideInfoArea();

            NavigationFrame.Navigating += NavigationFrame_Navigating;
            NavigationFrame.Navigated  += NavigationFrameOnNavigated;
            SystemNavigationManager.GetForCurrentView().BackRequested += OnBackRequested;

            if (!string.IsNullOrWhiteSpace(e?.Parameter?.ToString()))
            {
                var parser       = DeepLinkParser.Create(e.Parameter.ToString());
                var targetSample = await Sample.FindAsync(parser.Root, parser["sample"]);

                if (targetSample != null)
                {
                    NavigateToSample(targetSample);
                }
            }

            _compositor = ElementCompositionPreview.GetElementVisual(this).Compositor;

            if (AnimationHelper.IsImplicitHideShowSupported)
            {
                AnimationHelper.SetTopLevelShowHideAnimation(SamplePickerGrid);

                AnimationHelper.SetTopLevelShowHideAnimation(SamplePickerDetailsGrid);
                AnimationHelper.SetSecondLevelShowHideAnimation(SamplePickerDetailsGridContent);
                AnimationHelper.SetSecondLevelShowHideAnimation(InfoAreaGrid);
                AnimationHelper.SetSecondLevelShowHideAnimation(Splitter);

                ////ElementCompositionPreview.SetImplicitHideAnimation(ContentShadow, GetOpacityAnimation(0, 1, _defaultHideAnimationDiration));
                ElementCompositionPreview.SetImplicitShowAnimation(ContentShadow, AnimationHelper.GetOpacityAnimation(_compositor, (float)ContentShadow.Opacity, 0, _defaultShowAnimationDuration));
            }
        }
Example #7
0
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            NavigationFrame.Navigated += NavigationFrameOnNavigated;
            NavView.BackRequested     += NavView_BackRequested;

#if HAS_UNO
            if (!string.IsNullOrWhiteSpace(e?.Parameter?.ToString()))
            {
                var parser = DeepLinkParser.Create(e.Parameter.ToString());
                System.Console.WriteLine($"Deeplink Root:{parser.Root}, Keys: {string.Join(",", parser.Keys)}");

                if (parser.TryGetValue("ShowUnoUnsupported", out var showUnoUnsupportedString) &&
                    bool.TryParse(showUnoUnsupportedString, out bool showUnoUnsupported))
                {
                    Console.WriteLine($"");
                    Samples.ShowUnoUnsupported = showUnoUnsupported;
                }
            }
#endif

            // Get list of samples
            var sampleCategories = await Samples.GetCategoriesAsync();

            System.Console.WriteLine($"Got {sampleCategories.Count} categorie (p: {e.Parameter})");
            NavView.MenuItemsSource = sampleCategories;

            SetAppTitle(string.Empty);
            NavigateToSample(null);

            if (!string.IsNullOrWhiteSpace(e?.Parameter?.ToString()))
            {
                var parser = DeepLinkParser.Create(e.Parameter.ToString());

                if (parser.TryGetValue("sample", out var sample))
                {
                    var targetSample = await Sample.FindAsync(parser.Root, sample);

                    if (targetSample != null)
                    {
                        NavigateToSample(targetSample);
                    }
                }
            }

            // NavView goes into a weird size on load unless the window size changes
            // Needs a gentle push to update layout
            NavView.Loaded += (s, args) => NavView.InvalidateMeasure();
            System.Console.WriteLine($"Done navigating");
        }
Example #8
0
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            // Get list of samples
            HamburgerMenu.ItemsSource = await Samples.GetCategoriesAsync();

            // Options
            HamburgerMenu.OptionsItemsSource = new[] { new Option {
                                                           Glyph = "", Name = "About", PageType = typeof(About)
                                                       } };

            HideInfoArea();

            NavigationFrame.Navigated += NavigationFrameOnNavigated;
        }
Example #9
0
        private async void ShowSamplePicker(Sample[] samples = null)
        {
            if (samples == null && _currentSample != null)
            {
                var category = await Samples.GetCategoryBySample(_currentSample);

                if (category != null)
                {
                    samples = category.Samples;
                }
            }

            if (samples == null)
            {
                samples = (await Samples.GetCategoriesAsync()).FirstOrDefault()?.Samples;
            }

            if (samples == null)
            {
                return;
            }

            if (SamplePickerGrid.Visibility == Windows.UI.Xaml.Visibility.Visible &&
                SamplePickerGridView.ItemsSource is Sample[] currentSamples &&
                currentSamples.Count() == samples.Count() &&
                currentSamples.Except(samples).Count() == 0)
            {
                return;
            }

            SamplePickerGridView.ItemsSource = samples;

            if (_currentSample != null && samples.Contains(_currentSample))
            {
                SamplePickerGridView.SelectedItem = _currentSample;
            }
            else
            {
                SamplePickerGridView.SelectedItem = null;
            }

            SamplePickerGrid.Visibility = Windows.UI.Xaml.Visibility.Visible;
        }