Skip to content

Commit

Permalink
Re-work watch node display logic
Browse files Browse the repository at this point in the history
  • Loading branch information
QilongTang committed Jan 12, 2024
1 parent 06ac24b commit 647bff1
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 27 deletions.
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

0 comments on commit 647bff1

Please sign in to comment.