Skip to content

Commit

Permalink
Merge branch 'master' into update_license
Browse files Browse the repository at this point in the history
  • Loading branch information
pinzart committed Oct 24, 2023
2 parents 03a8cfe + 892253e commit a55605a
Show file tree
Hide file tree
Showing 19 changed files with 235 additions and 78 deletions.
14 changes: 7 additions & 7 deletions src/DynamoCore/DynamoCore.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<ImportGroup Label="PropertySheets">
<Import Project="$(SolutionDir)Config\CS_SDK.props" />
</ImportGroup>
Expand Down Expand Up @@ -27,11 +27,11 @@
</ItemGroup>
<ItemGroup Label="Common dependencies">
<PackageReference Include="Autodesk.IDSDK" Version="1.1.6" />
<PackageReference Include="Greg" Version="3.0.0.2955" />
<PackageReference Include="DynamoVisualProgramming.LibG_229_0_0" Version="3.0.0.2855" GeneratePathProperty="true" />
<PackageReference Include="DynamoVisualProgramming.LibG_230_0_0" Version="3.0.0.2880" GeneratePathProperty="true" />
<PackageReference Include="Greg" Version="2.5.0.5076" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" CopyXML="true" />
<PackageReference Include="RestSharp" Version="106.12.0" CopyXML="true" />
<PackageReference Include="RestSharp" Version="109.0.1" CopyXML="true" />
<PackageReference Include="Lucene.Net" Version="4.8.0-beta00016" />
<PackageReference Include="Lucene.Net.Analysis.Common" Version="4.8.0-beta00016" />
<PackageReference Include="Lucene.Net.QueryParser" Version="4.8.0-beta00016" />
Expand Down Expand Up @@ -121,10 +121,10 @@
<LibG230 Include="$(PkgDynamoVisualProgramming_LibG_230_0_0)\tools\netstandard2.0\$(LibGOsToken)\LibG_230_0_0\*" />
<LibG229 Include="$(PkgDynamoVisualProgramming_LibG_229_0_0)\tools\netstandard2.0\$(LibGOsToken)\LibG_229_0_0\*" />
<SampleFiles Include="$(SolutionDir)..\doc\distrib\Samples\**\*.*" />
<NodeHelpMDFiles Include="$(SolutionDir)..\doc\distrib\NodeHelpFiles\**\*.md"/>
<NodeHelpDYNFiles Include="$(SolutionDir)..\doc\distrib\NodeHelpFiles\**\*.dyn"/>
<NodeHelpTXTFiles Include="$(SolutionDir)..\doc\distrib\NodeHelpFiles\**\*.txt"/>
<NodeHelpSATFiles Include="$(SolutionDir)..\doc\distrib\NodeHelpFiles\**\*.sat"/>
<NodeHelpMDFiles Include="$(SolutionDir)..\doc\distrib\NodeHelpFiles\**\*.md" />
<NodeHelpDYNFiles Include="$(SolutionDir)..\doc\distrib\NodeHelpFiles\**\*.dyn" />
<NodeHelpTXTFiles Include="$(SolutionDir)..\doc\distrib\NodeHelpFiles\**\*.txt" />
<NodeHelpSATFiles Include="$(SolutionDir)..\doc\distrib\NodeHelpFiles\**\*.sat" />
<NodeHelpJpgImageFiles Include="$(SolutionDir)..\doc\distrib\NodeHelpFiles\**\*.jpg" />
<NodeHelpPngImageFiles Include="$(SolutionDir)..\doc\distrib\NodeHelpFiles\**\*.png" />
<NodeHelpGifImageFiles Include="$(SolutionDir)..\doc\distrib\NodeHelpFiles\**\*.gif" />
Expand Down
11 changes: 7 additions & 4 deletions src/DynamoCoreWpf/Controls/ShortcutToolbar.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -137,15 +137,17 @@
<Menu HorizontalAlignment="Right"
Style="{StaticResource MainMenu}"
Margin="0,0,10,0"
IsMainMenu="True">
IsMainMenu="True"
Name="RightMenu">
<MenuItem Name="loginMenu" Margin="0,-3,-10,0">
<MenuItem.Header>
<Button Name="LoginButton" Click="LoginButton_OnClick" Foreground="#DCDCDC" Padding="5,0,5,0">
<Button Name="LoginButton" Click="LoginButton_OnClick" Foreground="#DCDCDC"
>
<StackPanel FlowDirection="LeftToRight" Orientation="Horizontal">

