Skip to content

Commit ed5547d

Browse files
authored
Merge branch 'master' into DYN-9032
2 parents fe63ab8 + 03e7878 commit ed5547d

File tree

7 files changed

+112
-8
lines changed

7 files changed

+112
-8
lines changed

src/DynamoCoreWpf/Views/Core/DynamoView.xaml.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1589,7 +1589,11 @@ private void HidePopupWhenWindowDeactivated(object obj)
15891589
{
15901590
var workspace = this.ChildOfType<WorkspaceView>();
15911591
if (workspace != null)
1592+
{
15921593
workspace.HideAllPopUp(obj);
1594+
workspace.DestroyPortContextMenu();
1595+
}
1596+
15931597
}
15941598

15951599
private void TrackStartupAnalytics()

src/DynamoCoreWpf/Views/Core/WorkspaceView.xaml.cs

Lines changed: 45 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,11 @@ public WorkspaceView()
108108

109109
InitializeComponent();
110110

111+
Loaded += WorkspaceView_Loaded;
112+
Unloaded += WorkspaceView_Unloaded;
113+
114+
LostFocus += WorkspaceView_LostFocus;
115+
111116
DataContextChanged += OnWorkspaceViewDataContextChanged;
112117

113118
// view of items to drag
@@ -119,6 +124,11 @@ public WorkspaceView()
119124
dictionaries.Add(SharedDictionaryManager.DataTemplatesDictionary);
120125
}
121126

127+
private void WorkspaceView_LostFocus(object sender, RoutedEventArgs e)
128+
{
129+
DestroyPortContextMenu();
130+
}
131+
122132
void ViewModel_PropertyChanged(object sender, PropertyChangedEventArgs e)
123133
{
124134
switch (e.PropertyName)
@@ -906,20 +916,47 @@ private void OnCanvasMouseDown(object sender, MouseButtonEventArgs e)
906916
InCanvasSearchBar.IsOpen = false;
907917
if (GeoScalingPopup != null)
908918
GeoScalingPopup.IsOpen = false;
909-
910-
if(PortContextMenu.IsOpen) DestroyPortContextMenu();
919+
920+
if (PortContextMenu.IsOpen) DestroyPortContextMenu();
911921

912922
if (!ViewModel.IsConnecting && !ViewModel.IsPanning && e.MiddleButton == MouseButtonState.Pressed)
913923
{
914924
ViewModel.RequestTogglePanMode();
915925
}
916926
}
917927

928+
private void WorkspaceView_Loaded(object sender, RoutedEventArgs e)
929+
{
930+
var ownerWindow = Window.GetWindow(this);
931+
if (ownerWindow != null)
932+
{
933+
ownerWindow.Deactivated += OwnerWindow_Deactivated;
934+
}
935+
}
936+
937+
private void WorkspaceView_Unloaded(object sender, RoutedEventArgs e)
938+
{
939+
var ownerWindow = Window.GetWindow(this);
940+
if (ownerWindow != null)
941+
{
942+
ownerWindow.Deactivated -= OwnerWindow_Deactivated;
943+
}
944+
}
945+
946+
/// <summary>
947+
/// When the Dynamo/Revit window loses focus, close the port context menu
948+
/// so it doesn't float above other windows.
949+
/// </summary>
950+
private void OwnerWindow_Deactivated(object sender, EventArgs e)
951+
{
952+
DestroyPortContextMenu();
953+
}
954+
918955
/// <summary>
919956
/// Closes the port's context menu and sets its references to null.
920957
/// </summary>
921-
private void DestroyPortContextMenu() => PortContextMenu.IsOpen = false;
922-
958+
internal void DestroyPortContextMenu() => PortContextMenu.IsOpen = false;
959+
923960
private void OnMouseRelease(object sender, MouseButtonEventArgs e)
924961
{
925962
if (e == null) return; // in certain bizarre cases, e can be null
@@ -1261,6 +1298,10 @@ private void OnGeometryScaling_Click(object sender, RoutedEventArgs e)
12611298
public void Dispose()
12621299
{
12631300
RemoveViewModelsubscriptions(ViewModel);
1301+
1302+
Loaded -= WorkspaceView_Loaded;
1303+
Unloaded -= WorkspaceView_Unloaded;
1304+
LostFocus -= WorkspaceView_LostFocus;
12641305
DataContextChanged -= OnWorkspaceViewDataContextChanged;
12651306
}
12661307
}

src/Notifications/NotificationsViewExtension.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
using Dynamo.ViewModels;
1010
using Dynamo.Wpf.Extensions;
1111
using Dynamo.Utilities;
12+
using System.IO;
1213

