Skip to content
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
4 changes: 4 additions & 0 deletions src/DynamoCoreWpf/PublicAPI.Unshipped.txt
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,10 @@ Dynamo.Controls.LeftThicknessConverter
Dynamo.Controls.LeftThicknessConverter.Convert(object value, System.Type targetType, object parameter, System.Globalization.CultureInfo culture) -> object
Dynamo.Controls.LeftThicknessConverter.ConvertBack(object value, System.Type targetType, object parameter, System.Globalization.CultureInfo culture) -> object
Dynamo.Controls.LeftThicknessConverter.LeftThicknessConverter() -> void
Dynamo.Controls.LengthToVisibilityConverter
Dynamo.Controls.LengthToVisibilityConverter.Convert(object value, System.Type targetType, object parameter, System.Globalization.CultureInfo culture) -> object
Dynamo.Controls.LengthToVisibilityConverter.ConvertBack(object value, System.Type targetType, object parameter, System.Globalization.CultureInfo culture) -> object
Dynamo.Controls.LengthToVisibilityConverter.LengthToVisibilityConverter() -> void
Dynamo.Controls.LibraryTreeItemsHostVisibilityConverter
Dynamo.Controls.LibraryTreeItemsHostVisibilityConverter.Convert(object value, System.Type targetType, object parameter, System.Globalization.CultureInfo culture) -> object
Dynamo.Controls.LibraryTreeItemsHostVisibilityConverter.ConvertBack(object value, System.Type targetType, object parameter, System.Globalization.CultureInfo culture) -> object
Expand Down
16 changes: 16 additions & 0 deletions src/DynamoCoreWpf/UI/Converters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4310,4 +4310,20 @@ public object ConvertBack(object value, Type targetType, object parameter, Cultu
return Binding.DoNothing;
}
}

public class LengthToVisibilityConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is int length)
return length > 0 ? Visibility.Collapsed : Visibility.Visible;

return Visibility.Visible;
}

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}
1 change: 1 addition & 0 deletions src/DynamoCoreWpf/UI/Themes/Modern/DynamoConverters.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -176,4 +176,5 @@
<controls:PortTypeToStringConverter x:Key="PortTypeToStringConverter" />
<controls:BooleanNegationConverter x:Key="BooleanNegationConverter" />
<controls:LeftMarginConverter x:Key="LeftMarginConverter" />
<controls:LengthToVisibilityConverter x:Key="LengthToVisibilityConverter" />
</ResourceDictionary>
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ public bool IsOpen
}
}

private int ClusterResultsCount => DropdownResults == null ? 0 : DropdownResults.Count();
private int ClusterResultsCount => FilteredView == null ? 0 : FilteredView.Cast<object>().ToList().Count;

private int selectedIndex = 0;

Expand Down Expand Up @@ -231,6 +231,8 @@ public string SearchInput
{
FilteredView.Refresh();
}

RaisePropertyChanged(nameof(SearchInput));
}
}

Expand All @@ -245,30 +247,19 @@ public int SelectedIndex
}
set
{
/*don't try to add a node if the index is out of range or a selection is not made yet (-1)
an index of -1 occurs when using the switch to change between modes.*/
if (selectedIndex != value && value >= 0 && selectedIndex != -1)
if (selectedIndex != value && value >= -1)
{
ReAddNode(value);
}
selectedIndex = value;
RaisePropertyChanged(nameof(SelectedIndex));
RaisePropertyChanged(nameof(NthofTotal));
RaisePropertyChanged(nameof(PreviousSource));
RaisePropertyChanged(nameof(NextSource));
}
}
selectedIndex = value;
if (selectedIndex != -1)
{
AddCluster(selectedIndex);
}

private void ReAddNode(int index)
{
if(FullResults == null)
{
return;
}
var results = QualifiedResults.ToList();
if(index >= 0 && index < results.Count)
{
AddCluster(results[index]);
RaisePropertyChanged(nameof(SelectedIndex));
RaisePropertyChanged(nameof(NthofTotal));
RaisePropertyChanged(nameof(PreviousSource));
RaisePropertyChanged(nameof(NextSource));
}
}
}

Expand Down Expand Up @@ -426,6 +417,7 @@ internal void ResetAutoCompleteSearchViewState()
FilteredResults = new List<NodeSearchElementViewModel>();
FilteredHighConfidenceResults = new List<NodeSearchElementViewModel>();
FilteredLowConfidenceResults = new List<NodeSearchElementViewModel>();
SearchInput = string.Empty;
}

internal MLNodeAutoCompletionRequest GenerateRequestForMLAutocomplete()
Expand Down Expand Up @@ -796,6 +788,19 @@ internal void DeleteTransientNodes()
}
}


internal void AddCluster(int filterredIndex)
{
var currentFilter = FilteredView.Cast<DNADropdownViewModel>().ToList();
var currentItem = filterredIndex >= 0 && filterredIndex < currentFilter.Count ? currentFilter[filterredIndex] : null;

var realCluster = QualifiedResults.FirstOrDefault(x => x.Description.Equals(currentItem.Description));
if (realCluster != null)
{
AddCluster(realCluster);
}
}

