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

Dyn 4837 group styles default font size #13447

Merged
merged 15 commits into from
Nov 2, 2022
2 changes: 1 addition & 1 deletion src/AssemblySharedInfoGenerator/AssemblySharedInfo.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
QilongTang marked this conversation as resolved.
Show resolved Hide resolved
using System;
using System.Reflection;
using System.Resources;
using System.Runtime.InteropServices;
Expand Down
14 changes: 7 additions & 7 deletions src/DynamoCore/Configuration/GroupStyleItem.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Collections.ObjectModel;
using System.Collections.ObjectModel;
using Dynamo.Properties;

namespace Dynamo.Configuration
Expand All @@ -12,12 +12,12 @@ public class GroupStyleItem: StyleItem
/// <summary>
/// Static set of default group styles defined by Dynamo Team
/// </summary>
public static ObservableCollection<GroupStyleItem> DefaultGroupStyleItems =
new ObservableCollection<GroupStyleItem>() {
new GroupStyleItem() { Name = Resources.GroupStyleDefaultActions, HexColorString = Resources.GroupStyleDefaultActionsColor, IsDefault = true },
new GroupStyleItem() { Name = Resources.GroupStyleDefaultInputs, HexColorString = Resources.GroupStyleDefaultInputsColor, IsDefault = true },
new GroupStyleItem() { Name = Resources.GroupStyleDefaultOutputs, HexColorString = Resources.GroupStyleDefaultOutputsColor, IsDefault = true },
new GroupStyleItem() { Name = Resources.GroupStyleDefaultReview, HexColorString = Resources.GroupStyleDefaultReviewColor, IsDefault = true }
public static ObservableCollection<GroupStyleItem> DefaultGroupStyleItems =
new ObservableCollection<GroupStyleItem>() {
new GroupStyleItem() { Name = Resources.GroupStyleDefaultActions, HexColorString = Resources.GroupStyleDefaultActionsColor, FontSize = 14, IsDefault = true },
new GroupStyleItem() { Name = Resources.GroupStyleDefaultInputs, HexColorString = Resources.GroupStyleDefaultInputsColor, FontSize = 14, IsDefault = true },
new GroupStyleItem() { Name = Resources.GroupStyleDefaultOutputs, HexColorString = Resources.GroupStyleDefaultOutputsColor, FontSize = 14, IsDefault = true },
new GroupStyleItem() { Name = Resources.GroupStyleDefaultReview, HexColorString = Resources.GroupStyleDefaultReviewColor, FontSize = 14 ,IsDefault = true }
};
}
}
16 changes: 15 additions & 1 deletion src/DynamoCore/Configuration/StyleItem.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Dynamo.Core;
using Dynamo.Core;

namespace Dynamo.Configuration
{
Expand All @@ -10,6 +10,7 @@ public class StyleItem : NotificationObject
private string hexColorString;
private string name;
private bool isDefault = false;
private int fontSize = 14;

/// This property will contain the Group Name of the stored style
public string Name
Expand Down Expand Up @@ -45,5 +46,18 @@ public bool IsDefault
RaisePropertyChanged(nameof(IsDefault));
}
}

/// <summary>
/// This property will support the font size of the GroupStyle
/// </summary>
public int FontSize
{
get { return fontSize; }
set
{
fontSize = value;
RaisePropertyChanged(nameof(FontSize));
}
}
}
}
1 change: 1 addition & 0 deletions src/DynamoCoreWpf/DynamoCoreWpf.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -829,6 +829,7 @@
<Resource Include="UI\Images\TitleBarButtons\restore-lighttheme-default-16px.png" />
<Resource Include="UI\Images\TitleBarButtons\restore-lighttheme-hover-16px.png" />
<Resource Include="UI\Images\warning_16px.png" />
<Resource Include="UI\Images\font-size.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="UI\Images\whiteclosetab.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.

