Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NodeView Icon xaml simplification #15763

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
162 changes: 85 additions & 77 deletions src/DynamoCoreWpf/Views/Core/NodeView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
xmlns:dp="clr-namespace:Dynamo.Properties;assembly=DynamoCore"
xmlns:controls="clr-namespace:Dynamo.Views"
xmlns:fa="clr-namespace:FontAwesome5;assembly=FontAwesome5.Net" xmlns:dp1="clr-namespace:Dynamo.Properties;assembly=DynamoCore"
xmlns:po="http://schemas.microsoft.com/winfx/2006/xaml/presentation/options"
Name="topControl"
Width="Auto"
Height="Auto"
Expand All @@ -19,6 +20,14 @@
PreviewMouseLeftButtonDown="OnPreviewMouseLeftButtonDown"
PreviewMouseMove="OnNodeViewMouseMove">

<UserControl.Resources>
<BitmapImage
po:Freeze="true"
RenderOptions.BitmapScalingMode="LowQuality"
x:Key="defaultIcon"
UriSource="/DynamoCoreWpf;component/UI/Images/default-node-icon.png" />
</UserControl.Resources>

<Grid Name="grid"
HorizontalAlignment="Left"
x:FieldModifier="public"
Expand Down Expand Up @@ -315,28 +324,16 @@
Panel.ZIndex="3"
FlowDirection="LeftToRight">
<!-- The Icon for this Node -->
<Rectangle Name="nodeIcon"
Width="34"
Height="34">
<Rectangle.Style>
<Style TargetType="Rectangle">
<Setter Property="Fill">
<Setter.Value>
<ImageBrush ImageSource="{Binding ImageSource}" Stretch="UniformToFill" />
</Setter.Value>
</Setter>
<Style.Triggers>
<!-- If no icon can be found, use default icon -->
<DataTrigger Binding="{Binding ImageSource, UpdateSourceTrigger=PropertyChanged}" Value="{x:Null}">
<Setter Property="Fill">
<Setter.Value>
<ImageBrush ImageSource="/DynamoCoreWpf;component/UI/Images/default-node-icon.png" Stretch="UniformToFill" />
</Setter.Value>
</Setter>
</DataTrigger>
</Style.Triggers>
</Style>
</Rectangle.Style>
<Rectangle
Name="nodeIcon"
Width="34"
Height="34">
<Rectangle.Fill>
<ImageBrush
RenderOptions.BitmapScalingMode="LowQuality"
ImageSource="{Binding ImageSource, FallbackValue={StaticResource defaultIcon}, TargetNullValue={StaticResource defaultIcon}}"
Stretch="UniformToFill" />
</Rectangle.Fill>
</Rectangle>

<TextBlock Name="NameBlock"
Expand Down Expand Up @@ -459,14 +456,16 @@
Foreground="{StaticResource Blue400Brush}"
VerticalAlignment="Center"
HorizontalAlignment="Center">
<fa:ImageAwesome.ToolTip>
<fa:ImageAwesome.ToolTip>
<ToolTip Content="{x:Static dp:Resources.DocsExperimentalPrefixMessage}" Style="{StaticResource GenericToolTipLight}"/>
</fa:ImageAwesome.ToolTip>
</fa:ImageAwesome>
</Grid>
<Grid x:Name="FrozenGlyph"
Visibility="{Binding Path=IsFrozen, Converter={StaticResource BooleanToVisibilityCollapsedConverter}, Mode=OneWay}">
<Image x:Name="FrozenImage"
po:Freeze="true"
RenderOptions.BitmapScalingMode="LowQuality"
Width="16px"
Height="16px"
HorizontalAlignment="Center"
Expand All @@ -477,6 +476,8 @@
<Grid x:Name="HiddenEyeGlyph"
Visibility="{Binding Path=IsVisible, Converter={StaticResource InverseBoolToVisibilityCollapsedConverter}, Mode=OneWay}">
<Image x:Name="HiddenEyeImage"
po:Freeze="true"
RenderOptions.BitmapScalingMode="LowQuality"
Width="16px"
Height="16px"
HorizontalAlignment="Center"
Expand Down Expand Up @@ -512,7 +513,7 @@
FontFamily="{StaticResource ArtifaktElementRegular}"
FontSize="10px"
Foreground="Black"
Style="{StaticResource SZoomFadeLabel}" />
Style="{StaticResource SZoomFadeLabel}"/>
</Border>
<Grid.Style>
<Style TargetType="Grid">
Expand Down Expand Up @@ -546,6 +547,7 @@
Background="Transparent"
CornerRadius="2" />
<Image x:Name="DotsImage"
RenderOptions.BitmapScalingMode="LowQuality"
Width="16px"
Height="16px"
Margin="1.5,0,0,0"
Expand Down Expand Up @@ -630,63 +632,69 @@
Converter={StaticResource ZoomToVisibilityCollapsedConverter}}" />

