/// <summary> /// Navigates to a Sample via a deep link. /// </summary> /// <param name="deepLink">The deep link. Specified as protocol://[collectionName]?sample=[sampleName]</param> /// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns> public async Task NavigateToSampleAsync(string deepLink) { var parser = DeepLinkParser.Create(deepLink); var targetSample = await Samples.GetSampleByName(parser["sample"]); if (targetSample != null) { NavigateToSample(targetSample); } }
private async void NavigationFrame_Navigating(object sender, NavigatingCancelEventArgs navigationEventArgs) { ProcessSampleEditorTime(); SampleCategory category; if (navigationEventArgs.SourcePageType == typeof(SamplePicker) || navigationEventArgs.Parameter == null) { DataContext = null; _currentSample = null; category = navigationEventArgs.Parameter as SampleCategory; if (category != null) { TrackingManager.TrackPage($"{navigationEventArgs.SourcePageType.Name} - {category.Name}"); } else { TrackingManager.TrackPage($"{navigationEventArgs.SourcePageType.Name}"); } HideInfoArea(); } else { TrackingManager.TrackPage(navigationEventArgs.SourcePageType.Name); Commands.Clear(); ShowInfoArea(); var sampleName = navigationEventArgs.Parameter.ToString(); _currentSample = await Samples.GetSampleByName(sampleName); DataContext = _currentSample; if (_currentSample == null) { HideInfoArea(); return; } category = await Samples.GetCategoryBySample(_currentSample); await Samples.PushRecentSample(_currentSample); var propertyDesc = _currentSample.PropertyDescriptor; InfoAreaPivot.Items.Clear(); if (propertyDesc != null) { _xamlRenderer.DataContext = propertyDesc.Expando; } Title.Text = _currentSample.Name; if (propertyDesc != null && propertyDesc.Options.Count > 0) { InfoAreaPivot.Items.Add(PropertiesPivotItem); } if (_currentSample.HasXAMLCode) { if (AnalyticsInfo.VersionInfo.GetDeviceFormFactor() != DeviceFormFactor.Desktop) { // Only makes sense (and works) for now to show Live Xaml on Desktop, so fallback to old system here otherwise. XamlReadOnlyCodeRenderer.XamlSource = _currentSample.UpdatedXamlCode; InfoAreaPivot.Items.Add(XamlReadOnlyPivotItem); } else { XamlCodeRenderer.Text = _currentSample.UpdatedXamlCode; InfoAreaPivot.Items.Add(XamlPivotItem); _xamlCodeRendererSupported = true; } InfoAreaPivot.SelectedIndex = 0; } if (_currentSample.HasCSharpCode) { CSharpCodeRenderer.CSharpSource = await this._currentSample.GetCSharpSourceAsync(); InfoAreaPivot.Items.Add(CSharpPivotItem); } if (_currentSample.HasJavaScriptCode) { JavaScriptCodeRenderer.CSharpSource = await this._currentSample.GetJavaScriptSourceAsync(); InfoAreaPivot.Items.Add(JavaScriptPivotItem); } if (!string.IsNullOrEmpty(_currentSample.CodeUrl)) { GitHub.NavigateUri = new Uri(_currentSample.CodeUrl); GitHub.Visibility = Visibility.Visible; } else { GitHub.Visibility = Visibility.Collapsed; } if (_currentSample.HasDocumentation) { var docs = await this._currentSample.GetDocumentationAsync(); if (!string.IsNullOrWhiteSpace(docs)) { DocumentationTextblock.Text = docs; InfoAreaPivot.Items.Add(DocumentationPivotItem); } } if (InfoAreaPivot.Items.Count == 0) { HideInfoArea(); } TitleTextBlock.Text = $"{category.Name} -> {_currentSample?.Name}"; ApplicationView.SetTitle(this, $"{category.Name} - {_currentSample?.Name}"); } await SetHamburgerMenuSelection(); }
private async void NavigationFrame_Navigating(object sender, NavigatingCancelEventArgs navigationEventArgs) { if (navigationEventArgs.SourcePageType == typeof(SamplePicker) || navigationEventArgs.Parameter == null) { DataContext = null; if (navigationEventArgs.Parameter != null) { var category = navigationEventArgs.Parameter as SampleCategory; if (category != null) { TrackingManager.TrackPage($"{navigationEventArgs.SourcePageType.Name} - {category.Name}"); } } HideInfoArea(); } else { TrackingManager.TrackPage(navigationEventArgs.SourcePageType.Name); ShowInfoArea(); var sampleName = navigationEventArgs.Parameter.ToString(); var sample = await Samples.GetSampleByName(sampleName); if (sample == null) { HideInfoArea(); return; } var propertyDesc = sample.PropertyDescriptor; DataContext = sample; InfoAreaPivot.Items.Clear(); if (propertyDesc != null) { NavigationFrame.DataContext = propertyDesc.Expando; } Title.Text = sample.Name; _currentSample = sample; if (propertyDesc != null && propertyDesc.Options.Count > 0) { InfoAreaPivot.Items.Add(PropertiesPivotItem); } if (sample.HasXAMLCode) { XamlCodeRenderer.XamlSource = _currentSample.UpdatedXamlCode; InfoAreaPivot.Items.Add(XamlPivotItem); InfoAreaPivot.SelectedIndex = 0; } if (sample.HasCSharpCode) { CSharpCodeRenderer.CSharpSource = await _currentSample.GetCSharpSourceAsync(); InfoAreaPivot.Items.Add(CSharpPivotItem); } if (sample.HasJavaScriptCode) { JavaScriptCodeRenderer.CSharpSource = await _currentSample.GetJavaScriptSourceAsync(); InfoAreaPivot.Items.Add(JavaScriptPivotItem); } UpdateRootGridMinWidth(); if (!string.IsNullOrEmpty(sample.CodeUrl)) { GitHub.NavigateUri = new Uri(sample.CodeUrl); GitHub.Visibility = Visibility.Visible; } else { GitHub.Visibility = Visibility.Collapsed; } if (sample.HasDocumentation) { InfoAreaPivot.Items.Add(DocumentationPivotItem); DocumentationTextblock.Text = await _currentSample.GetDocumentationAsync(); } if (InfoAreaPivot.Items.Count == 0) { HideInfoArea(); } } }