From 0d33a86278ef4f10c21debbc7d7350a59a2ef94b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=AB=E5=9F=8Evia?= Date: Sat, 12 Aug 2023 00:44:28 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- VPet-Simulator.Core/Display/ToolBar.xaml | 22 ++++---- .../VPet-Simulator.Core.csproj | 2 +- VPet-Simulator.Core/packages.config | 2 +- .../VPet-Simulator.Windows.Interface.csproj | 2 +- .../packages.config | 2 +- .../Design/AutoUniformGrid.cs | 25 ++++++++- .../VPet-Simulator.Windows.csproj | 19 +++---- .../WinDesign/winBetterBuy.xaml | 43 +++++++++------ .../WinDesign/winBetterBuy.xaml.cs | 52 ++++++++++++++++--- .../WinDesign/winGameSetting.xaml | 2 +- .../WinDesign/winGameSetting.xaml.cs | 4 +- VPet-Simulator.Windows/packages.config | 3 +- 12 files changed, 127 insertions(+), 51 deletions(-) diff --git a/VPet-Simulator.Core/Display/ToolBar.xaml b/VPet-Simulator.Core/Display/ToolBar.xaml index b795a85..cf7ded1 100644 --- a/VPet-Simulator.Core/Display/ToolBar.xaml +++ b/VPet-Simulator.Core/Display/ToolBar.xaml @@ -105,28 +105,28 @@ Foreground="{DynamicResource DARKPrimary}" /> - + - - + - - - - + + + + - - - diff --git a/VPet-Simulator.Core/VPet-Simulator.Core.csproj b/VPet-Simulator.Core/VPet-Simulator.Core.csproj index 731f2a8..9120f46 100644 --- a/VPet-Simulator.Core/VPet-Simulator.Core.csproj +++ b/VPet-Simulator.Core/VPet-Simulator.Core.csproj @@ -81,7 +81,7 @@ ..\packages\Panuon.WPF.1.0.2\lib\net462\Panuon.WPF.dll - ..\packages\Panuon.WPF.UI.1.1.15.3\lib\net462\Panuon.WPF.UI.dll + ..\packages\Panuon.WPF.UI.1.1.15.4\lib\net462\Panuon.WPF.UI.dll diff --git a/VPet-Simulator.Core/packages.config b/VPet-Simulator.Core/packages.config index 36b6e51..5391ae0 100644 --- a/VPet-Simulator.Core/packages.config +++ b/VPet-Simulator.Core/packages.config @@ -3,5 +3,5 @@ - + \ No newline at end of file diff --git a/VPet-Simulator.Windows.Interface/VPet-Simulator.Windows.Interface.csproj b/VPet-Simulator.Windows.Interface/VPet-Simulator.Windows.Interface.csproj index ad38acc..d273cd6 100644 --- a/VPet-Simulator.Windows.Interface/VPet-Simulator.Windows.Interface.csproj +++ b/VPet-Simulator.Windows.Interface/VPet-Simulator.Windows.Interface.csproj @@ -99,7 +99,7 @@ ..\packages\Panuon.WPF.1.0.2\lib\net462\Panuon.WPF.dll - ..\packages\Panuon.WPF.UI.1.1.15.3\lib\net462\Panuon.WPF.UI.dll + ..\packages\Panuon.WPF.UI.1.1.15.4\lib\net462\Panuon.WPF.UI.dll diff --git a/VPet-Simulator.Windows.Interface/packages.config b/VPet-Simulator.Windows.Interface/packages.config index 36b6e51..5391ae0 100644 --- a/VPet-Simulator.Windows.Interface/packages.config +++ b/VPet-Simulator.Windows.Interface/packages.config @@ -3,5 +3,5 @@ - + \ No newline at end of file diff --git a/VPet-Simulator.Windows/Design/AutoUniformGrid.cs b/VPet-Simulator.Windows/Design/AutoUniformGrid.cs index 3dadea8..8133974 100644 --- a/VPet-Simulator.Windows/Design/AutoUniformGrid.cs +++ b/VPet-Simulator.Windows/Design/AutoUniformGrid.cs @@ -1,4 +1,5 @@ -using System; +using Panuon.WPF.UI; +using System; using System.Windows; using System.Windows.Controls.Primitives; @@ -30,21 +31,43 @@ namespace VPet_Simulator.Windows DependencyProperty.Register("ItemsMinHeight", typeof(double), typeof(AutoUniformGrid), new PropertyMetadata(double.NaN)); #endregion + public event RoutedEventHandler Changed + { + add { AddHandler(ChangedEvent, value); } + remove { RemoveHandler(ChangedEvent, value); } + } + + public static readonly RoutedEvent ChangedEvent = + EventManager.RegisterRoutedEvent("Changed", RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(AutoUniformGrid)); + protected override void OnRenderSizeChanged(SizeChangedInfo sizeInfo) { base.OnRenderSizeChanged(sizeInfo); + var isChanged = false; if (!double.IsNaN(ItemsMinWidth)) { var columns = (int)Math.Floor(sizeInfo.NewSize.Width / ItemsMinWidth); + if(Columns != columns) + { + isChanged = true; + } SetCurrentValue(ColumnsProperty, columns); } if (!double.IsNaN(ItemsMinHeight)) { var rows = (int)Math.Floor(sizeInfo.NewSize.Height / ItemsMinHeight); + if(Rows != rows) + { + isChanged = true; + } SetCurrentValue(RowsProperty, rows); } + if(isChanged) + { + RaiseEvent(new RoutedEventArgs(ChangedEvent)); + } } } diff --git a/VPet-Simulator.Windows/VPet-Simulator.Windows.csproj b/VPet-Simulator.Windows/VPet-Simulator.Windows.csproj index 33b08c4..e24967f 100644 --- a/VPet-Simulator.Windows/VPet-Simulator.Windows.csproj +++ b/VPet-Simulator.Windows/VPet-Simulator.Windows.csproj @@ -97,6 +97,9 @@ ..\packages\CSCore.1.2.1.2\lib\net35-client\CSCore.dll + + ..\packages\Facepunch.Steamworks.2.3.3\lib\net46\Facepunch.Steamworks.Win64.dll + ..\packages\LinePutScript.1.9.2\lib\net462\LinePutScript.dll @@ -110,7 +113,7 @@ ..\packages\Panuon.WPF.1.0.2\lib\net462\Panuon.WPF.dll - ..\packages\Panuon.WPF.UI.1.1.15.3\lib\net462\Panuon.WPF.UI.dll + ..\packages\Panuon.WPF.UI.1.1.15.4\lib\net462\Panuon.WPF.UI.dll @@ -126,6 +129,9 @@ 4.0 + + ..\packages\Update.2.4.7\lib\net40\Update.exe + @@ -231,11 +237,6 @@ True - - - ..\packages\Facepunch.Steamworks.2.3.3\lib\net46\Facepunch.Steamworks.Win64.dll - - Code @@ -278,9 +279,6 @@ - - PreserveNewest - PreserveNewest @@ -314,5 +312,8 @@ false + + + \ No newline at end of file diff --git a/VPet-Simulator.Windows/WinDesign/winBetterBuy.xaml b/VPet-Simulator.Windows/WinDesign/winBetterBuy.xaml index 90ce6fd..2f01776 100644 --- a/VPet-Simulator.Windows/WinDesign/winBetterBuy.xaml +++ b/VPet-Simulator.Windows/WinDesign/winBetterBuy.xaml @@ -238,22 +238,33 @@ - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + diff --git a/VPet-Simulator.Windows/WinDesign/winBetterBuy.xaml.cs b/VPet-Simulator.Windows/WinDesign/winBetterBuy.xaml.cs index f2de987..a6295ff 100644 --- a/VPet-Simulator.Windows/WinDesign/winBetterBuy.xaml.cs +++ b/VPet-Simulator.Windows/WinDesign/winBetterBuy.xaml.cs @@ -35,6 +35,8 @@ namespace VPet_Simulator.Windows MainWindow mw; private bool AllowChange = false; private Switch _puswitch; + private int _columns; + private int _rows; public winBetterBuy(MainWindow mw) { @@ -133,7 +135,12 @@ namespace VPet_Simulator.Windows } Dispatcher.Invoke(() => { - IcCommodity.ItemsSource = ordered; + var totalCount = ordered.Count(); + var pageSize = _rows * _columns; + pagination.MaxPage = (int)Math.Ceiling(totalCount * 1.0 / pageSize); + var currentPage = Math.Max(0, Math.Min(pagination.MaxPage, pagination.CurrentPage) - 1); + pagination.CurrentPage = currentPage + 1; + IcCommodity.ItemsSource = ordered.Skip(pageSize * currentPage).Take(pageSize); }); }); } @@ -153,10 +160,10 @@ namespace VPet_Simulator.Windows //} private void ScrollViewer_PreviewMouseWheel(object sender, MouseWheelEventArgs e) { - var eventArg = new MouseWheelEventArgs(e.MouseDevice, e.Timestamp, e.Delta); - eventArg.RoutedEvent = UIElement.MouseWheelEvent; - eventArg.Source = sender; - PageDetail.RaiseEvent(eventArg); + //var eventArg = new MouseWheelEventArgs(e.MouseDevice, e.Timestamp, e.Delta); + //eventArg.RoutedEvent = UIElement.MouseWheelEvent; + //eventArg.Source = sender; + //PageDetail.RaiseEvent(eventArg); } private void BtnBuy_Click(object sender, RoutedEventArgs e) { @@ -252,7 +259,12 @@ namespace VPet_Simulator.Windows private void Search() { - OrderItemSource((Food.FoodType)LsbCategory.SelectedIndex, LsbSortRule.SelectedIndex, LsbSortAsc.SelectedIndex == 0, _searchTextBox.Text); + var searchText = ""; + if (_searchTextBox != null) + { + searchText = _searchTextBox.Text; + } + OrderItemSource((Food.FoodType)LsbCategory.SelectedIndex, LsbSortRule.SelectedIndex, LsbSortAsc.SelectedIndex == 0, searchText); } private void TbTitleSearch_Loaded(object sender, RoutedEventArgs e) @@ -292,5 +304,33 @@ namespace VPet_Simulator.Windows { mw.Set["betterbuy"].SetBool("noautoclose", _puswitch.IsChecked.Value); } + + private void AutoUniformGrid_SizeChanged(object sender, SizeChangedEventArgs e) + { + var rows = Math.Max(0, (int)Math.Floor(IcCommodity.ActualHeight / 150d)); + if (rows != _rows) + { + _rows = rows; + Search(); + } + _rows = rows; + } + + private void AutoUniformGrid_Changed(object sender, RoutedEventArgs e) + { + var uniformGrid = e.OriginalSource as AutoUniformGrid; + var columns = uniformGrid.Columns; + if (columns != _columns) + { + _columns = columns; + Search(); + } + _columns = columns; + } + + private void pagination_CurrentPageChanged(object sender, SelectedValueChangedRoutedEventArgs e) + { + Search(); + } } } diff --git a/VPet-Simulator.Windows/WinDesign/winGameSetting.xaml b/VPet-Simulator.Windows/WinDesign/winGameSetting.xaml index 202aa32..4bee3d7 100644 --- a/VPet-Simulator.Windows/WinDesign/winGameSetting.xaml +++ b/VPet-Simulator.Windows/WinDesign/winGameSetting.xaml @@ -19,7 +19,7 @@ pu:TabControlHelper.ItemsCornerRadius="4" pu:TabControlHelper.ItemsHoverBackground="{DynamicResource PrimaryLight}" pu:TabControlHelper.ItemsSelectedBackground="{DynamicResource PrimaryDark}" - pu:TabControlHelper.ItemsSelectedForeground="{DynamicResource DARKPrimaryText}" + pu:TabControlHelper.ItemsSelectedForeground="{DynamicResource DARKPrimaryText}" pu:TabControlHelper.CanHeaderPanelScroll="True" Foreground="{DynamicResource PrimaryText}" SelectionChanged="MainTab_SelectionChanged"> diff --git a/VPet-Simulator.Windows/WinDesign/winGameSetting.xaml.cs b/VPet-Simulator.Windows/WinDesign/winGameSetting.xaml.cs index dbdf953..b39878d 100644 --- a/VPet-Simulator.Windows/WinDesign/winGameSetting.xaml.cs +++ b/VPet-Simulator.Windows/WinDesign/winGameSetting.xaml.cs @@ -109,7 +109,7 @@ namespace VPet_Simulator.Windows if (mw.Set.Diagnosis) RBDiagnosisYES.IsChecked = true; - List cbDiagnosis = new List { 200, 500, 1000, 2000, 5000, 10000, 20000 } + List cbDiagnosis = new List { 200, 500, 1000, 2000, 5000, 10000, 20000 }; int ds = cbDiagnosis.IndexOf(mw.Set.DiagnosisInterval); if (ds == -1) ds = 1; @@ -957,7 +957,7 @@ namespace VPet_Simulator.Windows mw.Main.MsgBar.SetPlaceIN(); } - private void numBackupSaveMaxNum_ValueChanged(object sender, Panuon.WPF.SelectedValueChangedRoutedEventArgs e) + private void numBackupSaveMaxNum_ValueChanged(object sender, Panuon.WPF.SelectedValueChangedRoutedEventArgs e) { if (!AllowChange) return; diff --git a/VPet-Simulator.Windows/packages.config b/VPet-Simulator.Windows/packages.config index 34184d8..bbeeeae 100644 --- a/VPet-Simulator.Windows/packages.config +++ b/VPet-Simulator.Windows/packages.config @@ -8,5 +8,6 @@ - + + \ No newline at end of file