Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DYN-5816 locale splash screen #14118

Merged
merged 62 commits into from
Aug 9, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
18c74c4
Display the proper language in the Splash Screen
jesusalvino Jun 29, 2023
2ebe836
spacing RootDirectories
jesusalvino Jun 29, 2023
9614f08
Keeping spacing
jesusalvino Jun 29, 2023
b265118
Remove Splash Screen default title
jesusalvino Jun 30, 2023
4766900
Dissect the Preferences creation from the DynamoModel ctor
jesusalvino Jun 30, 2023
7194409
removing null validation
jesusalvino Jun 30, 2023
fe25ed1
Refactoring based on the PathManager and Preferences
Jul 11, 2023
f27f2de
Adding a PathManager and Preference singleton
Jul 12, 2023
49cfc60
cleaning text
Jul 12, 2023
4da1ea6
PathManager and PreferenceSetttings as singleton
Jul 13, 2023
695628c
Cleaning spacing and others
Jul 13, 2023
1fb48cb
Using the singleton PathManager class instead of the Interface
Jul 14, 2023
db89a94
Changing the scope and documenting the function CreateIPathResolver
Jul 20, 2023
fb647ec
Changing access to be flexible for integrators
Jul 20, 2023
777f584
Removing unused function
Jul 21, 2023
4c42d65
Setting the Preferences to the RecorderTests
Jul 21, 2023
7dd7321
Add the PreferenceSettings.Instance to the DynamoCoreTests setup
Jul 22, 2023
06bbbd4
Adding the preference settings to the DynamoTestUIBase Start configur…
Jul 22, 2023
1aefe4a
Set the Preferences to the SystemTesttBase
Jul 23, 2023
2ce8be4
Set the PreferenceSettings.Instance to the DynamoViewModelUnitTest Start
Jul 24, 2023
d229f81
Dealing with the PathResolver
Jul 25, 2023
0b3902f
Passing the Preferences to the DynamoModel Start function and update …
Jul 25, 2023
1f449e0
Passing the Prererences to the VisualizationTest Start
Jul 25, 2023
b63a8dd
Update the MakeCLIModel function
Jul 25, 2023
2eab90c
Passing the Preferences to the DefaultStartConfiguration
Jul 25, 2023
9e1f6d9
merge master-resolve conflicts
reddyashish Jul 28, 2023
b50b5e4
Update AssemblySharedInfo.cs
reddyashish Jul 28, 2023
ff3862c
Passing the settings to the configuration from the parameter
Jul 31, 2023
6fc2258
untouch the hostApplicationDirectory
Jul 31, 2023
e81b146
Untouching the preLoadedLibraries field and renaming
Jul 31, 2023
9da3a1f
Restoring fields and adding doc
Aug 1, 2023
f4bafcd
Adding the preferences to the start of some tests
Aug 1, 2023
7ed64f7
Validating the settings in the DynamoModelTestBase setup
Aug 2, 2023
4dfdef4
Adding Preferences to the config Settings Test
Aug 3, 2023
7252051
Refactoring the PathManager and Preference creation on the DynamoMode…
Aug 3, 2023
1ddba71
Merge branch 'master' into DYN-5816-locale-splash-screen
Aug 3, 2023
84e111d
Cleaning Tests setup and ignore Pref Instance property for xml
Aug 3, 2023
37620ba
Merge branch 'DynamoDS:master' into DYN-5816-locale-splash-screen
jesusalvino Aug 4, 2023
1321eb7
Merge branch 'DynamoDS:master' into DYN-5816-locale-splash-screen
jesusalvino Aug 4, 2023
8c3ee26
Removing Pref Singleton to the CoreTest Setup
Aug 4, 2023
cc58ece
Rollback fron the 6213 commit
Aug 4, 2023
90e4a7f
Merge branch 'master' into DYN-5816-locale-splash-screen
Aug 4, 2023
1f0d671
keep the StartInTestMode to false since this is an special case and s…
Aug 4, 2023
e14ee63
Handling Preferences
Aug 5, 2023
fe980b9
clieaning references
Aug 5, 2023
4771ed4
Saving them with the proper Unicode
Aug 5, 2023
33a5d63
Removing Singletion Preferences
Aug 5, 2023
e5e92ab
Explicit Settings since the StartInTestMode is false
Aug 5, 2023
745a431
Add the specific Preferences
Aug 7, 2023
53d2218
Rollback the cc58
Aug 7, 2023
2539d97
Rollback the cc58
Aug 7, 2023
b630a38
Merge branch 'master' of https://github.com/jesusalvino/Dynamo
Aug 7, 2023
06ea6c5
Merge branch 'master' into DYN-5816-T1
Aug 7, 2023
2caf714
Fix Solution
Aug 8, 2023
c290e73
Fixing the Assembly character and test file
Aug 8, 2023
63e905a
Merge branch 'master' into DYN-5816-locale-splash-screen
Aug 8, 2023
87636bb
Merge branch 'DYN-5816-T1' into DYN-5816-locale-splash-screen
Aug 8, 2023
d10541a
Forcing to update the cc58 commit
Aug 8, 2023
549e3c2
Removing the test file
Aug 8, 2023
162fe2c
Fixing Tests Unicode
Aug 8, 2023
d2f3731
No new line
Aug 8, 2023
5a22b9d
Merge branch 'DynamoDS:master' into DYN-5816-locale-splash-screen
jesusalvino Aug 8, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/DynamoApplications/StartupUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ public static DynamoModel MakeModel(bool CLImode, string asmPath = "", string ho
/// <returns></returns>
public static DynamoModel MakeModel(bool CLImode, string asmPath = "", HostAnalyticsInfo info = new HostAnalyticsInfo())
{
new DynamoModel();
QilongTang marked this conversation as resolved.
Show resolved Hide resolved
// Preload ASM and display corresponding message on splash screen
DynamoModel.OnRequestUpdateLoadBarStatus(new SplashScreenLoadEventArgs(Resources.SplashScreenPreLoadingAsm, 10));
var isASMloaded = PreloadASM(asmPath, out string geometryFactoryPath, out string preloaderLocation);
Expand Down
30 changes: 30 additions & 0 deletions src/DynamoCore/Configuration/PathManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,36 @@ public bool ResolveDocumentPath(ref string document)

#region Public Class Operational Methods

/// <summary>
/// Specific constructor to get the preferenceFilePath
/// </summary>
internal PathManager()
{
var dynamoCorePath = Assembly.GetExecutingAssembly().Location;
QilongTang marked this conversation as resolved.
Show resolved Hide resolved
var corePath = Path.GetDirectoryName(dynamoCorePath);
var assemblyPath = Path.Combine(corePath, "DynamoCore.dll");

if (!PathHelper.IsValidPath(assemblyPath))
{
throw new Exception("Dynamo's core path could not be found. " +
"If you are running Dynamo from a test, try specifying the " +
"Dynamo core location in the DynamoBasePath variable in " +
"TestServices.dll.config.");
}

// If both major/minor versions are zero, get from assembly.
if (majorFileVersion == 0 && (minorFileVersion == 0))
{
var v = FileVersionInfo.GetVersionInfo(assemblyPath);
majorFileVersion = v.FileMajorPart;
minorFileVersion = v.FileMinorPart;
}

// Current user specific directories.
var userDataDir = GetUserDataFolder();
preferenceFilePath = Path.Combine(userDataDir, PreferenceSettingsFileName);
}

/// <summary>
/// Constructs an instance of PathManager object.
/// </summary>
Expand Down
24 changes: 22 additions & 2 deletions src/DynamoCore/Models/DynamoModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -646,6 +646,23 @@ private void InitializeLuceneConfig()
}
}

