Skip to content

Commit

Permalink
Add and update icons and Update icon automation (debug mode) (#14942)
Browse files Browse the repository at this point in the history
* add

* tspline icon update

* comments

* optimizations

* remove dmode

* Update DynamoView.xaml
  • Loading branch information
zeusongit authored Feb 22, 2024
1 parent 051b380 commit 1c1d3e2
Show file tree
Hide file tree
Showing 23 changed files with 126,287 additions and 10,662 deletions.
203 changes: 175 additions & 28 deletions src/DynamoCore/BuiltInAndOperators/BuiltInImages.resx

Large diffs are not rendered by default.

5,300 changes: 4,900 additions & 400 deletions src/DynamoCore/BuiltInAndOperators/OperatorsImages.resx

Large diffs are not rendered by default.

609 changes: 557 additions & 52 deletions src/DynamoCore/DynamoCoreImages.resx

Large diffs are not rendered by default.

10 changes: 9 additions & 1 deletion src/DynamoCoreWpf/DynamoCoreWpf.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<Exec Command="npm pack @dynamods/splash-screen@latest" />
</Target>

<Target Name="ExtractTGZFile" DependsOnTargets="NpmRunBuild" BeforeTargets="BeforeBuild">
<Target Name="ExtractTGZFile" DependsOnTargets="NpmRunBuild" BeforeTargets="BeforeBuild">
<!--Locates the .tgz files-->
<ItemGroup>
<TGZFiles Include="./dynamods-splash-screen-*.tgz" />
Expand Down Expand Up @@ -71,6 +71,7 @@
<None Remove="Views\Core\CustomColorPicker.xaml" />
<None Remove="Views\Core\GeometryScalingPopup.xaml" />
<None Remove="UI\Images\question-hover-blue-16px.png" />
<None Remove="Views\Core\UpdateIconWindow.xaml" />
<None Remove="Views\PackageManager\Controls\ControlColorsAndBrushes.xaml" />
<None Remove="Views\PackageManager\Controls\LoadingAnimationStripeControl.xaml" />
<None Remove="Views\PackageManager\Controls\NumericUpDownControl.xaml" />
Expand Down Expand Up @@ -411,6 +412,9 @@
<DependentUpon>ConnectorContextMenuView.xaml</DependentUpon>
</Compile>
<Compile Include="Views\Core\CustomColorPicker.xaml.cs" />
<Compile Include="Views\Debug\UpdateNodeIconsWindow.xaml.cs">
<DependentUpon>UpdateNodeIconsWindow.xaml</DependentUpon>
</Compile>
<Compile Include="Views\Core\DynamoOpenFileDialog.cs" />
<Compile Include="Views\Core\ConnectorPinView.xaml.cs">
<DependentUpon>ConnectorPinView.xaml</DependentUpon>
Expand Down Expand Up @@ -594,6 +598,10 @@
<CopyToOutputDirectory></CopyToOutputDirectory>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\Debug\UpdateNodeIconsWindow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\Core\GeometryScalingPopup.xaml">
<Generator>MSBuild:Compile</Generator>
</Page>
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 @@ -3915,6 +3915,9 @@ In certain complex graphs or host program scenarios, Automatic mode may cause in
<data name="PublishPackageRetainFolderStructureToggleButtonText" xml:space="preserve">
<value>Retain folder structure</value>
</data>
<data name="UpdateNodeIconsDebugMenu" xml:space="preserve">
<value>Update Node Icons</value>
</data>
<data name="PreferencesViewEnablePanelingNodes" xml:space="preserve">
<value>Enable Paneling nodes</value>
<comment>Preferences | Features | Experimental | Enable Paneling nodes</comment>
Expand Down
3 changes: 3 additions & 0 deletions src/DynamoCoreWpf/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -3902,6 +3902,9 @@ In certain complex graphs or host program scenarios, Automatic mode may cause in
<data name="PublishPackageRetainFolderStructureToggleButtonText" xml:space="preserve">
<value>Retain folder structure</value>
</data>
<data name="UpdateNodeIconsDebugMenu" xml:space="preserve">
<value>Update Node Icons</value>
</data>
<data name="PreferencesViewEnablePanelingNodes" xml:space="preserve">
<value>Enable Paneling nodes</value>
<comment>Preferences | Features | Experimental | Enable Paneling nodes</comment>
Expand Down
7 changes: 4 additions & 3 deletions src/DynamoCoreWpf/Services/IconServices.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
Expand Down Expand Up @@ -67,8 +67,9 @@ internal IconWarehouse(Assembly resAssembly)

internal ImageSource LoadIconInternal(string iconKey)
{
if (cachedIcons.ContainsKey(iconKey))
return cachedIcons[iconKey];
ImageSource icon;
if (cachedIcons.TryGetValue(iconKey, out icon))
return icon;

if (resourceAssembly == null)
{
Expand Down
31 changes: 31 additions & 0 deletions src/DynamoCoreWpf/UI/Converters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
using System.Windows.Controls.Primitives;
using System.Windows.Data;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Xml.Linq;
using Dynamo.Configuration;
using Dynamo.Graph.Nodes;
using Dynamo.Graph.Workspaces;
Expand Down Expand Up @@ -3370,6 +3372,35 @@ public object ConvertBack(object value, Type targetType, object parameter, Syste
}
}

public class Base64ToImageConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
if (value == null) return null;

string s = string.Empty;
if (value is string)
{
s = value as string;
}

if (string.IsNullOrEmpty(s)) return null;

BitmapImage bi = new BitmapImage();

bi.BeginInit();
bi.StreamSource = new MemoryStream(System.Convert.FromBase64String(s));
bi.EndInit();

return bi;
}

public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotImplementedException();
}
}

