private async void DownvoteBtn_Click(object sender, RoutedEventArgs e)
        {
            var btn      = sender as ToggleButton;
            var fbc      = btn.DataContext as FeedbackControl;
            var feedback = fbc.Feedback;

            var index = feedbacks.IndexOf(feedback);

            //disable button
            btn.IsEnabled = false;

            //Cast a vote, 1 for upvote,2 for downvote, update if existed
            var result = await MainPage.SO.VoteAsync(MainPage.instance.user.UserId, 0, feedback);

            //Update number
            feedback = await MainPage.SO.RefreshVotes(feedback);

            feedbacks[index] = feedback;

            try
            {
                (CommentFrame.Content as CommentPage).Feedback = feedback;
            }
            catch (Exception)
            {
                await HelpersClass.ShowDialogAsync("Có lỗi xảy ra");
            }

            //enable button
            btn.IsEnabled = true;
            //fbc.DownvoteBtn.IsChecked = result;
            //fbc.UpvoteBtn.IsChecked = fbc.UpvoteBtn.IsChecked == true ? false : false;
        }
Beispiel #2
0
        public async Task SetNewFeedback(Feedback fb)
        {
            try
            {
                ImageLoadingStackPanel.Visibility = Visibility.Collapsed;

                if (downloadTask != null)
                {
                    if (!downloadTask.IsCanceled)
                    {
                        App.CloudStorage.CancelDownload();
                        downloadTask.AsAsyncOperation().Cancel();
                    }
                }
                SupportImage.Source = null;
                Feedback            = fb;
                await GetComments(Feedback);

                downloadTask = LoadImage(fb);

                SupportImage.Source = await downloadTask;
            }
            catch (Exception e)
            {
                await HelpersClass.ShowDialogAsync("Something went wrong " + e.Message);
            }
        }
Beispiel #3
0
        private async Task StartPreviewAsync()
        {
            try
            {
                _mediaCapture = new MediaCapture();
                await _mediaCapture.InitializeAsync();

                _displayRequest.RequestActive();
            }
            catch (UnauthorizedAccessException)
            {
                // This will be thrown if the user denied access to the camera in privacy settings
                await HelpersClass.ShowDialogAsync("The app was denied access to the camera");

                return;
            }

            try
            {
                PreviewControl.Source = _mediaCapture;
                await _mediaCapture.StartPreviewAsync();

                _isPreviewing = true;
            }
            catch (System.IO.FileLoadException)
            {
                //_mediaCapture.CaptureDeviceExclusiveControlStatusChanged += _mediaCapture_CaptureDeviceExclusiveControlStatusChanged;
            }
        }
        private async void UpvoteBtn_Click(object sender, RoutedEventArgs e)
        {
            var btn      = sender as ToggleButton;
            var fbc      = btn.DataContext as FeedbackControl;
            var feedback = fbc.Feedback;

            try
            {
                var index = feedbacks.IndexOf(feedback);

                //Disable butn
                btn.IsEnabled = false;

                var result = await MainPage.SO.VoteAsync(MainPage.instance.user.UserId, 1, feedback);

                //Update number
                feedback = await MainPage.SO.RefreshVotes(feedback);

                feedbacks[index] = feedback;

                if (CommentFrame.Content != null)
                {
                    (CommentFrame.Content as CommentPage).Feedback = feedback;
                }
                //Enable Butn
                btn.IsEnabled = true;
            }
            catch (Exception ex)
            {
                await HelpersClass.ShowDialogAsync("Khi con tim yếu mềm, lỗi xuất hiện: " + ex.Message);
            }
        }
Beispiel #5
0
        private async Task CreateChannelAsync()
        {
            ChannelControl.CreateChannelButton.IsEnabled = false;
            var c       = ChannelControl;
            var channel = new Channel()
            {
                Name       = c.ChannelName,
                Location   = c.Location,
                AccessCode = c.AccessCode,
                UserId     = MainPage.instance.user.UserId,
                StorageURL = c.Web,
                Phone      = c.Phone
            };

            var result = await MainPage.SO.AddChannelAsync(channel);

            if (result)
            {
                channels.Clear();
                channels.Add(channel);
                SetChannelCreationUI(false);
            }
            else
            {
                await HelpersClass.ShowDialogAsync("Kiểm tra lại thông tin nhập.");
            }
        }
        private async void GGLoginButton_Click(object sender, RoutedEventArgs e)
        {
            this.user = await MainPage.SO.Login(MobileServiceAuthenticationProvider.Google);

            if (user != null)
            {
                this.Frame.Navigate(typeof(NavigationPage));
            }
            else
            {
                await HelpersClass.ShowDialogAsync("Something went wrong");
            }
        }
Beispiel #7
0
        private async void GoToChannelBtn_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                var channel = await MainPage.SO.GetChannelById(Feedback.ChannelID);

                NavigationPage.instance.NavigateTo(typeof(ChannelFeedbackPage), channel);
            }
            catch
            {
                await HelpersClass.ShowDialogAsync("Có lỗi xảy ra :( ");
            }
        }
Beispiel #8
0
        private async Task <List <Channel> > GetChannelsAsync()
        {
            try
            {
                var list = await MainPage.SO.GetChannelAsync(MainPage.instance.user.UserId);

                return(list.ToList());
            }
            catch (Exception e)
            {
                await HelpersClass.ShowDialogAsync("Something wrong retrieving Channels" + e.Message);
            }
            return(null);
        }
        private async void ApplyBtn_Click(object sender, RoutedEventArgs e)
        {
            var sd      = sender as Button;
            var control = sd.DataContext as AdminFeedbackControl;
            var fb      = control.DataContext as Feedback;

            control.ActionApplying = true;

            fb.Action = control.SelectedIndex;
            if (await MainPage.SO.ActionChange(fb) == false)
            {
                await HelpersClass.ShowDialogAsync("Something went wrong");
            }
            control.ActionApplying = false;
        }
