Skip to content

Commit

Permalink
Fixing Ghost warning
Browse files Browse the repository at this point in the history
  • Loading branch information
jesusalvino committed Mar 14, 2023
1 parent 16caf9b commit 04c14c1
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 26 deletions.
26 changes: 26 additions & 0 deletions src/DynamoCore/Graph/Nodes/NodeModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1912,6 +1912,31 @@ public void NotifyAstBuildBroken(string p)
infos.Add(new Info(p, ElementState.AstBuildBroken));
}

public void UpdateAssociatedWarning(string fileFromPathNodeName, string imageReadFromFileNodeName)
{

if (this.Name == imageReadFromFileNodeName && this.InputNodes.Count > 0)
{
if (this.InputNodes.First().Value != null)
{
var previousNode = this.InputNodes.First().Value.Item2;


if (previousNode != null && previousNode.Name == fileFromPathNodeName)
{
if (this.Infos.Count > 0)
{
previousNode.State = ElementState.AssociatedWarning;
}
else
{
previousNode.State = ElementState.Active;
}
}
}
}
}

#endregion

#region Port Management
Expand Down Expand Up @@ -2914,6 +2939,7 @@ public enum ElementState
Active,
Warning,
PersistentWarning,
AssociatedWarning,
Error,
AstBuildBroken,
Info
Expand Down
16 changes: 9 additions & 7 deletions src/DynamoCoreWpf/UI/Converters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1736,19 +1736,21 @@ public object ConvertBack(object value, Type targetType, object parameter, Syste
/// <summary>
/// Hides (collapses) if the zoom level is larger than the designated value
/// </summary>
public class ZoomToVisibilityCollapsedConverter : IValueConverter
public class ZoomToVisibilityCollapsedConverter : IMultiValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
double number = (double)System.Convert.ChangeType(value, typeof(double));
double number = (double)System.Convert.ChangeType(values[0], typeof(double));
ElementState state = (ElementState)values[1];
bool nodeWarningBarVisible = (bool)values[2];

if (number > Configurations.ZoomThreshold)
return Visibility.Collapsed;
if (number < Configurations.ZoomThreshold && (state == ElementState.AssociatedWarning || nodeWarningBarVisible))
return Visibility.Visible;

return Visibility.Visible;
return Visibility.Collapsed;
}

public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
public object[] ConvertBack(object values, Type[] targetTypes, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotSupportedException();
}
Expand Down
16 changes: 10 additions & 6 deletions src/DynamoCoreWpf/ViewModels/Core/NodeViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1342,8 +1342,7 @@ Pass through all possible states in reverse order
ImgGlyphThreeSource = infoGlyph;
}
}

if (NodeModel.State == ElementState.Warning || NodeModel.State == ElementState.PersistentWarning)
if (NodeModel.State == ElementState.Warning || NodeModel.State == ElementState.PersistentWarning || NodeModel.State == ElementState.AssociatedWarning)
{
result = warningColor;
if (ImgGlyphTwoSource == null)
Expand All @@ -1366,7 +1365,7 @@ Pass through all possible states in reverse order
{
ImgGlyphThreeSource = errorGlyph;
}
}
}

return result;
}
Expand Down Expand Up @@ -1399,15 +1398,20 @@ private void DisposeErrorBubble()
ErrorBubble.PropertyChanged -= ErrorBubble_PropertyChanged;

ErrorBubble.Dispose();
}
}

