コード例 #1
0
ファイル: NotifierViewModel.cs プロジェクト: a1lic/Mystique
        private void OnEventRegistered(object o, EventDescriptionEventArgs e)
        {
            if (e.EventDescription == null || !Setting.Instance.NotificationProperty.IsEnabledNotificationBar)
            {
                return;
            }
            switch (e.EventDescription.Kind)
            {
            case EventKind.DirectMessage:
                if (!Setting.Instance.NotificationProperty.NotifyDmEvent)
                {
                    return;
                }
                break;

            case EventKind.Favorite:
            case EventKind.Unfavorite:
                if (!Setting.Instance.NotificationProperty.NotifyFavoriteEvent)
                {
                    return;
                }
                break;

            case EventKind.Mention:
                if (!Setting.Instance.NotificationProperty.NotifyMentionEvent)
                {
                    return;
                }
                break;

            case EventKind.Retweet:
                if (!Setting.Instance.NotificationProperty.NotifyRetweetEvent)
                {
                    return;
                }
                break;

            case EventKind.Follow:
                if (!Setting.Instance.NotificationProperty.NotifyFollowEvent)
                {
                    return;
                }
                break;
            }
            var nivm = new NotificationItemViewModel(e.EventDescription);

            nivm.RequireClose += (no, ne) => _notifications.Remove(nivm);
            _notifications.Add(nivm);
            Task.Factory.StartNew(() => Thread.Sleep(Setting.Instance.ExperienceProperty.TwitterActionNotifyShowLength))
            .ContinueWith(_ =>
            {
                try
                {
                    _notifications.Remove(nivm);
                }
                catch { }
            });
        }
コード例 #2
0
 private static void RaiseNotificationEvent(object sender, EventDescriptionEventArgs e)
 {
     if (Setting.Instance.StateProperty.IsInSilentMode)
     {
         return;
     }
     if (NotificationEvent == null)
     {
         return;
     }
     NotificationEvent(sender, e);
 }
コード例 #3
0
 void EventStorage_EventRegistered(object sender, EventDescriptionEventArgs e)
 {
     Task.Factory.StartNew(() =>
     {
         switch (e.EventDescription.Kind)
         {
         case EventKind.Follow:
             CheckFollower(e.EventDescription.SourceUser, e.EventDescription.TargetUser.TwitterUser.ScreenName);
             break;
         }
     });
 }
コード例 #4
0
        private static void EventStorage_EventRegistered(object sender, EventDescriptionEventArgs e)
        {
            switch (e.EventDescription.Kind)
            {
            case EventKind.Favorite:
                if (Setting.Instance.NotificationProperty.NotifyFavorite)
                {
                    RaiseNotificationEvent(sender, e);
                    IssueNotification(
                        e.EventDescription.SourceUser,
                        e.EventDescription.TargetUser,
                        e.EventDescription.TargetTweet.Text, EventKind.Favorite);
                }
                break;

            case EventKind.Follow:
                if (Setting.Instance.NotificationProperty.NotifyFollow)
                {
                    RaiseNotificationEvent(sender, e);
                    IssueNotification(
                        e.EventDescription.SourceUser,
                        e.EventDescription.TargetUser,
                        e.EventDescription.SourceUser.TwitterUser.Bio,
                        EventKind.Follow);
                }
                break;

            case EventKind.Mention:
                if (Setting.Instance.NotificationProperty.NotifyMention)
                {
                    RaiseNotificationEvent(sender, e);
                    IssueNotification(
                        e.EventDescription.SourceUser,
                        e.EventDescription.TargetUser,
                        e.EventDescription.TargetTweet.Text,
                        EventKind.Mention);
                }
                break;

            case EventKind.Retweet:
                if (Setting.Instance.NotificationProperty.NotifyRetweet)
                {
                    RaiseNotificationEvent(sender, e);
                    IssueNotification(
                        e.EventDescription.SourceUser,
                        e.EventDescription.TargetUser,
                        e.EventDescription.TargetTweet.Text,
                        EventKind.Retweet);
                }
                break;

            case EventKind.Unfavorite:
                if (Setting.Instance.NotificationProperty.NotifyFavorite)
                {
                    RaiseNotificationEvent(sender, e);
                    IssueNotification(
                        e.EventDescription.SourceUser,
                        e.EventDescription.TargetUser,
                        e.EventDescription.TargetTweet.Text, EventKind.Unfavorite);
                }
                break;
            }
        }