<Image Source="/DynamoCoreWpf;component/UI/Images/Profile_48px.png" Width="16" Height ="16"></Image>

<TextBlock Name="txtSignIn" Padding="10,5,5,5">
<TextBlock Name="txtSignIn" Padding="10,5,5,5" Visibility="{Binding ShowMenuItemText, Converter={StaticResource BooleanToVisibilityCollapsedConverter}}">
<TextBlock.Style>
<Style TargetType="{x:Type TextBlock}">
<Setter Property="Text" Value="{x:Static p:Resources.SignInButtonText}" />
Expand Down Expand Up @@ -237,7 +239,8 @@
VerticalAlignment="Center"
Margin="10 0 0 0"
Foreground="#DCDCDC"
FontFamily="{StaticResource ArtifaktElementRegular}">
FontFamily="{StaticResource ArtifaktElementRegular}"
Visibility="{Binding ShowMenuItemText, Converter={StaticResource BooleanToVisibilityCollapsedConverter}}">
</TextBlock>
</StackPanel>
</MenuItem.Header>
Expand Down
4 changes: 2 additions & 2 deletions src/DynamoCoreWpf/DynamoCoreWpf.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,10 @@
<PackageReference Include="DynamoVisualProgramming.LibG_229_0_0" Version="3.0.0.2855" />
<PackageReference Include="FontAwesome5" Version="2.1.11" />
<PackageReference Include="AvalonEdit" Version="6.3.0.90" CopyXML="true" />
<PackageReference Include="Greg" Version="2.5.0.5076" />
<PackageReference Include="Greg" Version="3.0.0.2955" />
<PackageReference Include="Microsoft.Web.WebView2" Version="1.0.2045.28" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="RestSharp" Version="106.12.0" />
<PackageReference Include="RestSharp" Version="109.0.1" />
<PackageReference Include="Cyotek.Drawing.BitmapFont" Version="2.0.0" />
<PackageReference Include="SharpDX" Version="4.2.0" />
<PackageReference Include="SharpDX.D3DCompiler" Version="4.2.0">
Expand Down
23 changes: 15 additions & 8 deletions src/DynamoCoreWpf/Utilities/CrashReportTool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -125,16 +125,23 @@ private static string FindCERToolInInstallLocations()

try
{
string rootFolder = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
var assemblyPath = Path.Combine(Path.Combine(rootFolder, "DynamoInstallDetective.dll"));
if (!File.Exists(assemblyPath))
throw new FileNotFoundException(assemblyPath);

var assembly = Assembly.LoadFrom(assemblyPath);

var type = assembly.GetType("DynamoInstallDetective.Utilities");
// Try to directly get the type for the detective class
// (this will in many cases also load the assembly)
var type = Type.GetType("DynamoInstallDetective.Utilities, DynamoInstallDetective", false);
if (type == null)
{
// fallback, load the assembly and get the type using LoadFrom
string rootFolder = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
var assemblyPath = Path.Combine(rootFolder, "DynamoInstallDetective.dll");
if (!File.Exists(assemblyPath))
throw new FileNotFoundException(assemblyPath);

var assembly = Assembly.LoadFrom(assemblyPath);
type = assembly.GetType("DynamoInstallDetective.Utilities");
}

var installationsMethod = type.GetMethod(
var installationsMethod = type.GetMethod(
"FindMultipleProductInstallations",
BindingFlags.Public | BindingFlags.Static);

Expand Down
11 changes: 10 additions & 1 deletion src/DynamoCoreWpf/ViewModels/Core/DynamoViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -830,11 +830,19 @@ void Watch3DViewModelPropertyChanged(object sender, PropertyChangedEventArgs e)
}
}

