コード例 #1
0
        private void SetCommands()
        {
            this.ShowImageCommand = new RelayCommand(() =>
            {
                dynamic pars = new DynamicNavigationParameters();
                pars.Attachment = this;
                (Window.Current.Content as Frame).Navigate(typeof(FeedbackImagePage), pars);
            });

            SaveImageCommand = new RelayCommand(async () =>
            {
                ImageBuffer = await Canvas.SaveAsPngIntoBufferAsync();
                InitialImage = await ImageBuffer.AsBitmapImageAsync();
                (Window.Current.Content as Frame).Navigate(typeof(FeedbackFormPage), this);
            });
            DeleteImageCommand = new RelayCommand(() =>
            {
                MarkedAsDeleted = true;
                (Window.Current.Content as Frame).Navigate(typeof(FeedbackFormPage), this);
            });
            ResetImageCommand = new RelayCommand(() =>
            {
                Canvas.Children.Clear();
                Canvas.Background = InitialImage.AsImageBrush();
            });
            CloseImageCommand = new RelayCommand(() => { (Window.Current.Content as Frame).GoBack(); });

        }
コード例 #2
0
        private void SetCommands()
        {
            Frame rootFrame = (Window.Current.Content as Frame);

            CancelCommand = new RelayCommand(() =>
            {
                rootFrame.GoBack();
            });

            SendCommand = new RelayCommand(async () =>
            {
                bool success = true;
                if (await ValidateInputAsync())
                {
                    if(NetworkInterface.GetIsNetworkAvailable())
                    {
                    this.IsBusy = true;
                    try
                    {
                        IFeedbackMessage sentMessage = await this.SendFeedbackAsync();
                        await FeedbackManager.Current.ClearMessageCacheAsync();
                        await AfterSendActionAsync(sentMessage);
                    }
                    catch (WebException e)
                    {
                        HockeyClient.Current.AsInternal().HandleInternalUnhandledException(e);
                        success = false;
                    }
                    finally
                    {
                        this.IsBusy = false;
                    }
                    if (!success)
                    {
                        await new MessageDialog(LocalizedStrings.LocalizedResources.FeedbackSendError).ShowAsync();
                    }
                    } 
                    else
                    {
                        await new MessageDialog(LocalizedStrings.LocalizedResources.FeedbackNoInternet).ShowAsync();
                    }
                }
            });

            AttachImgCommand = new RelayCommand(() =>
            {
                PickPhoto();
            });

            EditAttachmentCommand = new RelayCommand((attachVM) =>
            {
                var vm = attachVM as FeedbackAttachmentVM;
                vm.IsNewAttachment = false;
                dynamic pars = new DynamicNavigationParameters();
                pars.Attachment = vm;
                rootFrame.Navigate(this.FeedbackImagePageType, pars);
            });

        }
コード例 #3
0
        public void SetCommands()
        {

            RemoveAttachmentCommand = new RelayCommand(() =>
            {
                if (this.FeedbackMessageVM != null)
                {
                    this.FeedbackMessageVM.Attachments.Remove(this);
                }
            });

            OpenAttachmentCommand = new RelayCommand(async () =>
            {
                await OpenAttachmentAsync();
            });

        }
