mirror of
https://github.com/MaxiFan/TunnelX.git
synced 2026-05-19 08:04:41 +03:00
0bc8992813
Co-authored-by: Cursor <cursoragent@cursor.com>
77 lines
2.8 KiB
C#
77 lines
2.8 KiB
C#
using System.Windows;
|
|
using AppTunnel.Views;
|
|
using AppTunnel.Services;
|
|
using Application = System.Windows.Application;
|
|
|
|
namespace AppTunnel.Helpers;
|
|
|
|
/// <summary>
|
|
/// Service for showing modern styled dialogs matching the app's UI theme.
|
|
/// Replaces Windows MessageBox with Persian-friendly, styled dialogs.
|
|
/// </summary>
|
|
public static class DialogService
|
|
{
|
|
/// <summary>
|
|
/// Show a confirmation dialog and return user's choice
|
|
/// </summary>
|
|
/// <param name="message">پیام فارسی</param>
|
|
/// <param name="title">عنوان (پیشفرض: "تاییدیه")</param>
|
|
/// <param name="owner">پنجره والد (پیشفرض: MainWindow)</param>
|
|
/// <returns>true اگر کاربر "بله" را انتخاب کند</returns>
|
|
public static bool Confirm(string message, string title = "تاییدیه", Window? owner = null)
|
|
{
|
|
return ModernDialog.ShowConfirm(LocalizationService.Instance.T(message), LocalizationService.Instance.T(title), owner);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Show an information message
|
|
/// </summary>
|
|
public static void Info(string message, string title = "اطلاعات", Window? owner = null)
|
|
{
|
|
ModernDialog.ShowInfo(LocalizationService.Instance.T(message), LocalizationService.Instance.T(title), owner);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Show a success message
|
|
/// </summary>
|
|
public static void Success(string message, string title = "موفقیت", Window? owner = null)
|
|
{
|
|
ModernDialog.ShowSuccess(LocalizationService.Instance.T(message), LocalizationService.Instance.T(title), owner);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Show an error message
|
|
/// </summary>
|
|
public static void Error(string message, string title = "خطا", Window? owner = null)
|
|
{
|
|
ModernDialog.ShowError(LocalizationService.Instance.T(message), LocalizationService.Instance.T(title), owner);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Show a warning message
|
|
/// </summary>
|
|
public static void Warning(string message, string title = "هشدار", Window? owner = null)
|
|
{
|
|
ModernDialog.ShowWarning(LocalizationService.Instance.T(message), LocalizationService.Instance.T(title), owner);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Show a clipboard copy notification (toast, no dialog)
|
|
/// </summary>
|
|
public static void ShowCopied(string itemName = "متن")
|
|
{
|
|
ShowToast(LocalizationService.Instance.Format("{0} کپی شد", itemName), "✅");
|
|
}
|
|
|
|
/// <summary>
|
|
/// Show a small auto-dismiss toast notification for 3 seconds
|
|
/// </summary>
|
|
public static void ShowToast(string message, string icon = "✅")
|
|
{
|
|
if (Application.Current.MainWindow is MainWindow mainWindow)
|
|
{
|
|
mainWindow.ShowToast(LocalizationService.Instance.T(message), icon);
|
|
}
|
|
}
|
|
}
|