From d57eb39ad110a13b70b9612b5b28b83be8f448f5 Mon Sep 17 00:00:00 2001 From: Deyan Nenov Date: Mon, 30 Oct 2023 00:24:52 +0000 Subject: [PATCH] fixed custombrowsercontrol visuals - multiple ui fixes to the custom browser control --- .../Controls/CustomBrowserControl.xaml | 169 ++++++------------ .../Controls/CustomBrowserControl.xaml.cs | 106 +++++++---- .../Pages/PublishPackagePublishPage.xaml | 1 + 3 files changed, 120 insertions(+), 156 deletions(-) diff --git a/src/DynamoCoreWpf/Views/PackageManager/Controls/CustomBrowserControl.xaml b/src/DynamoCoreWpf/Views/PackageManager/Controls/CustomBrowserControl.xaml index 6a4e1dd5ee8..231b45fb215 100644 --- a/src/DynamoCoreWpf/Views/PackageManager/Controls/CustomBrowserControl.xaml +++ b/src/DynamoCoreWpf/Views/PackageManager/Controls/CustomBrowserControl.xaml @@ -23,6 +23,7 @@ + @@ -70,99 +71,6 @@ - - - - - - - @@ -316,38 +224,69 @@ + - + - + - + - + - - - - + + + + + + + + + + + + - - - - + - - - + + + - - - - @@ -463,7 +394,7 @@ SnapsToDevicePixels="True" UseLayoutRounding="True" TextTrimming="CharacterEllipsis" - Width="230" + Width="180" FontFamily="{StaticResource ArtifaktElementRegular}"/> diff --git a/src/DynamoCoreWpf/Views/PackageManager/Controls/CustomBrowserControl.xaml.cs b/src/DynamoCoreWpf/Views/PackageManager/Controls/CustomBrowserControl.xaml.cs index 94199c2342e..3612b2c2ed0 100644 --- a/src/DynamoCoreWpf/Views/PackageManager/Controls/CustomBrowserControl.xaml.cs +++ b/src/DynamoCoreWpf/Views/PackageManager/Controls/CustomBrowserControl.xaml.cs @@ -1,5 +1,3 @@ -using Dynamo.Utilities; -using Lucene.Net.Util; using System; using System.Collections.Generic; using System.Collections.ObjectModel; @@ -12,6 +10,8 @@ using System.Windows.Data; using System.Windows.Input; using System.Windows.Media; +using Dynamo.Utilities; +using Lucene.Net.Util; namespace Dynamo.PackageManager.UI { @@ -20,8 +20,6 @@ namespace Dynamo.PackageManager.UI /// public partial class CustomBrowserControl : UserControl { - private PublishPackageViewModel PublishPackageViewModel; - /// /// Binds the ItemsSource of the TreeView /// @@ -77,42 +75,52 @@ private void UpdateCustomTreeView(object sender) var visualChildren = FindVisualChildren(treeView); if (visualChildren == null || visualChildren.Count() == 0) return; - ApplyLastTreeItem(visualChildren); + var root = visualChildren.First(); + + var hmarker = FindVisualChild(root, "HorizontalMarker"); + if (hmarker != null) hmarker.Visibility = Visibility.Hidden; + + root.IsSelected = true; + + + //ApplyLastTreeItem(visualChildren); // setting the visual styles for each separate 'root' folder - foreach(var item in visualChildren) - { - var rootItem = item.Header as PackageItemRootViewModel; - if (rootItem.isChild) continue; + //foreach (var item in visualChildren) + //{ + // var rootItem = item.Header as PackageItemRootViewModel; + // if (rootItem.isChild) continue; - item.ApplyTemplate(); - item.IsExpanded = true; - item.UpdateLayout(); - - var hmarker = FindVisualChild(item, "HorizontalMarker"); - if (hmarker != null) hmarker.Visibility = Visibility.Hidden; - var vmarker = FindVisualChild(item, "VerticalMarker"); - if (vmarker != null) vmarker.Visibility = Visibility.Hidden; - - //var children = FindVisualChildren(item); - //if(children != null) - //{ - // try - // { - // var lastItem = children.Last(); - - // lastItem.IsExpanded = true; - // lastItem.UpdateLayout(); - // lastItem.ApplyTemplate(); - - // var lmarker = FindVisualChild(lastItem, "LongMarker"); - // if (lmarker != null) lmarker.Visibility = Visibility.Hidden; - // } - // catch (Exception) { } - //} - } + // item.ApplyTemplate(); + // item.IsExpanded = true; + // item.UpdateLayout(); + + + // var hmarker = FindVisualChild(item, "HorizontalMarker"); + // if (hmarker != null) hmarker.Visibility = Visibility.Hidden; + // var vmarker = FindVisualChild(item, "VerticalMarker"); + // if (vmarker != null) vmarker.Visibility = Visibility.Hidden; + + + // //var children = FindVisualChildren(item); + // //if(children != null) + // //{ + // // try + // // { + // // var lastItem = children.Last(); + + // // lastItem.IsExpanded = true; + // // lastItem.UpdateLayout(); + // // lastItem.ApplyTemplate(); + + // // var lmarker = FindVisualChild(lastItem, "LongMarker"); + // // if (lmarker != null) lmarker.Visibility = Visibility.Hidden; + // // } + // // catch (Exception) { } + // //} + //} - visualChildren.First().IsSelected = true; + //visualChildren.First().IsSelected = true; } //private static TreeViewItem FindTreeViewSelectedItemContainer(ItemsControl root, object selection) @@ -157,8 +165,10 @@ private static void ApplyLastTreeItem(IEnumerable treeViewItems) lastItem.UpdateLayout(); lastItem.ApplyTemplate(); + var marker = FindVisualChild(item, "VerticalMarker"); if (marker != null) marker.Height = 12; + } } } @@ -319,7 +329,7 @@ public static void SetIndent(DependencyObject obj, GridLength value) public class IndentConverter : IValueConverter { - private const int IndentSize = 16; // hard-coded into the XAML template + private const int IndentSize = 20; // hard-coded into the XAML template public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { @@ -382,6 +392,28 @@ public object ConvertBack(object value, Type targetType, object parameter, Cultu } } + public class ChildrenItemsContainsFolderToVisibilityConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + if (value is ICollection children) + { + bool containsFolders = children.Any(x => x.DependencyType.Equals(DependencyType.Folder)); + + // Return visible if there are any folders in this root item's children + return containsFolders ? Visibility.Visible : Visibility.Collapsed; + } + + // Default style or value if the input is not a TreeViewItem + return Visibility.Visible; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } + public class SortingConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, CultureInfo culture) diff --git a/src/DynamoCoreWpf/Views/PackageManager/Pages/PublishPackagePublishPage.xaml b/src/DynamoCoreWpf/Views/PackageManager/Pages/PublishPackagePublishPage.xaml index 7e9ebf27889..8fb5443cca5 100644 --- a/src/DynamoCoreWpf/Views/PackageManager/Pages/PublishPackagePublishPage.xaml +++ b/src/DynamoCoreWpf/Views/PackageManager/Pages/PublishPackagePublishPage.xaml @@ -667,6 +667,7 @@