Skip to content

Commit

Permalink
Fix #429
Browse files Browse the repository at this point in the history
  • Loading branch information
Iridium-IO committed Jun 28, 2024
1 parent 2a326b7 commit 5054395
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 13 deletions.
2 changes: 1 addition & 1 deletion CompactGUI.Watcher/Watcher.vb
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ Public Class WatchedFolder : Inherits ObservableObject
Public ReadOnly Property DecayPercentage As Decimal
Get
If LastCompressedSize = 0 Then Return 1
Return Math.Clamp((LastCheckedSize - LastCompressedSize) / (LastUncompressedSize - LastCompressedSize), 0, 1)
Return If(LastUncompressedSize = LastCompressedSize OrElse LastCompressedSize > LastUncompressedSize, 0D, Math.Clamp((LastCheckedSize - LastCompressedSize) / (LastUncompressedSize - LastCompressedSize), 0, 1))
End Get
End Property

Expand Down
15 changes: 3 additions & 12 deletions CompactGUI/Views/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -1156,15 +1156,15 @@
<ui:FontIcon Glyph="&#xE9F3;" FontSize="14" />
</Button>

<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: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">
<ui:ListView.ItemContainerStyle>
<Style TargetType="ui:ListViewItem">
<Setter Property="Margin" Value="0,0,0,10"/>
</Style>
</ui:ListView.ItemContainerStyle>
<ui:ListView.ItemTemplate >
<DataTemplate >
<Border Padding="6" Background="WhiteSmoke" d:Height="100" Height="50" Width="470" KeyboardNavigation.TabNavigation="None">
<Border Padding="6" Background="WhiteSmoke" d:Height="100" Height="50" Width="470" KeyboardNavigation.TabNavigation="None" MouseDown="ToggleBorderHeight" MouseEnter="ToggleBorderHeight">

<Grid >
<Label>
Expand Down Expand Up @@ -1226,16 +1226,7 @@


</Grid>
<bh:Interaction.Triggers>
<bh:EventTrigger EventName="MouseEnter">
<bh:ChangePropertyAction TargetObject="{Binding RelativeSource={RelativeSource AncestorType={x:Type Border}}}" PropertyName="Height" Value="100" Duration="00:00:00.2"/>
</bh:EventTrigger>
<bh:EventTrigger EventName="MouseLeave">
<bh:ChangePropertyAction TargetObject="{Binding RelativeSource={RelativeSource AncestorType={x:Type Border}}}" PropertyName="Height" Value="50" Duration="00:00:00.2"/>
</bh:EventTrigger>

</bh:Interaction.Triggers>


</Border>
</DataTemplate>
</ui:ListView.ItemTemplate>
Expand Down
34 changes: 34 additions & 0 deletions CompactGUI/Views/MainWindow.xaml.vb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ Imports MethodTimer
Imports System.Windows.Media.Animation
Imports ModernWpf.Controls
Imports CompactGUI.Core
Imports System.Windows.Threading

Class MainWindow

Expand Down Expand Up @@ -69,4 +70,37 @@ Class MainWindow
If Me.Top < 0 Then Me.Top = 0

End Sub

Private currentlyExpandedBorder As Border = Nothing


Private Sub ToggleBorderHeight(sender As Object, e As RoutedEventArgs)
Dim border As Border = DirectCast(sender, Border)
Dim newHeight As Double = If(border.Height = 100, 50, 100)

If currentlyExpandedBorder IsNot Nothing AndAlso currentlyExpandedBorder IsNot border Then
AnimateBorderHeight(currentlyExpandedBorder, 50)
End If

AnimateBorderHeight(border, newHeight)
currentlyExpandedBorder = If(newHeight = 100, border, Nothing)
End Sub

Private Sub AnimateBorderHeight(border As Border, targetHeight As Double)
Dim animation As New DoubleAnimation() With {
.From = border.ActualHeight,
.To = targetHeight,
.Duration = TimeSpan.FromSeconds(0.2)
}

Dim storyboard As New Storyboard()
Storyboard.SetTarget(animation, border)
Storyboard.SetTargetProperty(animation, New PropertyPath(Border.HeightProperty))

storyboard.Children.Add(animation)
storyboard.Begin()
End Sub



End Class

0 comments on commit 5054395

Please sign in to comment.