Skip to content

Commit

Permalink
feat: 完善界面
Browse files Browse the repository at this point in the history
  • Loading branch information
tangge233 committed Oct 17, 2024
1 parent 9d0a496 commit eb86965
Show file tree
Hide file tree
Showing 2 changed files with 94 additions and 83 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
mc:Ignorable="d" x:Class="PageDownloadCompFavorites"
PanScroll="{Binding ElementName=PanBack}">
<Grid>
<local:MyScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled" x:Name="PanBack">
<Grid>
<Grid x:Name="PanContent">
<Grid x:Name="PanContent">
<local:MyScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled" x:Name="PanBack">
<Grid>
<StackPanel Orientation="Vertical" Margin="25">
<StackPanel>
<local:MySearchBox HintText="搜索收藏夹内容" x:Name="PanSearchBox" Margin="0,0,0,15"/>
<local:MyHint Text="部分资源在线信息获取失败,当前收藏夹内容可能不齐全。" IsWarn="True" Margin="0,0,0,15" x:Name="HintGetFail"/>
<local:MyHint Text="部分资源在线信息获取失败,当前收藏夹内容可能不齐全。" IsWarn="True" Margin="0,0,0,15" x:Name="HintGetFail" Visibility="Collapsed"/>
<local:MyCard x:Name="CardProjectsMod" Title="Mod" IsSwaped="True" CanSwap="True" Margin="0,0,0,15">
<StackPanel x:Name="PanProjectsMod" Margin="12,38,12,12" />
</local:MyCard>
Expand All @@ -20,43 +20,43 @@
</local:MyCard>
</StackPanel>
</StackPanel>
<local:MyCard HorizontalAlignment="Center" VerticalAlignment="Center" Margin="40" x:Name="CardNoContent">
<Grid Margin="20,17">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="1*" />
</Grid.ColumnDefinitions>
<TextBlock Grid.Row="0" Grid.ColumnSpan="4" Margin="0,0,0,9" HorizontalAlignment="Center" Text="还没有收藏内容" FontSize="19" UseLayoutRounding="True" SnapsToDevicePixels="True" Foreground="{DynamicResource ColorBrush3}" />
<Rectangle Grid.Row="1" Grid.ColumnSpan="4" HorizontalAlignment="Stretch" Height="2" Fill="{DynamicResource ColorBrush3}" />
<TextBlock Grid.Row="2" Grid.ColumnSpan="4" Margin="10,15,10,5" Text="在资源详细信息界面中可以点击收藏按钮进行收藏" TextWrapping="Wrap" />
</Grid>
</local:MyCard>
</Grid>
</Grid>
</local:MyScrollViewer>
</local:MyScrollViewer>
<local:MyCard HorizontalAlignment="Center" VerticalAlignment="Center" Margin="40" x:Name="CardNoContent" Visibility="Collapsed">
<Grid Margin="20,17">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="1*" />
</Grid.ColumnDefinitions>
<TextBlock Grid.Row="0" Grid.ColumnSpan="4" Margin="0,0,0,9" HorizontalAlignment="Center" Text="还没有收藏内容" FontSize="19" UseLayoutRounding="True" SnapsToDevicePixels="True" Foreground="{DynamicResource ColorBrush3}" />
<Rectangle Grid.Row="1" Grid.ColumnSpan="4" HorizontalAlignment="Stretch" Height="2" Fill="{DynamicResource ColorBrush3}" />
<TextBlock Grid.Row="2" Grid.ColumnSpan="4" Margin="10,15,10,5" Text="在资源详细信息界面中可以点击收藏按钮进行收藏" TextWrapping="Wrap" />
</Grid>
</local:MyCard>
<local:MyCard x:Name="CardSelect" Visibility="Collapsed" Opacity="0"
HorizontalAlignment="Center" VerticalAlignment="Bottom" Margin="25,25,25,0" UseAnimation="False" HasMouseAnimation="False">
<local:MyCard.RenderTransform>
<TranslateTransform x:Name="TransSelect" Y="-10" />
</local:MyCard.RenderTransform>
<TextBlock x:Name="LabSelect" Text="已选择 8 个文件" HorizontalAlignment="Center" VerticalAlignment="Top" Margin="9" Foreground="{DynamicResource ColorBrush2}" />
<StackPanel Orientation="Horizontal" Margin="5,28,5,5">
<local:MyIconTextButton x:Name="Btn_FavoritesCancel" Text="取消收藏"
LogoScale="1" Logo="M700.856 155.543c-74.769 0-144.295 72.696-190.046 127.26-45.737-54.576-115.247-127.26-190.056-127.26-134.79 0-244.443 105.78-244.443 235.799 0 77.57 39.278 131.988 70.845 175.713C238.908 694.053 469.62 852.094 479.39 858.757c9.41 6.414 20.424 9.629 31.401 9.629 11.006 0 21.998-3.215 31.398-9.63 9.782-6.662 240.514-164.703 332.238-291.701 31.587-43.724 70.874-98.143 70.874-175.713-0.001-130.02-109.656-235.8-244.445-235.8z m0 0" />
<local:MyIconTextButton x:Name="Btn_SelectCancel" Text="取消选择"
LogoScale="0.8" Logo="M867.648 951.296 512 595.648l-355.648 355.648c-11.52 11.52-30.272 11.52-41.856 0L72.64 909.44c-11.52-11.52-11.52-30.272 0-41.856L428.352 512 72.64 156.352c-11.52-11.52-11.52-30.272 0-41.856l41.856-41.856c11.52-11.52 30.272-11.52 41.856 0L512 428.288l355.648-355.648c11.52-11.52 30.272-11.52 41.856 0l41.856 41.856c11.52 11.52 11.52 30.272 0 41.856L595.648 512l355.648 355.648c11.52 11.52 11.52 30.272 0 41.856l-41.856 41.856C897.984 962.88 879.168 962.88 867.648 951.296L867.648 951.296z" />
</StackPanel>
</local:MyCard>
</Grid>
<local:MyCard HorizontalAlignment="Center" VerticalAlignment="Center" SnapsToDevicePixels="True" x:Name="PanLoad" UseAnimation="False" Margin="40,50">
<local:MyLoading Text="正在加载收藏夹列表" Margin="20,20,20,17" x:Name="Load" HorizontalAlignment="Center" VerticalAlignment="Center" />
</local:MyCard>
<local:MyCard x:Name="CardSelect" Visibility="Collapsed" Opacity="0"
HorizontalAlignment="Center" VerticalAlignment="Bottom" Margin="25,25,25,0" UseAnimation="False" HasMouseAnimation="False">
<local:MyCard.RenderTransform>
<TranslateTransform x:Name="TransSelect" Y="-10" />
</local:MyCard.RenderTransform>
<TextBlock x:Name="LabSelect" Text="已选择 8 个文件" HorizontalAlignment="Center" VerticalAlignment="Top" Margin="9" Foreground="{DynamicResource ColorBrush2}" />
<StackPanel Orientation="Horizontal" Margin="5,28,5,5">
<local:MyIconTextButton x:Name="Btn_FavoritesCancel" Text="取消收藏"
LogoScale="1" Logo="M700.856 155.543c-74.769 0-144.295 72.696-190.046 127.26-45.737-54.576-115.247-127.26-190.056-127.26-134.79 0-244.443 105.78-244.443 235.799 0 77.57 39.278 131.988 70.845 175.713C238.908 694.053 469.62 852.094 479.39 858.757c9.41 6.414 20.424 9.629 31.401 9.629 11.006 0 21.998-3.215 31.398-9.63 9.782-6.662 240.514-164.703 332.238-291.701 31.587-43.724 70.874-98.143 70.874-175.713-0.001-130.02-109.656-235.8-244.445-235.8z m0 0" />
<local:MyIconTextButton x:Name="Btn_SelectCancel" Text="取消选择"
LogoScale="0.8" Logo="M867.648 951.296 512 595.648l-355.648 355.648c-11.52 11.52-30.272 11.52-41.856 0L72.64 909.44c-11.52-11.52-11.52-30.272 0-41.856L428.352 512 72.64 156.352c-11.52-11.52-11.52-30.272 0-41.856l41.856-41.856c11.52-11.52 30.272-11.52 41.856 0L512 428.288l355.648-355.648c11.52-11.52 30.272-11.52 41.856 0l41.856 41.856c11.52 11.52 11.52 30.272 0 41.856L595.648 512l355.648 355.648c11.52 11.52 11.52 30.272 0 41.856l-41.856 41.856C897.984 962.88 879.168 962.88 867.648 951.296L867.648 951.296z" />
</StackPanel>
</local:MyCard>
</Grid>
</local:MyPageRight>
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
PageLoaderInit(Load, PanLoad, PanContent, Nothing, Loader, AddressOf Load_OnFinish, AddressOf LoaderInput)
End Sub
Private Sub PageDownloadCompFavorites_Loaded(sender As Object, e As EventArgs) Handles Me.Loaded
SelectedItemList.Clear()
RefreshBar()
If Loader.Input IsNot Nothing AndAlso Not Loader.Input.Equals(CompFavorites.GetAll()) Then
Loader.Start()
End If
Expand All @@ -27,57 +29,62 @@
#Region "UI 化"
'结果 UI 化
Private Sub Load_OnFinish()
CompItemList.Clear()
For Each item In Loader.Output
Dim CompItem = item.ToMiniCompItem()