<!-- Grid containing the State overlay Glyphs in Zoomed Out state -->
<Grid Name="zoomGlyphsGrid"
Grid.Row="0"
Grid.RowSpan="4"
Grid.Column="0"
Grid.ColumnSpan="3"
Canvas.ZIndex="7"
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">
<Grid
Name="zoomGlyphsGrid"
Grid.Row="0"
Grid.RowSpan="4"
Grid.Column="0"
Grid.ColumnSpan="3"
Canvas.ZIndex="7"
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">
<Grid.RowDefinitions>
<RowDefinition Height="{Binding ImgGlyphThreeSource, Mode=OneWay, Converter={StaticResource EmptyToZeroLengthConverter}, UpdateSourceTrigger=PropertyChanged}" />
<RowDefinition
Height="{Binding ImgGlyphThreeSource, Mode=OneWay, Converter={StaticResource EmptyToZeroLengthConverter}, UpdateSourceTrigger=PropertyChanged}" />
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<UniformGrid Grid.Row="0"
Margin="0 10 0 -10"
Columns="1" Rows="1" Name="ZoomGlyphRowZero"
HorizontalAlignment="Center" VerticalAlignment="Bottom"
Visibility="{Binding ImgGlyphThreeSource, Converter={StaticResource EmptyToVisibilityCollapsedConverter}, UpdateSourceTrigger=PropertyChanged}">
<Image Stretch="Uniform" HorizontalAlignment="Center" VerticalAlignment="Bottom"
x:Name="ZoomStateImgOne"
Width="64"
Source="{Binding ImgGlyphThreeSource, UpdateSourceTrigger=PropertyChanged, TargetNullValue={x:Null}}"
Visibility="{Binding ImgGlyphThreeSource,Converter={StaticResource EmptyToVisibilityCollapsedConverter}, UpdateSourceTrigger=PropertyChanged}"/>
</UniformGrid>
<Grid Grid.Row="1"
Margin="0 0 0 0"
Name="ZoomGlyphRowOne"
HorizontalAlignment="Center" VerticalAlignment="Stretch">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="{Binding ImgGlyphOneSource, Mode=OneWay, Converter={StaticResource EmptyToZeroLengthConverter}, UpdateSourceTrigger=PropertyChanged}" />
<ColumnDefinition Width="{Binding ImgGlyphTwoSource, Mode=OneWay, Converter={StaticResource EmptyToZeroLengthConverter}, UpdateSourceTrigger=PropertyChanged}" />
</Grid.ColumnDefinitions>
<Image Grid.Column="0"
x:Name="ZoomStateImgTwo"
Stretch="Uniform"
HorizontalAlignment="Left" VerticalAlignment="Center"
Margin="5 0 "
Width="64"
Source="{Binding ImgGlyphOneSource, UpdateSourceTrigger=PropertyChanged, TargetNullValue={x:Null}}"
Visibility="{Binding ImgGlyphOneSource, Converter={StaticResource EmptyToVisibilityCollapsedConverter}, UpdateSourceTrigger=PropertyChanged}"/>
<Image Grid.Column="1"
x:Name="ZoomStateImgThree"
Stretch="Uniform"
HorizontalAlignment="Right" VerticalAlignment="Center"
Margin="5 0"
Width="64"
Source="{Binding ImgGlyphTwoSource, UpdateSourceTrigger=PropertyChanged, TargetNullValue={x:Null}}"
Visibility="{Binding ImgGlyphTwoSource, Converter={StaticResource EmptyToVisibilityCollapsedConverter}, UpdateSourceTrigger=PropertyChanged}"/>
</Grid>
</Grid>

<Image
Stretch="Uniform"
HorizontalAlignment="Center"
VerticalAlignment="Bottom"
Grid.Row="0"
Grid.ColumnSpan="2"
Margin="0 10 0 -10"
RenderOptions.BitmapScalingMode="LowQuality"
x:Name="ZoomStateImgOne"
Width="64"
Source="{Binding ImgGlyphThreeSource, UpdateSourceTrigger=PropertyChanged, TargetNullValue={x:Null}}"
Visibility="{Binding ImgGlyphThreeSource,Converter={StaticResource EmptyToVisibilityCollapsedConverter}, UpdateSourceTrigger=PropertyChanged}" />

<WrapPanel
Grid.Row="1"
HorizontalAlignment="Center"
VerticalAlignment="Center">
<Image
x:Name="ZoomStateImgTwo"
Stretch="Uniform"
RenderOptions.BitmapScalingMode="LowQuality"
HorizontalAlignment="Left"
VerticalAlignment="Center"
Margin="5 0 "
Width="64"
Source="{Binding ImgGlyphOneSource, UpdateSourceTrigger=PropertyChanged, TargetNullValue={x:Null}}"
Visibility="{Binding ImgGlyphOneSource, Converter={StaticResource EmptyToVisibilityCollapsedConverter}, UpdateSourceTrigger=PropertyChanged}" />

<Image
x:Name="ZoomStateImgThree"
Stretch="Uniform"
RenderOptions.BitmapScalingMode="LowQuality"
HorizontalAlignment="Right"
VerticalAlignment="Center"
Margin="5 0"
Width="64"
Source="{Binding ImgGlyphTwoSource, UpdateSourceTrigger=PropertyChanged, TargetNullValue={x:Null}}"
Visibility="{Binding ImgGlyphTwoSource, Converter={StaticResource EmptyToVisibilityCollapsedConverter}, UpdateSourceTrigger=PropertyChanged}" />
</WrapPanel>
</Grid>

<!-- Displays when the node is selected -->
<Border Name="selectionBorder"
Expand Down
Loading