Bläddra i källkod

Remove ShowTooltipMessage

Ruben 10 månader sedan
förälder
incheckning
b8150801f5

+ 1 - 1
src/PicView.Avalonia/Navigation/ExifHandling.cs

@@ -165,7 +165,7 @@ public static class ExifHandling
         {
             #if DEBUG
             Console.WriteLine(e);
-            TooltipHelper.ShowTooltipMessage(e);
+            _ = TooltipHelper.ShowTooltipMessageAsync(e);
             #endif
         }
     }

+ 0 - 64
src/PicView.Avalonia/UI/TooltipHelper.cs

@@ -75,70 +75,6 @@ public static class TooltipHelper
         }
     }
 
-    /// <summary>
-    /// Shows the tooltip message on the UI.
-    /// </summary>
-    /// <param name="message">The message to display in the tooltip.</param>
-    /// <param name="center">Determines whether the tooltip should be centered or aligned at the bottom.</param>
-    /// <param name="interval">The duration for which the tooltip should be visible.</param>
-    public static void ShowTooltipMessage(object message, bool center, TimeSpan interval)
-    {
-        var timer = new DispatcherTimer { Interval = interval };
-        timer.Tick += (_, _) =>
-        {
-            if (!_isRunning)
-            {
-                Dispatcher.UIThread.Invoke(() =>
-                {
-                    var toolTip = UIHelper.GetToolTipMessage;
-                    if (toolTip != null)
-                    {
-                        toolTip.Opacity = 0;
-                    }
-                });
-            }
-
-            _isRunning = false;
-            timer.Stop();
-        };
-        timer.Start();
-
-        try
-        {
-            Dispatcher.UIThread.Invoke(() =>
-            {
-                var toolTip = UIHelper.GetToolTipMessage;
-                if (toolTip is null)
-                {
-                    return;
-                }
-
-                _isRunning = true;
-                toolTip.IsVisible = true;
-                toolTip.ToolTipMessageText.Text = message.ToString();
-                toolTip.Margin = center ? new Thickness(0) : new Thickness(0, 0, 0, 15);
-                toolTip.VerticalAlignment = center ? VerticalAlignment.Center : VerticalAlignment.Bottom;
-                toolTip.Opacity = 1;
-            });
-        }
-        catch (Exception exception)
-        {
-#if DEBUG
-            Console.WriteLine($"{nameof(ShowTooltipMessage)} exception, \n{exception.Message}");
-#endif
-        }
-    }
-
-    /// <summary>
-    /// Shows the tooltip message on the UI with a default duration of 2 seconds.
-    /// </summary>
-    /// <param name="message">The message to display in the tooltip.</param>
-    /// <param name="center">Determines whether the tooltip should be centered or aligned at the bottom.</param>
-    internal static void ShowTooltipMessage(object message, bool center = false)
-    {
-        ShowTooltipMessage(message, center, TimeSpan.FromSeconds(2));
-    }
-
     /// <summary>
     /// Shows the tooltip message on the UI with a default duration of 2 seconds.
     /// </summary>

+ 2 - 2
src/PicView.Avalonia/ViewModels/MainViewModel.cs

@@ -1279,7 +1279,7 @@ public class MainViewModel : ViewModelBase
                 var errorMsg = FileDeletionHelper.DeleteFileWithErrorMsg(path, recycle: false);
                 if (!string.IsNullOrWhiteSpace(errorMsg))
                 {
-                    TooltipHelper.ShowTooltipMessage(errorMsg);
+                    _ = TooltipHelper.ShowTooltipMessageAsync(errorMsg);
                 }
                 else
                 {
@@ -1288,7 +1288,7 @@ public class MainViewModel : ViewModelBase
             }
             catch (Exception e)
             {
-                TooltipHelper.ShowTooltipMessage(e);
+                _ = TooltipHelper.ShowTooltipMessageAsync(e);
 #if DEBUG
                 Console.WriteLine(e);
 #endif