Browse Source

added copy-button to diff-tooltip

pull/15/head
Siegfried Pammer 15 years ago
parent
commit
aeee313f0b
  1. 5
      src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/ChangeMarkerMargin.cs
  2. 13
      src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/DiffControl.xaml
  3. 15
      src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/DiffControl.xaml.cs

5
src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/ChangeMarkerMargin.cs

@ -153,6 +153,8 @@ namespace ICSharpCode.AvalonEdit.AddIn @@ -153,6 +153,8 @@ namespace ICSharpCode.AvalonEdit.AddIn
differ.editor.Document.Text = oldText;
differ.Background = Brushes.White;
// TODO : deletions on line 0 cannot be displayed.
LineChangeInfo prevLineInfo = changeWatcher.GetChange(startLine - 1);
LineChangeInfo lineInfo = changeWatcher.GetChange(startLine);
@ -163,6 +165,7 @@ namespace ICSharpCode.AvalonEdit.AddIn @@ -163,6 +165,7 @@ namespace ICSharpCode.AvalonEdit.AddIn
if (oldText == string.Empty) {
differ.editor.Visibility = Visibility.Collapsed;
differ.copyButton.Visibility = Visibility.Collapsed;
} else {
var baseDocument = new TextDocument(changeWatcher.BaseDocument.Text);
var mainHighlighter = new DocumentHighlighter(baseDocument, differ.editor.SyntaxHighlighting.MainRuleSet);
@ -174,7 +177,7 @@ namespace ICSharpCode.AvalonEdit.AddIn @@ -174,7 +177,7 @@ namespace ICSharpCode.AvalonEdit.AddIn
popupHighlighter.InitialSpanStack = mainHighlighter.GetSpanStack(lineInfo.OldStartLineNumber);
}
differ.undoButton.Click += delegate {
differ.revertButton.Click += delegate {
if (hasNewVersion) {
int delimiter = 0;
DocumentLine l = Document.GetLineByOffset(offset + length);

13
src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/DiffControl.xaml

@ -1,11 +1,18 @@ @@ -1,11 +1,18 @@
<UserControl x:Class="ICSharpCode.AvalonEdit.AddIn.DiffControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:sd="http://icsharpcode.net/sharpdevelop/core"
xmlns:ae="http://icsharpcode.net/sharpdevelop/avalonedit"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<StackPanel Orientation="Vertical">
<ToolBar>
<Button x:Name="undoButton" Content="Undo" />
<ToolBar ToolBarTray.IsLocked="True" ToolBar.OverflowMode="Never">
<Button x:Name="revertButton"
Content="{sd:Localize AddIns.Subversion.Revert}"
ToolTip="{sd:Localize AddIns.Subversion.Revert}" />
<Button x:Name="copyButton"
Click="CopyButtonClick"
Content="{sd:Localize ProjectComponent.ContextMenu.AddExistingFiles.Copy}"
ToolTip="{sd:Localize ProjectComponent.ContextMenu.AddExistingFiles.Copy}" />
</ToolBar>
<ae:TextEditor x:Name="editor" />
<ae:TextEditor x:Name="editor" IsReadOnly="True" />
</StackPanel>
</UserControl>

15
src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/DiffControl.xaml.cs

@ -24,7 +24,20 @@ namespace ICSharpCode.AvalonEdit.AddIn @@ -24,7 +24,20 @@ namespace ICSharpCode.AvalonEdit.AddIn
{
InitializeComponent();
undoButton.Content = PresentationResourceService.GetImage("Icons.16x16.UndoIcon");
revertButton.Content = PresentationResourceService.GetImage("Icons.16x16.UndoIcon");
copyButton.Content = PresentationResourceService.GetImage("Icons.16x16.CopyIcon");
}
void CopyButtonClick(object sender, RoutedEventArgs e)
{
if (editor.SelectionLength == 0) {
int offset = editor.CaretOffset;
editor.SelectAll();
editor.Copy();
editor.Select(offset, 0);
} else {
editor.Copy();
}
}
}
}
Loading…
Cancel
Save