Skip to content

Commit 831f1d0

Browse files
committed
* Code improvements to scrolling
1 parent 531fd57 commit 831f1d0

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

MemPlus/Windows/ApplicationLogWindow.xaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
UseLayoutRounding="True"
1111
WindowStartupLocation="CenterScreen"
1212
TitleTextAlignment="Center"
13-
Title="MemPlus - Application Logs" Height="300" Width="300">
13+
Title="MemPlus - Application Logs" Height="300" Width="300" Icon="/MemPlus;component/Resources/ram.png">
1414
<Grid>
1515
<Grid.RowDefinitions>
1616
<RowDefinition></RowDefinition>

MemPlus/Windows/ApplicationLogWindow.xaml.cs

+3-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
using System;
2-
using System.Diagnostics;
32
using System.Linq;
4-
using System.Windows;
53
using System.Windows.Controls;
64
using System.Windows.Controls.Primitives;
75
using MemPlus.Classes;
@@ -66,8 +64,7 @@ private void LogAddedEvent(Log log)
6664

6765
if (_autoScroll)
6866
{
69-
LsvLogs.SelectedIndex = LsvLogs.Items.Count - 1;
70-
LsvLogs.ScrollIntoView(LsvLogs.SelectedItem);
67+
LsvLogs.ScrollIntoView(LsvLogs.Items[LsvLogs.Items.Count - 1]);
7168
}
7269
});
7370
}
@@ -81,9 +78,9 @@ private void ChangeVisualStyle()
8178

8279
private void LsvLogs_OnScroll(object sender, ScrollEventArgs e)
8380
{
84-
ScrollBar sb = e.OriginalSource as ScrollBar;
81+
if (!(e.OriginalSource is ScrollBar sb)) return;
8582

86-
if (sb != null && sb.Orientation == Orientation.Horizontal)
83+
if (sb.Orientation == Orientation.Horizontal)
8784
return;
8885
_autoScroll = Math.Abs(sb.Value - sb.Maximum) < 1;
8986
}

0 commit comments

Comments
 (0)