rft: TooltipBlock封装 (#12773)

* rft: TooltipBlock封装

* fix: TooltipText 绑定失败

* rft: 自动战斗提示替换

---------

Co-authored-by: uye <99072975+ABA2396@users.noreply.github.com>
This commit is contained in:
status102
2025-05-22 17:53:22 +08:00
committed by GitHub
parent ec6c219673
commit 1d7efcd07b
4 changed files with 78 additions and 43 deletions

View File

@@ -0,0 +1,30 @@
<UserControl
x:Class="MaaWpfGui.Styles.Controls.TooltipBlock"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="clr-namespace:MaaWpfGui.Styles.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
d:DataContext="{d:DesignInstance {x:Type controls:TooltipBlock}}"
mc:Ignorable="d">
<Border
Width="15"
Height="15"
Margin="5,0,0,0"
Background="{DynamicResource MouseOverRegionBrush}"
Style="{StaticResource BorderCircular}"
ToolTipService.InitialShowDelay="0">
<Border.ToolTip>
<TextBlock
MaxWidth="{Binding TooltipMaxWidth}"
Text="{Binding TooltipText}"
TextWrapping="Wrap" />
</Border.ToolTip>
<TextBlock
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontSize="10"
Foreground="{DynamicResource PrimaryTextBrush}"
Text="?" />
</Border>
</UserControl>

View File

@@ -0,0 +1,45 @@
// <copyright file="TooltipBlock.xaml.cs" company="MaaAssistantArknights">
// MaaWpfGui - A part of the MaaCoreArknights project
// Copyright (C) 2021 MistEO and Contributors
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License v3.0 only as published by
// the Free Software Foundation, either version 3 of the License, or
// any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY
// </copyright>
#nullable enable
using System.Windows;
using System.Windows.Controls;
namespace MaaWpfGui.Styles.Controls;
/// <summary>
/// TooltipBlock.xaml 的交互逻辑
/// </summary>
public partial class TooltipBlock : UserControl
{
public TooltipBlock()
{
InitializeComponent();
DataContext = this;
}
public static readonly DependencyProperty TooltipTextProperty = DependencyProperty.Register(nameof(TooltipText), typeof(string), typeof(TooltipBlock), new PropertyMetadata(string.Empty));
public static readonly DependencyProperty TooltipMaxWidthProperty = DependencyProperty.Register(nameof(TooltipMaxWidth), typeof(double), typeof(TooltipBlock), new PropertyMetadata(double.MaxValue));
public string TooltipText
{
get => (string)GetValue(TooltipTextProperty);
set => SetValue(TooltipTextProperty, value);
}
public double TooltipMaxWidth
{
get => (double)GetValue(TooltipMaxWidthProperty);
set => SetValue(TooltipMaxWidthProperty, value);
}
}

View File

@@ -13,7 +13,6 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:properties="clr-namespace:MaaWpfGui.Styles.Properties"
xmlns:s="https://github.com/canton7/Stylet"
xmlns:styles="clr-namespace:MaaWpfGui.Styles"
xmlns:ui="clr-namespace:MaaWpfGui.ViewModels.UI"
xmlns:viewModels="clr-namespace:MaaWpfGui.ViewModels"
xmlns:vm="clr-namespace:MaaWpfGui"
@@ -103,27 +102,8 @@
HorizontalAlignment="Center"
Content="{DynamicResource UseCopilotList}"
IsChecked="{Binding UseCopilotList}"
IsEnabled="{Binding Idle}"/>
<Border
Width="15"
Height="15"
Margin="5,0,0,0"
Background="{DynamicResource MouseOverRegionBrush}"
Style="{StaticResource BorderCircular}"
ToolTipService.InitialShowDelay="0">
<Border.ToolTip>
<TextBlock
MaxWidth="350"
Text="{DynamicResource UseCopilotListTip}"
TextWrapping="Wrap" />
</Border.ToolTip>
<TextBlock
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontSize="10"
Foreground="{DynamicResource PrimaryTextBrush}"
Text="?" />
</Border>
IsEnabled="{Binding Idle}" />
<controls:TooltipBlock TooltipText="{DynamicResource UseCopilotListTip}" />
</StackPanel>
<StackPanel
Height="30"

View File

@@ -94,27 +94,7 @@
Margin="8,0,0,0"
HorizontalAlignment="Left"
Text="{DynamicResource UpdateSource}" />
<Border
Width="15"
Height="15"
Margin="5,0,0,0"
Background="{DynamicResource MouseOverRegionBrush}"
Style="{StaticResource BorderCircular}"
ToolTipService.InitialShowDelay="0">
<Border.ToolTip>
<TextBlock
MaxWidth="350"
Text="{DynamicResource UpdateSourceTip}"
TextWrapping="Wrap" />
</Border.ToolTip>
<TextBlock
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontSize="10"
Foreground="{DynamicResource PrimaryTextBrush}"
Text="?" />
</Border>
<controls:TooltipBlock TooltipMaxWidth="350" TooltipText="{DynamicResource UpdateSourceTip}" />
</StackPanel>
<hc:ComboBox
Width="150"