Esempio n. 1
0
        private async void menuFlyoutItemMediaFromClipboard_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                var image = await Clipboard.GetContent().GetBitmapAsync();

                var stream = await image.OpenReadAsync();

                var    size   = stream.Size;
                byte[] bytes  = new byte[size];
                var    reader = new DataReader(stream.GetInputStreamAt(0));
                await reader.LoadAsync((uint)size);

                reader.ReadBytes(bytes);



                var media = new PostMedia();
                media.Data     = bytes;
                media.FileName = DateTime.Now.ToString("yyyyMMddhhmmss");

                viewModel.SetPostImageCommand.Execute(media);
            }
            catch (Exception)
            {
                ToastText text = new ToastText("クリップボードの取得に失敗しました", ToastTemplateType.ToastText01);
                text.Show();
            }
        }
Esempio n. 2
0
        private async void menuFlyoutItemMediaFromCamera_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                var         camUI = new CameraCaptureUI();
                StorageFile file  = await camUI.CaptureFileAsync(CameraCaptureUIMode.Photo);

                if (file != null)
                {
                    await SetPostImageAsync(file);
                }
            }
            catch (Exception)
            {
                ToastText text = new ToastText("カメラの起動に失敗しました", ToastTemplateType.ToastText01);
                text.Show();
            }
        }
Esempio n. 3
0
        private async void menuFlyoutItemMediaFromLibrary_Click(object sender, RoutedEventArgs e)
        {
            try{
                FileOpenPicker openPicker = new FileOpenPicker();
                openPicker.ViewMode = PickerViewMode.Thumbnail;
                openPicker.SuggestedStartLocation = PickerLocationId.PicturesLibrary;
                openPicker.FileTypeFilter.Add(".jpg");
                openPicker.FileTypeFilter.Add(".jpeg");
                openPicker.FileTypeFilter.Add(".png");

                StorageFile file = await openPicker.PickSingleFileAsync();

                if (file != null)
                {
                    await SetPostImageAsync(file);
                }
            }
            catch (Exception)
            {
                ToastText text = new ToastText("メディアの取得に失敗しました", ToastTemplateType.ToastText01);
                text.Show();
            }
        }
Esempio n. 4
0
        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));
            });
        }