Skip to content

Commit

Permalink
Add command bar for diff viewer.
Browse files Browse the repository at this point in the history
  • Loading branch information
kingcean authored and mmanela committed Jun 10, 2023
1 parent 99868e2 commit 400b2e3
Show file tree
Hide file tree
Showing 8 changed files with 614 additions and 428 deletions.
6 changes: 3 additions & 3 deletions DiffPlex.App/DiffPlex.App.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0-windows10.0.19041.0</TargetFramework>
<TargetFramework>net7.0-windows10.0.19041.0</TargetFramework>
<TargetPlatformMinVersion>10.0.17763.0</TargetPlatformMinVersion>
<RootNamespace>DiffPlex.UI</RootNamespace>
<AssemblyName>DiffPlex.App</AssemblyName>
Expand Down Expand Up @@ -43,8 +43,8 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.1.5" />
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.22621.1" />
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.3.230502000" />
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.22621.756" />
<Manifest Include="$(ApplicationManifest)" />
</ItemGroup>

Expand Down
14 changes: 7 additions & 7 deletions DiffPlex.Windows/DiffPlex.Windows.csproj
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net6.0-windows10.0.17763.0;net6.0-windows10.0.19041.0;net6.0-windows10.0.22000.0</TargetFrameworks>
<TargetFrameworks>net6.0-windows10.0.17763.0;net6.0-windows10.0.19041.0;net6.0-windows10.0.22000.0;net7.0-windows10.0.17763.0;net7.0-windows10.0.19041.0;net7.0-windows10.0.22000.0</TargetFrameworks>
<TargetPlatformMinVersion>10.0.17763.0</TargetPlatformMinVersion>
<RootNamespace>DiffPlex.UI</RootNamespace>
<AssemblyName>DiffPlex.Windows</AssemblyName>
<PackageId>DiffPlex.Windows</PackageId>
<RuntimeIdentifiers>win10-x86;win10-x64;win10-arm64</RuntimeIdentifiers>
<UseWinUI>true</UseWinUI>
<Version>1.0.1</Version>
<Version>1.1.0</Version>
<PackageTags>diff</PackageTags>
<PackageIcon>diffplex_icon.png</PackageIcon>
<Description>DiffPlex.Windows is a Windows App SDK control library that allows you to programatically render visual text diffs in your application.</Description>
<LangVersion>10.0</LangVersion>
<AssemblyVersion>1.0.1.0</AssemblyVersion>
<FileVersion>1.0.1.0</FileVersion>
<AssemblyVersion>1.1.0.0</AssemblyVersion>
<FileVersion>1.1.0.0</FileVersion>
<Authors>Kingcean Tuan; Matthew Manela</Authors>
<Copyright>Copyright (c) 2022 Matthew Manela. All rights reserved.</Copyright>
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
Expand All @@ -35,9 +35,9 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.1.5" />
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.22621.1" />
<PackageReference Include="Trivial.WindowsKit" Version="6.5.0" />
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.3.230502000" />
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.22621.756" />
<PackageReference Include="Trivial.WindowsKit" Version="7.0.0" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
</ItemGroup>

