mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-23 20:47:25 -08:00
feature<TextEdit>: supports scroll by mouse wheel
This commit is contained in:
parent
8fa3a558a0
commit
b0d5c1fd52
4 changed files with 47 additions and 2 deletions
|
@ -35,6 +35,24 @@ namespace SourceGit.Views.Controls {
|
||||||
SelectionChanged += OnSelectionChanged;
|
SelectionChanged += OnSelectionChanged;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void OnMouseWheel(MouseWheelEventArgs e) {
|
||||||
|
base.OnMouseWheel(e);
|
||||||
|
|
||||||
|
if (Keyboard.IsKeyDown(Key.LeftShift) || Keyboard.IsKeyDown(Key.RightShift)) {
|
||||||
|
if (e.Delta > 0) {
|
||||||
|
LineLeft();
|
||||||
|
} else {
|
||||||
|
LineRight();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (e.Delta > 0) {
|
||||||
|
LineUp();
|
||||||
|
} else {
|
||||||
|
LineDown();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void OnTextChanged(object sender, TextChangedEventArgs e) {
|
private void OnTextChanged(object sender, TextChangedEventArgs e) {
|
||||||
PlaceholderVisibility = string.IsNullOrEmpty(Text) ? Visibility.Visible : Visibility.Collapsed;
|
PlaceholderVisibility = string.IsNullOrEmpty(Text) ? Visibility.Visible : Visibility.Collapsed;
|
||||||
}
|
}
|
||||||
|
|
|
@ -170,7 +170,7 @@
|
||||||
BorderThickness="0"
|
BorderThickness="0"
|
||||||
TextWrapping="Wrap"
|
TextWrapping="Wrap"
|
||||||
Margin="11,5,16,0"
|
Margin="11,5,16,0"
|
||||||
MaxHeight="80"
|
MaxHeight="100"
|
||||||
HorizontalScrollBarVisibility="Disabled"
|
HorizontalScrollBarVisibility="Disabled"
|
||||||
VerticalScrollBarVisibility="Auto"
|
VerticalScrollBarVisibility="Auto"
|
||||||
VerticalAlignment="Top"/>
|
VerticalAlignment="Top"/>
|
||||||
|
|
|
@ -6,6 +6,7 @@ using System.Threading.Tasks;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
using System.Windows.Input;
|
using System.Windows.Input;
|
||||||
|
using System.Windows.Media;
|
||||||
using System.Windows.Navigation;
|
using System.Windows.Navigation;
|
||||||
|
|
||||||
namespace SourceGit.Views.Widgets {
|
namespace SourceGit.Views.Widgets {
|
||||||
|
@ -44,6 +45,7 @@ namespace SourceGit.Views.Widgets {
|
||||||
private void UpdateInformation(Models.Commit commit) {
|
private void UpdateInformation(Models.Commit commit) {
|
||||||
txtSHA.Text = commit.SHA;
|
txtSHA.Text = commit.SHA;
|
||||||
txtMessage.Text = (commit.Subject + "\n\n" + commit.Message.Trim()).Trim();
|
txtMessage.Text = (commit.Subject + "\n\n" + commit.Message.Trim()).Trim();
|
||||||
|
txtMessage.ScrollToHome();
|
||||||
|
|
||||||
avatarAuthor.Email = commit.Author.Email;
|
avatarAuthor.Email = commit.Author.Email;
|
||||||
avatarAuthor.FallbackLabel = commit.Author.Name;
|
avatarAuthor.FallbackLabel = commit.Author.Name;
|
||||||
|
@ -90,6 +92,10 @@ namespace SourceGit.Views.Widgets {
|
||||||
|
|
||||||
Dispatcher.Invoke(() => {
|
Dispatcher.Invoke(() => {
|
||||||
changeList.ItemsSource = changes;
|
changeList.ItemsSource = changes;
|
||||||
|
|
||||||
|
ScrollViewer sw = GetVisualChild<ScrollViewer>(changeList);
|
||||||
|
if (sw != null) sw.ScrollToHome();
|
||||||
|
|
||||||
changeContainer.SetData(repo, new List<Models.Commit>() { commit }, changes);
|
changeContainer.SetData(repo, new List<Models.Commit>() { commit }, changes);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -189,5 +195,25 @@ namespace SourceGit.Views.Widgets {
|
||||||
e.Handled = true;
|
e.Handled = true;
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
private T GetVisualChild<T>(DependencyObject parent) where T : Visual {
|
||||||
|
T child = null;
|
||||||
|
|
||||||
|
int count = VisualTreeHelper.GetChildrenCount(parent);
|
||||||
|
for (int i = 0; i < count; i++) {
|
||||||
|
Visual v = (Visual)VisualTreeHelper.GetChild(parent, i);
|
||||||
|
child = v as T;
|
||||||
|
|
||||||
|
if (child == null) {
|
||||||
|
child = GetVisualChild<T>(v);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (child != null) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return child;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,10 +53,11 @@
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition Width="24"/>
|
<ColumnDefinition Width="24"/>
|
||||||
<ColumnDefinition Width="*"/>
|
<ColumnDefinition Width="*"/>
|
||||||
|
<ColumnDefinition Width="10"/>
|
||||||
</Grid.ColumnDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
|
|
||||||
<Border
|
<Border
|
||||||
Grid.Column="0" Grid.ColumnSpan="2"
|
Grid.Column="0" Grid.ColumnSpan="3"
|
||||||
Background="{DynamicResource Brush.Contents}"
|
Background="{DynamicResource Brush.Contents}"
|
||||||
BorderThickness="1" BorderBrush="{DynamicResource Brush.Border0}"
|
BorderThickness="1" BorderBrush="{DynamicResource Brush.Border0}"
|
||||||
CornerRadius="14"/>
|
CornerRadius="14"/>
|
||||||
|
|
Loading…
Reference in a new issue