public WindowsPhoneRunner(Windows.UI.Core.CoreDispatcher dispatcher, Windows.UI.Xaml.Controls.TextBlock textBlock)
        {
            _dispatcher = dispatcher;
            _output = textBlock;


        }
 public LabelWidget(cave.GuiApplicationContext context)
 {
     widgetContext = context;
     setWidgetStyle("LabelWidget");
     textBlock    = new Windows.UI.Xaml.Controls.TextBlock();
     this.Content = textBlock;
 }
        /// <summary>
        /// WARNING!  Calling this will cause a crash IF target version of APP is not set to Windows10 FallCreatorsUpdate (10.0.16299.0) or greater
        /// </summary>
        /// <param name="textBlock"></param>
        /// <param name="color"></param>
        /// <param name="startIndex"></param>
        /// <param name="length"></param>
        public static void ApplyBackgroundColor(this Windows.UI.Xaml.Controls.TextBlock textBlock, Xamarin.Forms.Color color, int startIndex = 0, int length = -1)
        {
            if (TextHeghLighterPresent)
            {
                if (length < 0)
                {
                    if (startIndex != 0)
                    {
                        return;
                    }
                    length  = textBlock.Text.Length;
                    length += textBlock.Inlines.Count;
                }

                var highlighter = new TextHighlighter
                {
                    Background = new Windows.UI.Xaml.Media.SolidColorBrush(color.ToWindowsColor()),
                    //Foreground = new Windows.UI.Xaml.Media.SolidColorBrush(metaFont.TextColor.ToWindowsColor()),
                };
                highlighter.Ranges.Add(new Windows.UI.Xaml.Documents.TextRange
                {
                    StartIndex = startIndex,
                    Length     = length
                });
                textBlock.TextHighlighters.Add(highlighter);
            }
        }
Exemple #4
0
        private void Host_ChildChanged(object sender, EventArgs e)
        {
            WindowsXamlHost windowsXamlHost = (WindowsXamlHost)sender;

            Windows.UI.Xaml.Controls.TextBlock textBlock =
                (Windows.UI.Xaml.Controls.TextBlock)windowsXamlHost.Child;

            textBlock.Text = "❤❤❤❤😍😍😍😍";
        }
        void UnderlineText(Windows.UI.Xaml.Controls.TextBlock control, string originalText)
        {
            control.Text = string.Empty;
            Underline ul  = new Underline();
            Run       run = new Run();

            run.Text = originalText;
            ul.Inlines.Add(run);
            control.Inlines.Add(ul);
        }