Expand Down
99 changes: 91 additions & 8 deletions DiffPlex.Wpf/Controls/DiffViewer.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,101 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:DiffPlex.Wpf.Controls"
x:Name="SelfControl"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<UserControl.Resources>
<Style x:Key="FocusVisual">
<Setter Property="Control.Template">
<Setter.Value>
<ControlTemplate>
<Rectangle Margin="2" StrokeDashArray="1 2" SnapsToDevicePixels="true" StrokeThickness="1" Stroke="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<SolidColorBrush x:Key="Button.Static.Background" Color="#33808080"/>
<SolidColorBrush x:Key="Button.Static.Border" Color="#44808080"/>
<SolidColorBrush x:Key="Button.MouseOver.Background" Color="#990099FF"/>
<SolidColorBrush x:Key="Button.MouseOver.Border" Color="#CC0099FF"/>
<SolidColorBrush x:Key="Button.Pressed.Background" Color="#EE0099FF"/>
<SolidColorBrush x:Key="Button.Pressed.Border" Color="#FF0099FF"/>
<SolidColorBrush x:Key="Button.Disabled.Background" Color="#99808080"/>
<SolidColorBrush x:Key="Button.Disabled.Border" Color="#CC808080"/>
<SolidColorBrush x:Key="Button.Disabled.Foreground" Color="#FF808080"/>
<Style x:Key="SolidButtonStyle" TargetType="{x:Type Button}">
<Setter Property="FocusVisualStyle" Value="{StaticResource FocusVisual}"/>
<Setter Property="Background" Value="{StaticResource Button.Static.Background}"/>
<Setter Property="BorderBrush" Value="{StaticResource Button.Static.Border}"/>
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="HorizontalContentAlignment" Value="Center"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>
<Setter Property="Padding" Value="1"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<Border x:Name="border" Background="{TemplateBinding Background}" BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}" SnapsToDevicePixels="true">
<ContentPresenter x:Name="contentPresenter" Focusable="False" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsDefaulted" Value="true">
<Setter Property="BorderBrush" TargetName="border" Value="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}"/>
</Trigger>
<Trigger Property="IsMouseOver" Value="true">
<Setter Property="Background" TargetName="border" Value="{StaticResource Button.MouseOver.Background}"/>
<Setter Property="BorderBrush" TargetName="border" Value="{StaticResource Button.MouseOver.Border}"/>
</Trigger>
<Trigger Property="IsPressed" Value="true">
<Setter Property="Background" TargetName="border" Value="{StaticResource Button.Pressed.Background}"/>
<Setter Property="BorderBrush" TargetName="border" Value="{StaticResource Button.Pressed.Border}"/>
</Trigger>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="Background" TargetName="border" Value="{StaticResource Button.Disabled.Background}"/>
<Setter Property="BorderBrush" TargetName="border" Value="{StaticResource Button.Disabled.Border}"/>
<Setter Property="TextElement.Foreground" TargetName="contentPresenter" Value="{StaticResource Button.Disabled.Foreground}"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</UserControl.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition x:Name="CommandRow" Height="0" />
<RowDefinition x:Name="HeaderRow" Height="0"/>
<RowDefinition x:Name="ContentRow" Height="*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition x:Name="LeftColumn"/>
<ColumnDefinition x:Name="RightColumn"/>
</Grid.ColumnDefinitions>
<Border x:Name="HeaderBorder" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Grid.ColumnSpan="2" >
<StackPanel x:Name="ActionBar" Background="#20808080" Orientation="Horizontal" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Grid.ColumnSpan="2" >
<StackPanel x:Name="MenuPanel" Orientation="Horizontal" Margin="0" ></StackPanel>
<StackPanel Orientation="Horizontal" Margin="16,0,16,0" >
<Button Style="{DynamicResource SolidButtonStyle}" Width="100" Height="20" x:Name="OpenFileButton" Content="Open File" Click="OpenFileButton_Click" Foreground="{Binding Foreground, ElementName=SelfControl}" Margin="0,0,16,0">
<Button.ContextMenu>
<ContextMenu x:Name="OpenFileContextMenu">
<MenuItem x:Name="OpenLeftFileMenuItem" Header="Left" Click="OpenLeftFileMenuItem_Click" />
<MenuItem x:Name="OpenRightFileMenuItem" Header="Right" Click="OpenRightFileMenuItem_Click" />
</ContextMenu>
</Button.ContextMenu>
</Button>
<Button Width="120" Height="20" x:Name="DiffButton" Content="Switch Mode" Click="DiffButton_Click" Foreground="{Binding Foreground, ElementName=SelfControl}" Margin="0" Style="{DynamicResource SolidButtonStyle}" />
<Button Width="20" Height="20" x:Name="FurtherActionsButton" Content="" Click="FurtherActionsButton_Click" Foreground="{Binding Foreground, ElementName=SelfControl}" Margin="1,0,15,0" Style="{DynamicResource SolidButtonStyle}" />
<Label x:Name="GoToLabel" Height="20" Padding="0" Margin="16,0,8,0" VerticalContentAlignment="Center" Foreground="{Binding Foreground, ElementName=SelfControl}" >Go to</Label>
<TextBox Width="80" Height="20" VerticalContentAlignment="Center" x:Name="GoToText" Padding="8,0,8,0" Text="" Foreground="{Binding Foreground, ElementName=SelfControl}" CaretBrush="{Binding Foreground, ElementName=SelfControl}" Background="{x:Null}" Margin="0,0,8,0" TextChanged="GoToText_TextChanged" LostFocus="GoToText_LostFocus" />
<Button Width="20" Height="20" x:Name="NextButton" Click="NextButton_Click" Foreground="{Binding Foreground, ElementName=SelfControl}" Margin="0,0,1,0" Style="{DynamicResource SolidButtonStyle}" >
<Path Width="10" Height="10" Stretch="Fill" Stroke="{Binding Foreground, ElementName=SelfControl}" Data="M0,1 L4,8 5,8 9,1" />
</Button>
<Button Width="20" Height="20" x:Name="PreviousButton" Click="PreviousButton_Click" Foreground="{Binding Foreground, ElementName=SelfControl}" Margin="0" Style="{DynamicResource SolidButtonStyle}" >
<Path Width="10" Height="10" Stretch="Fill" Stroke="{Binding Foreground, ElementName=SelfControl}" Data="M0,8 L4,1 5,1 9,8" />
</Button>
</StackPanel>
<StackPanel x:Name="AdditionalMenuPanel" Orientation="Horizontal" Margin="0" ></StackPanel>
</StackPanel>
<Border x:Name="HeaderBorder" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Grid.Row="1" Grid.ColumnSpan="2" >
<Border.ContextMenu>
<ContextMenu x:Name="HeaderContextMenu">
<MenuItem x:Name="InlineModeToggle" Header="_Unified view" Click="InlineModeToggle_Click" />
Expand All @@ -38,12 +121,12 @@
</ContextMenu>
</Border.ContextMenu>
</Border>
<TextBlock x:Name="InlineHeaderText" HorizontalAlignment="Center" VerticalAlignment="Center" Grid.ColumnSpan="2" Visibility="Collapsed" />
<local:InternalLinesViewer x:Name="InlineContentPanel" Grid.ColumnSpan="2" Grid.Row="1" Visibility="Collapsed" />
<TextBlock x:Name="LeftHeaderText" HorizontalAlignment="Center" VerticalAlignment="Center" />
<local:InternalLinesViewer x:Name="LeftContentPanel" ScrollChanged="LeftContentPanel_ScrollChanged" Grid.Row="1" />
<GridSplitter x:Name="Splitter" Width="5" Grid.RowSpan="2" />
<TextBlock x:Name="RightHeaderText" HorizontalAlignment="Center" VerticalAlignment="Center" Grid.Column="1" />
<local:InternalLinesViewer x:Name="RightContentPanel" ScrollChanged="RightContentPanel_ScrollChanged" Grid.Row="1" Grid.Column="1" />
<TextBlock x:Name="InlineHeaderText" HorizontalAlignment="Center" VerticalAlignment="Center" Grid.Row="1" Grid.ColumnSpan="2" Visibility="Collapsed" />
<local:InternalLinesViewer x:Name="InlineContentPanel" Grid.ColumnSpan="2" Grid.Row="2" Visibility="Collapsed" />
<TextBlock x:Name="LeftHeaderText" HorizontalAlignment="Center" VerticalAlignment="Center" Grid.Row="1" />
<local:InternalLinesViewer x:Name="LeftContentPanel" ScrollChanged="LeftContentPanel_ScrollChanged" Grid.Row="2" />
<GridSplitter x:Name="Splitter" Width="5" Grid.Row="1" Grid.RowSpan="2" />
<TextBlock x:Name="RightHeaderText" HorizontalAlignment="Center" VerticalAlignment="Center" Grid.Row="1" Grid.Column="1" />
<local:InternalLinesViewer x:Name="RightContentPanel" ScrollChanged="RightContentPanel_ScrollChanged" Grid.Row="2" Grid.Column="1" />
</Grid>
</UserControl>
Loading

0 comments on commit 400b2e3

Please sign in to comment.