internal event EventHandler WindowRezised;
internal void OnWindowResized(object underThreshold)
{
if(WindowRezised != null)
{
WindowRezised(underThreshold, new EventArgs());
}
}

internal event EventHandler PreferencesWindowChanged;
internal void OnPreferencesWindowChanged(object preferencesView)
{
if(PreferencesWindowChanged != null)
if (PreferencesWindowChanged != null)
{
PreferencesWindowChanged(preferencesView, new EventArgs());
}
Expand Down Expand Up @@ -2669,6 +2677,7 @@ private void CloseHomeWorkspace(object parameter)
this.ShowStartPage = (Model.Workspaces.Count() <= 1);
RunSettings.ForceBlockRun = false;
OnEnableShortcutBarItems(false);
OnRequestCloseHomeWorkSpace();
}
}

Expand Down
9 changes: 9 additions & 0 deletions src/DynamoCoreWpf/ViewModels/Core/DynamoViewModelEvents.cs
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,15 @@ private void OnRequestPaste()
}
}

internal event Action RequestCloseHomeWorkSpace;
private void OnRequestCloseHomeWorkSpace()
{
if (RequestCloseHomeWorkSpace != null)
{
RequestCloseHomeWorkSpace();
}
}

internal event Action <object> RequestExportWorkSpaceAsImage;
private void OnRequestExportWorkSpaceAsImage(object parameter)
{
Expand Down
53 changes: 31 additions & 22 deletions src/DynamoCoreWpf/ViewModels/Core/NodeViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,3 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Windows;
using System.Windows.Controls.Primitives;
using System.Windows.Media;
using Dynamo.Configuration;
using Dynamo.Engine.CodeGeneration;
using Dynamo.Graph;
Expand All @@ -18,9 +7,19 @@
using Dynamo.Logging;
using Dynamo.Models;
using Dynamo.Selection;
using Dynamo.UI;
using Dynamo.Wpf.ViewModels.Core;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Windows;
using System.Windows.Controls.Primitives;
using System.Windows.Media;
using Point = System.Windows.Point;
using Size = System.Windows.Size;

Expand Down Expand Up @@ -1349,7 +1348,7 @@ internal SolidColorBrush GetBorderColor()

/*
Priorities seem to be:
Error > Warning > Info ; Frozen > Preview > None
Error > Warning > Info ; Frozen > Package > Preview > None
Pass through all possible states in reverse order
to assign icon values for each possible scenario
*/
Expand All @@ -1358,14 +1357,6 @@ Pass through all possible states in reverse order

if (this.NodeModel == null) return result;

if (this.NodeModel.IsCustomFunction)
{
result = nodeCustomColor;
if(result != null)
{
ImgGlyphOneSource = packageGlyph;
}
}
if (!this.IsVisible)
{
result = nodePreviewColor;
Expand All @@ -1374,6 +1365,24 @@ Pass through all possible states in reverse order
ImgGlyphOneSource = previewGlyph;
}
}

if (this.NodeModel.IsCustomFunction)
{
result = nodeCustomColor;
if(result != null)
{
if (ImgGlyphOneSource == null)
{
ImgGlyphOneSource = packageGlyph;
}
else
{
ImgGlyphOneSource = packageGlyph;
ImgGlyphTwoSource = previewGlyph;
}
}
}

