Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/DynamoDS/Dynamo into CERT…
Browse files Browse the repository at this point in the history
…oolFixes
  • Loading branch information
sm6srw committed Oct 23, 2023
2 parents fa12a1a + bdc6ba4 commit fe26327
Show file tree
Hide file tree
Showing 16 changed files with 177 additions and 42 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 @@ -122,10 +122,10 @@
<LibG229 Include="$(PkgDynamoVisualProgramming_LibG_229_0_0)\tools\netstandard2.0\$(LibGOsToken)\LibG_229_0_0\*" />
<ExternSimplexNoise Include="$(SolutionDir)..\extern\SimplexNoise\*" />
<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
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
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
78 changes: 78 additions & 0 deletions src/DynamoCoreWpf/Views/Core/DynamoView.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,14 @@ public partial class DynamoView : Window, IDisposable
private bool isPSSCalledOnViewModelNoCancel = false;
private readonly DispatcherTimer _workspaceResizeTimer = new DispatcherTimer { Interval = new TimeSpan(0, 0, 0, 0, 500), IsEnabled = false };
private ViewLoadedParams sharedViewExtensionLoadedParams;
/// <summary>
/// keeps the width right menu of the ShourtcutBar
/// </summary>
private double toolBarRightMenuWidth = 0;
/// <summary>
/// Keeps the additional Width based on the paddings and margins from the shorcutBar controls to calculate the whole Width
/// </summary>
private double additionalWidth = 50;

/// <summary>
/// Extensions currently displayed as windows.
Expand All @@ -101,6 +109,11 @@ internal PreferencesView PreferencesWindow {
get { return preferencesWindow; }
}

/// <summary>
/// Keeps the default value of the Window's MinWidth to calculate it again later
/// </summary>
internal double DefaultMinWidth = 0;

/// <summary>
/// Constructor
/// </summary>
Expand Down Expand Up @@ -228,9 +241,12 @@ public DynamoView(DynamoViewModel dynamoViewModel)
this.HideOrShowRightSideBar();

this.dynamoViewModel.RequestPaste += OnRequestPaste;
this.dynamoViewModel.RequestCloseHomeWorkSpace += OnRequestCloseHomeWorkSpace;
this.dynamoViewModel.RequestReturnFocusToView += OnRequestReturnFocusToView;
this.dynamoViewModel.Model.WorkspaceSaving += OnWorkspaceSaving;
this.dynamoViewModel.Model.WorkspaceOpened += OnWorkspaceOpened;
this.dynamoViewModel.Model.WorkspaceAdded += OnWorkspaceAdded;
this.dynamoViewModel.Model.WorkspaceHidden += OnWorkspaceHidden;
this.dynamoViewModel.RequestEnableShortcutBarItems += DynamoViewModel_RequestEnableShortcutBarItems;
this.dynamoViewModel.RequestExportWorkSpaceAsImage += OnRequestExportWorkSpaceAsImage;

Expand All @@ -244,8 +260,30 @@ public DynamoView(DynamoViewModel dynamoViewModel)
{
Application.Current.MainWindow = this;
}

DefaultMinWidth = MinWidth;
}

private void OnRequestCloseHomeWorkSpace()
{
CalculateWindowMinWidth();
}

private void OnWorkspaceHidden(WorkspaceModel workspace)
{
CalculateWindowMinWidth();
}

private void OnWorkspaceAdded(WorkspaceModel workspace)
{
CalculateWindowMinWidth();
}

protected override async void OnContentRendered(EventArgs e)
{
base.OnContentRendered(e);
toolBarRightMenuWidth = shortcutBar.RightMenu.ActualWidth;
}
private void OnRequestExportWorkSpaceAsImage(object parameter)
{
var workspace = this.ChildOfType<WorkspaceView>();
Expand Down Expand Up @@ -1027,6 +1065,43 @@ private void DynamoView_SizeChanged(object sender, SizeChangedEventArgs e)
}

UpdateGeometryScalingPopupLocation();

CalculateWindowThreshold();
}

