Esempio n. 1
0
        public static void OnMessage <T>(T presenter, AppNotificationMessage msg)
            where T : FrameworkElement, IInAppNotificationPresenter
        {
            if (msg.Local && !presenter.Dispatcher.HasThreadAccess)
            {
                return;
            }

            if (msg.Data is ExportResult result)
            {
                if (!result.Success)
                {
                    return;
                }

                var content = ResourceHelper.InflateDataTemplate("ExportNotificationTemplate", result);
                ShowNotification(presenter, content, 5000);
            }
            else if (msg.Data is AddToCollectionResult added)
            {
                if (!added.Success)
                {
                    return;
                }

                var content = ResourceHelper.InflateDataTemplate("AddedToCollectionNotificationTemplate", added);
                ShowNotification(presenter, content, 5000);
            }
            else if (msg.Data is CollectionUpdatedArgs cua)
            {
                var content = ResourceHelper.InflateDataTemplate("RemoveFromCollectionNotification", cua);
                ShowNotification(presenter, content, 5000);
            }
            else if (msg.Data is string s)
            {
                ShowNotification(presenter, s, msg.DurationInMilliseconds > 0 ? msg.DurationInMilliseconds : 4000);
            }
        }