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-5743 I want to view multiline string to be better readable in Watch Node #14841

Merged
merged 1 commit into from
Jan 15, 2024
Merged
Show file tree
Hide file tree
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
14 changes: 10 additions & 4 deletions src/DynamoCoreWpf/ViewModels/Preview/WatchViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,11 @@ public bool IsCollection
get { return isCollection; }
set
{
isCollection = value;
RaisePropertyChanged("IsCollection");
if (isCollection != value)
{
isCollection = value;
RaisePropertyChanged(nameof(IsCollection));
}
}
}

Expand All @@ -199,8 +202,11 @@ public IEnumerable<int> Levels
get { return levels; }
set
{
levels = value;
RaisePropertyChanged("Levels");
if (levels != value)
{
levels = value;
RaisePropertyChanged(nameof(Levels));
}
}
}

Expand Down
49 changes: 30 additions & 19 deletions src/DynamoCoreWpf/Views/Preview/WatchTree.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -389,24 +389,17 @@
BorderBrush="#D3D3D3"
CornerRadius="0,0,2,2"
BorderThickness="0">

<DockPanel Name="ListLevelsDisplay" Height="27px" Visibility="{Binding IsCollection, Converter={StaticResource BooleanToVisibilityCollapsedConverter}}">

<!-- A draggable control to resize the Watch window -->
<Thumb Name="resizeThumb"
DockPanel.Dock="Right"
Margin="1,3,5,3"
HorizontalAlignment="Right"
VerticalAlignment="Center"
Cursor="SizeNWSE"
DragDelta="ThumbResizeThumbOnDragDeltaHandler"
Visibility="Hidden">
<Thumb.Template>
<ControlTemplate>
<Polygon Fill="#AFAFAF" Points="0,8 8,8 8,0" />
</ControlTemplate>
</Thumb.Template>
</Thumb>
<Grid Name="ListLevelsGrid">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>

<!-- Left Column display List Levels -->
<DockPanel Name="ListLevelsDisplay"
Height="27px"
Grid.Column="0"
Visibility="{Binding IsCollection, Converter={StaticResource BooleanToVisibilityCollapsedConverter}}">

<!-- Shows counts of all items in List -->
<TextBlock Name="ListItems"
Expand Down Expand Up @@ -466,7 +459,25 @@
</ListView.ItemTemplate>
</ListView>

</DockPanel>
</DockPanel>

<!-- Left Column display a draggable control to resize the Watch window -->
<Thumb Name="resizeThumb"
Grid.Column="1"
DockPanel.Dock="Right"
Margin="1,3,5,3"
HorizontalAlignment="Right"
VerticalAlignment="Center"
Cursor="SizeNWSE"
DragDelta="ThumbResizeThumbOnDragDeltaHandler"
Visibility="Collapsed">
<Thumb.Template>
<ControlTemplate>
<Polygon Fill="#AFAFAF" Points="0,8 8,8 8,0" />
</ControlTemplate>
</Thumb.Template>
</Thumb>
</Grid>
</Border>
</Grid>
</UserControl>
14 changes: 10 additions & 4 deletions src/DynamoCoreWpf/Views/Preview/WatchTree.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using Dynamo.ViewModels;
using System;
using CoreNodeModels;
using System.Linq;

namespace Dynamo.Controls
{
Expand Down Expand Up @@ -68,7 +69,7 @@ private void _vm_PropertyChanged(object sender, System.ComponentModel.PropertyCh

if (e.PropertyName == nameof(WatchViewModel.IsCollection))
{
// // The WatchTree controll will resize only if its role is a WatchNode (starts with an specific height), otherwise it won't resize (Bubble role).
// The WatchTree controll will resize only if its role is a WatchNode (starts with an specific height), otherwise it won't resize (Bubble role).
if (!Double.IsNaN(this.Height))
{
if (_vm.IsCollection)
Expand Down Expand Up @@ -100,10 +101,13 @@ private void _vm_PropertyChanged(object sender, System.ComponentModel.PropertyCh
{
if (!_vm.Children[0].IsCollection)
{
// We will use 7.5 as width factor for each character.
// if multiline string
if (NodeLabel.Contains(Environment.NewLine) || NodeLabel.Contains("\n"))
this.Height = defaultHeightSize;

double requiredWidth = (NodeLabel.Length * widthPerCharacter);
if (requiredWidth > (MaxWidthSize))
// We will use 7.5 as width factor for each character.
double requiredWidth = NodeLabel.Length * widthPerCharacter;
if (requiredWidth > MaxWidthSize)
{
requiredWidth = MaxWidthSize;
}
Expand All @@ -123,6 +127,8 @@ private void _vm_PropertyChanged(object sender, System.ComponentModel.PropertyCh
// Forcing not to display the Levels content when is being used for display info from another node like the Color Range
this.ListLevelsDisplay.Visibility = Visibility.Hidden;
this.ListLevelsDisplay.Height = 0;
// Hide resize grip
resizeThumb.Visibility = Visibility.Collapsed;
}
}
}
Expand Down
Loading