'----添加按钮----
'删除按钮
Dim Btn_Delete As New MyIconButton
Btn_Delete.Logo = Logo.IconButtonLikeFill
Btn_Delete.ToolTip = "取消收藏"
ToolTipService.SetPlacement(Btn_Delete, Primitives.PlacementMode.Center)
ToolTipService.SetVerticalOffset(Btn_Delete, 30)
ToolTipService.SetHorizontalOffset(Btn_Delete, 2)
AddHandler Btn_Delete.Click, Sub(sender As Object, e As EventArgs)
Items_CancelFavorites(CompItem)
RefreshContent()
RefreshCardTitle()
RefreshBar()
End Sub
CompItem.Buttons = {Btn_Delete}
'---操作逻辑---
'右键查看详细信息界面
AddHandler CompItem.MouseRightButtonUp, Sub(sender As Object, e As EventArgs)
FrmMain.PageChange(New FormMain.PageStackData With {.Page = FormMain.PageType.CompDetail,
.Additional = {CompItem.Entry, New List(Of String), String.Empty, CompModLoaderType.Any}})
End Sub
'---其它事件---
AddHandler CompItem.Changed, AddressOf ItemCheckStatusChanged
CompItemList.Add(CompItem)
Next
Try
If Loader.Input.Any() Then '有收藏
PanSearchBox.Visibility = Visibility.Visible
CardProjectsMod.Visibility = Visibility.Visible
CardProjectsModpack.Visibility = Visibility.Visible
CardNoContent.Visibility = Visibility.Collapsed
RefreshContent()
Else '没有收藏
PanSearchBox.Visibility = Visibility.Collapsed
CardProjectsMod.Visibility = Visibility.Collapsed
CardProjectsModpack.Visibility = Visibility.Collapsed
CardNoContent.Visibility = Visibility.Visible
End If
RemoveHandler PanSearchBox.TextChanged, AddressOf SearchRun
PanSearchBox.Text = String.Empty
AddHandler PanSearchBox.TextChanged, AddressOf SearchRun
CompItemList.Clear()
HintGetFail.Visibility = If(Loader.Input.Count = Loader.Output.Count, Visibility.Collapsed, Visibility.Visible)
For Each item In Loader.Output
Dim CompItem = item.ToMiniCompItem()

