更新搜索

This commit is contained in:
muqing 2024-08-23 07:59:16 +08:00
parent bf54ae4dd0
commit 1424fb2de9
17 changed files with 406 additions and 73 deletions

View File

@ -1,15 +1,19 @@
using RustTools.muqing; using System.Diagnostics;
using RustTools.muqing;
namespace RustTools.ApiFox; namespace RustTools.ApiFox;
class mod
#pragma warning disable CS8981 // 该类型名称仅包含小写 ascii 字符。此类名称可能会成为该语言的保留值。
#pragma warning disable IDE1006 // 命名样式
public class mod
{ {
//最新时间 下载数量 投币数量 更新数量 //最新时间 下载数量 投币数量 更新数量
//latestTime downloadNumbercoinNumber updateNumber //latestTime downloadNumbercoinNumber updateNumber
public static string latestTime = "latestTime"; public const string latestTime = "latestTime";
public static string downloadNumber = "downloadNumber"; public const string downloadNumber = "downloadNumber";
public static string coinNumber = "coinNumber"; public const string coinNumber = "coinNumber";
public static string updateNumber = "updateNumber"; public const string updateNumber = "updateNumber";
/// <summary> /// <summary>

View File

@ -0,0 +1,17 @@

using RustTools.muqing;
using static IniHelper;
namespace RustTools.ApiFox;
#pragma warning disable CS8981 // 该类型名称仅包含小写 ascii 字符。此类名称可能会成为该语言的保留值。
#pragma warning disable IDE1006 // 命名样式
public class search
{
public static async Task<string> searchAll(string key)
{
return await wl.postAsync("/php/search.php?action=searchAll", new string[][]
{
new string[]{ "key", key},
});
}
}

View File

@ -39,8 +39,13 @@
<!-- 模组列表的视图 --> <!-- 模组列表的视图 -->
<DataTemplate x:Key="HomePageListItem"> <DataTemplate x:Key="HomePageListItem">
<StackPanel Orientation="Horizontal"> <Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Border <Border
Grid.Column="0"
Width="56" Width="56"
Height="56" Height="56"
BorderBrush="White" BorderBrush="White"
@ -50,15 +55,16 @@
<ImageBrush ImageSource="{Binding Icon}" Stretch="UniformToFill" /> <ImageBrush ImageSource="{Binding Icon}" Stretch="UniformToFill" />
</Border.Background> </Border.Background>
</Border> </Border>
<StackPanel Margin="10,10,10,10" Orientation="Vertical"> <StackPanel
Grid.Column="1"
Margin="10,10,10,10"
Orientation="Vertical">
<TextBlock Style="{StaticResource SubtitleTextBlockStyle}" Text="{Binding Name}" /> <TextBlock Style="{StaticResource SubtitleTextBlockStyle}" Text="{Binding Name}" />
<TextBlock <TextBlock
Width="500"
MaxLines="2" MaxLines="2"
Style="{StaticResource BodyStrongTextBlockStyle}" Style="{StaticResource BodyStrongTextBlockStyle}"
Text="{Binding Description}" Text="{Binding Description}"
TextTrimming="CharacterEllipsis" TextTrimming="CharacterEllipsis" />
TextWrapping="Wrap" />
<StackPanel Orientation="Horizontal"> <StackPanel Orientation="Horizontal">
<TextBlock Style="{StaticResource BodyTextBlockStyle}" Text="{Binding UpdateTime}" /> <TextBlock Style="{StaticResource BodyTextBlockStyle}" Text="{Binding UpdateTime}" />
<TextBlock <TextBlock
@ -68,8 +74,7 @@
<TextBlock Style="{StaticResource BodyTextBlockStyle}" Text="次下载" /> <TextBlock Style="{StaticResource BodyTextBlockStyle}" Text="次下载" />
</StackPanel> </StackPanel>
</StackPanel> </StackPanel>
</Grid>
</StackPanel>
</DataTemplate> </DataTemplate>

View File

@ -0,0 +1,88 @@
using Newtonsoft.Json;
namespace RustTools.DataList;
#pragma warning disable CS8618 // 在退出构造函数时,不可为 null 的字段必须包含非 null 值。请考虑声明为可以为 null。
#pragma warning disable IDE1006 // 命名样式
public class SearchAllList
{
[JsonProperty("code")]
public int Code
{
get; set;
}
[JsonProperty("message")]
public string Message
{
get; set;
}
[JsonProperty("data")]
public Data data
{
get; set;
}
public class Data
{
[JsonProperty("total")]
public List<TotalItem> Total
{
get; set;
}
[JsonProperty("type")]
public List<TypeItem> Type
{
get; set;
}
}
public class TotalItem
{
[JsonProperty("title")]
public string Title
{
get; set;
}
[JsonProperty("type")]
public string Type
{
get; set;
}
[JsonProperty("content")]
public string Content
{
get; set;
}
[JsonProperty("icon")]
public string Icon
{
get; set;
}
[JsonProperty("id")]
public string Id
{
get; set;
}
}
public class TypeItem
{
[JsonProperty("typeName")]
public string TypeName
{
get; set;
}
[JsonProperty("num")]
public int Num
{
get; set;
}
}
}

View File

@ -6,7 +6,7 @@
xmlns:local="using:RustTools" xmlns:local="using:RustTools"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:windowex="using:WinUIEx" xmlns:windowex="using:WinUIEx"
MinWidth="500" MinWidth="600"
MinHeight="500" MinHeight="500"
PersistenceId="MainWindow" PersistenceId="MainWindow"
mc:Ignorable="d" /> mc:Ignorable="d" />

View File

@ -71,4 +71,5 @@
<ItemGroup Condition="'$(DisableMsixProjectCapabilityAddedByProject)'!='true' and '$(EnableMsixTooling)'=='true'"> <ItemGroup Condition="'$(DisableMsixProjectCapabilityAddedByProject)'!='true' and '$(EnableMsixTooling)'=='true'">
<ProjectCapability Include="Msix" /> <ProjectCapability Include="Msix" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@ -3,6 +3,7 @@
using Microsoft.UI.Xaml.Navigation; using Microsoft.UI.Xaml.Navigation;
using RustTools.Contracts.Services; using RustTools.Contracts.Services;
using RustTools.muqing;
using RustTools.Views; using RustTools.Views;
namespace RustTools.ViewModels; namespace RustTools.ViewModels;
@ -35,9 +36,8 @@ public partial class ShellViewModel : ObservableRecipient
private void OnNavigated(object sender, NavigationEventArgs e) private void OnNavigated(object sender, NavigationEventArgs e)
{ {
System.GC.Collect(); GC.Collect();
IsBackEnabled = NavigationService.CanGoBack; IsBackEnabled = NavigationService.CanGoBack;
if (e.SourcePageType == typeof(SettingsPage)) if (e.SourcePageType == typeof(SettingsPage))
{ {
Selected = NavigationViewService.SettingsItem; Selected = NavigationViewService.SettingsItem;
@ -49,5 +49,9 @@ public partial class ShellViewModel : ObservableRecipient
{ {
Selected = selectedItem; Selected = selectedItem;
} }
else
{
Selected = null;
}
} }
} }

View File

@ -34,7 +34,7 @@ using static RustTools.DataList.DataBaseManifest;
namespace RustTools.Views; namespace RustTools.Views;
/// <summary> /// <summary>
/// An empty page that can be used on its own or navigated to within a Frame. /// エ惲<EFBFBD>棏鯣ャ
/// </summary> /// </summary>
public sealed partial class CodeTablePage : Page public sealed partial class CodeTablePage : Page
{ {

View File

@ -31,7 +31,7 @@ public sealed partial class HomePage : Page
ListA.ItemClick += ListAClick; ListA.ItemClick += ListAClick;
ListB.ItemClick += ListAClick; ListB.ItemClick += ListAClick;
//为了节省流量测试的时候不加载这些 //为了节省流量测试的时候不加载这些
if (true) if (false)
{ {
ViewModel.random(); ViewModel.random();
ViewModel.Latest(); ViewModel.Latest();

View File

@ -12,8 +12,7 @@
mc:Ignorable="d"> mc:Ignorable="d">
<Grid> <Grid>
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="auto" /> <RowDefinition Height="*" />
<RowDefinition Height="auto" />
</Grid.RowDefinitions> </Grid.RowDefinitions>
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="*" /> <ColumnDefinition Width="*" />
@ -22,7 +21,6 @@
<AppBarButton <AppBarButton
Grid.Row="0" Grid.Row="0"
Grid.Column="1" Grid.Column="1"
Margin="0,3,9,0"
Icon="Sort" Icon="Sort"
IsCompact="False" IsCompact="False"
Label="下载量" Label="下载量"
@ -52,6 +50,7 @@
<ListView <ListView
x:Name="list" x:Name="list"
Grid.Row="1" Grid.Row="1"
Margin="0,0,0,9"
Padding="0,0,16,0" Padding="0,0,16,0"
HorizontalAlignment="Stretch" HorizontalAlignment="Stretch"
IsItemClickEnabled="True" IsItemClickEnabled="True"

View File

@ -29,7 +29,7 @@ public sealed partial class RankingPage : Page
private void Page_SizeChanged(object sender, SizeChangedEventArgs e) private void Page_SizeChanged(object sender, SizeChangedEventArgs e)
{ {
list.Height = ActualHeight - 100; //list.Height = ActualHeight - 100;
} }

View File

@ -0,0 +1,63 @@
<?xml version="1.0" encoding="utf-8" ?>
<Page
x:Class="RustTools.Views.SearchModPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="using:RustTools.Views"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<TextBlock Grid.Row="0">
<Run Text="一共搜索到" />
<Run Text="{x:Bind ListSearch.Count}" />
<Run Text="个数据" />
</TextBlock>
<ListView
Name="list"
Grid.Row="1"
IsItemClickEnabled="True"
ItemsSource="{x:Bind ListSearch}"
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
SelectionMode="None">
<ListView.ItemTemplate>
<DataTemplate xmlns:a="using:RustTools.DataList" x:DataType="a:SearchAllList">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Border
Grid.Column="0"
Width="56"
Height="56"
BorderBrush="White"
BorderThickness="0"
CornerRadius="9">
<Border.Background>
<ImageBrush ImageSource="{Binding Icon}" Stretch="UniformToFill" />
</Border.Background>
</Border>
<StackPanel
Grid.Column="1"
Margin="10,10,10,10"
Orientation="Vertical">
<TextBlock Style="{StaticResource SubtitleTextBlockStyle}" Text="{Binding Title}" />
<TextBlock
LineHeight="2"
MaxLines="2"
Style="{StaticResource BodyTextBlockStyle}"
Text="{Binding Content}"
TextTrimming="CharacterEllipsis" />
</StackPanel>
</Grid>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</Grid>
</Page>

View File

@ -0,0 +1,95 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using CommunityToolkit.Mvvm.ComponentModel;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Controls.Primitives;
using Microsoft.UI.Xaml.Data;
using Microsoft.UI.Xaml.Input;
using Microsoft.UI.Xaml.Media;
using Microsoft.UI.Xaml.Navigation;
using Newtonsoft.Json;
using RustTools.DataList;
using RustTools.muqing;
using RustTools.WindowUI;
using Windows.Foundation;
using Windows.Foundation.Collections;
// To learn more about WinUI, the WinUI project structure,
// and more about our project templates, see: http://aka.ms/winui-project-info.
namespace RustTools.Views;
/// <summary>
/// 搜索模组碎片
/// </summary>
public sealed partial class SearchModPage : Page
{
public ObservableCollection<SearchAllList.TotalItem> ListSearch
{
get; set;
} = new();
public SearchModPage()
{
InitializeComponent();
list.ItemClick += List_ItemClick; ;
}
private void List_ItemClick(object sender, ItemClickEventArgs e)
{
if (e.ClickedItem is not SearchAllList.TotalItem item) { return; }
if (item.Type == "mod")
{
// 查找已存在的 ModulePage如果存在则激活它
var existingWindow = ModuleInfoWin.ModulePageList.FirstOrDefault(window => window.Mod.Id == item.Id);
if (existingWindow != null)
{
existingWindow.Activate();
}
else
{
var newWindow = new ModuleInfoWin(item.Id);
newWindow.Activate();
ModuleInfoWin.ModulePageList.Add(newWindow);
}
}
}
protected async override void OnNavigatedTo(NavigationEventArgs e)
{
base.OnNavigatedTo(e);
if (e.Parameter is string param)
{
try
{
var v = await ApiFox.search.searchAll(param);
//gj.sc(v);
var searchAllList = JsonConvert.DeserializeObject<SearchAllList>(v);
if (searchAllList.Code == 0)
{
foreach (var item in searchAllList.data.Total)
{
if (item.Type == "mod")
{
item.Icon = string.IsNullOrEmpty(item.Icon) ? "/Assets/image/image.svg" : item.Icon.Replace("..", wl.api);
ListSearch.Add(item);
}
}
}
}
catch (Exception ex)
{
await Dialog.DialogWarn(ex.Message,XamlRoot);
}
}
}
protected override void OnNavigatedFrom(NavigationEventArgs e){
base.OnNavigatedFrom(e);
}
}

View File

@ -104,8 +104,17 @@
<HyperlinkButton x:Uid="SettingsPage_PrivacyTermsLink" Margin="{StaticResource SettingsPageHyperlinkButtonMargin}" /> <HyperlinkButton x:Uid="SettingsPage_PrivacyTermsLink" Margin="{StaticResource SettingsPageHyperlinkButtonMargin}" />
</StackPanel> </StackPanel>
</StackPanel> </StackPanel>
<TextBlock Style="{ThemeResource SubtitleTextBlockStyle}" Text="特别鸣谢" />
<StackPanel Margin="{StaticResource XSmallTopMargin}" Orientation="Horizontal">
<PersonPicture
Width="56"
Height="56"
Margin="6"
ProfilePicture="http://q.qlogo.cn/headimg_dl?dst_uin=2923268971&amp;spec=640&amp;img_type=jpg"
ToolTipService.ToolTip="感谢薄荷对本软件后端的帮助,也希望薄荷能尽快出来官方的电脑版" />
</StackPanel>
</StackPanel> </StackPanel>
</Grid> </Grid>
</ScrollView> </ScrollView>
</Page> </Page>

View File

@ -7,34 +7,60 @@
xmlns:helpers="using:RustTools.Helpers" xmlns:helpers="using:RustTools.Helpers"
xmlns:i="using:Microsoft.Xaml.Interactivity" xmlns:i="using:Microsoft.Xaml.Interactivity"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
Loaded="OnLoaded"> Loaded="OnLoaded"
SizeChanged="Page_SizeChanged">
<Grid> <Grid x:Name="gridview">
<!-- Height="{Binding ElementName=NavigationViewControl, Path=CompactPaneLength}" -->
<Grid <Grid
x:Name="AppTitleBar" x:Name="AppTitleBar"
Height="{Binding ElementName=NavigationViewControl, Path=CompactPaneLength}" Height="48"
VerticalAlignment="Top" VerticalAlignment="Top"
Canvas.ZIndex="1" Canvas.ZIndex="1"
IsHitTestVisible="True"> IsHitTestVisible="True">
<Grid.ColumnDefinitions>
<ColumnDefinition x:Name="IconColumn" Width="Auto" />
<ColumnDefinition x:Name="TitleColumn" Width="Auto" />
<ColumnDefinition
x:Name="RightDragColumn"
Width="*"
MinWidth="48" />
</Grid.ColumnDefinitions>
<Image <Image
x:Name="TitleIcon"
Grid.Column="0"
Width="16" Width="16"
Height="16" Height="16"
HorizontalAlignment="Left" Margin="0,0,6,0"
Source="/Assets/WindowIcon.ico" /> Source="/Assets/WindowIcon.ico" />
<TextBlock <TextBlock
x:Name="AppTitleBarText" x:Name="AppTitleBarText"
Margin="28,0,0,0" Grid.Column="1"
VerticalAlignment="Center" VerticalAlignment="Center"
Style="{StaticResource CaptionTextBlockStyle}" Style="{StaticResource CaptionTextBlockStyle}"
TextWrapping="NoWrap" /> TextWrapping="NoWrap" />
<AutoSuggestBox
x:Name="TitleBarSearchBox"
Grid.Column="2"
MaxWidth="600"
Margin="6,0,150,0"
VerticalAlignment="Center"
PlaceholderText="搜索模组"
QueryIcon="Find"
QuerySubmitted="TitleBarSearchBox_QuerySubmitted" />
<!--<PersonPicture
x:Name="PersonPic"
Grid.Column="6"
Height="32"
Margin="0,0,16,0" />-->
</Grid> </Grid>
<NavigationView <NavigationView
x:Name="NavigationViewControl" x:Name="NavigationViewControl"
Canvas.ZIndex="0"
DisplayModeChanged="NavigationViewControl_DisplayModeChanged" DisplayModeChanged="NavigationViewControl_DisplayModeChanged"
ExpandedModeThresholdWidth="1280" ExpandedModeThresholdWidth="1280"
Header="{x:Bind ((ContentControl)ViewModel.Selected).Content, Mode=OneWay}" Header="{x:Bind ((ContentControl)ViewModel.Selected).Content, Mode=OneWay}"
IsBackButtonVisible="Visible" IsBackButtonVisible="Auto"
IsBackEnabled="{x:Bind ViewModel.IsBackEnabled, Mode=OneWay}" IsBackEnabled="{x:Bind ViewModel.IsBackEnabled, Mode=OneWay}"
IsSettingsVisible="True" IsSettingsVisible="True"
SelectedItem="{x:Bind ViewModel.Selected, Mode=OneWay}"> SelectedItem="{x:Bind ViewModel.Selected, Mode=OneWay}">
@ -84,7 +110,7 @@
</NavigationViewItem.Icon> </NavigationViewItem.Icon>
</NavigationViewItem> </NavigationViewItem>
</NavigationView.MenuItems> </NavigationView.MenuItems>
<NavigationView.HeaderTemplate> <!--<NavigationView.HeaderTemplate>
<DataTemplate> <DataTemplate>
<Grid> <Grid>
<TextBlock Style="{ThemeResource TitleTextBlockStyle}" Text="{Binding}" /> <TextBlock Style="{ThemeResource TitleTextBlockStyle}" Text="{Binding}" />
@ -102,7 +128,7 @@
</DataTemplate> </DataTemplate>
</behaviors:NavigationViewHeaderBehavior.DefaultHeaderTemplate> </behaviors:NavigationViewHeaderBehavior.DefaultHeaderTemplate>
</behaviors:NavigationViewHeaderBehavior> </behaviors:NavigationViewHeaderBehavior>
</i:Interaction.Behaviors> </i:Interaction.Behaviors>-->
<Grid Margin="{StaticResource NavigationViewPageContentMargin}"> <Grid Margin="{StaticResource NavigationViewPageContentMargin}">
<Frame x:Name="NavigationFrame" /> <Frame x:Name="NavigationFrame" />
</Grid> </Grid>

View File

@ -1,4 +1,5 @@
 
using Microsoft.UI.Input;
using Microsoft.UI.Xaml; using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls; using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Input; using Microsoft.UI.Xaml.Input;
@ -7,7 +8,7 @@ using RustTools.Contracts.Services;
using RustTools.Helpers; using RustTools.Helpers;
using RustTools.muqing; using RustTools.muqing;
using RustTools.ViewModels; using RustTools.ViewModels;
using Windows.Foundation;
using Windows.System; using Windows.System;
namespace RustTools.Views; namespace RustTools.Views;
@ -26,7 +27,7 @@ public sealed partial class ShellPage : Page
InitializeComponent(); InitializeComponent();
ViewModel.NavigationService.Frame = NavigationFrame; ViewModel.NavigationService.Frame = NavigationFrame;
//ViewModel.NavigationService.Frame.ElementSoundMode.isna = "False"; //ViewModel.NavigationService.UnregisterFrameEvents();
ViewModel.NavigationViewService.Initialize(NavigationViewControl); ViewModel.NavigationViewService.Initialize(NavigationViewControl);
// TODO: Set the title bar icon by updating /Assets/WindowIcon.ico. // TODO: Set the title bar icon by updating /Assets/WindowIcon.ico.
@ -37,46 +38,48 @@ public sealed partial class ShellPage : Page
App.MainWindow.SetTitleBar(AppTitleBar); App.MainWindow.SetTitleBar(AppTitleBar);
App.MainWindow.Activated += MainWindow_Activated; App.MainWindow.Activated += MainWindow_Activated;
} }
AppTitleBarText.Text = "app_name".GetLocalized() + " " + "app_version".GetLocalized(); AppTitleBarText.Text = "app_name".GetLocalized() + " PC";//+ "app_version".GetLocalized();
//NavigationViewControl.SelectedItem = NavigationViewControl.MenuItems[0];
//NavigationViewControl.SelectionChanged += NavigationViewControl_SelectionChanged;
//NavigateToPage("Home");
}
private void NavigationViewControl_SelectionChanged(NavigationView sender, NavigationViewSelectionChangedEventArgs args)
{
System.GC.Collect();
if (args.SelectedItem is NavigationViewItem selectedItem)
{
var tag = selectedItem.Tag.ToString();
gj.sc(tag);
if (tag != null)
{
NavigateToPage(tag);
}
}
}
private void NavigateToPage(string pageTag)
{
var pageType = pageTag switch
{
"Home" => typeof(HomePage),
"Concern" => typeof(ConcernPage),
"Ranking" => typeof(RankingPage),
"User"=>typeof(UserPage),
"Module" => typeof(ModulePage),
"Settings" => typeof(SettingsPage),
_ => typeof(HomePage),
};
NavigationFrame.Navigate(pageType);
} }
private void OnLoaded(object sender, Microsoft.UI.Xaml.RoutedEventArgs e) private void OnLoaded(object sender, Microsoft.UI.Xaml.RoutedEventArgs e)
{ {
//gj.sc(RequestedTheme); if (App.MainWindow?.ExtendsContentIntoTitleBar == true)
TitleBarHelper.UpdateTitleBar(RequestedTheme); {
// Update interactive regions if the size of the window changes.
SetRegionsForCustomTitleBar();
}
//TitleBarHelper.UpdateTitleBar(RequestedTheme);
KeyboardAccelerators.Add(BuildKeyboardAccelerator(VirtualKey.Left, VirtualKeyModifiers.Menu)); //KeyboardAccelerators.Add(BuildKeyboardAccelerator(VirtualKey.Left, VirtualKeyModifiers.Menu));
KeyboardAccelerators.Add(BuildKeyboardAccelerator(VirtualKey.GoBack)); //KeyboardAccelerators.Add(BuildKeyboardAccelerator(VirtualKey.GoBack));
}
private void SetRegionsForCustomTitleBar()
{
// Specify the interactive regions of the title bar.
var m_AppWindow = App.MainWindow?.AppWindow;
if (m_AppWindow == null) { return; }
var scaleAdjustment = AppTitleBar.XamlRoot.RasterizationScale;
var transform = TitleBarSearchBox.TransformToVisual(null);
var bounds = transform.TransformBounds(new Rect(0, 0,
TitleBarSearchBox.ActualWidth,
TitleBarSearchBox.ActualHeight));
Windows.Graphics.RectInt32 SearchBoxRect = GetRect(bounds, scaleAdjustment);
var rectArray = new Windows.Graphics.RectInt32[] { SearchBoxRect };
InputNonClientPointerSource nonClientInputSrc =
InputNonClientPointerSource.GetForWindowId(m_AppWindow.Id);
nonClientInputSrc.SetRegionRects(NonClientRegionKind.Passthrough, rectArray);
}
private Windows.Graphics.RectInt32 GetRect(Rect bounds, double scale)
{
return new Windows.Graphics.RectInt32(
_X: (int)Math.Round(bounds.X * scale),
_Y: (int)Math.Round(bounds.Y * scale),
_Width: (int)Math.Round(bounds.Width * scale),
_Height: (int)Math.Round(bounds.Height * scale)
);
} }
private void MainWindow_Activated(object sender, WindowActivatedEventArgs args) private void MainWindow_Activated(object sender, WindowActivatedEventArgs args)
@ -84,11 +87,13 @@ public sealed partial class ShellPage : Page
App.AppTitlebar = AppTitleBarText; App.AppTitlebar = AppTitleBarText;
} }
//DisplayModeChanged="NavigationViewControl_DisplayModeChanged"
private void NavigationViewControl_DisplayModeChanged(NavigationView sender, NavigationViewDisplayModeChangedEventArgs args) private void NavigationViewControl_DisplayModeChanged(NavigationView sender, NavigationViewDisplayModeChangedEventArgs args)
{ {
AppTitleBar.Margin = new Thickness() AppTitleBar.Margin = new Thickness()
{ {
Left = sender.CompactPaneLength * (sender.DisplayMode == NavigationViewDisplayMode.Minimal ? 2 : 1), Left = sender.CompactPaneLength * (sender.DisplayMode == NavigationViewDisplayMode.Minimal ? 2 : 1),
//Left = sender.CompactPaneLength,
Top = AppTitleBar.Margin.Top, Top = AppTitleBar.Margin.Top,
Right = AppTitleBar.Margin.Right, Right = AppTitleBar.Margin.Right,
Bottom = AppTitleBar.Margin.Bottom Bottom = AppTitleBar.Margin.Bottom
@ -118,4 +123,21 @@ public sealed partial class ShellPage : Page
args.Handled = result; args.Handled = result;
} }
private void Page_SizeChanged(object sender, SizeChangedEventArgs e)
{
if (App.MainWindow?.ExtendsContentIntoTitleBar == true)
{
// Update interactive regions if the size of the window changes.
SetRegionsForCustomTitleBar();
}
}
private void TitleBarSearchBox_QuerySubmitted(AutoSuggestBox sender, AutoSuggestBoxQuerySubmittedEventArgs args)
{
var text = sender.Text;
NavigationFrame.Navigate(typeof(SearchModPage),text);
NavigationFrame.BackStack.Clear();
//ViewModel.NavigationService.Frame.Visibility= Visibility.Collapsed;
}
} }

View File

@ -4,7 +4,7 @@ namespace RustTools.muqing;
#pragma warning disable CS8981 // 该类型名称仅包含小写 ascii 字符。此类名称可能会成为该语言的保留值。 #pragma warning disable CS8981 // 该类型名称仅包含小写 ascii 字符。此类名称可能会成为该语言的保留值。
class wl class wl
{ {
public static string api = "https://rust.coldmint.top"; public const string api = "https://rust.coldmint.top";
/// <summary> /// <summary>
/// <para>异步Post请求</para> /// <para>异步Post请求</para>
@ -28,7 +28,7 @@ class wl
if (response != null) if (response != null)
{ {
var str = response.Content; var str = response.Content;
return str; return str ?? string.Empty;
} }
return string.Empty; return string.Empty;
} }