Compare commits

...
4 Commits
11 changed files with 758 additions and 379 deletions

No files matched your search

+1
View File
@@ -17,6 +17,7 @@
<FontFamily x:Key="TextThemeFontFamily">/Resources/Fonts/MiSans-Regular.ttf#MiSans</FontFamily>
<FontFamily x:Key="DigitalThemeFontFamily">/Resources/Fonts/deluge-led.ttf#Deluge LED</FontFamily>
<bgivc:DomainNameToCascadingItemConverter x:Key="DomainNameConverter" />
<BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
<bgivc:BooleanToVisibilityRevertConverter x:Key="BooleanToVisibilityRevertConverter" />
<bgivc:BooleanToEnableTextConverter x:Key="BooleanToEnableTextConverter" />
@@ -95,7 +95,7 @@
<PackageReference Include="WPF-UI" Version="4.2.0" />
<PackageReference Include="WPF-UI.DependencyInjection" Version="4.2.0" />
<PackageReference Include="WPF-UI.Tray" Version="4.2.0" />
<PackageReference Include="WPF-UI.Violeta" Version="4.2.0.1" />
<PackageReference Include="WPF-UI.Violeta" Version="4.2.0.10" />
<PackageReference Include="gong-wpf-dragdrop" Version="3.2.1" />
<PackageReference Include="YamlDotNet" Version="16.3.0" />
<PackageReference Include="YoloSharp" Version="6.0.3" />
@@ -2,7 +2,6 @@ using System;
using System.Buffers;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using BetterGenshinImpact.Core.Recognition.OCR.Engine;
using BetterGenshinImpact.Core.Recognition.OCR.Engine.data;
@@ -153,46 +152,46 @@ public class Rec(
{
var resultArray = resultTensor.Item2;
var resultShape = resultTensor.Item1;
GCHandle dataHandle = default;
try
{
dataHandle = GCHandle.Alloc(resultArray, GCHandleType.Pinned);
var dataPtr = dataHandle.AddrOfPinnedObject();
var labelCount = resultShape[2];
var charCount = resultShape[1];
var labelCount = resultShape[2];
var charCount = resultShape[1];
return Enumerable.Range(0, resultShape[0])
.Select(i =>
return Enumerable.Range(0, resultShape[0])
.Select(i =>
{
StringBuilder sb = new();
var lastIndex = 0;
float score = 0;
var batchOffset = i * charCount * labelCount;
for (var n = 0; n < charCount; ++n)
{
StringBuilder sb = new();
var lastIndex = 0;
float score = 0;
for (var n = 0; n < charCount; ++n)
var rowOffset = batchOffset + n * labelCount;
var maxVal = float.MinValue;
var maxIndex = 0;
for (var c = 0; c < labelCount; c++)
{
using var mat = Mat.FromPixelData(1, labelCount, MatType.CV_32FC1,
dataPtr + (n + i * charCount) * labelCount * sizeof(float));
var maxIdx = new int[2];
mat.MinMaxIdx(out _, out var maxVal, [], maxIdx);
if (maxIdx[1] > 0 && !(n > 0 && maxIdx[1] == lastIndex))
var value = resultArray[rowOffset + c];
if (value > maxVal)
{
score += (float)maxVal;
sb.Append(OcrUtils.GetLabelByIndex(maxIdx[1], labels));
maxVal = value;
maxIndex = c;
}
lastIndex = maxIdx[1];
}
return new OcrRecognizerResult(sb.ToString(), score / sb.Length);
})
.ToArray();
}
finally
{
dataHandle.Free();
}
if (maxIndex > 0 && !(n > 0 && maxIndex == lastIndex))
{
score += maxVal;
sb.Append(OcrUtils.GetLabelByIndex(maxIndex, labels));
}
lastIndex = maxIndex;
}
var text = sb.ToString();
return new OcrRecognizerResult(text, text.Length > 0 ? score / text.Length : 0);
})
.ToArray();
}).ToArray();
}
public string GetConfigName => config.Name;
}
}
@@ -1226,7 +1226,7 @@
"nameEn": "barbara",
"type": "character",
"name": "芭芭拉",
"hp": 10,
"hp": 12,
"energy": 3,
"element": "水元素",
"weapon": "法器",
@@ -2158,6 +2158,152 @@
}
]
},
{
"id": 1215,
"nameEn": "dahlia",
"type": "character",
"name": "塔利雅",
"hp": 10,
"energy": 2,
"element": "水元素",
"weapon": "单手剑",
"skills": [
{
"nameEn": "favonius_bladework_ritual",
"name": "西风剑术·祭仪",
"skillTag": [
"普通攻击"
],
"cost": [
{
"id": 1102,
"nameEn": "hydro",
"type": "水元素",
"count": 1
},
{
"id": 1109,
"nameEn": "unaligned_element",
"type": "无色元素",
"count": 2
}
]
},
{
"nameEn": "immersive_ordinance",
"name": "圣浸的礼典",
"skillTag": [
"元素战技"
],
"cost": [
{
"id": 1102,
"nameEn": "hydro",
"type": "水元素",
"count": 3
}
]
},
{
"nameEn": "radiant_psalter",
"name": "纯耀的祷咏",
"skillTag": [
"元素爆发"
],
"cost": [
{
"id": 1102,
"nameEn": "hydro",
"type": "水元素",
"count": 3
},
{
"id": 1110,
"nameEn": "energy",
"type": "充能",
"count": 2
}
]
}
]
},
{
"id": 1216,
"nameEn": "aino",
"type": "character",
"name": "爱诺",
"hp": 10,
"energy": 2,
"element": "水元素",
"weapon": "双手剑",
"skills": [
{
"nameEn": "bishbashbosh_repair",
"name": "敲打修理法",
"skillTag": [
"普通攻击"
],
"cost": [
{
"id": 1102,
"nameEn": "hydro",
"type": "水元素",
"count": 1
},
{
"id": 1109,
"nameEn": "unaligned_element",
"type": "无色元素",
"count": 2
}
]
},
{
"nameEn": "musecatcher",
"name": "妙思捕手",
"skillTag": [
"元素战技"
],
"cost": [
{
"id": 1102,
"nameEn": "hydro",
"type": "水元素",
"count": 3
}
]
},
{
"nameEn": "precision_hydronic_cooler",
"name": "精密水冷仪",
"skillTag": [
"元素爆发"
],
"cost": [
{
"id": 1102,
"nameEn": "hydro",
"type": "水元素",
"count": 3
},
{
"id": 1110,
"nameEn": "energy",
"type": "充能",
"count": 2
}
]
},
{
"nameEn": "modular_efficiency_protocol",
"name": "模块式高效运作",
"skillTag": [
"被动技能"
],
"cost": []
}
]
},
{
"id": 1301,
"nameEn": "diluc",
@@ -9676,5 +9822,82 @@
"cost": []
}
]
},
{
"id": 2705,
"nameEn": "consecrated_fanged_beast",
"type": "character",
"name": "圣骸牙兽",
"hp": 10,
"energy": 2,
"element": "草元素",
"weapon": "其他武器",
"skills": [
{
"nameEn": "claw_slash",
"name": "利爪猛击",
"skillTag": [
"普通攻击"
],
"cost": [
{
"id": 1107,
"nameEn": "dendro",
"type": "草元素",
"count": 1
},
{
"id": 1109,
"nameEn": "unaligned_element",
"type": "无色元素",
"count": 2
}
]
},
{
"nameEn": "siphon_wave",
"name": "掠能绿波",
"skillTag": [
"元素战技"
],
"cost": [
{
"id": 1107,
"nameEn": "dendro",
"type": "草元素",
"count": 3
}
]
},
{
"nameEn": "sprawling_blighted_vines",
"name": "横生厄蔓",
"skillTag": [
"元素爆发"
],
"cost": [
{
"id": 1107,
"nameEn": "dendro",
"type": "草元素",
"count": 3
},
{
"id": 1110,
"nameEn": "energy",
"type": "充能",
"count": 2
}
]
},
{
"nameEn": "hunger_from_the_remains",
"name": "亡骸饥渴",
"skillTag": [
"被动技能"
],
"cost": []
}
]
}
]
@@ -15827,6 +15827,411 @@
]
}
]
},
{
"sceneId": 103,
"mapName": "TempleOfSpace",
"description": "空之神殿",
"points": [
{
"id": 1,
"type": "TeleportWaypoint",
"name": "传送锚点",
"country": "空之神殿",
"areas": [
"空之神殿"
],
"position": [
-54.55967,
94.86076,
422.8673
],
"tranPosition": [
-56.074036,
94.98824,
416.23694
]
},
{
"id": 2,
"type": "TeleportWaypoint",
"name": "传送锚点",
"country": "空之神殿",
"areas": [
"空之神殿",
"「沙上楼阁」"
],
"position": [
753.4533,
167.7142,
406.8993
],
"tranPosition": [
750.10944,
168.12778,
404.4207
]
},
{
"id": 3,
"type": "TeleportWaypoint",
"name": "传送锚点",
"country": "空之神殿",
"areas": [
"空之神殿",
"柱殿中央区"
],
"position": [
199.4993,
285.1512,
421.763
],
"tranPosition": [
188.9862,
286,
415.9903
]
},
{
"id": 4,
"type": "TeleportWaypoint",
"name": "传送锚点",
"country": "空之神殿",
"areas": [
"空之神殿",
"非有非无有之笼"
],
"position": [
141.1487,
1023.361,
397.4059
],
"tranPosition": [
146.44849,
1023.595,
398.8499
]
},
{
"id": 5,
"type": "TeleportWaypoint",
"name": "传送锚点",
"country": "空之神殿",
"areas": [
"空之神殿",
"大方广"
],
"position": [
-211.06,
99.55,
1077.296
],
"tranPosition": [
-208.68654,
99.78452,
1078.6156
]
},
{
"id": 6,
"type": "TeleportWaypoint",
"name": "传送锚点",
"country": "空之神殿",
"areas": [
"空之神殿",
"「沙上楼阁」"
],
"position": [
820.533,
205.5557,
398.7081
],
"tranPosition": [
827.40546,
205.42303,
397.87726
]
},
{
"id": 7,
"type": "TeleportWaypoint",
"name": "传送锚点",
"country": "空之神殿",
"areas": [
"空之神殿",
"麓阳书院"
],
"position": [
278.373,
76.166,
-63.747
],
"tranPosition": [
274.3983,
81.7,
-90.75065
]
},
{
"id": 8,
"type": "TeleportWaypoint",
"name": "传送锚点",
"country": "空之神殿",
"areas": [
"空之神殿",
"无想之间"
],
"position": [
223.6314,
-639.5626,
340.3265
],
"tranPosition": [
234.13805,
-639.21765,
340.76056
]
},
{
"id": 9,
"type": "TeleportWaypoint",
"name": "传送锚点",
"country": "空之神殿",
"areas": [
"空之神殿",
"柱殿中央区"
],
"position": [
488.6741,
222.6675,
420.6201
],
"tranPosition": [
486.98044,
222.82823,
412.4271
]
},
{
"id": 10,
"type": "TeleportWaypoint",
"name": "传送锚点",
"country": "空之神殿",
"areas": [
"空之神殿",
"柱殿中央区"
],
"position": [
155.0897,
149.385,
554.323
],
"tranPosition": [
152.0113,
149,
557.715
]
},
{
"id": 11,
"type": "TeleportWaypoint",
"name": "传送锚点",
"country": "空之神殿",
"areas": [
"空之神殿",
"大方广"
],
"position": [
-29.19872,
96.02325,
798.1201
],
"tranPosition": [
-33.452164,
95.713165,
797.0473
]
},
{
"id": 13,
"type": "TeleportWaypoint",
"name": "传送锚点",
"country": "空之神殿",
"areas": [
"空之神殿",
"「沙上楼阁」"
],
"position": [
775.6891,
-327.1821,
377.7858
],
"tranPosition": [
774.40875,
-327.0491,
373.75824
]
},
{
"id": 15,
"type": "TeleportWaypoint",
"name": "传送锚点",
"country": "空之神殿",
"areas": [
"空之神殿",
"非有非无有之笼·偏观"
],
"position": [
182.5881,
849.3398,
439.3099
],
"tranPosition": [
187.40652,
853.72705,
456.6145
]
},
{
"id": 16,
"type": "TeleportWaypoint",
"name": "传送锚点",
"country": "空之神殿",
"areas": [
"空之神殿",
"麓阳书院"
],
"position": [
246.311,
98.3308,
-386.82
],
"tranPosition": [
245.6576,
98.5,
-384.9
]
},
{
"id": 17,
"type": "TeleportWaypoint",
"name": "传送锚点",
"country": "空之神殿",
"areas": [
"空之神殿",
"麓阳书院"
],
"position": [
308.613,
144.1657,
-471.317
],
"tranPosition": [
311.5699,
144.1,
-470.9256
]
},
{
"id": 18,
"type": "TeleportWaypoint",
"name": "传送锚点",
"country": "空之神殿",
"areas": [
"空之神殿"
],
"position": [
-151.602,
90.222,
61.155
],
"tranPosition": [
-156,
90.57036,
61
]
},
{
"id": 19,
"type": "TeleportWaypoint",
"name": "传送锚点",
"country": "空之神殿",
"areas": [
"空之神殿",
"遗世之路"
],
"position": [
-320.8844,
-503.6001,
319.1273
],
"tranPosition": [
-320.71454,
-503.4747,
309.4051
]
},
{
"id": 20,
"type": "TeleportWaypoint",
"name": "传送锚点",
"country": "空之神殿",
"areas": [
"空之神殿",
"柱殿中央区"
],
"position": [
339.9739,
205.945,
519.2927
],
"tranPosition": [
329.09018,
206.11433,
517.0902
]
},
{
"id": 25,
"type": "TeleportWaypoint",
"name": "传送锚点",
"country": "空之神殿",
"areas": [
"空之神殿",
"麓阳书院"
],
"position": [
303.0637,
247.7,
-557.0782
],
"tranPosition": [
307.1052,
247.2,
-565.4739
]
},
{
"id": 26,
"type": "TeleportWaypoint",
"name": "传送锚点",
"country": "空之神殿",
"areas": [
"空之神殿",
"大方广"
],
"position": [
-214.0386,
136.9813,
1307.659
],
"tranPosition": [
-204.69,
137.13,
1305.77
]
}
]
}
]
}
@@ -0,0 +1,32 @@
using System.Collections.Generic;
using System.Linq;
using BetterGenshinImpact.GameTask.Common.Element.Assets;
using Wpf.Ui.Violeta.Controls;
namespace BetterGenshinImpact.Helpers;
public static class DomainCascadingItems
{
private static IReadOnlyList<ICascadingItem>? _items;
public static IReadOnlyList<ICascadingItem> Items =>
_items ??= BuildItems();
private static IReadOnlyList<ICascadingItem> BuildItems()
{
return MapLazyAssets.Instance.CountryToDomains.Keys
.Reverse()
.Select(country => (ICascadingItem)new CascadingItem(
country,
MapLazyAssets.Instance.CountryToDomains[country]
.AsEnumerable()
.Reverse()
.Select(d => (ICascadingItem)new CascadingItem(
d.Name! + " | " + string.Join(" ", d.Rewards))
{
Tag = d.Name
})
))
.ToList();
}
}
@@ -1,108 +0,0 @@
<UserControl x:Class="BetterGenshinImpact.View.Controls.DomainSelector"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
mc:Ignorable="d"
d:DesignHeight="60" d:DesignWidth="300"
Name="Root">
<Grid>
<ToggleButton x:Name="MainToggle"
HorizontalAlignment="Stretch"
HorizontalContentAlignment="Stretch"
Padding="12,6"
Height="34"
Background="{DynamicResource ControlFillColorDefaultBrush}"
BorderBrush="{DynamicResource SurfaceStrokeColorDefaultBrush}"
BorderThickness="1">
<ToggleButton.Template>
<ControlTemplate TargetType="ToggleButton">
<Border Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="4">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<TextBlock Text="{Binding SelectedDomain, ElementName=Root, TargetNullValue='请选择', FallbackValue='请选择'}"
VerticalAlignment="Center"
Margin="5,0,0,0"
TextTrimming="CharacterEllipsis"/>
<ui:SymbolIcon Grid.Column="1" Symbol="ChevronDown24" Margin="0,0,10,0"/>
</Grid>
</Border>
</ControlTemplate>
</ToggleButton.Template>
</ToggleButton>
<Popup x:Name="MainPopup"
IsOpen="{Binding IsChecked, ElementName=MainToggle, Mode=TwoWay}"
PlacementTarget="{Binding ElementName=MainToggle}"
StaysOpen="False"
AllowsTransparency="True"
PopupAnimation="Slide"
Opened="MainPopup_Opened"
Closed="MainPopup_Closed">
<Border x:Name="PopupBorder"
Background="{DynamicResource ApplicationBackgroundBrush}"
BorderBrush="{DynamicResource SurfaceStrokeColorDefaultBrush}"
BorderThickness="1"
CornerRadius="8"
Margin="0,4,0,0"
Padding="4"
MinHeight="200"
MaxHeight="400"
Width="350"
PreviewMouseWheel="PopupBorder_PreviewMouseWheel">
<Border.Effect>
<DropShadowEffect BlurRadius="10" ShadowDepth="2" Direction="270" Color="Black" Opacity="0.2"/>
</Border.Effect>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="90"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<!-- Countries -->
<ui:ListView x:Name="CountriesListView"
ItemsSource="{Binding Countries, ElementName=Root}"
SelectedItem="{Binding SelectedCountry, ElementName=Root, Mode=TwoWay}"
BorderThickness="0"
ScrollViewer.VerticalScrollBarVisibility="Auto"
ScrollViewer.CanContentScroll="False">
<ui:ListView.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding}" Margin="8,4"/>
</DataTemplate>
</ui:ListView.ItemTemplate>
</ui:ListView>
<!-- Divider -->
<Rectangle Grid.Column="1" Width="1" Fill="{DynamicResource SurfaceStrokeColorDefaultBrush}" Margin="2,0"/>
<!-- Domains -->
<ui:ListView Grid.Column="2" x:Name="DomainsListView"
ItemsSource="{Binding FilteredDomains, ElementName=Root}"
SelectedValue="{Binding SelectedDomain, ElementName=Root, Mode=TwoWay}"
SelectedValuePath="Item2.Name"
BorderThickness="0"
SelectionChanged="DomainListView_SelectionChanged"
ScrollViewer.VerticalScrollBarVisibility="Auto"
ScrollViewer.CanContentScroll="False">
<ui:ListView.ItemTemplate>
<DataTemplate>
<TextBlock Margin="8,4">
<Run Text="{Binding Item1, Mode=OneWay}"/>
</TextBlock>
</DataTemplate>
</ui:ListView.ItemTemplate>
</ui:ListView>
</Grid>
</Border>
</Popup>
</Grid>
</UserControl>
@@ -1,218 +0,0 @@
using System;
using BetterGenshinImpact.GameTask.AutoTrackPath.Model;
using BetterGenshinImpact.GameTask.Common.Element.Assets;
using System.Collections.Generic;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
namespace BetterGenshinImpact.View.Controls;
public partial class DomainSelector : UserControl
{
public DomainSelector()
{
InitializeComponent();
Countries = MapLazyAssets.Instance.CountryToDomains.Keys.Reverse().ToList();
Unloaded += OnUnloaded;
}
/// <summary>
/// 控件卸载时清理事件处理器,防止内存泄漏
/// </summary>
private void OnUnloaded(object sender, RoutedEventArgs e)
{
RemoveWindowMouseWheelHandler();
}
public List<string> Countries
{
get { return (List<string>)GetValue(CountriesProperty); }
set { SetValue(CountriesProperty, value); }
}
public static readonly DependencyProperty CountriesProperty =
DependencyProperty.Register("Countries", typeof(List<string>), typeof(DomainSelector), new PropertyMetadata(null));
public string SelectedCountry
{
get { return (string)GetValue(SelectedCountryProperty); }
set { SetValue(SelectedCountryProperty, value); }
}
public static readonly DependencyProperty SelectedCountryProperty =
DependencyProperty.Register("SelectedCountry", typeof(string), typeof(DomainSelector), new PropertyMetadata(null, OnSelectedCountryChanged));
private static void OnSelectedCountryChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
var control = (DomainSelector)d;
var country = (string)e.NewValue;
if (string.IsNullOrEmpty(country))
{
control.FilteredDomains = new List<System.Tuple<string, GiTpPosition>>();
}
else
{
if (MapLazyAssets.Instance.CountryToDomains.TryGetValue(country, out var domains))
{
// Reverse the list for display
control.FilteredDomains = domains.Select(i => new System.Tuple<string, GiTpPosition>(i.Name! + " | " + string.Join(" ", i.Rewards), i)).Reverse().ToList();
}
else
{
control.FilteredDomains = new List<System.Tuple<string, GiTpPosition>>();
}
}
}
public List<System.Tuple<string, GiTpPosition>> FilteredDomains
{
get { return (List<System.Tuple<string, GiTpPosition>>)GetValue(FilteredDomainsProperty); }
set { SetValue(FilteredDomainsProperty, value); }
}
public static readonly DependencyProperty FilteredDomainsProperty =
DependencyProperty.Register("FilteredDomains", typeof(List<System.Tuple<string, GiTpPosition>>), typeof(DomainSelector), new PropertyMetadata(null));
public string SelectedDomain
{
get { return (string)GetValue(SelectedDomainProperty); }
set { SetValue(SelectedDomainProperty, value); }
}
public static readonly DependencyProperty SelectedDomainProperty =
DependencyProperty.Register("SelectedDomain", typeof(string), typeof(DomainSelector), new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnSelectedDomainChanged));
private static void OnSelectedDomainChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
var control = (DomainSelector)d;
var domain = (string)e.NewValue;
if (string.IsNullOrEmpty(domain)) return;
// Verify if domain matches current country, if not, update country
var country = MapLazyAssets.Instance.GetCountryByDomain(domain);
if (country != null && country != control.SelectedCountry)
{
control.SelectedCountry = country;
}
}
private void DomainListView_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (MainToggle.IsChecked == true)
{
MainToggle.IsChecked = false;
}
}
/// <summary>
/// Popup 打开时添加全局滚轮事件拦截
/// </summary>
private void MainPopup_Opened(object sender, EventArgs e)
{
var window = Window.GetWindow(this);
if (window != null)
{
window.PreviewMouseWheel -= Window_PreviewMouseWheel;
window.PreviewMouseWheel += Window_PreviewMouseWheel;
}
}
/// <summary>
/// Popup 关闭时移除全局滚轮事件拦截
/// </summary>
private void MainPopup_Closed(object sender, EventArgs e)
{
RemoveWindowMouseWheelHandler();
}
/// <summary>
/// 移除窗口级滚轮事件处理器
/// </summary>
private void RemoveWindowMouseWheelHandler()
{
var window = Window.GetWindow(this);
if (window != null)
{
window.PreviewMouseWheel -= Window_PreviewMouseWheel;
}
}
/// <summary>
/// 全局滚轮事件处理,当 Popup 打开时拦截所有滚轮事件
/// </summary>
private void Window_PreviewMouseWheel(object sender, MouseWheelEventArgs e)
{
if (MainPopup.IsOpen)
{
e.Handled = true;
var scrollViewer1 = FindScrollViewer(CountriesListView);
var scrollViewer2 = FindScrollViewer(DomainsListView);
if (scrollViewer1 != null && scrollViewer1.IsMouseOver)
{
scrollViewer1.ScrollToVerticalOffset(scrollViewer1.VerticalOffset - e.Delta / 2.0);
return;
}
if (scrollViewer2 != null && scrollViewer2.IsMouseOver)
{
scrollViewer2.ScrollToVerticalOffset(scrollViewer2.VerticalOffset - e.Delta / 2.0);
return;
}
}
}
/// <summary>
/// 处理 Popup 内的鼠标滚轮事件,防止滚动穿透到外部页面
/// </summary>
private void PopupBorder_PreviewMouseWheel(object sender, MouseWheelEventArgs e)
{
e.Handled = true;
var scrollViewer1 = FindScrollViewer(CountriesListView);
var scrollViewer2 = FindScrollViewer(DomainsListView);
if (scrollViewer1 != null && scrollViewer1.IsMouseOver)
{
scrollViewer1.ScrollToVerticalOffset(scrollViewer1.VerticalOffset - e.Delta / 2.0);
return;
}
if (scrollViewer2 != null && scrollViewer2.IsMouseOver)
{
scrollViewer2.ScrollToVerticalOffset(scrollViewer2.VerticalOffset - e.Delta / 2.0);
return;
}
}
/// <summary>
/// 在视觉树中查找 ScrollViewer
/// </summary>
private ScrollViewer? FindScrollViewer(DependencyObject parent)
{
if (parent == null) return null;
for (int i = 0; i < VisualTreeHelper.GetChildrenCount(parent); i++)
{
var child = VisualTreeHelper.GetChild(parent, i);
if (child is ScrollViewer scrollViewer)
{
return scrollViewer;
}
var result = FindScrollViewer(child);
if (result != null)
{
return result;
}
}
return null;
}
}
@@ -0,0 +1,33 @@
using System;
using System.Globalization;
using System.Linq;
using System.Windows.Data;
using BetterGenshinImpact.Helpers;
using Wpf.Ui.Violeta.Controls;
namespace BetterGenshinImpact.View.Converters;
public class DomainNameToCascadingItemConverter : IValueConverter
{
public object? Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is string name && !string.IsNullOrEmpty(name))
{
foreach (var country in DomainCascadingItems.Items)
{
var found = country.Children?.FirstOrDefault(d => d.Tag as string == name);
if (found != null)
return found;
}
}
return null;
}
public object? ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is ICascadingItem item)
return item.Tag as string;
return null;
}
}
@@ -5,12 +5,14 @@
xmlns:controls="clr-namespace:BetterGenshinImpact.View.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:dd="urn:gong-wpf-dragdrop"
xmlns:helpers="clr-namespace:BetterGenshinImpact.Helpers"
xmlns:local="clr-namespace:BetterGenshinImpact.View.Pages"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:oneDragon="clr-namespace:BetterGenshinImpact.ViewModel.Pages.OneDragon"
xmlns:oneDragonView="clr-namespace:BetterGenshinImpact.View.Pages.OneDragon"
xmlns:pages="clr-namespace:BetterGenshinImpact.ViewModel.Pages"
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
xmlns:vio="http://schemas.lepo.co/wpfui/2022/xaml/violeta"
d:DataContext="{d:DesignInstance Type=pages:OneDragonFlowViewModel}"
d:DesignHeight="1000"
d:DesignWidth="800"
@@ -444,13 +446,14 @@
Text="秘境名称"
Width="Auto"
TextWrapping="Wrap" />
<controls:DomainSelector Grid.Row="0"
<vio:CascadingComboBox Grid.Row="0"
Grid.RowSpan="2"
Grid.Column="1"
Width="100"
HorizontalAlignment="Left"
Margin="10,0,10,0"
SelectedDomain="{Binding SelectedConfig.DomainName, Mode=TwoWay}" />
ItemsSource="{x:Static helpers:DomainCascadingItems.Items}"
SelectedCascadingItem="{Binding SelectedConfig.DomainName, Mode=TwoWay, Converter={StaticResource DomainNameConverter}}" />
<ui:TextBlock Grid.Row="0"
Grid.Column="2"
Margin="10,0,10,0"
@@ -550,11 +553,12 @@
VerticalAlignment="Center"
TextAlignment="Center"
PlaceholderText="填写队伍名称 " />
<controls:DomainSelector Grid.Row="0"
<vio:CascadingComboBox Grid.Row="0"
Grid.Column="2"
Width="100"
Margin="0,0,36,0"
SelectedDomain="{Binding SelectedConfig.MondayDomainName, Mode=TwoWay}" />
ItemsSource="{x:Static helpers:DomainCascadingItems.Items}"
SelectedCascadingItem="{Binding SelectedConfig.MondayDomainName, Mode=TwoWay, Converter={StaticResource DomainNameConverter}}" />
</Grid>
<Grid Margin="16">
<Grid.ColumnDefinitions>
@@ -578,11 +582,12 @@
VerticalAlignment="Center"
TextAlignment="Center"
PlaceholderText="填写队伍名称 " />
<controls:DomainSelector Grid.Row="0"
<vio:CascadingComboBox Grid.Row="0"
Grid.Column="2"
Width="100"
Margin="0,0,36,0"
SelectedDomain="{Binding SelectedConfig.TuesdayDomainName, Mode=TwoWay}" />
ItemsSource="{x:Static helpers:DomainCascadingItems.Items}"
SelectedCascadingItem="{Binding SelectedConfig.TuesdayDomainName, Mode=TwoWay, Converter={StaticResource DomainNameConverter}}" />
</Grid>
<Grid Margin="16">
<Grid.ColumnDefinitions>
@@ -605,11 +610,12 @@
VerticalAlignment="Center"
TextAlignment="Center"
PlaceholderText="填写队伍名称 " />
<controls:DomainSelector Grid.Row="0"
<vio:CascadingComboBox Grid.Row="0"
Grid.Column="2"
Width="100"
Margin="0,0,36,0"
SelectedDomain="{Binding SelectedConfig.WednesdayDomainName, Mode=TwoWay}" />
ItemsSource="{x:Static helpers:DomainCascadingItems.Items}"
SelectedCascadingItem="{Binding SelectedConfig.WednesdayDomainName, Mode=TwoWay, Converter={StaticResource DomainNameConverter}}" />
</Grid>
<Grid Margin="16">
@@ -633,11 +639,12 @@
VerticalAlignment="Center"
TextAlignment="Center"
PlaceholderText="填写队伍名称 " />
<controls:DomainSelector Grid.Row="0"
<vio:CascadingComboBox Grid.Row="0"
Grid.Column="2"
Width="100"
Margin="0,0,36,0"
SelectedDomain="{Binding SelectedConfig.ThursdayDomainName, Mode=TwoWay}" />
ItemsSource="{x:Static helpers:DomainCascadingItems.Items}"
SelectedCascadingItem="{Binding SelectedConfig.ThursdayDomainName, Mode=TwoWay, Converter={StaticResource DomainNameConverter}}" />
</Grid>
<Grid Margin="16">
@@ -661,11 +668,12 @@
VerticalAlignment="Center"
TextAlignment="Center"
PlaceholderText="填写队伍名称 " />
<controls:DomainSelector Grid.Row="0"
<vio:CascadingComboBox Grid.Row="0"
Grid.Column="2"
Width="100"
Margin="0,0,36,0"
SelectedDomain="{Binding SelectedConfig.FridayDomainName, Mode=TwoWay}" />
ItemsSource="{x:Static helpers:DomainCascadingItems.Items}"
SelectedCascadingItem="{Binding SelectedConfig.FridayDomainName, Mode=TwoWay, Converter={StaticResource DomainNameConverter}}" />
</Grid>
@@ -690,11 +698,12 @@
VerticalAlignment="Center"
TextAlignment="Center"
PlaceholderText="填写队伍名称 " />
<controls:DomainSelector Grid.Row="0"
<vio:CascadingComboBox Grid.Row="0"
Grid.Column="2"
Width="100"
Margin="0,0,36,0"
SelectedDomain="{Binding SelectedConfig.SaturdayDomainName, Mode=TwoWay}" />
ItemsSource="{x:Static helpers:DomainCascadingItems.Items}"
SelectedCascadingItem="{Binding SelectedConfig.SaturdayDomainName, Mode=TwoWay, Converter={StaticResource DomainNameConverter}}" />
</Grid>
<Grid Margin="16">
@@ -723,11 +732,12 @@
VerticalAlignment="Center"
TextAlignment="Center"
PlaceholderText="填写队伍名称 " />
<controls:DomainSelector Grid.Row="0"
<vio:CascadingComboBox Grid.Row="0"
Grid.Column="2"
Width="100"
Margin="0,0,36,0"
SelectedDomain="{Binding SelectedConfig.SundayDomainName, Mode=TwoWay}" />
ItemsSource="{x:Static helpers:DomainCascadingItems.Items}"
SelectedCascadingItem="{Binding SelectedConfig.SundayDomainName, Mode=TwoWay, Converter={StaticResource DomainNameConverter}}" />
<Border Grid.Row="1"
Grid.Column="0"
Grid.ColumnSpan="3"
@@ -9,6 +9,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:pages="clr-namespace:BetterGenshinImpact.ViewModel.Pages"
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
xmlns:vio="http://schemas.lepo.co/wpfui/2022/xaml/violeta"
xmlns:emoji="clr-namespace:Emoji.Wpf;assembly=Emoji.Wpf"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
Title="TaskSettingsPage"
@@ -1290,12 +1291,13 @@
Foreground="{ui:ThemeResource TextFillColorTertiaryBrush}"
Text="自动传送到刷取的秘境"
TextWrapping="Wrap" />
<controls:DomainSelector Grid.Row="0"
<vio:CascadingComboBox Grid.Row="0"
Grid.RowSpan="2"
Grid.Column="1"
Width="180"
Margin="0,0,36,0"
SelectedDomain="{Binding Config.AutoDomainConfig.DomainName, Mode=TwoWay}" />
ItemsSource="{x:Static helpers:DomainCascadingItems.Items}"
SelectedCascadingItem="{Binding Config.AutoDomainConfig.DomainName, Mode=TwoWay, Converter={StaticResource DomainNameConverter}}" />
</Grid>
<Grid Margin="16">
<Grid.RowDefinitions>