using CommunityToolkit.Mvvm.ComponentModel; using ivf_tl_Entity.Enums; using ivf_tl_Manage.Win; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ivf_tl_Manage.ViewModels { public class BaseViewModel: ObservableObject { protected string ViewModelName { get; set; } = "BaseViewModel"; public string NavName { get; set; } public List NavList { get; set; } = new List(); protected void ToastShow(bool b) { new ToastWindow(AppData.Instance.MainWindow, 1920, 65, b).Show(); } protected void ToastMessageShow(string mess) { new ToastMessageWindow(AppData.Instance.MainWindow, 1920, 65, mess).Show(); } protected bool? MessageBoxShow(string title, string mess) { try { AppData.Instance.MainWindowViewModel.MaskVisibility = true; var a = new MessageBoxWindow(title, mess, AppData.Instance.MainWindow).ShowDialog(); AppData.Instance.MainWindowViewModel.MaskVisibility = false; return a; } catch (Exception ex) { AppData.Instance.MainWindowViewModel.MaskVisibility = false; ExLog(ex, "MessageBoxShow"); return false; } } protected void ExLog(Exception ex, string name) { AppData.Instance.LogService.ExceptionLog(ex, $"{ViewModelName}.{name}", LogEnum.RunException); } protected void ErrorLog(string message, LogEnum logType) { AppData.Instance.LogService.TLLog($"{ViewModelName}.{message}", logType); } protected void DebugLog(string message, LogEnum logType) { AppData.Instance.LogService.TLLog($"{ViewModelName}.{message}", logType); } protected void TimeLog(string message, LogEnum logType) { AppData.Instance.LogService.TLLog($"{ViewModelName}.{message}", logType); } } }