画面解像度によってMoveJukeBoxのショーケース表示アイテム数を変更する
最近ノートPCを3台買い、うち2台はFull-HD(1920x1080)でなくHD(1366x768)でした。
MovieJukeBoxはFull-HDで使用する前提で作っていたので、HDでも最適に表示させるように変更します。
設定から画面解像度を選ぶとクッキーに解像度を書き込んで、それをListViewのPreRender時に読み込んで、表示するアイテム数を可変させます。アイテム数だけでなくデータページャーの数字ボタンの表示数も可変させます。
ただし、HD解像度向けに最適化する画面はメイン画面のショーケースだけに留めます。大変だから。
DataPagerのNumericPagerfieldのButtonCountのプロパティが見当たらなくて躓いてしまいました。下記を参考にして実装しました。
DataPager.Fields プロパティ (System.Web.UI.WebControls)
https://msdn.microsoft.com/ja-jp/library/system.web.ui.webcontrols.datapager.fields(v=vs.100).aspx
title="Default8Tile.aspx.vb">
Protected Sub ListViewJukeBox_PreRender(sender As Object, e As System.EventArgs) Handles ListViewJukeBox.PreRender
GenerateJS()
Dim DisplayResolution As String = Request.Cookies("UserSettings")("DisplayResolution")
If DisplayResolution IsNot Nothing Then
Dim intPageSize As Integer
Dim DP1 As DataPager = ListViewJukeBox.FindControl("DataPager1")
Dim DP2 As DataPager = ListViewJukeBox.FindControl("DataPager2")
If DP1 IsNot Nothing And DP2 IsNot Nothing Then
Dim pagerField As New NumericPagerField()
Dim NextPreviousPagerField As New NextPreviousPagerField()
NextPreviousPagerField.ButtonType = ButtonType.Button
NextPreviousPagerField.ShowFirstPageButton = True
NextPreviousPagerField.ShowLastPageButton = True
NextPreviousPagerField.ButtonCssClass = "Pager"
Select Case DisplayResolution
Case "Full-HD"
intPageSize = 36
ListViewJukeBox.GroupItemCount = 12
pagerField.ButtonCount = 80
Case "HD"
intPageSize = 16
ListViewJukeBox.GroupItemCount = 8
pagerField.ButtonCount = 50
Case Else
intPageSize = 36
ListViewJukeBox.GroupItemCount = 12
pagerField.ButtonCount = 80
End Select
DP1.PageSize = intPageSize
DP1.Fields.Clear()
DP1.Fields.Add(NextPreviousPagerField)
DP1.Fields.Add(pagerField)
DP2.PageSize = intPageSize
DP2.Fields.Clear()
DP2.Fields.Add(NextPreviousPagerField)
DP2.Fields.Add(pagerField)
End If
End If
End Sub
(解像度にHDを選択した状態)
(解像度にFull-HDを選択した状態)
コメント
コメントを投稿