Beispiel #1
0
        private View CreateHeader(InDef id)
        {
            var fs = new FormattedString
            {
                Spans = { new Span {
                              Text = id.Header, FontSize = 16, FontAttributes = FontAttributes.Bold
                          } }
            };

            return(new Label {
                FormattedText = fs
            });
        }
Beispiel #2
0
        private View CreateOList(InDef id)
        {
            var fs = new FormattedString();

            foreach (var p in id.OList)
            {
                fs.Spans.Add(new Span {
                    Text = p.Key + ": ", FontAttributes = FontAttributes.Bold
                });
                fs.Spans.Add(new Span {
                    Text = p.Value + Environment.NewLine
                });
            }
            return(new Label {
                FormattedText = fs
            });
        }
Beispiel #3
0
        private View CreateList(InDef id)
        {
            var fs = new FormattedString();

            foreach (var str in id.List)
            {
                fs.Spans.Add(new Span {
                    Text = "-> ", FontAttributes = FontAttributes.Bold
                });
                fs.Spans.Add(new Span {
                    Text = str + Environment.NewLine
                });
            }
            return(new Label {
                FormattedText = fs
            });
        }
Beispiel #4
0
        private static Image CreateImage(InDef id)
        {
            var iS  = id.ImageSource;
            var img = new Image
            {
                Source            = iS,
                VerticalOptions   = LayoutOptions.Fill,
                HorizontalOptions = LayoutOptions.CenterAndExpand,
                Aspect            = Aspect.AspectFill
            };
            var tgr = new TapGestureRecognizer()
            {
                Command          = new Command(OnImageTap),
                CommandParameter = iS
            };

            img.GestureRecognizers.Add(tgr);
            return(img);
        }
Beispiel #5
0
        private static Label CreateText(InDef id, bool italic = false)
        {
            if (id.Text == null)
            {
                return(new Label());
            }
            var fa = italic ? FontAttributes.Italic : FontAttributes.None;
            var ft = new FormattedString
            {
                Spans = { new Span {
                              Text = id.Text, FontAttributes = fa
                          } }
            };

            return(new Label
            {
                FormattedText = ft,
                HorizontalOptions = LayoutOptions.Fill,
                HorizontalTextAlignment = TextAlignment.Center
            });
        }
Beispiel #6
0
 public bool Equals(InDef other)
 {
     return(string.Equals(Image, other.Image) &&
            string.Equals(Text, other.Text) &&
            Layout == other.Layout);
 }
Beispiel #7
0
        private View CreateViewForInnerDefComp(InDef id)
        {
            try
            {
                var v = new StackLayout();
                if (id.Layout == InDefLayout.TextOverImage && id.Image == null)
                {
                    if (id.List != null)
                    {
                        id.Layout = InDefLayout.List;
                    }
                    else if (id.OList != null)
                    {
                        id.Layout = InDefLayout.OList;
                    }
                    else if (!string.IsNullOrWhiteSpace(id.Header))
                    {
                        id.Layout = InDefLayout.HeaderAndText;
                    }
                    else
                    {
                        id.Layout = InDefLayout.OnlyText;
                    }
                }
                switch (id.Layout)
                {
                case InDefLayout.TextUnderImage:
                    v.Orientation = StackOrientation.Vertical;
                    v.Children.Add(CreateImage(id));
                    v.Children.Add(CreateText(id, true));
                    break;

                case InDefLayout.TextOverImage:
                    v.Orientation = StackOrientation.Vertical;
                    v.Children.Add(CreateText(id, true));
                    v.Children.Add(CreateImage(id));
                    break;

                case InDefLayout.List:
                    v.Orientation = StackOrientation.Vertical;
                    if (!string.IsNullOrWhiteSpace(id.Header))
                    {
                        v.Children.Add(CreateHeader(id));
                    }
                    v.Children.Add(CreateList(id));
                    break;

                case InDefLayout.HeaderAndText:
                    v.Children.Add(CreateHeader(id));
                    v.Children.Add(CreateText(id));
                    break;

                case InDefLayout.OList:
                    v.Orientation = StackOrientation.Vertical;
                    if (!string.IsNullOrWhiteSpace(id.Header))
                    {
                        v.Children.Add(CreateHeader(id));
                    }
                    v.Children.Add(CreateOList(id));
                    break;

                case InDefLayout.OnlyText:
                    v.Children.Add(CreateText(id));
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
                return(v);
            }
            catch (Exception e)
            {
                Debug.WriteLine(e);
                CoreManager.Current.App.DialogManager.ShowWarningDialog("Błąd w pobranej zawartości", "Nie można utworzyć elementu definicji " + _def.Title);
            }
            return(null);
        }