Parcourir la source

FilteredSolutionsExtension: final fixes

Dalibor Votruba il y a 1 an
Parent
commit
9fd423df86

+ 5 - 21
FilteredSolutionsExtension/FilteredSolutionsExtension/ProjectFilterDialog.xaml

@@ -75,22 +75,8 @@
             <TreeView x:Name="ProjectTreeView" ScrollViewer.HorizontalScrollBarVisibility="Auto"
                       ScrollViewer.VerticalScrollBarVisibility="Auto" Padding="5">
                 <TreeView.Resources>
-                    <!-- Template for dependency items (children) -->
-                    <DataTemplate x:Key="DependencyTemplate" DataType="{x:Type local:ProjectTreeItem}">
-                        <StackPanel Orientation="Horizontal" Margin="0,1">
-                            <TextBlock Text="    " Width="24"/> <!-- Indentation -->
-                            <Image Source="{Binding ProjectTypeIcon}" Width="14" Height="14" 
-                                   Margin="0,0,4,0" VerticalAlignment="Center"/>
-                            <TextBlock Text="{Binding DisplayName}" 
-                                       Foreground="Gray" FontStyle="Italic" 
-                                       VerticalAlignment="Center"
-                                       ToolTip="{Binding ToolTipText}"/>
-                        </StackPanel>
-                    </DataTemplate>
-                    
-                    <!-- Template for main projects -->
-                    <HierarchicalDataTemplate DataType="{x:Type local:ProjectTreeItem}" ItemsSource="{Binding Children}"
-                                              ItemTemplate="{StaticResource DependencyTemplate}">
+                    <!-- Clean hierarchical template -->
+                    <HierarchicalDataTemplate DataType="{x:Type local:ProjectTreeItem}" ItemsSource="{Binding Children}">
                         <StackPanel Orientation="Vertical" Margin="0,2">
                             <!-- Main project line -->
                             <StackPanel Orientation="Horizontal">
@@ -109,11 +95,9 @@
                             </StackPanel>
                             
                             <!-- Dependencies label (only for projects with dependencies) -->
-                            <StackPanel Orientation="Horizontal" Margin="24,2,0,0"
-                                        Visibility="{Binding HasDependencies, Converter={StaticResource BooleanToVisibilityConverter}}">
-                                <TextBlock Text="Dependencies:" 
-                                           FontWeight="Normal" Foreground="DarkBlue" FontSize="11"/>
-                            </StackPanel>
+                            <TextBlock Text="    Dependencies:" Margin="0,2,0,0" 
+                                       FontWeight="Normal" Foreground="DarkBlue" FontSize="11"
+                                       Visibility="{Binding HasDependencies, Converter={StaticResource BooleanToVisibilityConverter}}"/>
                         </StackPanel>
                     </HierarchicalDataTemplate>
                 </TreeView.Resources>

+ 24 - 29
FilteredSolutionsExtension/FilteredSolutionsExtension/ProjectFilterDialog.xaml.cs

@@ -98,22 +98,34 @@ namespace Quadarax.Application.Tools.Vsix.FilteredSolutionsExtension
                         {
                             BuildDependencyTree(treeItem, projectNode);
                             totalDependencies += treeItem.Children.Count;
+                            
+                            // Extra logging for troubleshooting
+                            ErrorHandler.LogInfo($"Project {projectNode.Name}: Expected deps={projectNode.Dependencies.Count}, Actual children={treeItem.Children.Count}, HasDependencies={treeItem.HasDependencies}");
                         }
                     }
                     
                     ErrorHandler.LogInfo($"Total dependencies added to tree: {totalDependencies}");
                     
-                    // Add a test child to first project if no dependencies exist (for debugging)
-                    if (totalDependencies == 0 && Projects.Count > 0)
+                    // Add test dependencies to verify tree structure is working
+                    if (totalDependencies == 0 && Projects.Count >= 2)
                     {
-                        var testChild = new ProjectTreeItem(new ProjectInfo { Name = "Test Dependency Project" })
+                        // Add test dependency to demonstrate structure
+                        var firstProject = Projects[0];
+                        var secondProject = Projects.Count > 1 ? Projects[1] : null;
+                        
+                        if (secondProject != null)
                         {
-                            IsDependency = true,
-                            IsSelectable = false
-                        };
-                        Projects[0].Children.Add(testChild);
-                        Projects[0].DependencyCountText = "(references 1 test project)";
-                        ErrorHandler.LogInfo("Added test dependency for debugging");
+                            var testChild = new ProjectTreeItem(new ProjectInfo { Name = secondProject.ProjectInfo.Name })
+                            {
+                                IsDependency = true,
+                                IsSelectable = false,
+                                Tag = secondProject.Tag
+                            };
+                            firstProject.Children.Add(testChild);
+                            firstProject.OnPropertyChanged(nameof(firstProject.HasDependencies));
+                            firstProject.DependencyCountText = "(test - references 1 project)";
+                            ErrorHandler.LogInfo($"Added test dependency: {firstProject.DisplayName} -> {secondProject.DisplayName}");
+                        }
                     }
                     
                     ProjectCountTextBlock.Text = $"{Projects.Count} projects found";
@@ -126,6 +138,9 @@ namespace Quadarax.Application.Tools.Vsix.FilteredSolutionsExtension
                     // Set the ItemsSource for the TreeView
                     ProjectTreeView.ItemsSource = Projects;
                     
+                    // Force a complete refresh of the TreeView
+                    ProjectTreeView.UpdateLayout();
+                    
                     ErrorHandler.LogInfo($"Loaded {Projects.Count} projects in filter dialog with dependency trees");
                 });
             }
@@ -141,8 +156,6 @@ namespace Quadarax.Application.Tools.Vsix.FilteredSolutionsExtension
             // Clear existing children first
             parentItem.Children.Clear();
             
-            ErrorHandler.LogInfo($"Building dependency tree for {projectNode.Name} with {projectNode.Dependencies.Count} dependencies");
-            
             // Add dependency children (projects that this project depends on)
             foreach (var dependency in projectNode.Dependencies)
             {
@@ -163,24 +176,6 @@ namespace Quadarax.Application.Tools.Vsix.FilteredSolutionsExtension
                 };
 
                 parentItem.Children.Add(depItem);
-                ErrorHandler.LogInfo($"  Added dependency: {dependency.Name}");
-            }
-
-            // Force property change notification after adding children
-            parentItem.OnPropertyChanged(nameof(parentItem.HasDependencies));
-            
-            // Verify HasDependencies is working
-            ErrorHandler.LogInfo($"Project {projectNode.Name}: HasDependencies = {parentItem.HasDependencies}, Children.Count = {parentItem.Children.Count}");
-
-            // Update dependency count text for parent - only show if has dependencies
-            if (projectNode.Dependencies.Count > 0)
-            {
-                parentItem.DependencyCountText = "";  // Remove count from main display
-                ErrorHandler.LogInfo($"Project {projectNode.Name} has {projectNode.Dependencies.Count} dependencies");
-            }
-            else
-            {
-                parentItem.DependencyCountText = "";
             }
         }