'----添加按钮----
'删除按钮
Dim Btn_Delete As New MyIconButton
Btn_Delete.Logo = Logo.IconButtonLikeFill
Btn_Delete.ToolTip = "取消收藏"
ToolTipService.SetPlacement(Btn_Delete, Primitives.PlacementMode.Center)
ToolTipService.SetVerticalOffset(Btn_Delete, 30)
ToolTipService.SetHorizontalOffset(Btn_Delete, 2)
AddHandler Btn_Delete.Click, Sub(sender As Object, e As EventArgs)
Items_CancelFavorites(CompItem)
RefreshContent()
RefreshCardTitle()
RefreshBar()
End Sub
CompItem.Buttons = {Btn_Delete}
'---操作逻辑---
'右键查看详细信息界面
AddHandler CompItem.MouseRightButtonUp, Sub(sender As Object, e As EventArgs)
FrmMain.PageChange(New FormMain.PageStackData With {.Page = FormMain.PageType.CompDetail,
.Additional = {CompItem.Entry, New List(Of String), String.Empty, CompModLoaderType.Any}})
End Sub
'---其它事件---
AddHandler CompItem.Changed, AddressOf ItemCheckStatusChanged
CompItemList.Add(CompItem)
Next
RefreshCardTitle()
RefreshContent()
Catch ex As Exception
Log(ex, "可视化收藏夹列表出错", LogLevel.Feedback)
End Try
End Sub

