Skip to content

Commit

Permalink
Dynamo UI visual status of issues (#11776)
Browse files Browse the repository at this point in the history
* initial commit

* Update DynamoViewModelDelegates.cs

* Update Dynamo.All.sln

* update test

* event updates

* test update

* initial commit

* Update DynamoViewModel.cs

* add open linter view to issue count

* Update Resources.en-US.resx

* initial commit

* initial commit

* Update DynamoViewModelDelegates.cs

* Update Dynamo.All.sln

* test update

* add open linter view to issue count

* remove duplicated OnRequestOpenLinterView

* revert assembly info changes

* LinterManager null checks

* comment updates

* move linter count converter

* Update NotificationsControl.xaml.cs

* Update NotificationsControl.xaml.cs
  • Loading branch information
SHKnudsen authored Jun 29, 2021
1 parent 04da16e commit 0a18bfa
Show file tree
Hide file tree
Showing 10 changed files with 123 additions and 25 deletions.
42 changes: 39 additions & 3 deletions src/DynamoCoreWpf/Controls/NotificationsControl.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,24 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:core="clr-namespace:Dynamo.Wpf.ViewModels.Core"
xmlns:viewmodels="clr-namespace:Dynamo.ViewModels"
xmlns:converters="clr-namespace:Dynamo.Controls"
xmlns:p="clr-namespace:Dynamo.Wpf.Properties;assembly=DynamoCoreWpf"
d:DataContext="{d:DesignInstance Type=viewmodels:DynamoViewModel}"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">

<UserControl.Resources>
<core:NotificationLevelToColorConverter x:Key="NotificationLevelToColorConverter"></core:NotificationLevelToColorConverter>
<converters:LinterIssueCountToVisibilityConverter x:Key="LinterIssueCountToVisibilityConverter" />
</UserControl.Resources>

<Grid>
<TextBlock

<Grid HorizontalAlignment="Stretch">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<TextBlock
Text="{Binding Path=HomeSpaceViewModel.CurrentNotificationMessage}"
FontStyle="Italic"
FontSize="12"
Expand Down Expand Up @@ -42,5 +51,32 @@
</EventTrigger>
</TextBlock.Triggers>
</TextBlock>
<StackPanel Orientation="Horizontal"
Grid.Column="1"
HorizontalAlignment="Right"
VerticalAlignment="Center"
Margin="30,0"
MouseDown="StackPanel_MouseDown"
Visibility="{Binding LinterIssuesCount, Converter={StaticResource LinterIssueCountToVisibilityConverter}}">
<StackPanel.Style>
<Style TargetType="{x:Type StackPanel}">
<Style.Triggers>
<Trigger Property="IsMouseOver"
Value="True">
<Setter Property="Cursor"
Value="Hand" />
</Trigger>
</Style.Triggers>
</Style>
</StackPanel.Style>
<Image Width="20"
Source="/DynamoCoreWpf;component/UI/Images/alert.png" />
<TextBlock Margin="10,0"
Foreground="White">
<Run Text="{Binding LinterIssuesCount, Mode=OneWay}" />
<Run Text="{x:Static p:Resources.PersistentVisualStatusOfLinterIssues}" />
</TextBlock>
</StackPanel>

</Grid>
</UserControl>
6 changes: 6 additions & 0 deletions src/DynamoCoreWpf/Controls/NotificationsControl.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,11 @@ void window_PreviewMouseDown(object sender, MouseButtonEventArgs e)
// Commented this after MAGN - 8423
// hsvm.ClearWarning();
}

private void StackPanel_MouseDown(object sender, MouseButtonEventArgs e)
{
var viewModel = this.DataContext as DynamoViewModel;
viewModel?.OnViewExtensionOpenRequest("Graph Status");
}
}
}
1 change: 1 addition & 0 deletions src/DynamoCoreWpf/DynamoCoreWpf.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -1311,6 +1311,7 @@
<Resource Include="UI\Images\profile_normal.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="UI\Images\alert.png" />
<Resource Include="UI\Images\menu_16_16.png" />
<Resource Include="UI\Images\caret_down.png" />
<Resource Include="UI\Images\caret_up.png" />
Expand Down
9 changes: 9 additions & 0 deletions src/DynamoCoreWpf/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions src/DynamoCoreWpf/Properties/Resources.en-US.resx
Original file line number Diff line number Diff line change
Expand Up @@ -2437,4 +2437,7 @@ Uninstall the following packages: {0}?</value>
<data name="PreferencesViewShowRunPreviewTooltip" xml:space="preserve">
<value>Switchable only when the current workspace is in Manual run mode.</value>
</data>
<data name="PersistentVisualStatusOfLinterIssues" xml:space="preserve">
<value>Issues found</value>
</data>
</root>
3 changes: 3 additions & 0 deletions src/DynamoCoreWpf/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -2437,4 +2437,7 @@ Uninstall the following packages: {0}?</value>
<data name="PreferencesViewShowRunPreviewTooltip" xml:space="preserve">
<value>Switchable only when the current workspace is in Manual run mode.</value>
</data>
<data name="PersistentVisualStatusOfLinterIssues" xml:space="preserve">
<value>Issues found</value>
</data>
</root>
21 changes: 21 additions & 0 deletions src/DynamoCoreWpf/UI/Converters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3161,4 +3161,25 @@ public object ConvertBack(object value, Type targetType, object parameter, Cultu
}
}