Beispiel #10
0
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            try
            {
                bool b = false;
                if (e.Parameter is bool)
                {
                    b = (bool)e.Parameter;
                }

                await InitializePageAsync(b);
            }catch (Exception ex)
            {
                await HelpersClass.ShowDialogAsync(ex.Message);
            }

            base.OnNavigatedTo(e);
        }
        private async void AddImageBtn_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                var file = await FilePicker.OpenPicker(new List <string>() { ".jpg", ".png" });

                FBFormControl.SetSupportImageSource(await FilePicker.ConvertToBitmapFromFile(file));
                if (file != null)
                {
                    //var encoded = await FilePicker.EncodeFile(file);
                    FBFormControl.Imagefile = file;
                }
            }
            catch
            {
                await HelpersClass.ShowDialogAsync("Lỗi khi thêm hình ảnh");
            }
        }
Beispiel #12
0
        private async void Post_Click(object sender, RoutedEventArgs e)
        {
            Comment cmt = new Comment()
            {
                UserID = MainPage.instance.user.UserId, FeedbackID = Feedback.Id, CommentContent = CommentTextBox.Text
            };
            var res = await MainPage.SO.AddComment(cmt);

            if (res == null)
            {
                await HelpersClass.ShowDialogAsync("You have exceed 10 maximum comments for a day");
            }
            else
            {
                comments.Insert(0, res);
                NoCommentTB.Visibility = Visibility.Collapsed;
            }
            CommentTextBox.Text = "";
        }
        private async Task <bool> SendFeedbackAsync()
        {
            FBFormControl.SendBtn.IsEnabled = false;
            string id = Guid.NewGuid().ToString();

            string downloadURL;

            if (FBFormControl.Imagefile != null)
            {
                downloadURL = await App.CloudStorage.StoreFileAsync(FBFormControl.Imagefile, id);
            }
            else
            {
                downloadURL = null;
            }

            Feedback feedback = new Feedback()
            {
                UserID        = MainPage.instance.user.UserId,
                ChannelID     = Channel.Id,
                Upvote        = 0,
                Downvote      = 0,
                AttachedImage = downloadURL == null? "" : downloadURL,
                Content       = FBFormControl.FeedbackTextBox.Text,
                Action        = -1,
                Location      = "Unknown"
            };

            var result = await MainPage.SO.AddFeedbackAsync(feedback);

            if (result != null)
            {
                InserAFeedback(0, result);
                // scrollBar.ChangeView(0, 0, 0);
                return(true);
            }
            else
            {
                await HelpersClass.ShowDialogAsync("Bạn đã vượt quá 5 phản hồi cho ngày hôm nay :(");

                return(false);
            }
        }
        private async void FindChannelTBox_QuerySubmitted(AutoSuggestBox sender, AutoSuggestBoxQuerySubmittedEventArgs args)
        {
            try
            {
                var channel = await MainPage.SO.GetChannelByAccessCode(args.QueryText);

                if (channel != null)
                {
                    NavigationPage.instance.NavigateTo(typeof(ChannelFeedbackPage), channel);
                }
                else
                {
                    await HelpersClass.ShowDialogAsync("Không tìm thấy kênh");
                }
            }
            catch (Exception e)
            {
                await HelpersClass.ShowDialogAsync("Có lỗi xảy ra");
            }
        }
Beispiel #15
0
        private async void DeleteChannelsButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                foreach (Channel c in ChannelListView.SelectedItems)
                {
                    bool success = await MainPage.SO.DeleteChannel(c);

                    if (success)
                    {
                        channels.Remove(c);
                    }
                }
            }catch (Exception ex)
            {
                await HelpersClass.ShowDialogAsync("Can't delete: " + ex.Message);
            }
            EditChannelsTButton.IsChecked = false;
            EditChannelsTButton_Click(EditChannelsTButton, new RoutedEventArgs());
        }
Beispiel #16
0
        private async void SpamReportBtn_Click(object sender, RoutedEventArgs e)
        {
            var sd      = sender as MenuFlyoutItem;
            var comment = sd.DataContext as Comment;

            if (comment != null)
            {
                var res = await MainPage.SO.ReportSpamForComment(comment.id, MainPage.instance.user.UserId);

                if (res)
                {
                    await HelpersClass.ShowDialogAsync("Cám ơn bạn đã thông báo chúng tôi");
                }
                else
                {
                    await HelpersClass.ShowDialogAsync("Bạn đã báo cáo bình luận này rồi");
                }
            }
            //MainPage.SO.ReportSpamForComment()
        }
Beispiel #17
0
        private async Task GetBackgroundImagesAsync()
        {
            try
            {
                var folderPath    = @"Assets\Graphics\Backgrounds";
                var backgroundFol = await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFolderAsync(folderPath);

                if (backgroundFol != null)
                {
                    var files = await backgroundFol.GetFilesAsync();

                    Random rand  = new Random();
                    int    index = rand.Next(files.Count);
                    BackgroundImage.Source = await FilePicker.ConvertToBitmapFromFile(files[index]);
                }
            }catch (UnauthorizedAccessException unauthorizedEx)
            {
                await HelpersClass.ShowDialogAsync("Cannot access to background folder " + unauthorizedEx.Message);
            }catch (Exception ex)
            {
                await HelpersClass.ShowDialogAsync("something went really wrong " + ex.Message);
            }
        }