コード例 #1
0
ファイル: MainPage.xaml.cs プロジェクト: garicchi/Neuronia
        private void MessengerRegister()
        {
            Messenger.Default.Register<string>(this, "GetAuthorizedUrl", str =>
            {
                authenticationBrowser.NavigateUrl(str);
            });

            Messenger.Default.Register<bool>(this, "AuthorizedCompleted",async bln =>
            {
                if (bln)
                {
                    authenticationBrowser.Close();
                }
                else
                {
                    MessageDialog dialog=new MessageDialog("ピンコードが違います","エラー");
                    await dialog.ShowAsync();
                    authenticationBrowser.Close();
                    Authentication();
                }
            });

            Messenger.Default.Register<string>(this, "BrowsUrl", str =>
            {
                PreviewBrowserFlyout flyout = new PreviewBrowserFlyout();
                flyout.Show(new Uri(str), Window.Current.Bounds.Width * 2 / 3);
            });

            Messenger.Default.Register<SearchDetail>(this, "ShowSearchDetail", sd =>
            {
                SearchDetailFlyout flyout = new SearchDetailFlyout(viewModel);
                flyout.onAddTimeline += (timelineName, searchWord, account) =>
                {
                    var timeline = new SearchTimeline(account, timelineName, viewModel.GetNowTab().TabTitle, searchWord,viewModel.Setting, viewModel.CallTimelineAction, viewModel.CallRowAction);
                    viewModel.AddTimelineCommand.Execute(timeline);
                };
                flyout.ShowIndependent();
            });

            Messenger.Default.Register<UserDetail>(this, "ShowUserDetail", ud =>
            {
                UserDetailFlyout flyout = new UserDetailFlyout(viewModel, () =>
                {
                    viewModel.DirectMessageDetailCommand.Execute(new DirectMessageDetailParameter(ud.OwnerAccount.UserInfomation.screen_name,new DirectMessage
                    {
                        recipient_screen_name = viewModel.UserDetail.UserInformation.screen_name
                    }));
                    DirectMessageFlyout d_flyout = new DirectMessageFlyout(this.viewModel);
                    d_flyout.ShowIndependent();
                });
                flyout.ShowIndependent();
            });

            Messenger.Default.Register<TweetDetail>(this, "ShowTweetDetail", td =>
            {
                TweetDetailFlyout flyout = new TweetDetailFlyout(viewModel);
                flyout.ShowIndependent();
            });

         
            Messenger.Default.Register<bool>(this, "InternalNotification",async tweet =>
            {
                 notificationBarStoryboard.Begin();
                if (viewModel.Setting.IsSoundEnable)
                {
                    mediaElementNotification.Play();
                }

            });

            Messenger.Default.Register<bool>(this, "ToastNotification", async tweet =>
            {
                

                ToastText toast = new ToastText(viewModel.NotifyMessage.Message, Windows.UI.Notifications.ToastTemplateType.ToastText01);
                toast.Show();

            });

            Messenger.Default.Register<NotificationState>(this, "ChangeNotificationState", state =>
            {

            });

            Messenger.Default.Register<PostStatusBase>(this, "OnTweetBegin", status =>
            {
   
            });
            Messenger.Default.Register<PostStatusBase>(this, "OnTweetFailed", status =>
            {
            });
            Messenger.Default.Register<PostStatusBase>(this, "OnTweetCompleted", status =>
            {
            });
            Messenger.Default.Register<HttpRequestException>(this, "OnHttpGetError", e =>
            {
                
            });
            Messenger.Default.Register<HttpRequestException>(this, "OnHttpPostError", e =>
            {
            });
            Messenger.Default.Register<HttpRequestException>(this, "OnUserStreamHttpError", e =>
            {
            });
            Messenger.Default.Register<HttpRequestException>(this, "OnFollowStreamHttpError", e =>
            {
            });
            Messenger.Default.Register<TimelineBase>(this, "EditTimeline", timeline =>
            {
                EditTimelineFlyout flyout = new EditTimelineFlyout(viewModel);
                flyout.ShowIndependent();
            });
            Messenger.Default.Register<TimelineBase>(this, "DeleteTimeline", timeline =>
            {
                ChangeTimelineSize(new Size(Window.Current.Bounds.Width, Window.Current.Bounds.Height));
            });

            Messenger.Default.Register<TimelineTab>(this, "EditTimelineTab", tab =>
            {
                EditTabFlyout flyout = new EditTabFlyout(viewModel);
                flyout.ShowIndependent();
            });

            Messenger.Default.Register<TimelineTab>(this, "DeleteTimelineTab", tab =>
            {
                
            });

            Messenger.Default.Register<string>(this, "DeletePostImage", str =>
            {
      
            });
            Messenger.Default.Register<int>(this, "SetPostTextCursor", pos =>
            {
                
                if (timelineState == TimelineState.MultiTimeline)
                {
                    textPost.Select(pos, 0);
                }
                else
                {
                    textPostBottom.Select(pos, 0);
                }
            });

            Messenger.Default.Register<TimelineBase>(this, "AddTimeline", timeline =>
            {
                ChangeTimelineSize(new Size(Window.Current.Bounds.Width,Window.Current.Bounds.Height));
            });

            Messenger.Default.Register<DirectMessage>(this, "ShowDirectMessageDetail", dm =>
            {
                DirectMessageFlyout flyout = new DirectMessageFlyout(this.viewModel);
                flyout.ShowIndependent();
            });

            Messenger.Default.Register<TimelineTab>(this, "ChangeTab", tab =>
            {
                ChangeTimelineSize(new Size(Window.Current.Bounds.Width,Window.Current.Bounds.Height));
            });

            
        }
コード例 #2
0
ファイル: MainPage.xaml.cs プロジェクト: garicchi/Neuronia
        private void appBarButtonSearch_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e)
        {
            appBar_Bottom.IsOpen = false;
            appBar_Top.IsOpen = false;
            SearchDetailFlyout flyout = new SearchDetailFlyout(viewModel);
            flyout.onAddTimeline += (timelineName, searchWord, account) =>
            {
                var timeline = new SearchTimeline(account,timelineName,viewModel.GetNowTab().TabTitle,searchWord,viewModel.Setting,viewModel.CallTimelineAction,viewModel.CallRowAction);
                viewModel.AddTimelineCommand.Execute(timeline);
            };
            flyout.Show();

        }
コード例 #3
0
        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();
            }
           
        }