// Add Cluster from server result into the workspace
internal void AddCluster(ClusterResultItem clusterResultItem)
{
Expand Down Expand Up @@ -1040,8 +1045,6 @@ internal void PopulateAutoComplete()
if (comboboxResults.Any())
{
SelectedIndex = 0;
var ClusterResultItem = QualifiedResults.First();
AddCluster(ClusterResultItem);
}

});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
xmlns:ui="clr-namespace:Dynamo.UI;assembly=DynamoCoreWpf"
xmlns:local="clr-namespace:Dynamo.PackageManager.UI;assembly=DynamoCoreWpf"
xmlns:dynconverters="clr-namespace:Dynamo.Controls;assembly=DynamoCoreWpf"
xmlns:resxother="clr-namespace:Dynamo.Wpf.Properties;assembly=DynamoCoreWpf"
mc:Ignorable="d"
WindowStyle="None"
AllowsTransparency="True"
Expand Down Expand Up @@ -40,6 +41,7 @@
</Style>
<dynconverters:BoolToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
<dynconverters:InverseBoolToVisibilityConverter x:Key="InverseBooleanToVisibilityConverter"/>
<dynconverters:LengthToVisibilityConverter x:Key="LengthToVisibilityConverter"/>
</ResourceDictionary>
</Window.Resources>

Expand Down Expand Up @@ -160,21 +162,48 @@
</Style>
</ComboBox.Style>
<ComboBox.Tag>
<TextBox x:Name="AutoCompleteSearchBox"
HorizontalAlignment="Stretch"
Height="24"
Margin="16,5,16,5"
Padding="2"
Width="Auto"
Foreground="{Binding Foreground, RelativeSource={RelativeSource AncestorType=ComboBox}}"
Background="{Binding Background, RelativeSource={RelativeSource AncestorType=ComboBox}}"
FontFamily="{Binding FontFamily, RelativeSource={RelativeSource AncestorType=ComboBox}}"
CaretBrush="{Binding Foreground, RelativeSource={RelativeSource AncestorType=ComboBox}}"
FontSize="14">
<TextBox.Text>
<Binding Path="SearchInput" Mode="OneWayToSource" UpdateSourceTrigger="PropertyChanged" />
</TextBox.Text>
</TextBox>
<Grid>
<TextBox x:Name="AutoCompleteSearchBox"
HorizontalAlignment="Stretch"
Height="28"
Margin="7,3,7,3"
Padding="2"
Width="Auto"
BorderThickness="0,0,0,1"
Foreground="{Binding Foreground, RelativeSource={RelativeSource AncestorType=ComboBox}}"
Background="{Binding Background, RelativeSource={RelativeSource AncestorType=ComboBox}}"
FontFamily="{Binding FontFamily, RelativeSource={RelativeSource AncestorType=ComboBox}}"
CaretBrush="{Binding Foreground, RelativeSource={RelativeSource AncestorType=ComboBox}}"
FontSize="14">
<TextBox.Text>
<Binding Path="SearchInput" Mode="TwoWay" UpdateSourceTrigger="PropertyChanged" />
</TextBox.Text>
</TextBox>

<StackPanel x:Name="PlaceholderPanel"
Orientation="Horizontal"
VerticalAlignment="Center"
IsHitTestVisible="False"
HorizontalAlignment="Stretch"
Height="28"
Margin="12,3,7,3"
Width="Auto"
Visibility="{Binding Text.Length, ElementName=AutoCompleteSearchBox, Converter={StaticResource LengthToVisibilityConverter}}">
<Image x:Name="SearchIcon"
Width="20px"
Height="20px"
HorizontalAlignment="Left"
VerticalAlignment="Center"
DockPanel.Dock="Left">
<Image.Style>
<Style TargetType="{x:Type Image}">
<Setter Property="Source" Value="/DynamoCoreWpf;component/UI/Images/searchmagnifier.png" />
</Style>
</Image.Style>
</Image>
<TextBlock Padding="2" FontSize="14" Text="{x:Static resxother:Resources.LibraryViewSearchText}" Foreground="{Binding Foreground, RelativeSource={RelativeSource AncestorType=ComboBox}}" VerticalAlignment="Center"/>
</StackPanel>
</Grid>
</ComboBox.Tag>
<ComboBox.ItemTemplate>
<DataTemplate>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ private void GripHandle_MouseLeftButtonDown(object sender, MouseButtonEventArgs

private void MoveIndex(int step)
{
ViewModel.SelectedIndex = Math.Min(ViewModel.DropdownResults.Count() - 1, Math.Max(0, ViewModel.SelectedIndex + step));
ViewModel.SelectedIndex = Math.Min(ViewModel.FilteredView.Cast<object>().Count() - 1, Math.Max(0, ViewModel.SelectedIndex + step));
}

private void PrevButton_OnClick(object sender, RoutedEventArgs e)
Expand Down
Loading