Esempio n. 1
0
        public UIImage(PageObjectImage imageObject, Data storyData, Style style) : base(imageObject, storyData, style)
        {
            if (File.Exists(imageObject.Source))
            {
                // Image exists; display that.
                var source    = new Uri(imageObject.Source, UriKind.RelativeOrAbsolute);
                var container = new Viewbox {
                    Stretch          = Stretch.Uniform,
                    StretchDirection = StretchDirection.DownOnly
                };
                var image = new WpfImage {
                    HorizontalAlignment = HorizontalAlignment.Center,
                    Source = new BitmapImage(source)
                };

                image.Width  = image.Source.Width;
                image.Height = image.Source.Height;

                container.Child = image;
                Content         = container;
            }
            else
            {
                // Image doesn't exist; display text instead.
                TextBlock.FontSize            = 20.0;
                TextBlock.HorizontalAlignment = HorizontalAlignment.Center;

                Content = TextBlock;
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Initializes a new <see cref="UIPageObject" /> with a <see cref="TextSequence" />.
        /// </summary>
        /// <param name="pageObject">A <see cref="PageObject" /> to use to populate and style this control.</param>
        /// <param name="storyData">The <see cref="Data" /> that corresponds to the loaded story.</param>
        /// <param name="style">A <see cref="Style" /> object describing how this object should be drawn.</param>
        protected UIPageObject(IPageObject pageObject, Data storyData, Style style)
        {
            TextBlock = new TextBlock {
                FontFamily   = new FontFamily("Cambria"),
                FontSize     = 24.0,
                TextWrapping = TextWrapping.WrapWithOverflow
            };

            FormattedText   = pageObject.DisplayText(storyData);
            PageObjectStyle = style;
        }
Esempio n. 3
0
        public UIChoice(Choice choiceObject, Data storyData, Style style) : base(choiceObject, storyData, style)
        {
            TextBlock.FontSize = 18.0;
            var button = new Button {
                FontFamily = new FontFamily("Cambria"),
                FontSize   = 18.0,
                Tag        = choiceObject
            };
            var buttonText = new TextBlock();

            if (choiceObject.Shortcut != null)
            {
                buttonText.Inlines.Add(new Run($"{choiceObject.Shortcut}) ")
                {
                    FontWeight = FontWeights.Bold
                });
            }
            buttonText.Inlines.Add(TextBlock);
            button.Content = buttonText;
            button.Click  += Button_Click;
            Content        = button;
        }