Private Sub RefreshContent()
Private Sub RefreshContent() 'TODO: fix:在搜索时,使用下边栏取消收藏会使得整个界面变空
If CompItemList.Any() Then '有收藏
If Not IsSearching Then
PanSearchBox.Visibility = Visibility.Visible
CardProjectsMod.Visibility = Visibility.Visible
CardProjectsModpack.Visibility = Visibility.Visible
CardNoContent.Visibility = Visibility.Collapsed
End If
Else '没有收藏
PanSearchBox.Visibility = Visibility.Collapsed
CardProjectsMod.Visibility = Visibility.Collapsed
CardProjectsModpack.Visibility = Visibility.Collapsed
CardNoContent.Visibility = Visibility.Visible
End If

PanProjectsMod.Children.Clear()
PanProjectsModpack.Children.Clear()
Dim DataSource As List(Of MyMiniCompItem) = If(IsSearching, SearchResult, CompItemList)
Expand Down Expand Up @@ -182,7 +189,7 @@
Dim ErrorMessage As String = ""
If Loader.Error IsNot Nothing Then ErrorMessage = Loader.Error.Message
If ErrorMessage.Contains("不是有效的 json 文件") Then
Log("[Download] 下载的 Mod 列表 json 文件损坏,已自动重试", LogLevel.Debug)
Log("[Download] 下载的工程列表 JSON 文件损坏,已自动重试", LogLevel.Debug)
PageLoaderRestart()
End If
End Select
Expand Down Expand Up @@ -216,6 +223,10 @@
CompFavorites.Del(Item.Entry.Id)
End Sub

Private Sub Page_KeyDown(sender As Object, e As KeyEventArgs) Handles Me.KeyDown
If My.Computer.Keyboard.CtrlKeyDown AndAlso e.Key = Key.A Then Items_SetSelectAll(True)
End Sub

#Region "搜索"

Private ReadOnly Property IsSearching As Boolean
Expand All @@ -224,8 +235,8 @@
End Get
End Property

Private SearchResult As List(Of MyMiniCompItem)
Public Sub SearchRun() Handles PanSearchBox.TextChanged
Private SearchResult As New List(Of MyMiniCompItem)
Public Sub SearchRun()
If IsSearching Then
'构造请求
Dim QueryList As New List(Of SearchEntry(Of MyMiniCompItem))
Expand Down

0 comments on commit eb86965

Please sign in to comment.