Exemple #6
0
        private void WindowsXamlHost_ChildChanged(object sender, EventArgs e)
        {
            WindowsXamlHost windowsXamlHost = (WindowsXamlHost)sender;

            // 利用 Windows.UI.Xaml.Controls 做為轉換
            Windows.UI.Xaml.Controls.Button    button = (Windows.UI.Xaml.Controls.Button)windowsXamlHost.Child;
            Windows.UI.Xaml.Controls.TextBlock txt    = new Windows.UI.Xaml.Controls.TextBlock();
            txt.Text       = "123";
            button.Content = txt;
        }
        protected override void OnAttached()
        {
            Windows.UI.Xaml.Controls.TextBlock control = Control as Windows.UI.Xaml.Controls.TextBlock;

            control.Foreground = new Windows.UI.Xaml.Media.SolidColorBrush(ColorHelper.PlatformAccentColor);
            control.FontWeight = Windows.UI.Text.FontWeights.Bold;

            control.IsTapEnabled = true;
            control.Tapped      += (s, e) =>
            {
            };

            UnderlineText(control, control.Text);
        }
        protected override void OnElementChanged(ElementChangedEventArgs<Page> e)
        {
            base.OnElementChanged(e);

            var page = e.NewElement as MySecondPage;

            stackPanel = new Windows.UI.Xaml.Controls.StackPanel();
            stackPanel.Orientation = Windows.UI.Xaml.Controls.Orientation.Horizontal;

            var label = new Windows.UI.Xaml.Controls.TextBlock
            {
                Text = "2" + page.Heading
            };

            stackPanel.Children.Add(label);
            this.Children.Add(stackPanel);
        }
        protected override void OnElementChanged(ElementChangedEventArgs <Page> e)
        {
            base.OnElementChanged(e);

            var page = e.NewElement as MySecondPage;

            stackPanel             = new Windows.UI.Xaml.Controls.StackPanel();
            stackPanel.Orientation = Windows.UI.Xaml.Controls.Orientation.Horizontal;

            var label = new Windows.UI.Xaml.Controls.TextBlock
            {
                Text = "2" + page.Heading
            };

            stackPanel.Children.Add(label);
            this.Children.Add(stackPanel);
        }
            public GesturePage() :
                base(
                    "SemanticZoom",
                    "Pinch to semantic zoom",
                    "Semantic zoom is a new concept in our touch language. It’s designed to make it fast and fluid to jump within a list of content. Pinch two or more fingers on the screen  to change to an overview view.  Then tap or stretch the region or item you want to see more details for. For example, in People, pinch your contact list to see alphabet tiles (A, B, etc.), and then tap the desired letter to get back to the individual contact level (J for Jan).",
                    "Similar to when you use a mouse and click the “-” button, usually found in the lower-right corner.",
                    "Assets/pinch_sezo.png")
            {
                // Configure the app bar items for this page
                // GesturePageBase.Selected uses this._nonContextualItems to populate the global app bar when the page is selected.

                // Links button
                this._links["Doc: Guidelines for semantic zoom"] = new Uri("http://msdn.microsoft.com/en-us/library/windows/apps/hh465319.aspx");
                this._nonContextualItems.Add(GesturePageBase.CreateLinksAppBarButton(this._links));

                // Create the play area for this page
                var grid = new Windows.UI.Xaml.Controls.Grid();

                var row = new Windows.UI.Xaml.Controls.RowDefinition();

                row.Height = new Windows.UI.Xaml.GridLength(1, Windows.UI.Xaml.GridUnitType.Star);
                grid.RowDefinitions.Add(row);

                row        = new Windows.UI.Xaml.Controls.RowDefinition();
                row.Height = new Windows.UI.Xaml.GridLength(1, Windows.UI.Xaml.GridUnitType.Auto);
                grid.RowDefinitions.Add(row);

                var col = new Windows.UI.Xaml.Controls.ColumnDefinition();

                col.Width = new Windows.UI.Xaml.GridLength(2, Windows.UI.Xaml.GridUnitType.Star);
                grid.ColumnDefinitions.Add(col);

                col       = new Windows.UI.Xaml.Controls.ColumnDefinition();
                col.Width = new Windows.UI.Xaml.GridLength(1, Windows.UI.Xaml.GridUnitType.Star);
                grid.ColumnDefinitions.Add(col);

                var image = new Windows.UI.Xaml.Controls.Image
                {
                    Margin  = new Windows.UI.Xaml.Thickness(30, 30, 30, 30),
                    Source  = new Windows.UI.Xaml.Media.Imaging.BitmapImage(new Uri("ms-appx:///Assets/semantic_zoom.png")),
                    Stretch = Windows.UI.Xaml.Media.Stretch.Uniform
                };

                grid.Children.Add(image);
                Windows.UI.Xaml.Controls.Grid.SetColumn(image, 0);
                Windows.UI.Xaml.Controls.Grid.SetRow(image, 0);

                var textBlock = new Windows.UI.Xaml.Controls.TextBlock
                {
                    Style = App.Current.Resources["AppSubtitleTextStyle"] as Windows.UI.Xaml.Style,
                    Text  = "Pinch anywhere in this app to zoom out",
                    HorizontalAlignment = Windows.UI.Xaml.HorizontalAlignment.Center,
                    VerticalAlignment   = Windows.UI.Xaml.VerticalAlignment.Center,
                    TextWrapping        = Windows.UI.Xaml.TextWrapping.Wrap,
                    TextAlignment       = Windows.UI.Xaml.TextAlignment.Center
                };

                grid.Children.Add(textBlock);
                Windows.UI.Xaml.Controls.Grid.SetColumn(textBlock, 1);
                Windows.UI.Xaml.Controls.Grid.SetRow(textBlock, 0);

                this.Content = grid;
            }
 public WindowsPhoneRunner(Windows.UI.Core.CoreDispatcher dispatcher, Windows.UI.Xaml.Controls.TextBlock textBlock)
 {
     _dispatcher = dispatcher;
     _output     = textBlock;
 }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="bestScore">Field which shows best score</param>
 /// <param name="actualScore">Field which shows actual score</param>
 public GameScoreView(ref UIX.Controls.TextBlock bestScore, ref UIX.Controls.TextBlock actualScore)
 {
     this.bestScore   = bestScore;
     this.actualScore = actualScore;
 }
