Exemplo n.º 1
0
 void UpdateTimeLine(RestUsage r, RestUpdateDelegate func, TimeLineType type, int sinceListIndex)
 {
     r.LastExecTime = DateTime.Now;
     r.IsRunning    = true;
     ThreadPool.QueueUserWorkItem(delegate(object o) {
         try {
             Status[] statuses = func(_restSinceList[sinceListIndex], null, r.Count, null);
             _restSinceList[sinceListIndex] = TwitterClient.GetMaxStatusID(_restSinceList[sinceListIndex], statuses);
             _dispatcher.BeginInvoke(new EmptyDelegate(delegate() {
                 for (int i = 0; i < statuses.Length; i++)
                 {
                     statuses[i].AccountInfo = this;
                     if (type == TimeLineType.Home && IsMention(statuses[i]))
                     {
                         Mentions.Add(statuses[i]);
                         if (!_mgr.HomeIncludeMentions)
                         {
                             continue;
                         }
                     }
                     else if (type == TimeLineType.Mentions && _mgr.HomeIncludeMentions)
                     {
                         HomeTimeline.Add(statuses[i]);
                     }
                     r.TimeLine.Add(statuses[i]);
                 }
             }));
         } catch {
         } finally {
             r.IsRunning    = false;
             r.LastExecTime = DateTime.Now;
             r.UpdateNextExecTimeRemaining();
         }
     });
 }
