2024-02-22 18:46:23 +00:00
|
|
|
|
using LinePutScript;
|
2023-07-02 13:41:38 +00:00
|
|
|
|
using LinePutScript.Localization.WPF;
|
2023-06-08 11:44:41 +00:00
|
|
|
|
using Panuon.WPF;
|
2023-06-05 08:42:20 +00:00
|
|
|
|
using Panuon.WPF.UI;
|
|
|
|
|
using System;
|
2023-06-01 14:50:40 +00:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using System.Windows;
|
|
|
|
|
using System.Windows.Controls;
|
|
|
|
|
using System.Windows.Documents;
|
|
|
|
|
using System.Windows.Input;
|
2023-06-08 08:46:53 +00:00
|
|
|
|
using VPet_Simulator.Windows.Interface;
|
2023-06-01 14:50:40 +00:00
|
|
|
|
|
|
|
|
|
namespace VPet_Simulator.Windows
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// winBetterBuy.xaml 的交互逻辑
|
|
|
|
|
/// </summary>
|
2023-06-05 08:42:20 +00:00
|
|
|
|
public partial class winBetterBuy : WindowX
|
2023-06-01 14:50:40 +00:00
|
|
|
|
{
|
2023-06-05 08:42:20 +00:00
|
|
|
|
private TextBox _searchTextBox;
|
2023-06-08 08:46:53 +00:00
|
|
|
|
MainWindow mw;
|
|
|
|
|
private bool AllowChange = false;
|
2023-06-11 09:10:09 +00:00
|
|
|
|
private Switch _puswitch;
|
2023-08-11 16:44:28 +00:00
|
|
|
|
private int _columns;
|
|
|
|
|
private int _rows;
|
2023-06-05 08:42:20 +00:00
|
|
|
|
|
2023-06-01 14:50:40 +00:00
|
|
|
|
public winBetterBuy(MainWindow mw)
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
2023-06-08 08:46:53 +00:00
|
|
|
|
this.mw = mw;
|
2023-10-10 17:03:23 +00:00
|
|
|
|
Title = "更好买".Translate() + ' ' + mw.PrefixSave;
|
2023-06-08 08:46:53 +00:00
|
|
|
|
LsbSortRule.SelectedIndex = mw.Set["betterbuy"].GetInt("lastorder");
|
|
|
|
|
LsbSortAsc.SelectedIndex = mw.Set["betterbuy"].GetBool("lastasc") ? 0 : 1;
|
|
|
|
|
AllowChange = true;
|
|
|
|
|
}
|
2023-08-12 07:13:30 +00:00
|
|
|
|
Run rMoney;
|
2023-06-08 08:46:53 +00:00
|
|
|
|
public void Show(Food.FoodType type)
|
|
|
|
|
{
|
2023-09-20 10:58:22 +00:00
|
|
|
|
if (!AllowChange)
|
|
|
|
|
return;
|
2023-08-23 14:31:24 +00:00
|
|
|
|
showeatanm = true;//逃出
|
2023-06-08 23:23:11 +00:00
|
|
|
|
if (_searchTextBox != null)
|
|
|
|
|
_searchTextBox.Text = "";
|
|
|
|
|
if (LsbCategory.SelectedIndex == (int)type)
|
|
|
|
|
OrderItemSource(type, LsbSortRule.SelectedIndex, LsbSortAsc.SelectedIndex == 0);
|
|
|
|
|
else
|
|
|
|
|
LsbCategory.SelectedIndex = (int)type;
|
2023-08-12 07:13:30 +00:00
|
|
|
|
if (rMoney != null)
|
|
|
|
|
rMoney.Text = mw.Core.Save.Money.ToString("f2");
|
2023-08-16 06:46:59 +00:00
|
|
|
|
|
|
|
|
|
//喜好度刷新
|
2023-09-22 16:18:24 +00:00
|
|
|
|
foreach (var sub in mw.GameSavesData["buytime"])
|
2023-08-16 06:46:59 +00:00
|
|
|
|
{
|
2023-09-22 16:18:24 +00:00
|
|
|
|
var name = sub.Name;
|
|
|
|
|
var food = mw.Foods.FirstOrDefault(x => x.Name == name);
|
|
|
|
|
if (food != null)
|
2023-08-16 06:46:59 +00:00
|
|
|
|
{
|
2023-09-22 16:18:24 +00:00
|
|
|
|
food.LoadEatTimeSource(mw);
|
|
|
|
|
food.NotifyOfPropertyChange("Description");
|
2023-08-16 06:46:59 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2023-09-14 12:21:59 +00:00
|
|
|
|
//没钱了,宠物给你私房钱 (开罗传统)
|
|
|
|
|
if (mw.Core.Save.Money <= 1)
|
|
|
|
|
{
|
2023-09-22 16:18:24 +00:00
|
|
|
|
if (mw.GameSavesData[(gbol)"self"])
|
2023-09-14 12:21:59 +00:00
|
|
|
|
{
|
2023-09-14 16:31:09 +00:00
|
|
|
|
MessageBoxX.Show("更好买老顾客大优惠!桌宠的食物钱我来出!\n更好买提示您:$10以下的食物/药品等随便赊账".Translate());
|
2023-09-14 12:21:59 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2023-10-24 10:32:18 +00:00
|
|
|
|
MessageBoxX.Show("看到您囊中羞涩,{0}拿出了1000块私房钱出来给你".Translate(mw.Core.Save.Name));
|
2023-09-22 16:18:24 +00:00
|
|
|
|
mw.GameSavesData[(gbol)"self"] = true;
|
2023-09-14 12:21:59 +00:00
|
|
|
|
mw.Core.Save.Money += 1000;
|
2023-09-22 16:18:24 +00:00
|
|
|
|
}
|
2023-09-14 12:21:59 +00:00
|
|
|
|
}
|
2023-10-11 12:48:46 +00:00
|
|
|
|
else if (mw.Core.Save.Money >= 11000 && mw.GameSavesData[(gbol)"self"])
|
|
|
|
|
{
|
|
|
|
|
mw.Core.Save.Money -= 1000;
|
|
|
|
|
mw.GameSavesData[(gbol)"self"] = false;
|
|
|
|
|
MessageBoxX.Show("{0}偷偷藏了1000块私房钱".Translate());
|
|
|
|
|
}
|
2023-08-21 18:26:27 +00:00
|
|
|
|
|
2023-06-08 08:46:53 +00:00
|
|
|
|
Show();
|
|
|
|
|
}
|
2023-06-08 11:44:41 +00:00
|
|
|
|
public void OrderItemSource(Food.FoodType type, int sortrule, bool sortasc, string searchtext = null)
|
2023-06-08 08:46:53 +00:00
|
|
|
|
{
|
|
|
|
|
Task.Run(() =>
|
2023-06-05 08:42:20 +00:00
|
|
|
|
{
|
2023-06-08 11:44:41 +00:00
|
|
|
|
List<Food> foods;
|
2023-06-08 08:46:53 +00:00
|
|
|
|
switch (type)
|
2023-06-05 08:42:20 +00:00
|
|
|
|
{
|
2023-06-08 08:46:53 +00:00
|
|
|
|
case Food.FoodType.Food:
|
|
|
|
|
foods = mw.Foods;
|
|
|
|
|
break;
|
|
|
|
|
case Food.FoodType.Star:
|
|
|
|
|
//List<Food> lf = new List<Food>();
|
2024-03-20 18:59:11 +00:00
|
|
|
|
//foreach (var sub in mf.Set["betterbuy"].FindAll("star"))
|
2023-06-08 08:46:53 +00:00
|
|
|
|
//{
|
|
|
|
|
// var str = sub.Info;
|
2024-03-20 18:59:11 +00:00
|
|
|
|
// var food = mf.Foods.FirstOrDefault(x => x.Name == str);
|
2023-06-08 08:46:53 +00:00
|
|
|
|
// if (food != null)
|
|
|
|
|
// lf.Add(food);
|
|
|
|
|
//}
|
|
|
|
|
//foods = lf;
|
|
|
|
|
foods = mw.Foods.FindAll(x => x.Star);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
2023-09-28 16:44:25 +00:00
|
|
|
|
foods = mw.Foods.FindAll(x => x.Type == type);// || x.Type == Food.FoodType.Limit);
|
2023-06-08 08:46:53 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
2023-06-08 11:44:41 +00:00
|
|
|
|
if (!string.IsNullOrEmpty(searchtext))
|
|
|
|
|
{
|
2023-07-02 13:41:38 +00:00
|
|
|
|
foods = foods.FindAll(x => x.TranslateName.Contains(searchtext));
|
2023-06-08 11:44:41 +00:00
|
|
|
|
}
|
2023-06-08 08:46:53 +00:00
|
|
|
|
IOrderedEnumerable<Food> ordered;
|
|
|
|
|
switch (sortrule)
|
2023-06-05 08:42:20 +00:00
|
|
|
|
{
|
2023-08-23 14:31:24 +00:00
|
|
|
|
default:
|
2023-06-08 08:46:53 +00:00
|
|
|
|
case 0:
|
|
|
|
|
if (sortasc)
|
2023-07-02 13:41:38 +00:00
|
|
|
|
ordered = foods.OrderBy(x => x.TranslateName);
|
2023-06-08 08:46:53 +00:00
|
|
|
|
else
|
2023-07-02 13:41:38 +00:00
|
|
|
|
ordered = foods.OrderByDescending(x => x.TranslateName);
|
2023-06-08 08:46:53 +00:00
|
|
|
|
break;
|
|
|
|
|
case 1:
|
|
|
|
|
if (sortasc)
|
|
|
|
|
ordered = foods.OrderBy(x => x.Price);
|
|
|
|
|
else
|
|
|
|
|
ordered = foods.OrderByDescending(x => x.Price);
|
|
|
|
|
break;
|
|
|
|
|
case 2:
|
|
|
|
|
if (sortasc)
|
|
|
|
|
ordered = foods.OrderBy(x => x.StrengthFood);
|
|
|
|
|
else
|
|
|
|
|
ordered = foods.OrderByDescending(x => x.StrengthFood);
|
|
|
|
|
break;
|
|
|
|
|
case 3:
|
|
|
|
|
if (sortasc)
|
|
|
|
|
ordered = foods.OrderBy(x => x.StrengthDrink);
|
|
|
|
|
else
|
|
|
|
|
ordered = foods.OrderByDescending(x => x.StrengthDrink);
|
|
|
|
|
break;
|
|
|
|
|
case 4:
|
|
|
|
|
if (sortasc)
|
|
|
|
|
ordered = foods.OrderBy(x => x.Strength);
|
|
|
|
|
else
|
|
|
|
|
ordered = foods.OrderByDescending(x => x.Strength);
|
|
|
|
|
break;
|
|
|
|
|
case 5:
|
|
|
|
|
if (sortasc)
|
|
|
|
|
ordered = foods.OrderBy(x => x.Feeling);
|
|
|
|
|
else
|
|
|
|
|
ordered = foods.OrderByDescending(x => x.Feeling);
|
|
|
|
|
break;
|
2023-08-23 14:31:24 +00:00
|
|
|
|
case 6:
|
2023-06-08 08:46:53 +00:00
|
|
|
|
if (sortasc)
|
|
|
|
|
ordered = foods.OrderBy(x => x.Health);
|
|
|
|
|
else
|
|
|
|
|
ordered = foods.OrderByDescending(x => x.Health);
|
|
|
|
|
break;
|
2023-08-23 14:31:24 +00:00
|
|
|
|
case 7:
|
|
|
|
|
if (sortasc)
|
|
|
|
|
ordered = foods.OrderBy(x => x.Exp);
|
|
|
|
|
else
|
|
|
|
|
ordered = foods.OrderByDescending(x => x.Exp);
|
|
|
|
|
break;
|
2023-09-14 12:02:07 +00:00
|
|
|
|
case 8:
|
|
|
|
|
if (sortasc)
|
|
|
|
|
ordered = foods.OrderBy(x => x.Likability);
|
|
|
|
|
else
|
|
|
|
|
ordered = foods.OrderByDescending(x => x.Likability);
|
|
|
|
|
break;
|
2023-06-08 08:46:53 +00:00
|
|
|
|
}
|
|
|
|
|
Dispatcher.Invoke(() =>
|
|
|
|
|
{
|
2023-08-11 16:44:28 +00:00
|
|
|
|
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);
|
2023-06-08 08:46:53 +00:00
|
|
|
|
});
|
|
|
|
|
});
|
2023-06-05 08:42:20 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-06-08 08:46:53 +00:00
|
|
|
|
//private void RbtnIncrease_Click(object sender, RoutedEventArgs e)
|
|
|
|
|
//{
|
|
|
|
|
// var repeatButton = sender as RepeatButton;
|
|
|
|
|
// var item = repeatButton.DataContext as BetterBuyItem;
|
|
|
|
|
// item.Quantity = Math.Max(1, item.Quantity + 1);
|
|
|
|
|
//}
|
2023-06-05 08:42:20 +00:00
|
|
|
|
|
2023-06-08 08:46:53 +00:00
|
|
|
|
//private void RbtnDecrease_Click(object sender, RoutedEventArgs e)
|
|
|
|
|
//{
|
|
|
|
|
// var repeatButton = sender as RepeatButton;
|
|
|
|
|
// var item = repeatButton.DataContext as BetterBuyItem;
|
|
|
|
|
// item.Quantity = Math.Max(1, item.Quantity - 1);
|
|
|
|
|
//}
|
2023-06-08 21:06:46 +00:00
|
|
|
|
private void ScrollViewer_PreviewMouseWheel(object sender, MouseWheelEventArgs e)
|
|
|
|
|
{
|
2023-08-11 16:44:28 +00:00
|
|
|
|
//var eventArg = new MouseWheelEventArgs(e.MouseDevice, e.Timestamp, e.Delta);
|
|
|
|
|
//eventArg.RoutedEvent = UIElement.MouseWheelEvent;
|
|
|
|
|
//eventArg.Source = sender;
|
|
|
|
|
//PageDetail.RaiseEvent(eventArg);
|
2023-06-08 21:06:46 +00:00
|
|
|
|
}
|
2024-03-20 18:59:11 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// 是否显示吃东西动画
|
|
|
|
|
/// </summary>
|
|
|
|
|
public bool showeatanm = true;
|
2023-08-23 19:49:16 +00:00
|
|
|
|
|
2023-06-05 08:42:20 +00:00
|
|
|
|
private void BtnBuy_Click(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
2023-06-08 08:46:53 +00:00
|
|
|
|
var Button = sender as Button;
|
|
|
|
|
var item = Button.DataContext as Food;
|
2023-06-08 11:44:41 +00:00
|
|
|
|
//看是什么模式
|
|
|
|
|
if (mw.Set.EnableFunction)
|
2023-08-26 15:56:31 +00:00
|
|
|
|
{//$10以内的食物允许赊账
|
|
|
|
|
if (item.Price >= 10 && item.Price >= mw.Core.Save.Money)
|
2023-06-08 11:44:41 +00:00
|
|
|
|
{//买不起
|
2023-07-02 13:41:38 +00:00
|
|
|
|
MessageBoxX.Show("您没有足够金钱来购买 {0}\n您需要 {1:f2} 金钱来购买\n您当前 {2:f2} 拥有金钱"
|
|
|
|
|
.Translate(item.TranslateName, item.Price, mw.Core.Save.Money)
|
|
|
|
|
, "金钱不足".Translate());
|
2023-06-08 11:44:41 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
2023-08-24 20:22:09 +00:00
|
|
|
|
//看看是否超模
|
|
|
|
|
if (mw.HashCheck && item.IsOverLoad())
|
|
|
|
|
{
|
|
|
|
|
if (MessageBoxX.Show("当前食物/物品属性超模,是否继续使用?\n使用超模食物可能会导致游戏发生不可预料的错误\n使用超模食物不影响大部分成就解锁\n本物品推荐价格为{0:f0}"
|
|
|
|
|
.Translate(item.RealPrice), "超模食物/物品使用提醒".Translate(), MessageBoxButton.YesNo) != MessageBoxResult.Yes)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
mw.HashCheck = false;
|
|
|
|
|
}
|
2023-08-23 19:49:16 +00:00
|
|
|
|
mw.TakeItem(item);
|
2023-06-08 11:44:41 +00:00
|
|
|
|
}
|
2024-03-20 18:59:11 +00:00
|
|
|
|
|
|
|
|
|
mw.DisplayFoodAnimation(item.GetGraph(), item.ImageSource);
|
|
|
|
|
|
2023-08-15 12:28:11 +00:00
|
|
|
|
if (!_puswitch.IsChecked.Value)
|
|
|
|
|
{
|
|
|
|
|
TryClose();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
rMoney.Text = mw.Core.Save.Money.ToString("f2");
|
|
|
|
|
}
|
2023-06-05 08:42:20 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void BtnSearch_Click(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
Search();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void BtnTitle_Click(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
_searchTextBox.Text = "";
|
|
|
|
|
Search();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void Search()
|
|
|
|
|
{
|
2023-09-20 10:58:22 +00:00
|
|
|
|
if (!AllowChange)
|
|
|
|
|
return;
|
2023-08-11 16:44:28 +00:00
|
|
|
|
var searchText = "";
|
|
|
|
|
if (_searchTextBox != null)
|
|
|
|
|
{
|
|
|
|
|
searchText = _searchTextBox.Text;
|
|
|
|
|
}
|
|
|
|
|
OrderItemSource((Food.FoodType)LsbCategory.SelectedIndex, LsbSortRule.SelectedIndex, LsbSortAsc.SelectedIndex == 0, searchText);
|
2023-06-05 08:42:20 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void TbTitleSearch_Loaded(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
_searchTextBox = sender as TextBox;
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-08 08:46:53 +00:00
|
|
|
|
private void LsbSortRule_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (!AllowChange)
|
|
|
|
|
return;
|
|
|
|
|
int order = LsbSortRule.SelectedIndex;
|
|
|
|
|
bool asc = LsbSortAsc.SelectedIndex == 0;
|
|
|
|
|
mw.Set["betterbuy"].SetInt("lastorder", order);
|
|
|
|
|
mw.Set["betterbuy"].SetBool("lastasc", asc);
|
2023-06-08 11:44:41 +00:00
|
|
|
|
OrderItemSource((Food.FoodType)LsbCategory.SelectedIndex, order, asc, _searchTextBox?.Text);
|
2023-06-08 08:46:53 +00:00
|
|
|
|
}
|
2023-06-08 21:20:40 +00:00
|
|
|
|
public void TryClose()
|
2023-06-08 08:46:53 +00:00
|
|
|
|
{
|
2023-06-08 11:44:41 +00:00
|
|
|
|
IcCommodity.ItemsSource = null;
|
2024-03-20 18:59:11 +00:00
|
|
|
|
//mf.Topmost = mf.Set.TopMost;
|
2023-06-08 08:46:53 +00:00
|
|
|
|
Hide();
|
|
|
|
|
}
|
2023-06-08 21:20:40 +00:00
|
|
|
|
private void WindowX_Closing(object sender, System.ComponentModel.CancelEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
TryClose();
|
2023-08-12 07:13:30 +00:00
|
|
|
|
e.Cancel = mw.CloseConfirm;
|
2023-06-08 21:20:40 +00:00
|
|
|
|
}
|
2023-06-11 09:10:09 +00:00
|
|
|
|
|
|
|
|
|
private void Switch_Loaded(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
_puswitch = sender as Switch;
|
|
|
|
|
_puswitch.IsChecked = mw.Set["betterbuy"].GetBool("noautoclose");
|
2023-08-16 16:49:10 +00:00
|
|
|
|
_puswitch.Click += Switch_Checked;
|
2023-06-11 09:10:09 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void Switch_Checked(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
mw.Set["betterbuy"].SetBool("noautoclose", _puswitch.IsChecked.Value);
|
|
|
|
|
}
|
2023-08-11 16:44:28 +00:00
|
|
|
|
|
|
|
|
|
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<int> e)
|
|
|
|
|
{
|
2023-12-24 17:58:35 +00:00
|
|
|
|
if (!AllowChange)
|
|
|
|
|
return;
|
2023-08-11 16:44:28 +00:00
|
|
|
|
Search();
|
2023-12-18 09:49:06 +00:00
|
|
|
|
TbPage.Text = e.NewValue.ToString();
|
2023-08-11 16:44:28 +00:00
|
|
|
|
}
|
2023-08-12 07:13:30 +00:00
|
|
|
|
|
|
|
|
|
private void rMoney_Loaded(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
rMoney = sender as Run;
|
|
|
|
|
rMoney.Text = mw.Core.Save.Money.ToString("f2");
|
|
|
|
|
}
|
2023-08-23 19:49:16 +00:00
|
|
|
|
private Switch _puswitchautobuy;
|
|
|
|
|
private void Switch_Loaded_1(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
_puswitchautobuy = sender as Switch;
|
|
|
|
|
_puswitchautobuy.IsChecked = mw.Set.AutoBuy;
|
2023-09-14 12:21:59 +00:00
|
|
|
|
_puswitchautobuy.Click += Switch_AutoBuy_Checked;
|
2023-08-23 19:49:16 +00:00
|
|
|
|
}
|
|
|
|
|
private void Switch_AutoBuy_Checked(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (_puswitchautobuy.IsChecked.Value && mw.Core.Save.Money < 100)
|
|
|
|
|
{
|
|
|
|
|
_puswitchautobuy.IsChecked = false;
|
|
|
|
|
MessageBoxX.Show(mw, "余额不足100,无法开启自动购买".Translate(), "更好买".Translate());
|
|
|
|
|
return;
|
|
|
|
|
}
|
2023-09-12 16:36:30 +00:00
|
|
|
|
if (_puswitchautobuy.IsChecked.Value)
|
|
|
|
|
{
|
|
|
|
|
mw.Set.AutoBuy = true;
|
|
|
|
|
_puswitchautogift.Visibility = Visibility.Visible;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2023-09-14 12:21:59 +00:00
|
|
|
|
mw.Set.AutoBuy = false;
|
2023-09-12 16:36:30 +00:00
|
|
|
|
_puswitchautogift.Visibility = Visibility.Collapsed;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private Switch _puswitchautogift;
|
|
|
|
|
private void Switch_Loaded_2(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
_puswitchautogift = sender as Switch;
|
|
|
|
|
_puswitchautogift.IsChecked = mw.Set.AutoGift;
|
|
|
|
|
_puswitchautogift.Click += Switch_AutoGift_Checked;
|
|
|
|
|
if (mw.Set.AutoBuy)
|
|
|
|
|
{
|
|
|
|
|
_puswitchautogift.Visibility = Visibility.Visible;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private void Switch_AutoGift_Checked(object sender, RoutedEventArgs e)
|
2023-09-14 12:21:59 +00:00
|
|
|
|
{
|
2023-09-12 16:36:30 +00:00
|
|
|
|
mw.Set.AutoGift = _puswitchautogift.IsChecked.Value;
|
2023-08-23 19:49:16 +00:00
|
|
|
|
}
|
2023-10-11 12:48:46 +00:00
|
|
|
|
|
|
|
|
|
private void Button_Loaded(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
((Button)sender).Content = "更好买".Translate() + mw.PrefixSave;
|
|
|
|
|
;
|
|
|
|
|
}
|
2023-12-18 09:49:06 +00:00
|
|
|
|
|
|
|
|
|
private void TbPage_PreviewKeyDown(object sender, KeyEventArgs e)
|
|
|
|
|
{
|
2024-03-20 18:59:11 +00:00
|
|
|
|
if (e.Key == Key.Enter
|
2023-12-18 09:49:06 +00:00
|
|
|
|
&& int.TryParse(TbPage.Text?.Trim(), out int page))
|
|
|
|
|
{
|
2023-12-25 06:34:14 +00:00
|
|
|
|
pagination.CurrentPage = Math.Max(0, Math.Min(pagination.MaxPage, page));
|
2023-12-18 09:49:06 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2023-06-01 14:50:40 +00:00
|
|
|
|
}
|
|
|
|
|
}
|