Exemple #13
0
 public static void ChangeFontSize(double width, double height, double area, double scala, Windows.UI.Xaml.Controls.TextBlock textBlock)
 {
     if (width * height > area)
     {
         textBlock.FontSize = width * height / scala;
         area = width * height;
     }
     else if (width * height < area)
     {
         textBlock.FontSize = width * height / scala > 1 ? width * height / scala : 10;
         area = width * height;
     }
 }
Exemple #14
0
 public WinkTile(Windows.UI.Xaml.Controls.TextBlock status)
 {
     statusText = status;
 }
Exemple #15
0
        // Create constructor public MainPage.
        public MainPage()
        {
            // Necessary to instantiate this Page, add a stackPanel to this Page, et cetera.
            this.InitializeComponent();

            // Find width of app in view pixels and height between bottom of app and bottom of title bar in view pixels.
            double widthOfAppInViewPixels = Windows.UI.ViewManagement.ApplicationView.PreferredLaunchViewSize.Width;
            double heightBetweenBottomOfAppAndBottomOfTitleBarInViewPixels = Windows.UI.ViewManagement.ApplicationView.PreferredLaunchViewSize.Height;

            // Create a stackPanel.
            Windows.UI.Xaml.Controls.StackPanel stackPanel = new Windows.UI.Xaml.Controls.StackPanel();

            // Create a toolbar with width equal to the width of the app, height equal to 50 view pixels, and background color of light blue that has one row and three columns.
            Windows.UI.Xaml.Controls.Grid toolbar = new Windows.UI.Xaml.Controls.Grid();
            toolbar.Width      = widthOfAppInViewPixels;
            toolbar.Height     = 50;
            toolbar.Background = new Windows.UI.Xaml.Media.SolidColorBrush(Windows.UI.Colors.AliceBlue);
            Windows.UI.Xaml.Controls.RowDefinition row = new Windows.UI.Xaml.Controls.RowDefinition();
            toolbar.RowDefinitions.Add(row);
            Windows.UI.Xaml.Controls.ColumnDefinition columnForOpenImageButton         = new Windows.UI.Xaml.Controls.ColumnDefinition();
            Windows.UI.Xaml.Controls.ColumnDefinition columnForLoadBoundingBoxesButton = new Windows.UI.Xaml.Controls.ColumnDefinition();
            Windows.UI.Xaml.Controls.ColumnDefinition columnForTextboxForClassIndex    = new Windows.UI.Xaml.Controls.ColumnDefinition();
            Windows.UI.Xaml.Controls.ColumnDefinition columnForSaveLabeledImageButton  = new Windows.UI.Xaml.Controls.ColumnDefinition();
            Windows.UI.Xaml.Controls.ColumnDefinition columnForSaveLabelFileButton     = new Windows.UI.Xaml.Controls.ColumnDefinition();
            columnForOpenImageButton.Width         = new Windows.UI.Xaml.GridLength(widthOfAppInViewPixels * 3 / 7 / 2);
            columnForLoadBoundingBoxesButton.Width = new Windows.UI.Xaml.GridLength(widthOfAppInViewPixels * 3 / 7 / 2);
            columnForTextboxForClassIndex.Width    = new Windows.UI.Xaml.GridLength(widthOfAppInViewPixels / 7);
            columnForSaveLabeledImageButton.Width  = new Windows.UI.Xaml.GridLength(widthOfAppInViewPixels * 3 / 7 / 2);
            columnForSaveLabelFileButton.Width     = new Windows.UI.Xaml.GridLength(widthOfAppInViewPixels * 3 / 7 / 2);
            toolbar.ColumnDefinitions.Add(columnForOpenImageButton);
            toolbar.ColumnDefinitions.Add(columnForLoadBoundingBoxesButton);
            toolbar.ColumnDefinitions.Add(columnForTextboxForClassIndex);
            toolbar.ColumnDefinitions.Add(columnForSaveLabeledImageButton);
            toolbar.ColumnDefinitions.Add(columnForSaveLabelFileButton);

            // Add to toolbar's columnForOpenImageButton an "Open Image" button.
            Windows.UI.Xaml.Controls.Button openImageButton = new Windows.UI.Xaml.Controls.Button();
            openImageButton.Content = "Open Image";
            openImageButton.Height  = 40;
            Windows.UI.Xaml.Controls.Grid.SetRow(openImageButton, 0);
            Windows.UI.Xaml.Controls.Grid.SetColumn(openImageButton, 0);
            openImageButton.HorizontalAlignment = Windows.UI.Xaml.HorizontalAlignment.Center;
            openImageButton.Click += OpenImageButton_Click;
            toolbar.Children.Add(openImageButton);

            // Add to the toolbar's columnForLoadBoundingBoxesButton a "Load Bounding Boxes" button.
            Windows.UI.Xaml.Controls.Button loadBoundingBoxesButton = new Windows.UI.Xaml.Controls.Button();
            loadBoundingBoxesButton.Content = "Load Bounding Boxes";
            loadBoundingBoxesButton.Height  = 40;
            Windows.UI.Xaml.Controls.Grid.SetRow(loadBoundingBoxesButton, 0);
            Windows.UI.Xaml.Controls.Grid.SetColumn(loadBoundingBoxesButton, 1);
            loadBoundingBoxesButton.HorizontalAlignment = Windows.UI.Xaml.HorizontalAlignment.Center;
            loadBoundingBoxesButton.Click += LoadBoundingBoxesButton_Click;
            toolbar.Children.Add(loadBoundingBoxesButton);

            // Add to toolbar's columnForTextboxForClassIndex a labeled text box to store a user's choice of class index for an object they are about to bound.
            Windows.UI.Xaml.Controls.TextBlock textblockForClassIndex = new Windows.UI.Xaml.Controls.TextBlock();
            textblockForClassIndex.Text   = "Class Index: ";
            textblockForClassIndex.Height = 20;
            Windows.UI.Xaml.Controls.Grid.SetRow(textblockForClassIndex, 0);
            Windows.UI.Xaml.Controls.Grid.SetColumn(textblockForClassIndex, 2);
            toolbar.Children.Add(textblockForClassIndex);
            this.TextBoxForClassIndex        = new Windows.UI.Xaml.Controls.TextBox();
            this.TextBoxForClassIndex.Text   = "0";
            this.TextBoxForClassIndex.Width  = 40;
            this.TextBoxForClassIndex.Height = 40;
            Windows.UI.Xaml.Controls.Grid.SetRow(this.TextBoxForClassIndex, 0);
            Windows.UI.Xaml.Controls.Grid.SetColumn(this.TextBoxForClassIndex, 2);
            this.TextBoxForClassIndex.TextChanged += TextBoxForClassIndex_TextChanged;
            toolbar.Children.Add(this.TextBoxForClassIndex);

            // Add to toolbar's columnForSaveLabeledImageButton a "Save Labeled Image" button.
            Windows.UI.Xaml.Controls.Button saveLabeledImageButton = new Windows.UI.Xaml.Controls.Button();
            saveLabeledImageButton.Content = "Save Labeled Image";
            saveLabeledImageButton.Height  = 40;
            Windows.UI.Xaml.Controls.Grid.SetRow(saveLabeledImageButton, 0);
            Windows.UI.Xaml.Controls.Grid.SetColumn(saveLabeledImageButton, 3);
            saveLabeledImageButton.HorizontalAlignment = Windows.UI.Xaml.HorizontalAlignment.Center;
            saveLabeledImageButton.Click += SaveLabeledImageButton_Click;
            toolbar.Children.Add(saveLabeledImageButton);

            // Add to toolbar's columnForSaveLabelFileButton a "Save Label File" button.
            Windows.UI.Xaml.Controls.Button saveLabelFileButton = new Windows.UI.Xaml.Controls.Button();
            saveLabelFileButton.Content = "Save Label File";
            saveLabelFileButton.Height  = 40;
            Windows.UI.Xaml.Controls.Grid.SetRow(saveLabelFileButton, 0);
            Windows.UI.Xaml.Controls.Grid.SetColumn(saveLabelFileButton, 4);
            saveLabelFileButton.HorizontalAlignment = Windows.UI.Xaml.HorizontalAlignment.Center;
            saveLabelFileButton.Click += SaveLabelFileButton_Click;
            toolbar.Children.Add(saveLabelFileButton);

            // Add grid to the top of our stackPanel.
            stackPanel.Children.Add(toolbar);

            this.ImageCanvas                 = new Windows.UI.Xaml.Controls.Canvas();
            this.ImageCanvas.Width           = widthOfAppInViewPixels;
            this.ImageCanvas.Height          = heightBetweenBottomOfAppAndBottomOfTitleBarInViewPixels - toolbar.Height;
            this.ImageCanvas.PointerMoved   += new Windows.UI.Xaml.Input.PointerEventHandler(ImageCanvas_PointerMoved);
            this.ImageCanvas.PointerPressed += new Windows.UI.Xaml.Input.PointerEventHandler(ImageCanvas_PointerPressed);
            this.ImageCanvas.PointerExited  += new Windows.UI.Xaml.Input.PointerEventHandler(ImageCanvas_PointerExited);
            stackPanel.Children.Add(this.ImageCanvas);

            // Add stackPanel to the page defined in MainPage.xaml.
            page.Content = stackPanel;
        } // public MainPage
        public void FillText(string text, float x, float y)
        {
            var t = new Windows.UI.Xaml.Controls.TextBlock();

            t.Name = Guid.NewGuid().ToString();

            t.TextWrapping = Windows.UI.Xaml.TextWrapping.Wrap;
            t.FontSize = _fontSize;
            t.Text = text;
            t.Foreground = _foregroundBrush;
            t.FontFamily = _fontFamily;
            t.HorizontalAlignment = _textHAlignment;

            var posX = x;
            var posY = y;

            //approx measurement of text in order to offset for center/middle
            if (_textVBaseline == TextBaseline.Middle)
            {
                t.VerticalAlignment = Windows.UI.Xaml.VerticalAlignment.Center;
                var approxSize = MeasureText("X");
                posY = posY - approxSize / 2;
            }
            if (_textVBaseline == TextBaseline.Top)
            {
                t.VerticalAlignment = Windows.UI.Xaml.VerticalAlignment.Top;
            }
            if (_textVBaseline == TextBaseline.Bottom)
            {
                t.VerticalAlignment = Windows.UI.Xaml.VerticalAlignment.Bottom;
            }

            if (_textHAlignment == Windows.UI.Xaml.HorizontalAlignment.Center)
            {
                var width = MeasureText(text);
                posX = posX - (width / 4);
            }

            Windows.UI.Xaml.Controls.Canvas.SetTop(t, posY);
            Windows.UI.Xaml.Controls.Canvas.SetLeft(t, posX);

            _canvas.Children.Add(t);
        }