Skip to content

Commit

Permalink
Use a different icon for files that are source, destination or both
Browse files Browse the repository at this point in the history
  • Loading branch information
KirillOsenkov committed Jul 31, 2024
1 parent d7462fa commit 8f13cf7
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 1 deletion.
28 changes: 28 additions & 0 deletions src/StructuredLogViewer/themes/Generic.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,34 @@
</StackPanel>
</HierarchicalDataTemplate>

<HierarchicalDataTemplate DataType="{x:Type l:FileCopy}"
ItemsSource="{Binding Children}">
<StackPanel Orientation="Horizontal">
<Path x:Name="icon"
Data="M5,5 L5,11 L11,11 L11,5 Z M 0,8 L16,8"
Stroke="Thistle"
VerticalAlignment="Center"
StrokeThickness="1"
Width="16"
Height="16"
Margin="1,2,6,2"
Fill="Thistle" />
<TextBlock Text="{Binding ShortenedName}" />
</StackPanel>
<HierarchicalDataTemplate.Triggers>
<DataTrigger Binding="{Binding Kind}" Value="Source">
<Setter TargetName="icon" Property="Data" Value="M0,5 L0,11 L6,11 L6,5 Z M 6,8 L16,8" />
<Setter TargetName="icon" Property="Stroke" Value="LightSkyBlue" />
<Setter TargetName="icon" Property="Fill" Value="LightSkyBlue" />
</DataTrigger>
<DataTrigger Binding="{Binding Kind}" Value="Destination">
<Setter TargetName="icon" Property="Data" Value="M10,5 L10,11 L16,11 L16,5 Z M 0,8 L10,8" />
<Setter TargetName="icon" Property="Stroke" Value="DarkSalmon" />
<Setter TargetName="icon" Property="Fill" Value="DarkSalmon" />
</DataTrigger>
</HierarchicalDataTemplate.Triggers>
</HierarchicalDataTemplate>

<HierarchicalDataTemplate DataType="{x:Type l:Package}"
ItemsSource="{Binding Children}">
<StackPanel Orientation="Horizontal">
Expand Down
18 changes: 17 additions & 1 deletion src/StructuredLogger/Analyzers/FileCopyMap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,23 @@ private void TryGetFiles(string text, IList<SearchResult> resultSet, NodeQueryMa
continue;
}

var item = new Item { Name = file.FilePath };
string kind = null;
bool hasIncoming = file.Incoming.Any();
bool hasOutgoing = file.Outgoing.Any();
if (hasIncoming && hasOutgoing)
{
kind = "SourceAndDestination";
}
else if (hasIncoming)
{
kind = "Destination";
}
else if (hasOutgoing)
{
kind = "Source";
}

var item = new FileCopy { Name = file.FilePath, Kind = kind };
var result = new SearchResult(item);
if (text != null)
{
Expand Down
5 changes: 5 additions & 0 deletions src/StructuredLogger/ObjectModel/Item.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,9 @@ public string Text
set => Name = value;
}
}

public class FileCopy : Item
{
public string Kind { get; set; }
}
}

0 comments on commit 8f13cf7

Please sign in to comment.