Skip to content

Commit 5054395

Browse files
committed
Fix #429
1 parent 2a326b7 commit 5054395

File tree

3 files changed

+38
-13
lines changed

3 files changed

+38
-13
lines changed

CompactGUI.Watcher/Watcher.vb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ Public Class WatchedFolder : Inherits ObservableObject
224224
Public ReadOnly Property DecayPercentage As Decimal
225225
Get
226226
If LastCompressedSize = 0 Then Return 1
227-
Return Math.Clamp((LastCheckedSize - LastCompressedSize) / (LastUncompressedSize - LastCompressedSize), 0, 1)
227+
Return If(LastUncompressedSize = LastCompressedSize OrElse LastCompressedSize > LastUncompressedSize, 0D, Math.Clamp((LastCheckedSize - LastCompressedSize) / (LastUncompressedSize - LastCompressedSize), 0, 1))
228228
End Get
229229
End Property
230230

CompactGUI/Views/MainWindow.xaml

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1156,15 +1156,15 @@
11561156
<ui:FontIcon Glyph="&#xE9F3;" FontSize="14" />
11571157
</Button>
11581158

1159-
<ui:ListView x:Name="uiWatcherListView" Margin="-10,60,0,0" Padding="0" Width="480" ItemsSource="{Binding Source = {StaticResource src}}" d:ItemsSource="{d:SampleData}" KeyboardNavigation.TabNavigation="None">
1159+
<ui:ListView x:Name="uiWatcherListView" Margin="-10,60,0,0" Padding="0" Width="480" ItemsSource="{Binding Source = {StaticResource src}}" d:ItemsSource="{d:SampleData}" KeyboardNavigation.TabNavigation="None" ui:ScrollViewerHelper.AutoHideScrollBars="False">
11601160
<ui:ListView.ItemContainerStyle>
11611161
<Style TargetType="ui:ListViewItem">
11621162
<Setter Property="Margin" Value="0,0,0,10"/>
11631163
</Style>
11641164
</ui:ListView.ItemContainerStyle>
11651165
<ui:ListView.ItemTemplate >
11661166
<DataTemplate >
1167-
<Border Padding="6" Background="WhiteSmoke" d:Height="100" Height="50" Width="470" KeyboardNavigation.TabNavigation="None">
1167+
<Border Padding="6" Background="WhiteSmoke" d:Height="100" Height="50" Width="470" KeyboardNavigation.TabNavigation="None" MouseDown="ToggleBorderHeight" MouseEnter="ToggleBorderHeight">
11681168

11691169
<Grid >
11701170
<Label>
@@ -1226,16 +1226,7 @@
12261226

12271227

12281228
</Grid>
1229-
<bh:Interaction.Triggers>
1230-
<bh:EventTrigger EventName="MouseEnter">
1231-
<bh:ChangePropertyAction TargetObject="{Binding RelativeSource={RelativeSource AncestorType={x:Type Border}}}" PropertyName="Height" Value="100" Duration="00:00:00.2"/>
1232-
</bh:EventTrigger>
1233-
<bh:EventTrigger EventName="MouseLeave">
1234-
<bh:ChangePropertyAction TargetObject="{Binding RelativeSource={RelativeSource AncestorType={x:Type Border}}}" PropertyName="Height" Value="50" Duration="00:00:00.2"/>
1235-
</bh:EventTrigger>
1236-
1237-
</bh:Interaction.Triggers>
1238-
1229+
12391230
</Border>
12401231
</DataTemplate>
12411232
</ui:ListView.ItemTemplate>

CompactGUI/Views/MainWindow.xaml.vb

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ Imports MethodTimer
33
Imports System.Windows.Media.Animation
44
Imports ModernWpf.Controls
55
Imports CompactGUI.Core
6+
Imports System.Windows.Threading
67

78
Class MainWindow
89

@@ -69,4 +70,37 @@ Class MainWindow
6970
If Me.Top < 0 Then Me.Top = 0
7071

7172
End Sub
73+
74+
Private currentlyExpandedBorder As Border = Nothing
75+
76+
77+
Private Sub ToggleBorderHeight(sender As Object, e As RoutedEventArgs)
78+
Dim border As Border = DirectCast(sender, Border)
79+
Dim newHeight As Double = If(border.Height = 100, 50, 100)
80+
81+
If currentlyExpandedBorder IsNot Nothing AndAlso currentlyExpandedBorder IsNot border Then
82+
AnimateBorderHeight(currentlyExpandedBorder, 50)
83+
End If
84+
85+
AnimateBorderHeight(border, newHeight)
86+
currentlyExpandedBorder = If(newHeight = 100, border, Nothing)
87+
End Sub
88+
89+
Private Sub AnimateBorderHeight(border As Border, targetHeight As Double)
90+
Dim animation As New DoubleAnimation() With {
91+
.From = border.ActualHeight,
92+
.To = targetHeight,
93+
.Duration = TimeSpan.FromSeconds(0.2)
94+
}
95+
96+
Dim storyboard As New Storyboard()
97+
Storyboard.SetTarget(animation, border)
98+
Storyboard.SetTargetProperty(animation, New PropertyPath(Border.HeightProperty))
99+
100+
storyboard.Children.Add(animation)
101+
storyboard.Begin()
102+
End Sub
103+
104+
105+
72106
End Class

0 commit comments

Comments
 (0)