-
-
Notifications
You must be signed in to change notification settings - Fork 187
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow text wrapping in WPF controls #142
base: master
Are you sure you want to change the base?
Allow text wrapping in WPF controls #142
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left comments, can you also put a high level description in the PR for how you are approaching this?
DiffPlex.Wpf.Demo/MainWindow.xaml
Outdated
@@ -18,6 +18,7 @@ | |||
<StackPanel Orientation="Horizontal" Grid.Row="1" Background="#20808080"> | |||
<Button Width="100" Height="20" x:Name="DiffButton" Content="Switch Mode" Click="DiffButton_Click" BorderBrush="{x:Null}" BorderThickness="0" Margin="16,0,1,0" /> | |||
<Button Width="20" Height="20" x:Name="FutherActionsButton" Content="…" Click="FutherActionsButton_Click" BorderBrush="{x:Null}" BorderThickness="0" Margin="0,0,31,0" /> | |||
<Button Width="100" Height="20" x:Name="TextWrapButton" Content="WrapText" Click="TextWrapButton_Click" BorderBrush="{x:Null}" Background="Green" BorderThickness="0" Margin="16,0,1,0" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should not be a button but a check box where you can enable and disable word wrapping
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pushed
DiffPlex.Wpf.Demo/MainWindow.xaml.cs
Outdated
@@ -59,6 +59,11 @@ private void DiffButton_Click(object sender, RoutedEventArgs e) | |||
DiffView.ShowInline(); | |||
} | |||
|
|||
private void TextWrapButton_Click(object sender, RoutedEventArgs e) | |||
{ | |||
DiffView.EnableTextWrapping(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above, should be a toggle box that lets you enable and disable this mode
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pushed
x:Name="SelfControl" | ||
mc:Ignorable="d" | ||
d:DesignHeight="450" d:DesignWidth="800"> | ||
<UserControl |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: This file has a lot of formatting changes, ideally, we would only include the meaningful change for review
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
@@ -41,15 +41,26 @@ internal static class Helper | |||
internal static void RenderInlineDiffs(InternalLinesViewer viewer, ICollection<DiffPiece> lines, UIElement source, int contextLineCount) | |||
{ | |||
viewer.Clear(); | |||
var diffViewer = source as DiffViewer; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this work also for InlineDiffviewer too? If so, we can make a common interface for both to pass into this instead of UIElement.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This has been pushed
DiffPlex.Wpf/Controls/Helper.cs
Outdated
if (diffViewer.IsTextWrapEnabled) | ||
{ | ||
var c = viewer.Add(null, null, null as string, ChangeType.Unchanged.ToString(), source); | ||
c.Tag = line; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be done once after the block with a base element for c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This has been pushed
DiffPlex.Wpf/Controls/Helper.cs
Outdated
if (diffViewer.IsTextWrapEnabled) | ||
{ | ||
var c = viewer.Add(line.Position, "+", details, changeType.ToString(), source); | ||
c.Tag = line; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This has been pushed
|
||
public WrapPanel Add(int? number, string operation, List<KeyValuePair<string, string>> value, string changeType, UIElement source) | ||
{ | ||
if (source is DiffViewer diffViewer) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment here, we should support inlinedifferviewer and not do this check.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This has been pushed
…ewer and SideBySideDiffViewer
@mmanela any progress on this PR? |
Added the ability to wrap text by calling
DiffView.EnableTextWrapping()
. This addresses issue #113IsTextWrapEnabled
) that keeps track if the text should be wrapped or not(IfDiffViewer. ToggleTextWrapping()
is called).!IsTextWrapEnabled
then theAdd()
method would simply create aStackPanel
with horizontal Orientation, which does not allow text wrapping.IsTextWrapEnabled
theAdd()
method would create aWrapPanel
instead with the same orientation asStackPanel
, which does allow text wrapping.number,operation,text
variables align within the DiffViewer.IsTextWrapEnabled
then we would set the Horizontal scroll bar visibility to hidden/disabledBelow is an example of the text wrapping:
https://github.com/user-attachments/assets/53d3d13e-6338-4336-92f9-a566412f1fbc