Пример #1
0
        private async Task ContentDiashow(AppBarButton appBarButton)
        {
            ContentDialog contentDialog = new ContentDialog
            {
                Title               = "是否删除?",
                PrimaryButtonText   = "删除",
                SecondaryButtonText = "取消",
            };

            contentDialog.PrimaryButtonClick += (_s, _e) =>
            {
                var list = NameMap.FindParent <ListViewItem>(appBarButton);
                if (RootPivot.SelectedIndex == 0)
                {
                    drafts.RemoveAt(Draftlist.IndexFromContainer(list));
                }
                else if (RootPivot.SelectedIndex == 1)
                {
                    answerDrafts.RemoveAt(AnswerList.IndexFromContainer(list));
                }
            };
            contentDialog.SecondaryButtonClick += (_s, _e) =>
            {
            };
            await contentDialog.ShowAsync();
        }
        private async Task DeleteFollow(UserFollow userFollow, AppBarButton appBarButton)
        {
            HttpClient httpClient = new HttpClient();

            httpClient.DefaultRequestHeaders.Clear();
            httpClient.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));
            var content = new StringContent(JsonConvert.SerializeObject(userFollow), Encoding.UTF8, "application/json");
            HttpResponseMessage httpResponseMessage = await httpClient.PostAsync("http://localhost:60671/api/values/deletefollow", content);

            if (httpResponseMessage.IsSuccessStatusCode)
            {
                var res = await httpResponseMessage.Content.ReadAsAsync <bool>();

                if (res == true)
                {
                    var listviewitem = NameMap.FindParent <ListViewItem>(appBarButton);
                    if (listviewitem != null)
                    {
                        var contact   = (listviewitem.ContentTemplateRoot as FrameworkElement)?.FindName("Contact") as AppBarButton;
                        var addfriend = (listviewitem.ContentTemplateRoot as FrameworkElement)?.FindName("AddFriend") as AppBarButton;
                        contact.Visibility   = Visibility.Collapsed;
                        addfriend.Visibility = Visibility.Visible;
                    }
                }
            }
        }
        private async void DislikeButton_Click(object sender, RoutedEventArgs e)
        {
            AppBarButton appBarButton = (AppBarButton)sender;
            ListViewItem listViewItem = NameMap.FindParent <ListViewItem>(appBarButton);
            var          fore         = appBarButton.Foreground as SolidColorBrush;

            if (fore.Color == Colors.Blue)
            {
                await DelPutDisLike(people.UserId, myStruct.id, Convert.ToInt32(appBarButton.Tag));
            }
            else
            {
                await PutDisLike(people.UserId, myStruct.id, Convert.ToInt32(appBarButton.Tag));
            }
        }
Пример #4
0
        private void Send_Click(object sender, RoutedEventArgs e)
        {
            AppBarButton appBarButton = (AppBarButton)sender;
            var          list         = NameMap.FindParent <ListViewItem>(appBarButton);

            if (RootPivot.SelectedIndex == 0)
            {
                viewItem = list;
                Frame.Navigate(typeof(EditArtical), drafts[Draftlist.IndexFromContainer(list)]);
            }
            else if (RootPivot.SelectedIndex == 1)
            {
                vAnsItem = list;
                Frame.Navigate(typeof(MakeAnswer), answerDrafts[AnswerList.IndexFromContainer(list)]);
            }
        }
Пример #5
0
        private async void DislikeButton_Click(object sender, RoutedEventArgs e)
        {
            AppBarButton appBarButton = (AppBarButton)sender;
            ListViewItem listViewItem = NameMap.FindParent <ListViewItem>(appBarButton);

            if (listViewItem != null)
            {
            }
            int Answerid = Convert.ToInt32(appBarButton.Tag);
            int Myid     = (HomePage.Current.myStruct.id);
            var fore     = appBarButton.Foreground as SolidColorBrush;

            if (fore.Color == Colors.Blue)
            {
                await DelPutDisLike(Answerid, Myid, Qusitionid);
            }
            else
            {
                await PutDisLike(Answerid, Myid, Qusitionid);
            }
        }
Пример #6
0
        private void CommentButton_Click(object sender, RoutedEventArgs e)
        {
            AppBarButton appBarButton = (AppBarButton)sender;
            int          Answerid     = Convert.ToInt32(appBarButton.Tag);
            ListViewItem listViewItem = NameMap.FindParent <ListViewItem>(appBarButton);

            if (listViewItem != null)
            {
                string Name;
                if ((listViewItem.ContentTemplateRoot as FrameworkElement)?.FindName("NameBlock") is Button NameBlock)
                {
                    Name = NameBlock.Content.ToString();
                    Dictionary <string, string> keyValuePairs = new Dictionary <string, string> {
                        { "Qusitionid", Qusitionid.ToString() },
                        { "Userid", Answerid.ToString() },
                        { "Name", Name }
                    };

                    Frame.Navigate(typeof(AnswerCmt), keyValuePairs);
                }
            }
        }