/// <summary>
/// Light constructor only for get the Preference and apply the locale
/// </summary>
public DynamoModel()
{
var preferenceFilePath = new PathManager().PreferenceFilePath;
QilongTang marked this conversation as resolved.
Show resolved Hide resolved

IPreferences preferences = CreateOrLoadPreferences(null, preferenceFilePath);
if (preferences is PreferenceSettings settings)
{
PreferenceSettings = settings;
// Setting the new locale for Dynamo after Preferences loaded
Thread.CurrentThread.CurrentUICulture = new CultureInfo(PreferenceSettings.Locale);
Thread.CurrentThread.CurrentCulture = new CultureInfo(PreferenceSettings.Locale);
OnDetectLanguage();
}
}
/// <summary>
/// Default constructor for DynamoModel
/// </summary>
Expand Down Expand Up @@ -1727,7 +1744,7 @@ private void LoadNodeModels(List<TypeLoadData> nodes, bool isPackageMember)
}
}

private IPreferences CreateOrLoadPreferences(IPreferences preferences)
private IPreferences CreateOrLoadPreferences(IPreferences preferences, string explicitPreferencePath = "")
{
if (preferences != null) // If there is preference settings provided...
return preferences;
Expand All @@ -1746,9 +1763,12 @@ private IPreferences CreateOrLoadPreferences(IPreferences preferences)
// is not set, then fall back to the file path specified in PathManager.
//
var xmlFilePath = PreferenceSettings.DynamoTestPath;
if (string.IsNullOrEmpty(xmlFilePath))
if (string.IsNullOrEmpty(xmlFilePath) && pathManager != null)
xmlFilePath = pathManager.PreferenceFilePath;

if (!string.IsNullOrEmpty(explicitPreferencePath))
xmlFilePath = explicitPreferencePath;

if (File.Exists(xmlFilePath))
{
// If the specified xml file path exists, load it.
Expand Down
4 changes: 4 additions & 0 deletions src/DynamoCore/Models/DynamoModelDelegates.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,8 @@ namespace Dynamo.Models
/// <param name="args"></param>
internal delegate void SplashScreenLoadingHandler(SplashScreenLoadEventArgs args);

/// <summary>
/// This delegate is used to notify the detected language to the Splash Screen.
/// </summary>
internal delegate void SplashScreenLanguageDetected();
}
9 changes: 9 additions & 0 deletions src/DynamoCore/Models/DynamoModelEvents.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,15 @@ internal static void OnRequestUpdateLoadBarStatus(SplashScreenLoadEventArgs args
RequestUpdateLoadBarStatus?.Invoke(args);
}

/// <summary>
/// Event to throw for Splash Screen to display the content in the proper language
/// </summary>
internal static event SplashScreenLanguageDetected LanguageDetected;
QilongTang marked this conversation as resolved.
Show resolved Hide resolved
internal static void OnDetectLanguage()
{
LanguageDetected?.Invoke();
}

/// <summary>
/// Occurs when changes in data may affect UI and UI needs to be refreshed
/// </summary>
Expand Down
11 changes: 9 additions & 2 deletions src/DynamoCoreWpf/Views/SplashScreen/SplashScreen.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,16 +130,21 @@ public SplashScreen()
// Bind event handlers
webView.NavigationCompleted += WebView_NavigationCompleted;
DynamoModel.RequestUpdateLoadBarStatus += DynamoModel_RequestUpdateLoadBarStatus;
DynamoModel.LanguageDetected += DynamoModel_LanguageDetected;
StaticSplashScreenReady += OnStaticScreenReady;
RequestLaunchDynamo = LaunchDynamo;
RequestImportSettings = ImportSettings;
RequestSignIn = SignIn;
RequestSignOut = SignOut;
}