5 changes: 4 additions & 1 deletion src/DynamoCoreWpf/Properties/Resources.en-US.resx
Original file line number Diff line number Diff line change
Expand Up @@ -3378,4 +3378,7 @@ You can manage this in Preferences -&gt; Security.</value>
<data name="RecentFileNumberInfo" xml:space="preserve">
<value>Reducing this number will discard all recent files beyond your chosen number.</value>
</data>
</root>
<data name="GroupStyleFontSizeToolTip" xml:space="preserve">
<value>Font size</value>
</data>
</root>
5 changes: 4 additions & 1 deletion src/DynamoCoreWpf/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -3365,4 +3365,7 @@ You can manage this in Preferences -&gt; Security.</value>
<data name="RecentFileNumberInfo" xml:space="preserve">
<value>Reducing this number will discard all recent files beyond your chosen number.</value>
</data>
</root>
<data name="GroupStyleFontSizeToolTip" xml:space="preserve">
<value>Font size</value>
</data>
</root>
15 changes: 15 additions & 0 deletions src/DynamoCoreWpf/UI/Converters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1464,6 +1464,21 @@ public object ConvertBack(object value, Type targetType, object parameter, Syste
}
}

public class InverseBoolToEnablingConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
if ((bool)value)
return false;
return true;
}

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

public class InverseBooleanToVisibilityCollapsedConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
Expand Down
Binary file added src/DynamoCoreWpf/UI/Images/font-size.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 3 additions & 2 deletions src/DynamoCoreWpf/UI/Themes/Modern/DynamoConverters.xaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<ResourceDictionary
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="clr-namespace:Dynamo.Controls;assembly=DynamoCoreWpf"
Expand Down Expand Up @@ -114,6 +114,7 @@
<controls:IntegerDisplay x:Key="IntegerDisplayConverter" />
<controls:SnapRegionMarginConverter x:Key="SnapRegionMarginConverter" />
<controls:InverseBoolToVisibilityConverter x:Key="InverseBoolToVisibilityConverter" />
<controls:InverseBoolToEnablingConverter x:Key="InverseBoolToEnablingConverter" />
<controls:RunPreviewConverter x:Key="RunPreviewConverter" />
<controls:RunPreviewToolTipConverter x:Key="RunPreviewToolTipConverter" />
<controls:MenuItemCheckConverter x:Key="MenuItemCheckConverter" />
Expand Down Expand Up @@ -184,4 +185,4 @@
<controls:CollectionHasMoreThanNItemsToBoolConverter x:Key="CollectionHasMoreThanNItemsToBoolConverter" />
<controls:ListHasMoreThanNItemsToVisibilityConverter x:Key="ListHasMoreThanNItemsToVisibilityConverter" />
<controls:ObjectTypeConverter x:Key="ObjectTypeConverter" />
</ResourceDictionary>
</ResourceDictionary>
39 changes: 34 additions & 5 deletions src/DynamoCoreWpf/ViewModels/Menu/PreferencesViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public class PreferencesViewModel : ViewModelBase, INotifyPropertyChanged
private ObservableCollection<string> languagesList;
private ObservableCollection<string> packagePathsForInstall;
private ObservableCollection<string> fontSizeList;
private ObservableCollection<int> groupStyleFontSizeList;
private ObservableCollection<string> numberFormatList;
private StyleItem addStyleControl;
private ObservableCollection<string> pythonEngineList;
Expand Down Expand Up @@ -466,6 +467,21 @@ public ObservableCollection<string> FontSizeList
RaisePropertyChanged(nameof(FontSizeList));
}
}
/// <summary>
/// GroupStyleFontSizeList contains the list of sizes for defined fonts to be applied to a GroupStyle
/// </summary>
public ObservableCollection<int> GroupStyleFontSizeList
{
get
{
return groupStyleFontSizeList;
}
set
{
groupStyleFontSizeList = value;
RaisePropertyChanged(nameof(GroupStyleFontSizeList));
}
}

