diff --git a/src/DynamoCoreWpf/Controls/StartPage.xaml.cs b/src/DynamoCoreWpf/Controls/StartPage.xaml.cs index 4153aa62e0d..44dc611cf25 100644 --- a/src/DynamoCoreWpf/Controls/StartPage.xaml.cs +++ b/src/DynamoCoreWpf/Controls/StartPage.xaml.cs @@ -1,9 +1,3 @@ -using Dynamo.Configuration; -using Dynamo.Logging; -using Dynamo.Utilities; -using Dynamo.ViewModels; -using Dynamo.Wpf.Properties; -using Newtonsoft.Json; using System; using System.Collections.Generic; using System.Collections.ObjectModel; @@ -16,7 +10,12 @@ using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; -using static Dynamo.Wpf.Interfaces.ResourceNames; +using Dynamo.Configuration; +using Dynamo.Logging; +using Dynamo.Utilities; +using Dynamo.ViewModels; +using Dynamo.Wpf.Properties; +using Newtonsoft.Json; using NotificationObject = Dynamo.Core.NotificationObject; namespace Dynamo.UI.Controls @@ -120,7 +119,6 @@ public class StartPageViewModel : ViewModelBase ObservableCollection sampleFiles = null; ObservableCollection recentFiles = null; ObservableCollection backupFiles = null; - readonly ObservableCollection templateFiles; internal readonly DynamoViewModel DynamoViewModel; private readonly bool isFirstRun; @@ -132,7 +130,6 @@ internal StartPageViewModel(DynamoViewModel dynamoViewModel, bool isFirstRun) this.recentFiles = new ObservableCollection(); this.sampleFiles = new ObservableCollection(); this.backupFiles = new ObservableCollection(); - this.templateFiles = new ObservableCollection(); #region File Operations @@ -216,67 +213,7 @@ internal StartPageViewModel(DynamoViewModel dynamoViewModel, bool isFirstRun) var dvm = this.DynamoViewModel; RefreshRecentFileList(dvm.RecentFiles, true); RefreshBackupFileList(dvm.Model.PreferenceSettings.BackupFiles); - LoadTemplates(); dvm.RecentFiles.CollectionChanged += OnRecentFilesChanged; - - - } - - - private void LoadTemplates() - { - // Retrieve the current Temlates location from Dynamo properties - var templatesDirectory = DynamoViewModel.Model.PathManager.TemplatesDirectory; - - if (Directory.Exists(templatesDirectory)) - { - var rootDynPaths = new List(); - string[] filePaths = Directory.GetFiles(templatesDirectory, "*.dyn"); // This could change if we move to *dyt - - // We only collect the files in the root - if (filePaths.Length != 0) - { - foreach (string path in filePaths) - { - rootDynPaths.Add(path); - } - } - - // Make comment on legacy use of StartPage.xaml.cs - if (rootDynPaths.Any()) - { - foreach (var filePath in rootDynPaths) - { - AddTemplateListItemFromPath(filePath); - } - } - } - } - - private void AddTemplateListItemFromPath(string filePath) - { - var extension = Path.GetExtension(filePath).ToUpper(); - // If not extension specified and code reach here, this means this is still a valid file - // only without file type. Otherwise, simply take extension substring skipping the 'dot'. - var subScript = extension.StartsWith('.') ? extension.Substring(1) : ""; - var caption = Path.GetFileNameWithoutExtension(filePath); - - // deserializes the file only once - var properties = GetFileProperties(filePath); - - var templateItem = new StartPageListItem(caption) - { - ContextData = filePath, - ToolTip = filePath, - SubScript = subScript, - Description = properties.description, - Thumbnail = properties.thumbnail, - Author = properties.author, - DateModified = properties.date, - ClickAction = StartPageListItem.Action.FilePath, - }; - - this.TemplateFiles.Add(templateItem); } internal void WalkDirectoryTree(System.IO.DirectoryInfo root, SampleFileEntry rootProperty) @@ -448,15 +385,6 @@ public ObservableCollection SampleFiles get { return this.sampleFiles; } } - /// - /// A collection of Dynamo Template files - /// Fetched at load time from the current Dynamo Templates Propoerties location - /// - public ObservableCollection TemplateFiles - { - get { return this.templateFiles; } - } - public string BackupTitle { get @@ -542,7 +470,7 @@ private void RefreshFileList(ObservableCollection files, var extension = Path.GetExtension(filePath).ToUpper(); // If not extension specified and code reach here, this means this is still a valid file // only without file type. Otherwise, simply take extension substring skipping the 'dot'. - var subScript = extension.StartsWith('.') ? extension.Substring(1) : ""; + var subScript = extension.StartsWith(".") ? extension.Substring(1) : ""; var caption = Path.GetFileNameWithoutExtension(filePath); // deserializes the file only once diff --git a/src/DynamoCoreWpf/DynamoCoreWpf.csproj b/src/DynamoCoreWpf/DynamoCoreWpf.csproj index b412adba8f8..cc9c4715b08 100644 --- a/src/DynamoCoreWpf/DynamoCoreWpf.csproj +++ b/src/DynamoCoreWpf/DynamoCoreWpf.csproj @@ -59,7 +59,7 @@ - 1.0.28 + 1.0.26 DynamoHome @@ -799,7 +799,9 @@ SurveyPopupWindow.xaml + + diff --git a/src/DynamoCoreWpf/PublicAPI.Unshipped.txt b/src/DynamoCoreWpf/PublicAPI.Unshipped.txt index ba8f7e61ae7..de0da65161f 100644 --- a/src/DynamoCoreWpf/PublicAPI.Unshipped.txt +++ b/src/DynamoCoreWpf/PublicAPI.Unshipped.txt @@ -16,7 +16,6 @@ Dynamo.PackageManager.ViewModels.PackageManagerSearchElementViewModel.IsInstalle Dynamo.PackageManager.ViewModels.PackageManagerSearchElementViewModel.IsInstalledVersionSelected.get -> bool Dynamo.PackageManager.ViewModels.PackageManagerSearchElementViewModel.IsPublishedByDynamoTeam.get -> bool Dynamo.PackageManager.ViewModels.PackageManagerSearchElementViewModel.IsUninstallState.get -> bool -Dynamo.UI.Controls.StartPageViewModel.TemplateFiles.get -> System.Collections.ObjectModel.ObservableCollection Dynamo.UI.Views.ScriptObject.ResetSettings() -> void Dynamo.UI.Views.ScriptObject.ScriptObject(System.Action requestLaunchDynamo, System.Action requestImportSettings, System.Func requestSignIn, System.Func requestSignOut, System.Action requestResetSettings) -> void Dynamo.ViewModels.DynamoViewModel.OnlineAccess.get -> bool diff --git a/src/DynamoCoreWpf/Views/HomePage/HomePage.xaml.cs b/src/DynamoCoreWpf/Views/HomePage/HomePage.xaml.cs index 362c4b2507d..ebbe2db65b6 100644 --- a/src/DynamoCoreWpf/Views/HomePage/HomePage.xaml.cs +++ b/src/DynamoCoreWpf/Views/HomePage/HomePage.xaml.cs @@ -9,7 +9,6 @@ using System.Runtime.InteropServices; using System.Text.Json; using System.Text.Json.Serialization; -using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using Autodesk.DesignScript.Runtime; @@ -273,9 +272,8 @@ internal void LoadingDone() if (startPage == null) { return; } SendGuidesData(); - _ = SendSamplesData(); - _ = SendTemplateData(); - _ = SendRecentGraphsData(); + SendSamplesData(); + SendRecentGraphsData(); SendVideoData(); SetLocale(); } @@ -283,7 +281,7 @@ internal void LoadingDone() private void RecentFiles_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) { var recentFiles = startPage.RecentFiles?.DistinctBy(x => x.ContextData).ToList(); - _ = LoadGraphs(recentFiles); + LoadGraphs(recentFiles); } #region FrontEnd Initialization Calls @@ -291,7 +289,7 @@ private void RecentFiles_CollectionChanged(object sender, System.Collections.Spe /// Sends graph data to react app /// /// - private async Task LoadGraphs(List data) + private async void LoadGraphs(List data) { if (data == null) { return; } string jsonData = JsonSerializer.Serialize(data); @@ -302,26 +300,10 @@ private async Task LoadGraphs(List data) } } - - /// - /// Sends graph data to react app - /// - /// - private async Task LoadTemplates(List data) - { - if (data == null) { return; } - string jsonData = JsonSerializer.Serialize(data); - - if (dynWebView?.CoreWebView2 != null) - { - await dynWebView.CoreWebView2.ExecuteScriptAsync(@$"window.receiveTemplatesDataFromDotNet({jsonData})"); - } - } - /// /// Sends samples data to react app /// - private async Task SendSamplesData() + private async void SendSamplesData() { if (!this.startPage.SampleFiles.Any()) return; @@ -333,21 +315,9 @@ private async Task SendSamplesData() } } - /// - /// Sends samples data to react app - /// - private async Task SendTemplateData() - { - var items = startPage.TemplateFiles?.DistinctBy(x => x.ContextData).ToList(); - if (items != null && items.Any()) - { - await LoadTemplates(items); - } - } - - private async Task SendRecentGraphsData() + private async void SendRecentGraphsData() { - // Send user preferences (could be split to a separate call later instead of coupling with recent files). + // Send user preferences if (dynWebView?.CoreWebView2 != null) { if (startPage.DynamoViewModel.PreferenceSettings.HomePageSettings != null) @@ -364,7 +334,7 @@ private async Task SendRecentGraphsData() var recentFiles = startPage.RecentFiles?.DistinctBy(x => x.ContextData).ToList(); if (recentFiles != null && recentFiles.Any()) { - await LoadGraphs(recentFiles); + LoadGraphs(recentFiles); } if (startPage.DynamoViewModel != null && startPage.DynamoViewModel.RecentFiles != null)