Exemplo n.º 2
0
        void IStreamingHandler.Streaming_StatusArrived(object sender, StatusArrivedEventArgs e)
        {
            StreamingClient c = sender as StreamingClient;

            _dispatcher.BeginInvoke(new EmptyDelegate(delegate() {
                if (!IsIncludeOtherStatus)
                {
                    if (!_client.FriendSet.Contains(e.Status.User.ID))
                    {
                        return;
                    }
                    if (e.Status.InReplyToUserId > 0)
                    {
                        if (!_client.FriendSet.Contains(e.Status.InReplyToUserId))
                        {
                            return;
                        }
                    }
                    if (e.Status.RetweetedStatus != null && e.Status.RetweetedStatus.User != null)
                    {
                        if (e.Status.RetweetedStatus.User.ID == SelfUserID)
                        {
                            return;
                        }
                    }
                }
                e.Status.AccountInfo = this;
                if (IsMention(e.Status))
                {
                    Mentions.Add(e.Status);
                    if (!_mgr.HomeIncludeMentions)
                    {
                        return;
                    }
                }
                HomeTimeline.Add(e.Status);
            }));
        }
        private async void btnAdd_Click(object sender, RoutedEventArgs e)
        {
            bool isInputOK = true;

            if (textTimelineName.Text == string.Empty)
            {
                MessageDialog dialog = new MessageDialog("タイムライン名が入力されていません", "入力エラー");
                await dialog.ShowAsync();

                isInputOK = false;
            }
            foreach (var t in viewModel.NowTimelineList)
            {
                if (t.ListTitle == textTimelineName.Text)
                {
                    MessageDialog dialog = new MessageDialog("タイムライン名が競合しています。固有のタイムライン名を入力してください", "入力エラー");
                    await dialog.ShowAsync();

                    isInputOK = false;
                }
            }
            if (this.comboBoxAccount.SelectedIndex == -1)
            {
                MessageDialog dialog = new MessageDialog("アカウント名が選択されていません", "入力エラー");
                await dialog.ShowAsync();

                isInputOK = false;
            }
            if (this.comboBoxTimelineType.SelectedIndex == -1)
            {
                MessageDialog dialog = new MessageDialog("タイムラインタイプが選択されていません", "入力エラー");
                await dialog.ShowAsync();

                isInputOK = false;
            }

            if (isInputOK == true)
            {
                TimelineBase   resultModel = null;
                TwitterAccount account     = (TwitterAccount)comboBoxAccount.SelectedItem;
                switch (comboBoxTimelineType.SelectedIndex)
                {
                case 0:
                    resultModel = new HomeTimeline(account, textTimelineName.Text, viewModel.GetNowTab().TabTitle, viewModel.Setting, viewModel.CallTimelineAction, viewModel.CallRowAction);
                    break;

                case 1:
                    resultModel = new MentionTimeline(account, textTimelineName.Text, viewModel.GetNowTab().TabTitle, viewModel.Setting, viewModel.CallTimelineAction, viewModel.CallRowAction);

                    break;

                case 2:
                    resultModel = new NotificationTimeline(account, textTimelineName.Text, viewModel.GetNowTab().TabTitle, viewModel.Setting, viewModel.CallTimelineAction, viewModel.CallRowAction);

                    break;

                case 3:
                    if (textSearchWord.Text == string.Empty)
                    {
                        MessageDialog dialog = new MessageDialog("検索ワードが入力されていません", "入力エラー");
                        await dialog.ShowAsync();

                        return;
                    }
                    resultModel = new SearchTimeline(account, textTimelineName.Text, viewModel.GetNowTab().TabTitle, textSearchWord.Text, viewModel.Setting, viewModel.CallTimelineAction, viewModel.CallRowAction);

                    break;

                case 4:
                    if (comboList.SelectedIndex == -1)
                    {
                        MessageDialog dialog = new MessageDialog("リストが選択されていません", "入力エラー");
                        await dialog.ShowAsync();

                        return;
                    }
                    resultModel = new ListTimeline(account, textTimelineName.Text, viewModel.GetNowTab().TabTitle, (TwitterList)comboList.SelectedItem, viewModel.Setting, viewModel.CallTimelineAction, viewModel.CallRowAction);

                    break;

                case 5:
                    resultModel = new DirectMessageTimeline(account, textTimelineName.Text, viewModel.GetNowTab().TabTitle, viewModel.Setting, viewModel.CallTimelineAction, viewModel.CallRowAction);
                    break;

                case 6:
                    if (textUser.Text == string.Empty)
                    {
                        MessageDialog dialog = new MessageDialog("ユーザー名が入力されていません", "入力エラー");
                        await dialog.ShowAsync();

                        return;
                    }
                    resultModel = new UserTimeline(account, textTimelineName.Text, viewModel.GetNowTab().TabTitle, textUser.Text, viewModel.Setting, viewModel.CallTimelineAction, viewModel.CallRowAction);

                    break;

                case 7:
                    resultModel = new ImageTimeline(account, textTimelineName.Text, viewModel.GetNowTab().TabTitle, viewModel.Setting, viewModel.CallTimelineAction, viewModel.CallRowAction);
                    break;

                case 8:
                    resultModel = new LinkTimeline(account, textTimelineName.Text, viewModel.GetNowTab().TabTitle, viewModel.Setting, viewModel.CallTimelineAction, viewModel.CallRowAction);

                    break;
                }
                if (toggleTimelineFiltering.IsOn)
                {
                    resultModel.ExtractionAccountScreenNameStr = textExtractionAccount.Text;
                    resultModel.ExcludeAccountScreenNameStr    = textExcludeAccount.Text;
                    resultModel.ExtractionWordStr   = textExtractionWord.Text;
                    resultModel.ExcludeWordStr      = textExcludeWord.Text;
                    resultModel.IsTimelineFiltering = toggleTimelineFiltering.IsOn;
                    resultModel.IsNewNotification   = toggleNotification.IsOn;
                }

                viewModel.AddTimelineCommand.Execute(resultModel);
                onCreateCallBack(resultModel);
                this.Hide();
            }
        }
        private async void btnAdd_Click(object sender, RoutedEventArgs e)
        {
            bool isInputOK = true;
            if (textTimelineName.Text == string.Empty)
            {
                MessageDialog dialog = new MessageDialog("タイムライン名が入力されていません","入力エラー");
                await dialog.ShowAsync();
                isInputOK = false;
            }
            foreach (var t in viewModel.NowTimelineList)
            {
                if (t.ListTitle == textTimelineName.Text)
                {
                    MessageDialog dialog = new MessageDialog("タイムライン名が競合しています。固有のタイムライン名を入力してください", "入力エラー");
                    await dialog.ShowAsync();
                    isInputOK = false;
                }
            }
            if (this.comboBoxAccount.SelectedIndex == -1)
            {
                MessageDialog dialog = new MessageDialog("アカウント名が選択されていません", "入力エラー");
                await dialog.ShowAsync();
                isInputOK = false;
            }
            if (this.comboBoxTimelineType.SelectedIndex == -1)
            {
                MessageDialog dialog = new MessageDialog("タイムラインタイプが選択されていません", "入力エラー");
                await dialog.ShowAsync();
                isInputOK = false;
            }

            if (isInputOK == true)
            {
                
                
                TimelineBase resultModel=null;
                TwitterAccount account=(TwitterAccount)comboBoxAccount.SelectedItem;
                switch(comboBoxTimelineType.SelectedIndex)
                {
                    case 0:
                        resultModel = new HomeTimeline(account, textTimelineName.Text,viewModel.GetNowTab().TabTitle,viewModel.Setting,viewModel.CallTimelineAction,viewModel.CallRowAction);
                        break;
                    case 1:
                        resultModel = new MentionTimeline(account, textTimelineName.Text, viewModel.GetNowTab().TabTitle, viewModel.Setting, viewModel.CallTimelineAction, viewModel.CallRowAction);
                        
                        break;
                    case 2:
                        resultModel = new NotificationTimeline(account, textTimelineName.Text, viewModel.GetNowTab().TabTitle, viewModel.Setting, viewModel.CallTimelineAction, viewModel.CallRowAction);
                        
                        break;
                    case 3:
                        if (textSearchWord.Text ==string.Empty)
                        {
                            MessageDialog dialog = new MessageDialog("検索ワードが入力されていません","入力エラー");
                            await dialog.ShowAsync();
                            return;
                        }
                        resultModel = new SearchTimeline(account, textTimelineName.Text, viewModel.GetNowTab().TabTitle, textSearchWord.Text, viewModel.Setting, viewModel.CallTimelineAction, viewModel.CallRowAction);
                        
                        break;
                    case 4:
                        if (comboList.SelectedIndex==-1)
                        {
                            MessageDialog dialog = new MessageDialog("リストが選択されていません", "入力エラー");
                            await dialog.ShowAsync();
                            return;
                        }
                        resultModel = new ListTimeline(account, textTimelineName.Text, viewModel.GetNowTab().TabTitle, (TwitterList)comboList.SelectedItem, viewModel.Setting, viewModel.CallTimelineAction, viewModel.CallRowAction);
                        
                        break;
                    case 5:
                        resultModel = new DirectMessageTimeline(account, textTimelineName.Text, viewModel.GetNowTab().TabTitle, viewModel.Setting, viewModel.CallTimelineAction, viewModel.CallRowAction);
                        break;
                    case 6:
                        if (textUser.Text==string.Empty)
                        {
                            MessageDialog dialog = new MessageDialog("ユーザー名が入力されていません", "入力エラー");
                            await dialog.ShowAsync();
                            return;
                        }
                        resultModel = new UserTimeline(account, textTimelineName.Text, viewModel.GetNowTab().TabTitle, textUser.Text, viewModel.Setting, viewModel.CallTimelineAction, viewModel.CallRowAction);
                        
                        break;
                    case 7:
                        resultModel = new ImageTimeline(account, textTimelineName.Text,viewModel.GetNowTab().TabTitle,viewModel.Setting,viewModel.CallTimelineAction,viewModel.CallRowAction);
                        break;
                    case 8:
                        resultModel = new LinkTimeline(account, textTimelineName.Text, viewModel.GetNowTab().TabTitle, viewModel.Setting, viewModel.CallTimelineAction, viewModel.CallRowAction);
                        
                        break;

                }
                if (toggleTimelineFiltering.IsOn)
                {
                    resultModel.ExtractionAccountScreenNameStr = textExtractionAccount.Text;
                    resultModel.ExcludeAccountScreenNameStr = textExcludeAccount.Text;
                    resultModel.ExtractionWordStr = textExtractionWord.Text;
                    resultModel.ExcludeWordStr = textExcludeWord.Text;
                    resultModel.IsTimelineFiltering = toggleTimelineFiltering.IsOn;
                    resultModel.IsNewNotification = toggleNotification.IsOn;
                }
                
                viewModel.AddTimelineCommand.Execute(resultModel);
                onCreateCallBack(resultModel);
                this.Hide();
            }
           
        }