コード例 #1
0
        protected override void OnSendNotification(string title, string message, string testing)
        {
            Logger.Write("UI: Request Showing Taost received...", LogLevel.Debug);
            if (MainControl.DisableToasts.Checked)
            {
                Logger.Write("UI: Toasts are disabled!", LogLevel.Debug);
                return;
            }

            if (MainControl.EnableActToast.Checked)
            {
                Logger.Write("UI: Using ACT Toasts", LogLevel.Debug);
                var traySlider = new TraySlider();
                traySlider.ShowDurationMs   = 30000;
                traySlider.ButtonSE.Visible = false;
                traySlider.ButtonNE.Visible = false;
                traySlider.ButtonNW.Visible = false;
                traySlider.ButtonSW.Visible = true;
                traySlider.ButtonSW.Text    = LocalizationRepository.GetText("ui-close-act-toast");
                traySlider.TrayTitle.Font   = new Font(FontFamily.GenericSerif, 16, FontStyle.Bold);
                traySlider.TrayText.Font    = new Font(FontFamily.GenericSerif, 12, FontStyle.Regular);
                if (!string.IsNullOrWhiteSpace(testing))
                {
                    message += $"\nCode [{testing}]";
                }

                traySlider.ShowTraySlider(message, title);
            }
            else
            {
                Logger.Write("UI: Using Windows Toasts", LogLevel.Debug);
                try
                {
                    // clearing old toasts if needed
                    DesktopNotificationManagerCompat.History.Clear();

                    Logger.Write("UI: Creating new Toast...", LogLevel.Debug);
                    ToastManager.ShowToast(title, message, testing);
                }
                catch (Exception e)
                {
                    Logger.Write(e, "UI: Using built in notifier...", LogLevel.Error);
                    var icon = new NotifyIcon
                    {
                        Icon            = SystemIcons.WinLogo,
                        Text            = "DFAssist",
                        Visible         = true,
                        BalloonTipTitle = title,
                        BalloonTipText  = message
                    };
                    icon.ShowBalloonTip(3000);
                    icon.Dispose();
                }
            }
        }
コード例 #2
0
        protected override void OnSendNotification(string title, string message, string testing)
        {
            Logger.Write("UI: Request Showing Taost received...", LogLevel.Debug);
            if (MainControl.DisableToasts.Checked)
            {
                Logger.Write("UI: Toasts are disabled!", LogLevel.Debug);
                return;
            }

            if (MainControl.EnableActToast.Checked)
            {
                Logger.Write("UI: Using ACT Toasts", LogLevel.Debug);
                var traySlider = new TraySlider
                {
                    Font           = new Font(FontFamily.GenericSerif, 16, FontStyle.Bold),
                    ShowDurationMs = 30000
                };
                traySlider.ButtonSE.Visible = false;
                traySlider.ButtonNE.Visible = false;
                traySlider.ButtonNW.Visible = false;
                traySlider.ButtonSW.Visible = true;
                traySlider.ButtonSW.Text    = LocalizationRepository.GetText("ui-close-act-toast");
                traySlider.ShowTraySlider($"{message}\n{testing}", title);
            }
            else
            {
                Logger.Write("UI: Using Windows Toasts", LogLevel.Debug);
                try
                {
                    Logger.Write("UI: Creating new Toast...", LogLevel.Debug);
                    var attribution = nameof(DFAssist);

                    if (string.IsNullOrWhiteSpace(testing))
                    {
                        WinToastWrapper.CreateToast(
                            DFAssistPlugin.AppId,
                            DFAssistPlugin.AppId,
                            title,
                            message,
                            _toastEventCallback,
                            attribution,
                            true,
                            Duration.Long);
                    }
                    else
                    {
                        WinToastWrapper.CreateToast(
                            DFAssistPlugin.AppId,
                            DFAssistPlugin.AppId,
                            title,
                            message,
                            $"Code [{testing}]",
                            _toastEventCallback,
                            attribution,
                            Duration.Long);
                    }
                }
                catch (Exception e)
                {
                    Logger.Write(e, "UI: Unable to show toast notification", LogLevel.Error);
                }
            }
        }