1314
namespace Dynamo.Notifications
1415
{
@@ -112,6 +113,28 @@ public void Loaded(ViewLoadedParams viewStartupParams)
112113
viewStartupParams.dynamoMenu.Items.Add(notificationsMenuItem.MenuItem);
113114

114115
LoadNotificationCenter();
116+
117+
//If TrustedLocations contain paths pointing to ProgramData, log a warning notification.
118+
string programDataPath = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData);
119+
var unsafeLocations = new System.Collections.Generic.List<string>();
120+
foreach (var location in viewModel.Model.PreferenceSettings.TrustedLocations)
121+
{
122+
var fullChildPath = Path.GetFullPath(location);
123+
if (fullChildPath.StartsWith(programDataPath, StringComparison.OrdinalIgnoreCase))
124+
{
125+
unsafeLocations.Add(location);
126+
}
127+
}
128+
if (unsafeLocations.Count > 0)
129+
{
130+
foreach (var unsafePath in unsafeLocations)
131+
{
132+
string detail = Properties.Resources.UnsafePathDetectedDetail + "\n" + unsafePath;
133+
Notifications.Add(new NotificationMessage("Preference Settings", Properties.Resources.UnsafePathDetectedTitle, detail));
134+
}
135+
136+
notificationsMenuItem.NotificationsChangeHandler.Invoke(this, null);
137+
}
115138
}
116139

117140
private void LoadNotificationCenter()

src/Notifications/Properties/Resources.Designer.cs

Lines changed: 18 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Notifications/Properties/Resources.en-US.resx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?xml version="1.0" encoding="utf-8"?>
1+
<?xml version="1.0" encoding="utf-8"?>
22
<root>
33
<!--
44
Microsoft ResX Schema
@@ -150,4 +150,10 @@
150150
<data name="NotificationsCenterTitle" xml:space="preserve">
151151
<value>Notifications</value>
152152
</data>
153+
<data name="UnsafePathDetectedDetail" xml:space="preserve">
154+
<value>An unsafe path has been detected in Trusted Locations:</value>
155+
</data>
156+
<data name="UnsafePathDetectedTitle" xml:space="preserve">
157+
<value>Unsafe path detected</value>
158+
</data>
153159
</root>

src/Notifications/Properties/Resources.resx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?xml version="1.0" encoding="utf-8"?>
1+
<?xml version="1.0" encoding="utf-8"?>
22
<root>
33
<!--
44
Microsoft ResX Schema
@@ -135,6 +135,12 @@
135135
<data name="ExtensionName" xml:space="preserve">
136136
<value>Notifications</value>
137137
</data>
138+
<data name="NoNotificationsMsg" xml:space="preserve">
139+
<value>You currently have no notifications. New notifications will appear above</value>
140+
</data>
141+
<data name="NoNotificationsTitle" xml:space="preserve">
142+
<value>No notifications</value>
143+
</data>
138144
<data name="NotificationCenterDisabledMsg" xml:space="preserve">
139145
<value>Notification Center feature is disabled. Enable it in preference panel to see latest news.</value>
140146
</data>
@@ -144,4 +150,10 @@
144150
<data name="NotificationsCenterTitle" xml:space="preserve">
145151
<value>Notifications</value>
146152
</data>
153+
<data name="UnsafePathDetectedDetail" xml:space="preserve">
154+
<value>An unsafe path has been detected in Trusted Locations:</value>
155+
</data>
156+
<data name="UnsafePathDetectedTitle" xml:space="preserve">
157+
<value>Unsafe path detected</value>
158+
</data>
147159
</root>

src/Tools/NodeDocumentationMarkdownGenerator/NodeDocumentationMarkdownGenerator.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
<ItemGroup>
1414
<PackageReference Include="CommandLineParser" Version="2.8.0" />
1515
<PackageReference Include="Greg" Version="3.0.2.8780" />
16-
<PackageReference Include="Magick.NET.Core" Version="14.8.2" />
17-
<PackageReference Include="Magick.NET-Q8-AnyCPU" Version="14.8.2" />
16+
<PackageReference Include="Magick.NET.Core" Version="14.10.0" />
17+
<PackageReference Include="Magick.NET-Q8-AnyCPU" Version="14.10.0" />
1818
<PackageReference Include="DynamoVisualProgramming.LibG_232_0_0" Version="4.0.0.3217"/>
1919
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
2020
<PackageReference Include="RestSharp" Version="112.0.0" />

0 commit comments

Comments
 (0)