Ejemplo n.º 1
0
        private void Modifyinf(int Userid, int id)
        {
            var ans = answers.Where(p => p.Userid == Userid).FirstOrDefault();
            List <AppBarButton> appBarButtons = NameMap.GetChildObjects <AppBarButton>(CurrentAnswerList);

            if (id == 0)
            {
                var apps = appBarButtons.Where(p => p.Name == "LikeButton" && Convert.ToInt32(p.Tag) == Userid).FirstOrDefault();
                if (apps != null)
                {
                    var fore = apps.Foreground as SolidColorBrush;
                    if (fore.Color == Colors.Black)
                    {
                        ans.UpAnsnum++;
                        apps.Foreground = new SolidColorBrush(Colors.Blue);
                        NameMap.UPAnswer.Add($"{qusition.Qusitionid} {apps.Tag} {Myid}");
                    }
                    else
                    {
                        ans.UpAnsnum--;
                        apps.Foreground = new SolidColorBrush(Colors.Black);
                        NameMap.UPAnswer.Remove($"{qusition.Qusitionid} {apps.Tag} {Myid}");
                    }
                    apps.Label = ans.UpAnsnum.ToString();
                }
            }
            else if (id == 1)
            {
                var apps = appBarButtons.Where(p => p.Name == "DislikeButton" && Convert.ToInt32(p.Tag) == Userid).FirstOrDefault();
                if (apps != null)
                {
                    var fore = apps.Foreground as SolidColorBrush;
                    if (fore.Color == Colors.Black)
                    {
                        ans.DownAnsnum++;
                        apps.Foreground = new SolidColorBrush(Colors.Blue);
                        NameMap.DNAnswer.Add($"{qusition.Qusitionid} {apps.Tag} {Myid}");
                    }
                    else
                    {
                        ans.DownAnsnum--;
                        apps.Foreground = new SolidColorBrush(Colors.Black);
                        NameMap.DNAnswer.Remove($"{qusition.Qusitionid} {apps.Tag} {Myid}");
                    }
                    apps.Label = ans.DownAnsnum.ToString();
                }
            }
        }
        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            if (e.Parameter is People)
            {
                people = (People)e.Parameter;
                await GetArtical(people);

                if (people.UserId == HomePage.Current.myStruct.id)
                {
                    IEnumerable <AppBarButton> appBars = (NameMap.GetChildObjects <AppBarButton>(Articallist));
                    List <AppBarButton>        apps    = appBars.Where(p => p.Name.ToLower() == "Edit").ToList();
                    apps.ForEach(p => p.Visibility = Visibility.Visible);
                }
            }
            base.OnNavigatedTo(e);
        }