From 24718ec243ec2f73ce58bde362e2c7cdfcd01946 Mon Sep 17 00:00:00 2001 From: uye <99072975+ABA2396@users.noreply.github.com> Date: Sun, 13 Jul 2025 13:29:12 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E4=BD=BF=E7=94=A8=E8=87=AA=E5=AE=9A?= =?UTF-8?q?=E4=B9=89=E6=82=AC=E6=B5=AE=E7=AA=97=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/MaaWpfGui/ViewModels/LogItemViewModel.cs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/MaaWpfGui/ViewModels/LogItemViewModel.cs b/src/MaaWpfGui/ViewModels/LogItemViewModel.cs index 87b253150d..569f4028d3 100644 --- a/src/MaaWpfGui/ViewModels/LogItemViewModel.cs +++ b/src/MaaWpfGui/ViewModels/LogItemViewModel.cs @@ -19,6 +19,7 @@ using System.Windows; using System.Windows.Controls; using System.Windows.Controls.Primitives; using System.Windows.Documents; +using System.Windows.Media; using MaaWpfGui.Constants; using MaaWpfGui.Helper; using MaaWpfGui.Utilities; @@ -126,11 +127,29 @@ namespace MaaWpfGui.ViewModels private static ToolTip CreateTooltip(object content) { + var baseStyle = Application.Current.TryFindResource(typeof(ToolTip)) as Style; + + var borderFactory = new FrameworkElementFactory(typeof(Border)); + borderFactory.SetValue(Border.CornerRadiusProperty, new CornerRadius(4)); + borderFactory.SetValue(Border.BackgroundProperty, Application.Current.Resources["VersionUpdateViewBackgroundBrush"] as Brush); + borderFactory.SetValue(Border.BorderBrushProperty, new TemplateBindingExtension(Control.BorderBrushProperty)); + borderFactory.SetValue(Border.BorderThicknessProperty, new TemplateBindingExtension(Control.BorderThicknessProperty)); + borderFactory.SetValue(Border.PaddingProperty, new Thickness(5, 0, 5, 0)); + + var contentPresenterFactory = new FrameworkElementFactory(typeof(ContentPresenter)); + contentPresenterFactory.SetValue(ContentPresenter.ContentProperty, new TemplateBindingExtension(ContentControl.ContentProperty)); + borderFactory.AppendChild(contentPresenterFactory); + + var customTemplate = new ControlTemplate(typeof(ToolTip)) { VisualTree = borderFactory, }; + var style = new Style(typeof(ToolTip), baseStyle) { Setters = { new Setter(Control.TemplateProperty, customTemplate) } }; + var toolTip = new ToolTip { Content = content, Placement = PlacementMode.Center, + Style = style, }; + toolTip.Opened += (_, _) => { if (toolTip.PlacementTarget is FrameworkElement target)