private void WebView_NavigationCompleted(object sender, CoreWebView2NavigationCompletedEventArgs e)
private void DynamoModel_LanguageDetected()
{
SetLabels();
}

private void WebView_NavigationCompleted(object sender, CoreWebView2NavigationCompletedEventArgs e)
{
if (webView != null)
{
webView.NavigationCompleted -= WebView_NavigationCompleted;
Expand Down Expand Up @@ -276,7 +281,7 @@ protected override async void OnContentRendered(EventArgs e)
webView.CoreWebView2.Settings.IsZoomControlEnabled = false;

var assembly = Assembly.GetExecutingAssembly();

using (Stream stream = assembly.GetManifestResourceStream(htmlEmbeddedFile))
using (StreamReader reader = new StreamReader(stream))
{
Expand All @@ -296,6 +301,7 @@ protected override async void OnContentRendered(EventArgs e)
jsonString = jsonString.Replace("#base64BackgroundImage", $"data:image/{imageFileExtension};base64,{resourceBase64}");
}

jsonString = jsonString.Replace("Welcome to Dynamo!", "");
htmlString = htmlString.Replace("mainJs", jsonString);

webView.NavigateToString(htmlString);
Expand Down Expand Up @@ -474,6 +480,7 @@ protected override void OnClosed(EventArgs e)
base.OnClosed(e);

DynamoModel.RequestUpdateLoadBarStatus -= DynamoModel_RequestUpdateLoadBarStatus;
DynamoModel.LanguageDetected -= DynamoModel_LanguageDetected;
webView.Dispose();
webView = null;

Expand Down