private void LoadPackage(IPackage package, string packagePath, PackageType packageType) { DisposeViewModel(); if (package != null) { if (!HasLoadedContent <PackageViewer>()) { var packageViewer = new PackageViewer(UIServices, PackageChooser); var binding = new Binding { Converter = new NullToVisibilityConverter(), FallbackValue = Visibility.Collapsed }; packageViewer.SetBinding(VisibilityProperty, binding); MainContentContainer.Children.Add(packageViewer); // HACK HACK: set the Export of IPackageMetadataEditor here EditorService = packageViewer.PackageMetadataEditor; } PackageViewModel packageViewModel = PackageViewModelFactory.CreateViewModel(package, packagePath); packageViewModel.PropertyChanged += OnPackageViewModelPropertyChanged; DataContext = packageViewModel; if (!String.IsNullOrEmpty(packagePath)) { _mruManager.NotifyFileAdded(package, packagePath, packageType); } } }
private async void LoadPackage(IPackage package, string packagePath, string packageSource, PackageType packageType) { DisposeViewModel(); if (package != null) { if (!HasLoadedContent <PackageViewer>()) { var packageViewer = new PackageViewer(SettingsManager, UIServices, PackageChooser); var binding = new Binding { Converter = new NullToVisibilityConverter(), FallbackValue = Visibility.Collapsed }; packageViewer.SetBinding(VisibilityProperty, binding); MainContentContainer.Children.Add(packageViewer); #if !HAS_UNO // HACK HACK: set the Export of IPackageMetadataEditor here EditorService = packageViewer.PackageMetadataEditor; #endif } try { var packageViewModel = await PackageViewModelFactory.CreateViewModel(package, packagePath, packageSource); packageViewModel.PropertyChanged += OnPackageViewModelPropertyChanged; DataContext = packageViewModel; if (!string.IsNullOrEmpty(packageSource)) { _mruManager.NotifyFileAdded(package, packageSource, packageType); } } catch (Exception e) { if (!(e is ArgumentException)) { DiagnosticsClient.TrackException(e); } Console.WriteLine(e); UIServices.Show($"Error loading package\n{e.Message}", MessageLevel.Error); } } }
private void LoadPackage(IPackage package, string packagePath, PackageType packageType) { if (package != null) { if (!RootLayout.LastChildFill) { var packageViewer = new PackageViewer(UIServices, _packageViewModelFactory); Grid.SetRow(packageViewer, 1); RootLayout.Children.Add(packageViewer); RootLayout.LastChildFill = true; // set the Export of IPackageMetadataEditor here EditorService = packageViewer.PackageMetadataEditor; } DataContext = _packageViewModelFactory.CreateViewModel(package, packagePath); if (!String.IsNullOrEmpty(packagePath)) { _mruManager.NotifyFileAdded(package, packagePath, packageType); } } }
internal void OnSaved(string fileName) { HasEdit = false; _mruManager.NotifyFileAdded(PackageMetadata, fileName, PackageType.LocalPackage); }