/// <summary>
/// Converts an integer (linter issues count) to a visibility state
/// </summary>
[ValueConversion(typeof(int), typeof(Visibility))]
internal class LinterIssueCountToVisibilityConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (!(value is int issueCount) || issueCount == 0)
{
return Visibility.Collapsed;
}

return Visibility.Visible;
}

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}
Binary file added src/DynamoCoreWpf/UI/Images/alert.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 23 additions & 0 deletions src/DynamoCoreWpf/ViewModels/Core/DynamoViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,15 @@ public WorkspaceModel CurrentSpace
get { return model.CurrentWorkspace; }
}

/// <summary>
/// Count of unresolved issues on the linter manager.
/// This is used for binding in the NotificationsControl
/// </summary>
public int LinterIssuesCount
{
get => Model.LinterManager?.RuleEvaluationResults.Count ?? 0;
}

public double WorkspaceActualHeight { get; set; }
public double WorkspaceActualWidth { get; set; }

Expand Down Expand Up @@ -656,6 +665,10 @@ protected DynamoViewModel(StartConfiguration startConfiguration)

model.WorkspaceAdded += WorkspaceAdded;
model.WorkspaceRemoved += WorkspaceRemoved;
if (model.LinterManager != null)
{
model.LinterManager.RuleEvaluationResults.CollectionChanged += OnRuleEvaluationResultsCollectionChanged;
}

SubscribeModelCleaningUpEvent();
SubscribeModelUiEvents();
Expand Down Expand Up @@ -768,6 +781,11 @@ protected virtual void UnsubscribeAllEvents()

model.WorkspaceAdded -= WorkspaceAdded;
model.WorkspaceRemoved -= WorkspaceRemoved;
if (model.LinterManager != null)
{
model.LinterManager.RuleEvaluationResults.CollectionChanged -= OnRuleEvaluationResultsCollectionChanged;
}

DynamoSelection.Instance.Selection.CollectionChanged -= SelectionOnCollectionChanged;
UsageReportingManager.Instance.PropertyChanged -= CollectInfoManager_PropertyChanged;
}
Expand Down Expand Up @@ -1281,6 +1299,11 @@ private void WorkspaceRemoved(WorkspaceModel item)
workspaces.Remove(viewModel);
}

private void OnRuleEvaluationResultsCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
{
RaisePropertyChanged(nameof(LinterIssuesCount));
}

internal void AddToRecentFiles(string path)
{
if (path == null) return;
Expand Down
40 changes: 18 additions & 22 deletions src/DynamoCoreWpf/Views/Core/DynamoView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -1694,23 +1694,22 @@
</Grid>

<!--Bottom Panel including RunMode etc-->
<WrapPanel Orientation="Horizontal"
Grid.Row="5"
Grid.Column="0"
Grid.RowSpan="1"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
Grid.ColumnSpan="5">

<WrapPanel.Background>
<Grid
Grid.Row="5"
Grid.Column="0"
Grid.RowSpan="1"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
Grid.ColumnSpan="5">
<Grid.Background>
<LinearGradientBrush StartPoint="0.5,0"
EndPoint="0.5,1">
<GradientStop Color="#222"
Offset="0.0" />
<GradientStop Color="#111"
Offset="1.0" />
</LinearGradientBrush>
</WrapPanel.Background>
</Grid.Background>

<Grid Name="bottomBarGrid"
Grid.Row="4"
Expand All @@ -1720,30 +1719,27 @@
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"></ColumnDefinition>
<ColumnDefinition Width="Auto"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
</Grid.ColumnDefinitions>

<WrapPanel Orientation="Horizontal"
Grid.Row="0"
Grid.Column="0"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
VerticalAlignment="Stretch"
Visibility="{Binding IsAbleToGoHome, Converter={StaticResource InverseBoolToVisibilityConverter}}">

<controls1:RunSettingsControl x:Name="RunSettingsControl"
Margin="2.5,5,5,5"
VerticalAlignment="Stretch"
DataContext="{Binding Path=HomeSpaceViewModel.RunSettingsViewModel}"/>
<controls1:RunSettingsControl x:Name="RunSettingsControl"
Margin="2.5,5,5,5"
VerticalAlignment="Stretch"
DataContext="{Binding Path=HomeSpaceViewModel.RunSettingsViewModel}" />
</WrapPanel>

<!--NotificationControl for showing run-time notifications-->
<controls1:NotificationsControl Grid.Column="1"/>

<controls1:NotificationsControl Grid.Column="1" />
</Grid>

</WrapPanel>

</Grid>

<!--Split Between Console and Canvas-->
<GridSplitter ResizeDirection="Rows"
Expand Down

0 comments on commit 0a18bfa

Please sign in to comment.