Exemplo n.º 1
0
        private void SuperImage_Tapped(object sender, TappedRoutedEventArgs e)
        {
            iFixit.Domain.Models.UI.GuideStepItem item = (iFixit.Domain.Models.UI.GuideStepItem)((Coding4Fun.Toolkit.Controls.SuperImage)sender).DataContext;
            ZoomImage.Visibility            = Windows.UI.Xaml.Visibility.Visible;
            ImageScrollViewer.MinZoomFactor = 1;

            ImageScrollViewer.ZoomMode = ZoomMode.Enabled;
            ZoomImage.DataContext      = item;
            Debug.WriteLine(item.MainImage.LargeImageUrl);
        }
Exemplo n.º 2
0
        private async Task BindGuide(RESTModels.Guide.RootObject rp)
        {
            //TODO: TESTE
            Items.Clear();
            // DANGEROUS
            currentGuideId = AppBase.Current.GuideId;

            GuideTitle = rp.title;
            GuideUrl = rp.url;

            if (!string.IsNullOrEmpty(rp.author.username))
                Author = string.Format(International.Translation.GuideBy, rp.author.username);

            if (rp.image != null)
                GuideMainImage = rp.image.large;

            var firstPage = new GuideIntro()
            {
                TypeOfGuide = rp.type
                ,
                Subject = rp.subject
                ,
                Summary = rp.summary
                ,
                PageTitle = International.Translation.Intro
                ,
                Type = GuidesPageTypes.Intro
                ,
                StepTitle = International.Translation.Intro
                ,
                Difficulty = rp.difficulty
                ,
                TimeRequired = rp.time_required
                ,
                Author = rp.author.username
                ,
                Introduction = rp.introduction_rendered

            };

            //if (rp.flags != null)
            //{
            //    foreach (var item in rp.flags)
            //    {
            //        firstPage.Flags.Add(new Models.UI.Flag
            //        {
            //             Text = item.text, Title = item.title, Type = item.flagid
            //        });
            //    }
            //}


            //for (int i = 0; i < rp.prerequisites.Count(); i++)
            //{
            //    var item = rp.prerequisites[i];
            //    firstPage.PreRequisites.Add(new Models.UI.SearchResultItem
            //    {
            //        UniqueId = item.guideid.ToString(),
            //        Name = string.Format("{0}) {1}", i + 1, item.title),
            //        ImageUrl = item.image != null ? await ImagePathTranslated(item.image.medium) : "",
            //        Summary = item.subject
            //    });
            //}
            if (firstPage.PreRequisites.Count > 0)
                firstPage.HasPreRequisites = true;



            for (var i = 0; i < rp.parts.Count(); i++)
            {
                var item = rp.parts[i];
                firstPage.Parts.Add(new Tool
                {
                    Image = await ImagePathTranslated(item.thumbnail),
                    Title = GeneratePartName(item),
                    Url = item.url
                });
            }
            if (firstPage.Parts.Count > 0)
                firstPage.HasParts = true;


            for (var i = 0; i < rp.tools.Count(); i++)
            {
                var item = rp.tools[i];
                firstPage.Tools.Add(new Tool
                {
                    Image = await ImagePathTranslated(item.thumbnail),
                    Title = item.text,
                    Url = item.url
                });
            }





            for (var i = 0; i < rp.documents.Count(); i++)
            {
                var item = rp.documents[i];
                firstPage.Documents.Add(new Document
                {
                    DocumentId = item.documentid

                    ,
                    Title = item.text
                    ,
                    Url = item.url
                });
            }

            if (firstPage.Tools.Count > 0)
                firstPage.HasTools = true;


            if (firstPage.HasTools && firstPage.HasParts)
                firstPage.HasPartsAndTools = true;
            else
                firstPage.HasPartsAndTools = false;
            Items.Add(firstPage);







            var stepNum = 1;
            foreach (var item in rp.steps)
            {
                var newStep = new GuideStepItem
                {
                    index = item.orderby,
                    PageTitle = string.Format("{0} - {1}", International.Translation.Step, stepNum)
                    ,
                    Type = GuidesPageTypes.Step
                    ,
                    StepTitle = string.Format(International.Translation.StepNum, stepNum)
                    ,
                    StepIndex = stepNum
                };
                var m = 0;
                foreach (var lineitem in item.lines)
                {
                    newStep.Lines.Add(new GuideStepLine
                    {
                        Index = (m + 1).ToString(),
                        Title = lineitem.text_rendered,
                        VoiceText = Utils.StripHtml(lineitem.text_rendered),
                        BulletColor = GuideStepLine.SetIconColor(lineitem.bullet),
                        GuideIcon = GuideStepLine.SetIcon(lineitem.bullet),
                        Level = lineitem.level
                    });
                    m++;
                }



                // images
                if (item.media != null)
                {
                    if (item.media.videodata != null)
                    {
                        newStep.Video = new GuideStepVideo
                        {
                            VideoUrl = item.media.videodata.encodings.Where(o => o.mime == "video/mp4").First().url,
                            ImageUrl = item.media.videodata.image.image.medium
                        };
                        newStep.MainImage = new GuideStepImage
                        {
                            MediumImageUrl = item.media.videodata.image.image.medium
                        };
                    }
                    else
                    {

                        var n = 0;

                        if (item.media.type == "image")
                        {



                            foreach (var media in item.media.data)
                            {

                                if (n == 0)
                                    newStep.MainImage = new GuideStepImage
                                    {
                                        MediumImageUrl = media != null ? await ImagePathTranslated(media.medium) : ""
                                        ,
                                        SmallImageUrl = media != null ? await ImagePathTranslated(media.standard) : ""
                                        ,
                                        LargeImageUrl = media != null ? await ImagePathTranslated(media.original) : ""
                                    };



                                newStep.Images.Add(new GuideStepImage
                                {
                                    StepIndex = stepNum,
                                    ImageIndex = m,
                                    ImageId = media.id.ToString(),
                                    MediumImageUrl = media != null ? await ImagePathTranslated(media.medium) : ""
                                    ,
                                    SmallImageUrl = media != null ? await ImagePathTranslated(media.standard) : ""
                                    ,
                                    LargeImageUrl = media != null ? await ImagePathTranslated(media.original) : ""
                                });

                                n++;
                            }



                        }
                    }




                }

                if (AppBase.Current.ExtendeInfoApp)
                {
                    newStep.ShowListImages = newStep.Images.Count > 1;
                }

                Items.Add(newStep);

                stepNum++;
            }
        }