/// <summary>
/// Returns the sum of the width of the library, the width of the tabs from the workspace and the width of the shortcut toolbar.
/// </summary>
/// <returns></returns>
internal double GetSumOfControlsWidth()
{
List<TabItem> tabItems = WpfUtilities.ChildrenOfType<TabItem>(WorkspaceTabs).ToList();
double tabItemsWidth = tabItems.Count > 0 ? (double.IsNaN(tabItems[0].Width) ? 0 : tabItems[0].Width) * tabItems.Count : 0;
return Convert.ToDouble(dynamoViewModel.LibraryWidth) + tabItemsWidth + toolBarRightMenuWidth + additionalWidth;
}

/// <summary>
/// Calculates the Window threshold to display the text or only icons in the shortcut toolbar
internal void CalculateWindowThreshold()
{
dynamoViewModel.OnWindowResized(dynamoViewModel.Model.PreferenceSettings.WindowW <= GetSumOfControlsWidth());
}

/// <summary>
/// Calculates the Window minimum width bearing in mind the width of the controls and the current Window width, it's necessary to avoid the shortcut toolbar (gray) overlap the custom node tab (black)
/// </summary>
internal void CalculateWindowMinWidth()
{
if (dynamoViewModel.Model.PreferenceSettings.WindowW > DefaultMinWidth)
{
MinWidth = GetSumOfControlsWidth();
}
else
{
MinWidth = DefaultMinWidth;
}

CalculateWindowThreshold();
}

private void UpdateGeometryScalingPopupLocation()
Expand Down Expand Up @@ -1921,9 +1996,12 @@ private void WindowClosed(object sender, EventArgs e)

//COMMANDS
this.dynamoViewModel.RequestPaste -= OnRequestPaste;
this.dynamoViewModel.RequestCloseHomeWorkSpace -= OnRequestCloseHomeWorkSpace;
this.dynamoViewModel.RequestReturnFocusToView -= OnRequestReturnFocusToView;
this.dynamoViewModel.Model.WorkspaceSaving -= OnWorkspaceSaving;
this.dynamoViewModel.Model.WorkspaceOpened -= OnWorkspaceOpened;
this.dynamoViewModel.Model.WorkspaceAdded -= OnWorkspaceAdded;
this.dynamoViewModel.Model.WorkspaceHidden -= OnWorkspaceHidden;
this.dynamoViewModel.RequestEnableShortcutBarItems -= DynamoViewModel_RequestEnableShortcutBarItems;
this.dynamoViewModel.RequestExportWorkSpaceAsImage -= OnRequestExportWorkSpaceAsImage;

Expand Down
6 changes: 3 additions & 3 deletions src/DynamoPackages/DynamoPackages.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 @@ -30,9 +30,9 @@
<Content Include="PackageManagerExtension_ExtensionDefinition.xml" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Greg" Version="2.5.0.5076" />
<PackageReference Include="Greg" Version="3.0.0.2955" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="RestSharp" Version="106.12.0" />
<PackageReference Include="RestSharp" Version="109.0.1" />
</ItemGroup>
<ItemGroup>
<Compile Update="Properties\Resources.Designer.cs">
Expand Down
5 changes: 2 additions & 3 deletions src/DynamoPackages/PackageDirectoryBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text.Json;
using Dynamo.PackageManager.Interfaces;
using Dynamo.Utilities;
using RestSharp.Serialization.Json;

namespace Dynamo.PackageManager
{
Expand Down Expand Up @@ -127,8 +127,7 @@ private void WritePackageHeader(Package package, IDirectoryInfo rootDir)
var pkgHeader = PackageUploadBuilder.NewRequestBody(package);

// build the package header json, which will be stored with the pkg
var jsSer = new JsonSerializer();
var pkgHeaderStr = jsSer.Serialize(pkgHeader);
var pkgHeaderStr = JsonSerializer.Serialize(pkgHeader);

// write the pkg header to the root directory of the pkg
var headerPath = Path.Combine(rootDir.FullName, PackageJsonName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
<EnableDefaultPageItems>false</EnableDefaultPageItems>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Greg" Version="2.5.0.5076" />
<PackageReference Include="Greg" Version="3.0.0.2955" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="RestSharp" Version="106.12.0" />
<PackageReference Include="RestSharp" Version="109.0.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\DynamoCoreWpf\DynamoCoreWpf.csproj">
Expand Down
Loading

0 comments on commit fe26327

Please sign in to comment.