コード例 #4
0
        public FeedbackFlyoutVM()
        {
            RefreshCommand = new RelayCommand(() =>
            {
                this.IsBusy = true;
                var tasks = FeedbackThreadList.Where(t => !t.FeedbackThread.IsNewThread)
                                .Select(t => FeedbackManager.Current.RefreshFeedbackThreadVMAsync(SelectedFeedbackThread));
                Task.WaitAll(tasks.ToArray(),20);
                this.IsBusy = false;
            });

            AddThreadCommand = new RelayCommand(() =>
            {
                var threadVM = new FeedbackThreadVM();
                this.FeedbackThreadList.Add(threadVM);
                FeedbackManager.Current.AddFeedbackThread(threadVM);
                this.SelectedFeedbackThread = threadVM;
            });

            CloseThreadCommand = new RelayCommand(async () =>
            {
                var msg = this.SelectedFeedbackThread.IsNewThread ? 
                    LocalizedStrings.LocalizedResources.CloseNewThreadQuestion
                    : LocalizedStrings.LocalizedResources.CloseActiveThreadQuestion;
                var dialog = new MessageDialog(msg);
                dialog.Commands.Add(new UICommand() { Id = true, Label = LocalizedStrings.LocalizedResources.Yes });
                dialog.Commands.Add(new UICommand() { Id = false, Label = LocalizedStrings.LocalizedResources.No });
                var result = await dialog.ShowAsync();
                FeedbackFlyoutVM.ShowFlyout();
                if ((bool)result.Id)
                {
                    if (this.SelectedFeedbackThread.IsNewThread) { FeedbackManager.Current.SaveFeedbackThreadTokens(); }
                    this.FeedbackThreadList.Remove(this.SelectedFeedbackThread);
                    if (!this.FeedbackThreadList.Any())
                    {
                        this.FeedbackThreadList.Add(new FeedbackThreadVM());
                    }
                    this.SelectedFeedbackThread = this.FeedbackThreadList.First();
                }
            });
        }
コード例 #5
0
        private void SetCommands()
        {
            AddAttachmentCommand = new RelayCommand(async () =>
            {

                var picker = new FileOpenPicker();

                picker.ViewMode = PickerViewMode.List;
                picker.SuggestedStartLocation = PickerLocationId.DocumentsLibrary;
                picker.FileTypeFilter.Add("*");

                var files = await picker.PickMultipleFilesAsync();
                foreach (var file in files)
                {
                    byte[] bytes = null;
                    using (var stream = await file.OpenReadAsync()) {
                        IBuffer buffer = WindowsRuntimeBuffer.Create((int)stream.Size);
                        await stream.ReadAsync(buffer, (uint)stream.Size, InputStreamOptions.None);
                        bytes = buffer.ToArray();
                    }
                    var attach = new FeedbackAttachment(file.Name, bytes, file.ContentType);
                    this.Attachments.Add(new FeedbackAttachmentVM(attach) { FeedbackMessageVM = this });
                }

            });

            OpenAttachmentCommand = new RelayCommand(async (o) =>
            {
                await ((FeedbackAttachmentVM)o).OpenAttachmentAsync();
            });

            SendMessageCommand = new RelayCommand(async (o) =>
            {

                bool success = true;
                if (await ValidateInputAsync())
                {
                    if (NetworkInterface.GetIsNetworkAvailable())
                    {
                        this.IsBusy = true;
                        try
                        {
                            IFeedbackMessage sentMessage = await this.SendFeedbackAsync();
                            this.FeedbackThreadVM.HandleSentMessage(sentMessage);
                        }
                        catch (Exception e)
                        {
                            HockeyClient.Current.AsInternal().HandleInternalUnhandledException(e);
                            success = false;
                        }
                        finally
                        {
                            this.IsBusy = false;
                        }
                        if (!success)
                        {
                            await new MessageDialog(LocalizedStrings.LocalizedResources.FeedbackSendError).ShowAsync();
                            FeedbackFlyoutVM.ShowFlyout();
                        }
                    }
                    else
                    {
                        await new MessageDialog(LocalizedStrings.LocalizedResources.FeedbackNoInternet).ShowAsync();
                        FeedbackFlyoutVM.ShowFlyout();
                    }

                }
                else
                {
                    FeedbackFlyoutVM.ShowFlyout();
                }
            });

            CancelMessageCommand = new RelayCommand((o) => {
                this.Message = null;
                this.Attachments.Clear();
            });

            if (!String.IsNullOrWhiteSpace(this.Email))
            {
                Task t = this.ReLoadGravatar();
            }
            else
            {
                this.Gravatar = GravatarHelper.DefaultGravatar;
            }

        }