public void UpdateBubbleContent()
{
if (DynamoViewModel == null) return;

bool hasErrorOrWarning = NodeModel.IsInErrorState || NodeModel.State == ElementState.Warning;
bool hasErrorOrWarning = NodeModel.IsInErrorState || NodeModel.State == ElementState.Warning;
bool isNodeStateInfo = NodeModel.State == ElementState.Info;

var fileFromPathNode = typeof(CoreNodeModels.Input.FileObject).GetCustomAttributes(typeof(NodeNameAttribute), true).FirstOrDefault() as NodeNameAttribute;
string imageReadFromFileNodeName = "Image.ReadFromFile";

NodeModel.UpdateAssociatedWarning(fileFromPathNode.Name, imageReadFromFileNodeName);

// Persistent warnings should continue to be displayed even if nodes are not involved in an execution as they can include:
// 1. Compile-time warnings in CBNs
// 2. Obsolete nodes with warnings
Expand Down Expand Up @@ -1488,7 +1492,7 @@ public void UpdateBubbleContent()
}
HandleColorOverlayChange();
}
ErrorBubble.ChangeInfoBubbleStateCommand.Execute(InfoBubbleViewModel.State.Pinned);
ErrorBubble.ChangeInfoBubbleStateCommand.Execute(InfoBubbleViewModel.State.Pinned);
}

private void UpdateErrorBubblePosition()
Expand Down
33 changes: 20 additions & 13 deletions src/DynamoCoreWpf/Views/Core/NodeView.xaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<UserControl x:Class="Dynamo.Controls.NodeView"
<UserControl x:Class="Dynamo.Controls.NodeView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:configuration="clr-namespace:Dynamo.Configuration;assembly=DynamoCore"
Expand Down Expand Up @@ -601,11 +601,15 @@
CornerRadius="8,8,0,0"
IsHitTestVisible="False"
Opacity="0.5"
Style="{StaticResource SZoomFadeInPreview}"
Visibility="{Binding Path=DataContext.Zoom,
RelativeSource={RelativeSource FindAncestor,
AncestorType={x:Type controls:WorkspaceView}},
Converter={StaticResource ZoomToVisibilityCollapsedConverter}}" />
Style="{StaticResource SZoomFadeInPreview}">
<Border.Visibility>
<MultiBinding Converter="{StaticResource ZoomToVisibilityCollapsedConverter}">
<Binding Path="DataContext.Zoom" RelativeSource="{RelativeSource FindAncestor,AncestorType={x:Type controls:WorkspaceView}}"/>
<Binding Path="State"/>
<Binding Path="NodeWarningBarVisible"/>
</MultiBinding>
</Border.Visibility>
</Border>

<!-- Grid containing the State overlay Glyphs in Zoomed Out state -->
<Grid Name="zoomGlyphsGrid"
Expand All @@ -617,12 +621,15 @@
IsHitTestVisible="False"
Margin="0 5 0 0"
HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
Style="{StaticResource SZoomFadeInFrameworkElement}"
Visibility="{Binding Path=DataContext.Zoom,
RelativeSource={RelativeSource FindAncestor,
AncestorType={x:Type controls:WorkspaceView}},
Converter={StaticResource ZoomToVisibilityCollapsedConverter}}"
MinWidth="48">
Style="{StaticResource SZoomFadeInFrameworkElement}"
MinWidth="48">
<Grid.Visibility>
<MultiBinding Converter="{StaticResource ZoomToVisibilityCollapsedConverter}">
<Binding Path="DataContext.Zoom" RelativeSource="{RelativeSource FindAncestor,AncestorType={x:Type controls:WorkspaceView}}"/>
<Binding Path="State"/>
<Binding Path="NodeWarningBarVisible"/>
</MultiBinding>
</Grid.Visibility>
<Grid.RowDefinitions>
<RowDefinition Height="{Binding ImgGlyphThreeSource, Mode=OneWay, Converter={StaticResource EmptyToZeroLengthConverter}, UpdateSourceTrigger=PropertyChanged}" />
<RowDefinition></RowDefinition>
Expand Down Expand Up @@ -734,4 +741,4 @@
<Label HorizontalContentAlignment="Center" Content="{Binding ASTText}" />
</Canvas>
</Grid>
</UserControl>
</UserControl>

0 comments on commit 04c14c1

Please sign in to comment.