if (this.IsFrozen)
{
result = nodeFrozenOverlayColor;
Expand All @@ -1382,7 +1391,7 @@ Pass through all possible states in reverse order
if (ImgGlyphOneSource == null)
{
ImgGlyphOneSource = frozenGlyph;
}
}
else
{
ImgGlyphOneSource = frozenGlyph;
Expand Down
33 changes: 33 additions & 0 deletions src/DynamoCoreWpf/ViewModels/Core/ShortcutToolbarViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Dynamo.Core;
using Dynamo.UI.Commands;
using Dynamo.ViewModels;
using System;

namespace Dynamo.Wpf.ViewModels.Core
{
Expand All @@ -15,14 +16,24 @@ internal class ShortcutToolbarViewModel : ViewModelBase
private AuthenticationManager authManager;

private int notificationsNumber;
private bool showMenuItemText;
public readonly DynamoViewModel DynamoViewModel;

public ShortcutToolbarViewModel(DynamoViewModel dynamoViewModel)
{
this.DynamoViewModel = dynamoViewModel;
NotificationsNumber = 0;
authManager = dynamoViewModel.Model.AuthenticationManager;
ValidateWorkSpaceBeforeToExportAsImageCommand = new DelegateCommand(dynamoViewModel.ValidateWorkSpaceBeforeToExportAsImage);
SignOutCommand = new DelegateCommand(authManager.ToggleLoginState);
authManager.LoginStateChanged += (o) => { RaisePropertyChanged(nameof(LoginState)); };
this.DynamoViewModel.WindowRezised += OnDynamoViewModelWindowRezised;
ShowMenuItemText = true;
}

private void OnDynamoViewModelWindowRezised(object sender, System.EventArgs e)
{
if (sender is Boolean) ShowMenuItemText = !(bool)sender;
}

/// <summary>
Expand Down Expand Up @@ -70,5 +81,27 @@ public bool IsNotificationsCounterVisible
return true;
}
}

/// <summary>
/// Indicates if a MenuItem display its text or not (only Icon)
/// </summary>
public bool ShowMenuItemText
{
get
{
return showMenuItemText;
}
set
{
showMenuItemText = value;
RaisePropertyChanged(nameof(ShowMenuItemText));
}
}

public override void Dispose()
{
this.DynamoViewModel.WindowRezised -= OnDynamoViewModelWindowRezised;
base.Dispose();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -432,25 +432,19 @@ private MLNodeAutoCompletionResponse GetMLNodeAutocompleteResults(string request
MLNodeAutoCompletionResponse results = null;
var authProvider = dynamoViewModel.Model.AuthenticationManager.AuthProvider;

if (authProvider is IOAuth2AuthProvider oauth2AuthProvider)
if (authProvider is IOAuth2AuthProvider oauth2AuthProvider && authProvider is IOAuth2AccessTokenProvider tokenprovider)
{
try
{
// TODO: We need to implement something like GetToken() on the IOAuth2AuthProvider interface which will be used by all auth providers.
// For now, we are mocking the RestSharpRequest object to set the IDSDK token and then update the header in actual RestRequest with that token.
// LoginRequest() is also not available on RevitOAuth2Provider, so using the SignRequest() which will show the sign-in page when the user is logged out.
RestRequest restSharpRequest = new RestRequest();
RestClient restSharpClient = new RestClient();
oauth2AuthProvider.SignRequest(ref restSharpRequest, restSharpClient);

var uri = DynamoUtilities.PathHelper.getServiceBackendAddress(this, nodeAutocompleteMLEndpoint);
var client = new RestClient(uri);
var request = new RestRequest(Method.POST);
var request = new RestRequest(string.Empty,Method.Post);

request.AddHeader("Authorization", restSharpRequest.Parameters.FirstOrDefault(n => n.Name.Equals("Authorization")).Value.ToString());
request = request.AddJsonBody(requestJSON) as RestRequest;
request.AddHeader("Authorization",tokenprovider.GetAccessToken());
request = request.AddJsonBody(requestJSON);
request.RequestFormat = DataFormat.Json;
RestResponse response = client.Execute(request) as RestResponse;
RestResponse response = client.Execute(request);
//TODO maybe worth moving to system.text json in phases?
results = JsonConvert.DeserializeObject<MLNodeAutoCompletionResponse>(response.Content);
}
catch (Exception ex)
Expand Down
Loading

0 comments on commit a55605a

Please sign in to comment.