/// <summary>
/// Converter is used in WatchTree.xaml
/// It converts the boolean value of WatchViewModel.IsCollection to determine the margin of the listnode textblock
Expand Down
4 changes: 4 additions & 0 deletions src/DynamoCoreWpf/Views/Core/DynamoView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -716,6 +716,10 @@
Header="{x:Static p:Resources.DynamoShowFileTrustWarning}"
Click="FileTrustWarning_Click"
IsCheckable="False" />
<MenuItem Name="UpdateNodeIcons"
Header="{x:Static p:Resources.UpdateNodeIconsDebugMenu}"
Click="UpdateNodeIcons_Click"
IsCheckable="False" />
</MenuItem>
</Menu>

Expand Down
8 changes: 7 additions & 1 deletion src/DynamoCoreWpf/Views/Core/DynamoView.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,13 @@ private TabItem AddExtensionTab(IViewExtension viewExtension, UIElement content)

return tab;
}

private void UpdateNodeIcons_Click(object sender, RoutedEventArgs e)
{
var updateNodeIconsWindow = new UpdateNodeIconsWindow(dynamoViewModel.Model.SearchModel.Entries);
updateNodeIconsWindow.Owner = this;
updateNodeIconsWindow.WindowStartupLocation = WindowStartupLocation.CenterOwner;
updateNodeIconsWindow.ShowDialog();
}
/// <summary>
/// Dock the window to right side bar panel.
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion src/DynamoCoreWpf/Views/Debug/DebugModesWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Windows;
using Dynamo.Utilities;
Expand Down
114 changes: 114 additions & 0 deletions src/DynamoCoreWpf/Views/Debug/UpdateNodeIconsWindow.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
<Window x:Class="Dynamo.Wpf.Views.Debug.UpdateNodeIconsWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:p="clr-namespace:Dynamo.Wpf.Properties"
Title="Update Node Icons"
ResizeMode="NoResize" Width="750" Height="600"
xmlns:local="clr-namespace:Dynamo.Controls"
>
<Window.Resources>
<local:Base64ToImageConverter x:Key="Base64ToImageConverter"/>
</Window.Resources>
<StackPanel Orientation="Vertical" Margin="10 0 10 0">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" SharedSizeGroup="Label"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Label Grid.Row="0">Enter New Icon Sources:</Label>
<TextBox Grid.Row="1"
TextWrapping="Wrap"
AcceptsTab="True"
MinLines="3"
MinHeight="25"
MaxHeight="60"
Padding="3"
Text ="{Binding NewIconPaths}"></TextBox>
<TextBox Grid.Row="2" IsReadOnly="True" Margin="0 10"
Background="AliceBlue"
Name="OutputText" BorderThickness="0"
MaxHeight="105" Text ="{Binding Output, Mode=TwoWay}"></TextBox>
</Grid>
<Grid>
<ScrollViewer Margin="10,5,10,0" Height="320">
<DataGrid ItemsSource="{Binding UpdatedIconList}"
AutoGenerateColumns="False"
Name="IconGrid"
CanUserAddRows="False"
CanUserDeleteRows="False"
CanUserReorderColumns="False"
CanUserResizeColumns="False"
CanUserResizeRows="False"
CanUserSortColumns="False"
SelectionMode="Single"
SelectionUnit="FullRow"
IsReadOnly="True"
RowHeaderWidth="0"
HorizontalScrollBarVisibility="Auto"
VerticalScrollBarVisibility="Auto">
<DataGrid.Resources>
<Style TargetType="{x:Type DataGridRow}">
<Setter Property="Background" Value="#434343"/>
<Setter Property="Foreground" Value="#ccc"/>
</Style>
<Style TargetType="{x:Type DataGridColumnHeader}">
<Setter Property="Background" Value="#535353"/>
<Setter Property="Foreground" Value="#ccc"/>
</Style>
</DataGrid.Resources>

<DataGrid.Columns>
<DataGridTemplateColumn Header="Node Name" Width="*">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock>
<Run Text="{Binding NodeName}" />
<LineBreak/>
<Run Text="(" />
<Run Text="{Binding IconSuffix}" />
<Run Text=")" />
</TextBlock>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>

<DataGridTemplateColumn Header="Old Icon" Width="*">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Image Source="{Binding OldData, Converter={StaticResource Base64ToImageConverter}}" Width="40" Height="40"/>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn Header="New Icon" Width="*">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Image Source="{Binding Icon_Base64String, Converter={StaticResource Base64ToImageConverter}}" Width="40" Height="40"/>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
</DataGrid>

</ScrollViewer>
</Grid>


<Grid HorizontalAlignment="Right">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" SharedSizeGroup="Label"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Button Grid.Column="0" Content="Review"
Height="25" Margin="10,10,10,10" Width="75" x:Name="btnOK" TabIndex="1600" IsDefault="True" Click="OnOkClick"
VerticalContentAlignment="Center" HorizontalContentAlignment="Center" />
<Button Grid.Column="1" Content="Update"
Height="25" Margin="10,10,10,10" Width="75" x:Name="btnUpdate" TabIndex="1600" Click="OnUpdateClick"
VerticalContentAlignment="Center" HorizontalContentAlignment="Center" IsEnabled="{Binding IsUpdateEnabled}"/>
<Button Grid.Column="2" Content="Cancel"
Height="25" Margin="10,10,10,10" Width="75" x:Name="btnCancel" TabIndex="1700" IsCancel="True"
VerticalContentAlignment="Center" HorizontalContentAlignment="Center" Click="OnCancelClick" />
</Grid>
</StackPanel>
</Window>
Loading

0 comments on commit 1c1d3e2

Please sign in to comment.