/// <summary>
/// NumberFormatList contains the list of the format for numbers, right now in Dynamo has the next formats: 0, 0.0, 0.00, 0.000, 0.0000
Expand Down Expand Up @@ -505,9 +521,10 @@ public ObservableCollection<GroupStyleItem> StyleItemsList
/// <param name="style">style to be added</param>
public void AddStyle(StyleItem style)
{
preferenceSettings.GroupStyleItemsList.Add(new GroupStyleItem {
HexColorString = style.HexColorString,
Name = style.Name,
preferenceSettings.GroupStyleItemsList.Add(new GroupStyleItem {
HexColorString = style.HexColorString,
Name = style.Name,
FontSize = style.FontSize,
IsDefault = style.IsDefault
});
RaisePropertyChanged(nameof(StyleItemsList));
Expand Down Expand Up @@ -1014,6 +1031,19 @@ public PreferencesViewModel(DynamoViewModel dynamoViewModel)
};
SelectedFontSize = Wpf.Properties.Resources.ScalingMediumButton;

GroupStyleFontSizeList = new ObservableCollection<int>
{
14,
18,
24,
30,
36,
48,
60,
72,
96
};

// Number format settings
NumberFormatList = new ObservableCollection<string>
{
Expand Down Expand Up @@ -1412,8 +1442,7 @@ internal void ResetAddStyleControl()
{
IsEnabledAddStyleButton = true;
IsSaveButtonEnabled = true;
AddStyleControl.Name = String.Empty;
AddStyleControl.HexColorString = GetRandomHexStringColor();
AddStyleControl = new StyleItem();
IsWarningEnabled = false;
IsVisibleAddStyleBorder = false;
}
Expand Down
63 changes: 50 additions & 13 deletions src/DynamoCoreWpf/Views/Menu/PreferencesView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,17 @@
<controls:BinaryRadioButtonCheckedConverter x:Key="BinaryRadioButtonCheckedConverter"/>
<controls:ExpandersBindingConverter x:Key="ExpandersBindingConverter"/>
<controls:InverseBoolToVisibilityConverter x:Key="InverseBoolToVisibilityConverter "/>
<controls:InverseBoolToEnablingConverter x:Key="InverseBoolToEnablingConverter "/>
<BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>

<!--This Template will be used for the controls generated in the Styles list when a new Style is saved-->
<DataTemplate x:Key="styleViewItemTemplate">
<Border Background="{StaticResource PreferencesWindowVisualSettingsAddStyleBackground}"
BorderThickness="1">
<Border Background="{StaticResource PreferencesWindowBackgroundColor}" Padding="0,0,0,10" Margin="0,0,0,5"
BorderThickness="1" BorderBrush="#FF97A0A5">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="30" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid Grid.Column="0">
<Grid>
Expand All @@ -59,13 +60,18 @@
Grid.Row="0"
Margin="5,0,0,0"
Foreground="{StaticResource PreferencesWindowFontColor}"/>
<StackPanel Orientation="Horizontal"
Margin="10,0,0,0"
<StackPanel Orientation="Horizontal"
HorizontalAlignment="Left"
Width="auto"
Margin="10,0,20,0"
Grid.Row="1">
<Border x:Name="borderColor"
Background="{Binding HexColorString, Converter={StaticResource StringToBrushColorConverter}}"
<Button
Style="{StaticResource ButtonColorPickerStyle}"
Background="{Binding HexColorString, Converter={StaticResource StringToBrushColorConverter}}"
Click="onChangedGroupStyleColor_Click"
Width="25"
Height="15"/>
Height="15"
IsEnabled="{Binding Path=IsDefault, Converter={StaticResource InverseBoolToEnablingConverter}}" />
<Label Name="colorHexVal"
Foreground="{StaticResource PreferencesWindowFontColor}"
FontSize="13"
Expand All @@ -74,21 +80,44 @@
</Grid>
</Grid>
<Grid Grid.Column="1">
<Button Name="removeStyle"
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
</Grid.RowDefinitions>
<Button Name="removeStyle"
Margin="0,0,8,0"
HorizontalAlignment="Right"
VerticalAlignment="Top"
Visibility="{Binding Path=IsDefault, Converter={StaticResource InverseBoolToVisibilityConverter}}"
Click="RemoveStyle_Click"
Style="{StaticResource FlatIconButtonStyle}"
Width="20"
Height="30">
<fa:ImageAwesome Icon="Trash"
Height="30"
Grid.Row="0">
<fa:ImageAwesome Icon="Trash"
Width="15"
Height="25"
IsHitTestVisible="False"
Foreground="{StaticResource PreferencesWindowFontColor}"/>
</Button>
</Button>
<StackPanel Orientation="Horizontal"
Grid.Row="1">
<Image Width="24" Height="24" Margin="0,0,0,0" HorizontalAlignment="Left" VerticalAlignment="Center" Source="/DynamoCoreWpf;component/UI/Images/font-size.png">
<Image.ToolTip>
<ToolTip Content="{x:Static p:Resources.GroupStyleFontSizeToolTip}" Style="{StaticResource GenericToolTipLight}"/>
</Image.ToolTip>
</Image>
<ComboBox Grid.Row="1"
HorizontalAlignment="Left"
Margin="2,0,0,0"
ItemsSource="{Binding RelativeSource={RelativeSource AncestorType=Window},Path=DataContext.GroupStyleFontSizeList}"
SelectedItem="{Binding Path=FontSize}"
Style="{StaticResource NoBordersComboBoxStyle}"
IsEnabled="{Binding Path=IsDefault, Converter={StaticResource InverseBoolToEnablingConverter}}">
</ComboBox>
</StackPanel>
</Grid>
</Grid>
</Grid>
</Border>
Expand Down Expand Up @@ -824,7 +853,15 @@
<Label x:Name="colorHexVal"
FontSize="13"
Content="{Binding Background, ElementName=buttonColorPicker, Converter={StaticResource BrushColorToStringConverter}}"
Foreground="{StaticResource PreferencesWindowFontColor}"/>
Foreground="{StaticResource PreferencesWindowFontColor}" Margin="0,0,20,0"/>
<Image Width="24" Height="24" Margin="0,0,0,0" HorizontalAlignment="Left" VerticalAlignment="Center" Source="/DynamoCoreWpf;component/UI/Images/font-size.png"/>
<ComboBox x:Name="groupStyleFontSize"
HorizontalAlignment="Left"
Margin="2,0,0,0"
ItemsSource="{Binding RelativeSource={RelativeSource AncestorType=Window},Path=DataContext.GroupStyleFontSizeList}"
SelectedItem="{Binding Path=AddStyleControl.FontSize}"
Style="{StaticResource NoBordersComboBoxStyle}">
</ComboBox>
</StackPanel>
<Grid Grid.Column="1">
<Grid.ColumnDefinitions>
Expand Down
20 changes: 19 additions & 1 deletion src/DynamoCoreWpf/Views/Menu/PreferencesView.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,9 @@ private void AddStyle_SaveButton_Click(object sender, RoutedEventArgs e)

var colorHexString = grid.FindName("colorHexVal") as Label;

var newItem = new StyleItem() { Name = groupNameLabel.Text, HexColorString = colorHexString.Content.ToString() };
var groupStyleFontSize = grid.FindName("groupStyleFontSize") as ComboBox;
QilongTang marked this conversation as resolved.
Show resolved Hide resolved

var newItem = new StyleItem() { Name = groupNameLabel.Text, HexColorString = colorHexString.Content.ToString(), FontSize = Convert.ToInt32(groupStyleFontSize.SelectedValue) };

if (string.IsNullOrEmpty(newItem.Name))
newItem.Name = "Input";
Expand Down Expand Up @@ -273,6 +275,22 @@ private void ButtonColorPicker_Click(object sender, RoutedEventArgs e)
}
}

private void onChangedGroupStyleColor_Click(object sender, RoutedEventArgs e)
{
System.Windows.Forms.ColorDialog colorDialog = new System.Windows.Forms.ColorDialog();

if (colorDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
Button colorButton = sender as Button;

if (colorButton != null)
{
GroupStyleItem selectedGroupStyle = (GroupStyleItem)colorButton.DataContext;
selectedGroupStyle.HexColorString = colorDialog.Color.R.ToString("X2") + colorDialog.Color.G.ToString("X2") + colorDialog.Color.B.ToString("X2");
}
}
}

/// <summary>
/// This event is generated every time the user clicks a Radio Button in the Geometry Scaling section
/// The method just get the Radio Button clicked and saves the ScaleValue selected
Expand Down